Bug Summary

File:programs/Analysis/hdview2/hdv_mainframe.cc
Location:line 775, column 10
Description:Value stored to 'philo' during its initialization is never read

Annotated Source Code

1
2#include <iostream>
3#include <iomanip>
4#include <sstream>
5#include <cmath>
6#include <fstream>
7using namespace std;
8
9#include <unistd.h>
10#include <pthread.h>
11#include <sys/time.h>
12
13#include <TRACKING/DMCThrown.h>
14#include "hdv_mainframe.h"
15#include "hdview2.h"
16#include "MyProcessor.h"
17#include "FDC/DFDCGeometry.h"
18#include "FCAL/DFCALGeometry.h"
19#include "TOF/DTOFGeometry.h"
20#include "DVector2.h"
21#include "HDGEOMETRY/DGeometry.h"
22#include <PID/DNeutralParticle.h>
23#include <DAQ/DEPICSvalue.h>
24
25#include <TPolyMarker.h>
26#include <TLine.h>
27#include <TMarker.h>
28#include <TBox.h>
29#include <TVector3.h>
30#include <TGeoVolume.h>
31#include <TGeoManager.h>
32#include <TGLabel.h>
33#include <TGComboBox.h>
34#include <TGButton.h>
35#include <TGButtonGroup.h>
36#include <TGTextEntry.h>
37#include <TArrow.h>
38#include <TLatex.h>
39#include <TColor.h>
40#include <TMath.h>
41#include <TArc.h>
42
43extern JApplication *japp;
44//TGeoVolume *MOTHER = NULL;
45//TGeoCombiTrans *MotherRotTrans = NULL;
46
47extern int GO;
48extern bool SKIP_EPICS_EVENTS;
49
50// These values are just used to draw the detectors for visualization.
51// These should be replaced by a database lookup or something similar
52// at some point.
53static float BCAL_Rmin=65.0;
54static float BCAL_Rmax = 87.46;
55static float BCAL_MIDRAD = 77.0;
56static float BCAL_Zlen = 390.0;
57static float BCAL_Zmin = 212.0 - BCAL_Zlen/2.0;
58static float BCAL_MODS = 48;
59static float BCAL_LAYS1 = 3;
60//static float BCAL_LAYS2 = 4;
61static float BCAL_SECS1 = 4;
62static float BCAL_SECS2 = 4;
63static float BCAL_PHI_SHIFT = 0.0; // radians (will be overwritten in constructor!)
64static float FCAL_Zlen = 45.0;
65static float FCAL_Zmin = 622.8;
66static float FCAL_Rmin = 6.0;
67static float FCAL_Rmax = 212.0/2.0;
68static float CDC_Rmin = 9.0;
69static float CDC_Rmax = 59.0;
70static float CDC_Zlen = 150.0;
71static float CDC_Zmin = 17.0;
72static float TOF_Rmax = 125.0;
73static float TOF_Rmin = 6.0;
74static float TOF_Zlen = 2.54;
75static float TOF_Zmin = 618.8;
76static float FDC_Rmin = 3.5;
77static float FDC_Rmax = 48.5;
78static float TARGET_Zmid = 65.0;
79static float TARGET_Zlen = 30.0;
80
81// The DFCALGeometry object is not really available at the time we need it
82// when the program first starts. Create one of our own here.
83static DFCALGeometry *fcalgeom = new DFCALGeometry;
84// ditto for DTOFGeometry
85static DTOFGeometry *tofgeom = new DTOFGeometry;
86
87static vector<vector <DFDCWire *> >fdcwires;
88
89//-------------------
90// Constructor
91//-------------------
92hdv_mainframe::hdv_mainframe(const TGWindow *p, UInt_t w, UInt_t h):TGMainFrame(p,w,h)
93{
94 //Get pointer to DGeometry object
95 DApplication* dapp=dynamic_cast<DApplication*>(japp);
96 const DGeometry *dgeom = dapp->GetDGeometry(9999);
97
98 dgeom->GetFDCWires(fdcwires);
99
100 // Get Target parameters from XML
101 double my_TARGET_Zmid = TARGET_Zmid;
102 double my_TARGET_Zlen = TARGET_Zlen;
103 dgeom->GetTargetZ(my_TARGET_Zmid);
104 dgeom->GetTargetLength(my_TARGET_Zlen);
105 TARGET_Zmid = my_TARGET_Zmid;
106 TARGET_Zlen = my_TARGET_Zlen;
107
108 // Get overall phi shift of BCAL
109 float my_BCAL_PHI_SHIFT;
110 dgeom->GetBCALPhiShift(my_BCAL_PHI_SHIFT);
111 BCAL_PHI_SHIFT = my_BCAL_PHI_SHIFT*TMath::DegToRad(); // convert to radians
112
113 UInt_t MainWidth = w;
114
115 // First, define all of the of the graphics objects. Below that, make all
116 // of the connections to the methods so these things will work!
117
118 // Use the "color wheel" rather than the classic palette.
119 //TColor::CreateColorWheel();
120
121 // The main GUI window is divided into three sections, top, middle, and bottom.
122 // Create those frames here.
123 TGLayoutHints *hints = new TGLayoutHints(kLHintsNormal|kLHintsExpandX|kLHintsExpandY|kLHintsLeft, 5,5,5,5);
124 TGLayoutHints *lhints = new TGLayoutHints(kLHintsNormal, 2,2,2,2);
125 TGLayoutHints *rhints = new TGLayoutHints(kLHintsCenterY|kLHintsRight, 2,2,2,2);
126 TGLayoutHints *chints = new TGLayoutHints(kLHintsCenterY|kLHintsCenterX, 2,2,2,2);
127 TGLayoutHints *bhints = new TGLayoutHints(kLHintsBottom|kLHintsCenterX, 2,2,2,2);
128 //TGLayoutHints *tofhints = new TGLayoutHints(kLHintsBottom|kLHintsCenterX, 2,2,2,2);
129 TGLayoutHints *xhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandX, 2,2,2,2);
130 TGLayoutHints *yhints = new TGLayoutHints(kLHintsNormal|kLHintsExpandY, 2,2,2,2);
131 TGLayoutHints *dhints = new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 0,0,0,0);
132 TGLayoutHints *ehints = new TGLayoutHints(kLHintsNormal, 2,2,0,0);
133 TGLayoutHints *thints = new TGLayoutHints(kLHintsTop|kLHintsCenterX, 2,2,0,0);
134 TGLayoutHints *lxhints = new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,0,0);
135 TGHorizontalFrame *sourceframe = new TGHorizontalFrame(this,w,20);
136 TGHorizontalFrame *topframe = new TGHorizontalFrame(this, w, 200);
137 // TGHorizontalFrame *midframe = new TGHorizontalFrame(this, w, 200);
138 TGCompositeFrame *midframe = new TGCompositeFrame(this, w, 200, kHorizontalFrame);
139 TGHorizontalFrame *botframe = new TGHorizontalFrame(this, w, 200);
140 AddFrame(sourceframe, lxhints);
141 AddFrame(topframe, lhints);
142 AddFrame(midframe, lhints);
143 AddFrame(botframe, lhints);
144
145 //========== Source ===========
146 TGLabel *sourcelab = new TGLabel(sourceframe, "Source:");
147 sourceframe->AddFrame(sourcelab,ehints);
148 source = new TGLabel(sourceframe, "--");
149 sourceframe->AddFrame(source, lxhints);
150 source->SetTextJustify(1);
151
152 //========== TOP FRAME ============
153 TGGroupFrame *viewcontrols = new TGGroupFrame(topframe, "View Controls", kHorizontalFrame);
154 TGGroupFrame *eventcontrols = new TGGroupFrame(topframe, "Event Controls", kHorizontalFrame);
155 TGGroupFrame *eventinfo = new TGGroupFrame(topframe, "Info", kHorizontalFrame);
156 TGGroupFrame *inspectors = new TGGroupFrame(topframe, "Inspectors", kVerticalFrame);
157 TGHorizontalFrame *programcontrols = new TGHorizontalFrame(topframe);
158 topframe->AddFrame(viewcontrols, lhints);
159 topframe->AddFrame(eventcontrols, hints);
160 topframe->AddFrame(eventinfo, yhints);
161 topframe->AddFrame(inspectors, yhints);
162 topframe->AddFrame(programcontrols, yhints);
163
164 //-------------Pan buttons
165 TGVerticalFrame *panneg = new TGVerticalFrame(viewcontrols);
166 TGVerticalFrame *panpos = new TGVerticalFrame(viewcontrols);
167 viewcontrols->AddFrame(panneg, hints);
168 viewcontrols->AddFrame(panpos, hints);
169 TGTextButton *panxneg = new TGTextButton(panneg, "-X");
170 TGTextButton *panyneg = new TGTextButton(panneg, "-Y");
171 TGTextButton *panzneg = new TGTextButton(panneg, "-Z");
172 panneg->AddFrame(panxneg, dhints);
173 panneg->AddFrame(panyneg, dhints);
174 panneg->AddFrame(panzneg, dhints);
175
176 TGTextButton *panxpos = new TGTextButton(panpos, "X+");
177 TGTextButton *panypos = new TGTextButton(panpos, "Y+");
178 TGTextButton *panzpos = new TGTextButton(panpos, "Z+");
179 panpos->AddFrame(panxpos, dhints);
180 panpos->AddFrame(panypos, dhints);
181 panpos->AddFrame(panzpos, dhints);
182
183 panxneg->Connect("Clicked()","hdv_mainframe",this,"DoPanXneg()");
184 panyneg->Connect("Clicked()","hdv_mainframe",this,"DoPanYneg()");
185 panzneg->Connect("Clicked()","hdv_mainframe",this,"DoPanZneg()");
186 panxpos->Connect("Clicked()","hdv_mainframe",this,"DoPanXpos()");
187 panypos->Connect("Clicked()","hdv_mainframe",this,"DoPanYpos()");
188 panzpos->Connect("Clicked()","hdv_mainframe",this,"DoPanZpos()");
189 //------------- Zoom/Reset buttons
190 TGVerticalFrame *zoom = new TGVerticalFrame(viewcontrols);
191 viewcontrols->AddFrame(zoom, lhints);
192 TGGroupFrame *zoomframe = new TGGroupFrame(zoom, "ZOOM", kHorizontalFrame);
193 zoom->AddFrame(zoomframe, thints);
194 TGTextButton *zoomout = new TGTextButton(zoomframe, " - ");
195 TGTextButton *zoomin = new TGTextButton(zoomframe, " + ");
196 zoomframe->AddFrame(zoomout, thints);
197 zoomframe->AddFrame(zoomin, thints);
198 TGTextButton *reset = new TGTextButton(zoom, "Reset");
199 zoom->AddFrame(reset, chints);
200
201 //-------------- Transverse Coordinates
202 TGVButtonGroup *coordinates = new TGVButtonGroup(viewcontrols,"Transverse Coordinates");
203 viewcontrols->AddFrame(coordinates, lhints);
204 TGRadioButton *xy = new TGRadioButton(coordinates, "x/y");
205 new TGRadioButton(coordinates, "r/phi");
206
207 //-------------- Next, Previous
208 prev = new TGTextButton(eventcontrols, "<-- Prev");
209 next = new TGTextButton(eventcontrols, "Next -->");
210 TGVerticalFrame *contf = new TGVerticalFrame(eventcontrols);
211 eventcontrols->AddFrame(prev, chints);
212 eventcontrols->AddFrame(next, chints);
213 eventcontrols->AddFrame(contf, lhints);
214
215 // continuous, delay
216 checkbuttons["continuous"] = new TGCheckButton(contf, "continuous");
217 TGHorizontalFrame *delayf = new TGHorizontalFrame(contf);
218 contf->AddFrame(checkbuttons["continuous"], lhints);
219 contf->AddFrame(delayf, lhints);
220 TGLabel *delaylab = new TGLabel(delayf, "delay:");
221 delay = new TGComboBox(delayf, "0.25");
222 delay->Resize(50,20);
223 float delays[]={0, 0.25, 0.5, 1, 2, 3, 5, 10};
224 for(int i=0; i<8; i++){
225 stringstream ss;
226 ss<<delays[i];
227 delay->AddEntry(ss.str().c_str(),i);
228 }
229 delayf->AddFrame(delaylab, lhints);
230 delayf->AddFrame(delay, lhints);
231
232 //----------------- Event Info
233 TGVerticalFrame *eventlabs = new TGVerticalFrame(eventinfo);
234 TGVerticalFrame *eventvals = new TGVerticalFrame(eventinfo);
235 eventinfo->AddFrame(eventlabs, lhints);
236 eventinfo->AddFrame(eventvals, lhints);
237
238 TGLabel *runlab = new TGLabel(eventlabs, "Run:");
239 TGLabel *eventlab = new TGLabel(eventlabs, "Event:");
240 run = new TGLabel(eventvals, "----------");
241 event = new TGLabel(eventvals, "----------");
242 eventlabs->AddFrame(runlab, rhints);
243 eventlabs->AddFrame(eventlab,rhints);
244 eventvals->AddFrame(run, lhints);
245 eventvals->AddFrame(event, lhints);
246
247 //----------------- Inspectors
248 TGTextButton *trackinspector = new TGTextButton(inspectors, "Track Inspector");
249 //TGTextButton *tofinspector = new TGTextButton(inspectors, "TOF Inspector");
250 //TGTextButton *bcalinspector = new TGTextButton(inspectors, "BCAL Inspector");
251 //TGTextButton *fcalinspector = new TGTextButton(inspectors, "FCAL Inspector");
252 inspectors->AddFrame(trackinspector, xhints);
253 //inspectors->AddFrame(tofinspector, xhints);
254 //inspectors->AddFrame(bcalinspector, xhints);
255 //inspectors->AddFrame(fcalinspector, xhints);
256 //tofinspector->SetEnabled(kFALSE);
257 //bcalinspector->SetEnabled(kFALSE);
258 //fcalinspector->SetEnabled(kFALSE);
259
260 //-------------- Program Controls
261 TGTextButton *quit = new TGTextButton(programcontrols, "&Quit");
262 programcontrols->AddFrame(quit, new TGLayoutHints(kLHintsTop|kLHintsRight|kLHintsExpandX, 2,2,2,2));
263
264 //========== MID FRAME ============
265 TGHorizontalFrame *detectorframe = new TGHorizontalFrame(midframe);
266 midframe->AddFrame(detectorframe, hints);
267
268 //------ Detector Frame ------
269 TGVerticalFrame *sideviews = new TGVerticalFrame(detectorframe);
270 TGVerticalFrame *endviews = new TGVerticalFrame(detectorframe);
271 TGVerticalFrame *drawopts = new TGVerticalFrame(detectorframe);
272 TGVerticalFrame *caloColorCodes = new TGVerticalFrame(detectorframe);
273 detectorframe->AddFrame(sideviews, lhints);
274 detectorframe->AddFrame(endviews, lhints);
275 detectorframe->AddFrame(caloColorCodes, lhints);
276 detectorframe->AddFrame(drawopts, lhints);
277
278 // Side views
279 int width = MainWidth/6*2;
280 TGHorizontalFrame *sideviewAframe = new TGHorizontalFrame(sideviews);
281 TGHorizontalFrame *sideviewBframe = new TGHorizontalFrame(sideviews);
282 sideviews->AddFrame(sideviewAframe, lhints);
283 sideviews->AddFrame(sideviewBframe, lhints);
284 sideviewA = new TRootEmbeddedCanvas("sideviewA Canvas", sideviewAframe, width, width/2, kSunkenFrame, GetWhitePixel());
285 sideviewB = new TRootEmbeddedCanvas("sideviewB Canvas", sideviewBframe, width, width/2, kSunkenFrame, GetWhitePixel());
286 sideviewAframe->AddFrame(sideviewA, lhints);
287 sideviewBframe->AddFrame(sideviewB, lhints);
288 sideviewA->SetScrolling(TGCanvas::kCanvasScrollBoth);
289 sideviewB->SetScrolling(TGCanvas::kCanvasScrollBoth);
290 sideviewA->SetBackgroundColor(0xafeeee);
291 sideviewB->SetBackgroundColor(0xafeeee);
292
293 // End views
294 endviewA = new TRootEmbeddedCanvas("endviewA Canvas", endviews, width/2, width/2, kSunkenFrame, GetWhitePixel());
295 endviewB = new TRootEmbeddedCanvas("endviewB Canvas", endviews, width/2, width/2, kSunkenFrame, GetWhitePixel());
296 endviews->AddFrame(endviewA, lhints);
297 endviews->AddFrame(endviewB, lhints);
298 endviewA->SetScrolling(TGCanvas::kCanvasScrollBoth);
299 endviewB->SetScrolling(TGCanvas::kCanvasScrollBoth);
300 endviewA->GetCanvas()->SetFillColor(kGray+1);
301 endviewB->GetCanvas()->SetFillColor(kGray+1);
302
303 // Draw opts
304 TGGroupFrame *trkdrawopts = new TGGroupFrame(drawopts, "Track Draw Options", kVerticalFrame);
305 TGGroupFrame *hitdrawopts = new TGGroupFrame(drawopts, "Hit Draw Options", kVerticalFrame);
306 drawopts->AddFrame(trkdrawopts, lhints);
307 drawopts->AddFrame(hitdrawopts, lhints);
308
309 // Track
310 TGHorizontalFrame *candidatesf = new TGHorizontalFrame(trkdrawopts);
311 checkbuttons["candidates"] = new TGCheckButton(candidatesf, "DTrackCandidate:");
312 candidatesfactory = new TGComboBox(candidatesf, "<default>", 0);
313 candidatesfactory->Resize(80,20);
314 candidatesf->AddFrame(checkbuttons["candidates"], lhints);
315 for(int i=0; i<100; i++)candidatesfactory->AddEntry("a",i);
316 // For some reason, this is needed for ROOT >5.14 (??!!!) real entries are filled in later
317 candidatesf->AddFrame(candidatesfactory, lhints);
318 trkdrawopts->AddFrame(candidatesf, lhints);
319
320 TGHorizontalFrame *wiretracksf = new TGHorizontalFrame(trkdrawopts);
321 checkbuttons["wiretracks"] = new TGCheckButton(wiretracksf, "DTrackWireBased:");
322 wiretracksfactory = new TGComboBox(wiretracksf, "<default>", 0);
323 wiretracksfactory->Resize(80,20);
324 wiretracksf->AddFrame(checkbuttons["wiretracks"], lhints);
325 for(int i=0; i<100; i++)wiretracksfactory->AddEntry("a",i);
326 // For some reason, this is needed for ROOT >5.14 (??!!!) real entries are filled in later
327 wiretracksf->AddFrame(wiretracksfactory, lhints);
328 trkdrawopts->AddFrame(wiretracksf, lhints);
329
330 TGHorizontalFrame *timetracksf = new TGHorizontalFrame(trkdrawopts);
331 checkbuttons["timetracks"] = new TGCheckButton(timetracksf, "DTrackTimeBased:");
332 timetracksfactory = new TGComboBox(timetracksf, "<default>", 0);
333 timetracksfactory->Resize(80,20);
334 timetracksf->AddFrame(checkbuttons["timetracks"], lhints);
335 for(int i=0; i<100; i++)timetracksfactory->AddEntry("a",i);
336 // For some reason, this is needed for ROOT >5.14 (??!!!) real entries are filled in later
337 timetracksf->AddFrame(timetracksfactory, lhints);
338 trkdrawopts->AddFrame(timetracksf, lhints);
339 TGHorizontalFrame *chargedtracksf = new TGHorizontalFrame(trkdrawopts);
340 checkbuttons["chargedtracks"] = new TGCheckButton(chargedtracksf, "DChargedTrack:");
341 chargedtracksfactory = new TGComboBox(chargedtracksf, "<default>", 0);
342 chargedtracksfactory->Resize(80,20);
343 chargedtracksf->AddFrame(checkbuttons["chargedtracks"], lhints);
344 for(int i=0; i<100; i++)chargedtracksfactory->AddEntry("a",i);
345 // For some reason, this is needed for ROOT >5.14 (??!!!) real entries are filled in later
346 chargedtracksf->AddFrame(chargedtracksfactory, lhints);
347 trkdrawopts->AddFrame(chargedtracksf, lhints);
348
349 checkbuttons["neutrals"] = new TGCheckButton(trkdrawopts,"DNeutralParticle");
350 checkbuttons["thrown"] = new TGCheckButton(trkdrawopts,"DMCThrown");
351 checkbuttons["trajectories"] = new TGCheckButton(trkdrawopts, "DMCTrajectoryPoint");
352 trkdrawopts->AddFrame(checkbuttons["neutrals"], lhints);
353 trkdrawopts->AddFrame(checkbuttons["thrown"], lhints);
354 trkdrawopts->AddFrame(checkbuttons["trajectories"], lhints);
355
356 // Hit
357 checkbuttons["cdc"] = new TGCheckButton(hitdrawopts, "CDC");
358 checkbuttons["cdcdrift"] = new TGCheckButton(hitdrawopts, "CDC Drift Time");
359 checkbuttons["cdctruth"] = new TGCheckButton(hitdrawopts, "CDCTruth");
360 checkbuttons["fdcwire"] = new TGCheckButton(hitdrawopts, "FDC Wire");
361 checkbuttons["fdcpseudo"] = new TGCheckButton(hitdrawopts, "FDC Pseudo");
362 checkbuttons["fdctruth"] = new TGCheckButton(hitdrawopts, "FDCTruth");
363 checkbuttons["tof"] = new TGCheckButton(hitdrawopts, "TOF");
364 checkbuttons["toftruth"] = new TGCheckButton(hitdrawopts, "TOFTruth");
365 checkbuttons["fcal"] = new TGCheckButton(hitdrawopts, "FCAL");
366 checkbuttons["bcal"] = new TGCheckButton(hitdrawopts, "BCAL");
367
368 hitdrawopts->AddFrame(checkbuttons["cdc"], lhints);
369 hitdrawopts->AddFrame(checkbuttons["cdcdrift"], lhints);
370 hitdrawopts->AddFrame(checkbuttons["cdctruth"], lhints);
371 hitdrawopts->AddFrame(checkbuttons["fdcwire"], lhints);
372 hitdrawopts->AddFrame(checkbuttons["fdcpseudo"], lhints);
373 hitdrawopts->AddFrame(checkbuttons["fdctruth"], lhints);
374 hitdrawopts->AddFrame(checkbuttons["tof"], lhints);
375 hitdrawopts->AddFrame(checkbuttons["toftruth"], lhints);
376 hitdrawopts->AddFrame(checkbuttons["fcal"], lhints);
377 hitdrawopts->AddFrame(checkbuttons["bcal"], lhints);
378
379 TGTextButton *moreOptions = new TGTextButton(hitdrawopts, "More options");
380 hitdrawopts->AddFrame(moreOptions, lhints);
381
382 // Color codes
383 TGGroupFrame *bcalColorCodes = new TGGroupFrame(caloColorCodes, "BCAL colors", kVerticalFrame);
384 TGGroupFrame *fcalColorCodes = new TGGroupFrame(caloColorCodes, "FCAL colors", kVerticalFrame);
385 TGTextButton *debuger = new TGTextButton(caloColorCodes,"Debugger");
386 TGTextButton *bcaldisp = new TGTextButton(caloColorCodes,"BcalDisp");
387
388 caloColorCodes->AddFrame(bcalColorCodes, thints);
389 caloColorCodes->AddFrame(debuger,lhints);
390 caloColorCodes->AddFrame(bcaldisp,lhints);
391 caloColorCodes->AddFrame(fcalColorCodes, bhints);
392 bcalColorCodes->SetWidth(30);
393 fcalColorCodes->SetWidth(30);
394
395 // color lables BCAL
396 TGLabel* BCCLables[9];
397 unsigned int BCccodes[9] = {0x0000FF,0x7700FF,0xFF00FF,0xFF0077,0xFF0000,0xFF7700,0xFFFF00,0xFFFF77,0xFFFFFF};
398 for (int i=0;i<9;i++) {
399 double e = pow(10,((8-(double)i)/2.0));
400 char str1[128];
401 if (e >= 1000) {
402 sprintf(str1,"%7.2f GeV",e/1000.);
403 } else {
404 sprintf(str1,"%7.1f MeV",e);
405 }
406 BCCLables[i] = new TGLabel(bcalColorCodes, (const char*)str1);
407 //BCCLables[i]->SetTextColor(1);
408 BCCLables[i]->SetBackgroundColor(BCccodes[i]);
409 bcalColorCodes->AddFrame(BCCLables[i],lhints);
410 }
411 // color lables FCAL
412 TGLabel* FCCLables[9];
413 unsigned int FCccodes[9] = {0x0000FF,0x7700FF,0xFF00FF,0xFF0077,0xFF0000,0xFF7700,0xFFFF00,0xFFFF77,0xFFFFFF};
414 for (int i=0;i<9;i++) {
415 double e = pow(10,((8-(double)i)/2.0));
416 char str1[128];
417 if (e >= 1000) {
418 sprintf(str1,"%7.2f GeV",e/1000.);
419 } else {
420 sprintf(str1,"%7.1f MeV",e);
421 }
422 FCCLables[i] = new TGLabel(fcalColorCodes, (const char*)str1);
423 FCCLables[i]->SetBackgroundColor(FCccodes[i]);
424 fcalColorCodes->AddFrame(FCCLables[i],lhints);
425 }
426
427 //========== BOT FRAME ============
428 TGGroupFrame *trackinfo = new TGGroupFrame(botframe, "Track Info", kHorizontalFrame);
429 botframe->AddFrame(trackinfo, xhints);
430
431 //------ Track Info ------
432 throwninfo = new TGGroupFrame(trackinfo, "Thrown", kHorizontalFrame);
433 reconinfo = new TGGroupFrame(trackinfo, "Reconstructed", kHorizontalFrame);
434 trackinfo->AddFrame(throwninfo, lhints);
435 trackinfo->AddFrame(reconinfo, lhints);
436
437 // Column names
438 vector<string> colnames;
439 colnames.push_back("trk");
440 colnames.push_back("type");
441 colnames.push_back("p");
442 colnames.push_back("theta");
443 colnames.push_back("phi");
444 colnames.push_back("z");
445 colnames.push_back("chisq/Ndof");
446 colnames.push_back("Ndof");
447 colnames.push_back("FOM");
448 colnames.push_back("cand");
449
450 // Create a vertical frame for each column and insert the label as the first item
451 for(unsigned int i=0; i<colnames.size(); i++){
452 // create frames
453 TGVerticalFrame *tf = new TGVerticalFrame(throwninfo);
454 TGVerticalFrame *rf = new TGVerticalFrame(reconinfo);
455 throwninfo->AddFrame(tf, bhints);
456 reconinfo->AddFrame(rf, bhints);
457
458 // create column labels
459 string lab = colnames[i]+":";
460 TGLabel *tl = new TGLabel(tf, lab.c_str());
461 TGLabel *rl = new TGLabel(rf, lab.c_str());
462 if(i<6)tf->AddFrame(tl, chints);
463 rf->AddFrame(rl, chints);
464 vector<TGLabel*> tv;
465 vector<TGLabel*> rv;
466 tv.push_back(tl);
467 rv.push_back(rl);
468
469 // Add 8 labels to each column
470 // These have to be added in reverse order so we can pack them from
471 // the bottom. Otherwise, it doesn't draw correctly.
472 for(int j=0; j<14; j++){
473 stringstream ss;
474 ss<<(5-j);
475 if(i<6)tl = new TGLabel(tf, i==0 ? ss.str().c_str():"--------");
476 rl = new TGLabel(rf, i==0 ? ss.str().c_str():"--------");
477 if(i<6)tf->AddFrame(tl, bhints);
478 rf->AddFrame(rl, bhints);
479 tv.push_back(tl);
480 rv.push_back(rl);
481 }
482
483 // Record the label object pointers for later use
484 thrownlabs[colnames[i]] = tv;
485 reconlabs[colnames[i]] = rv;
486 }
487
488 // Reconstruction factory and full list button
489 TGVerticalFrame *vf = new TGVerticalFrame(reconinfo);
490 reconinfo->AddFrame(vf, yhints);
491 reconfactory = new TGComboBox(vf, "DTrackCandidate:", 0);
492 reconfactory->Resize(160,20);
493 for(int i=0; i<100; i++)reconfactory->AddEntry("a",i); // For some reason, this is needed for ROOT >5.14 (??!!!) real entries are filled in later
494 vf->AddFrame(reconfactory, thints);
495
496 TGTextButton *listall = new TGTextButton(vf, "Full List");
497 vf->AddFrame(listall, new TGLayoutHints(kLHintsBottom|kLHintsExpandX, 2,2,2,2));
498
499 // Pointers to optional daughter windows (these must be done before ReadPreferences in
500 // order for the options they implement to be filled into checkbuttons)
501 trkmf = NULL__null;
502 bcaldispmf = NULL__null;
503 optionsmf = new hdv_optionsframe(this, NULL__null, 100, 100);
504 debugermf = new hdv_debugerframe(this, NULL__null, 800, 800);
505 fulllistmf = new hdv_fulllistframe(this, NULL__null, 100, 100);
506 endviewAmf = new hdv_endviewAframe(this, NULL__null, 600, 600);
507 endviewBmf = new hdv_endviewBframe(this, NULL__null, 600, 600);
508
509 //&&&&&&&&&&&&&&&& Defaults
510 ReadPreferences();
511 xy->SetState(kButtonDown,kTRUE);
512 coordinatetype = COORD_XY;
513 r0 = 50.0;
514 phi0 = M_PI3.14159265358979323846;
515 x0 = 0.0;
516 y0 = 0.0;
517 z0 = 350.0;
518 zoom_factor = 1.0;
519
520 //&&&&&&&&&&&&&&&& Connections
521 zoomin->Connect("Clicked()","hdv_mainframe", this, "DoZoomIn()");
522 zoomout->Connect("Clicked()","hdv_mainframe", this, "DoZoomOut()");
523 reset->Connect("Clicked()","hdv_mainframe", this, "DoReset()");
524
525 coordinates->Connect("Clicked(Int_t)","hdv_mainframe", this, "DoSetCoordinates(Int_t)");
526 coordinates->Connect("Clicked(Int_t)","hdv_mainframe", this, "DoMyRedraw()");
527
528 quit->Connect("Clicked()","hdv_mainframe", this, "DoQuit()");
529 this->Connect("CloseWindow()", "hdv_mainframe", this, "DoQuit()");
530 this->DontCallClose();
531 next->Connect("Clicked()","hdv_mainframe", this, "DoNext()");
532 prev->Connect("Clicked()","hdv_mainframe", this, "DoPrev()");
533 checkbuttons["continuous"]->Connect("Clicked()","hdv_mainframe", this, "DoCont()");
534 delay->Connect("Selected(Int_t)","hdv_mainframe", this, "DoSetDelay(Int_t)");
535
536 trackinspector->Connect("Clicked()","hdv_mainframe", this, "DoOpenTrackInspector()");
537 moreOptions->Connect("Clicked()","hdv_mainframe", this, "DoOpenOptionsWindow()");
538 listall->Connect("Clicked()","hdv_mainframe", this, "DoOpenFullListWindow()");
539 debuger->Connect("Clicked()","hdv_mainframe", this, "DoOpenDebugerWindow()");
540 bcaldisp->Connect("Clicked()","hdv_mainframe", this, "DoBcalDispFrame()");
541 //tofinspector->Connect("Clicked()","hdv_mainframe", this, "DoOpenTOFInspector()");
542 //fcalinspector->Connect("Clicked()","hdv_mainframe", this, "DoOpenFCALInspector()");
543 //bcalinspector->Connect("Clicked()","hdv_mainframe", this, "DoOpenBCALInspector()");
544
545 checkbuttons["candidates"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
546 checkbuttons["wiretracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
547 checkbuttons["timetracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
548 checkbuttons["chargedtracks"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
549 checkbuttons["neutrals"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
550 checkbuttons["thrown"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
551
552 checkbuttons["cdc"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
553 checkbuttons["cdcdrift"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
554 checkbuttons["cdctruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
555 checkbuttons["fdcwire"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
556 checkbuttons["fdcpseudo"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
557 checkbuttons["fdctruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
558 checkbuttons["tof"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
559 checkbuttons["toftruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
560 checkbuttons["bcal"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
561 checkbuttons["bcaltruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
562 checkbuttons["fcal"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
563 checkbuttons["fcaltruth"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
564 checkbuttons["trajectories"]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
565
566 for (Int_t n=1;n<debugermf->GetNTrCand();n++){
567 char str1[128];
568 sprintf(str1,"Candidate%d",n);
569 checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
570 }
571
572 for (Int_t n=1;n<debugermf->GetNTrWB();n++){
573 char str1[128];
574 sprintf(str1,"WireBased%d",n);
575 checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
576 }
577
578 for (Int_t n=1;n<debugermf->GetNTrTB();n++){
579 char str1[128];
580 sprintf(str1,"TimeBased%d",n);
581 checkbuttons[str1]->Connect("Clicked()","hdv_mainframe", this, "DoMyRedraw()");
582 }
583
584 candidatesfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()");
585 wiretracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()");
586 timetracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()");
587 chargedtracksfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoMyRedraw()");
588 reconfactory->Connect("Selected(Int_t)","hdv_mainframe", this, "DoUpdateTrackLabels()");
589
590 endviewA->GetCanvas()->Connect("Selected(TVirtualPad*, TObject*, Int_t)", "hdv_mainframe", this, "DoEndViewAEvent(TVirtualPad*, TObject*, Int_t)");
591 endviewB->GetCanvas()->Connect("Selected(TVirtualPad*, TObject*, Int_t)", "hdv_mainframe", this, "DoEndViewBEvent(TVirtualPad*, TObject*, Int_t)");
592
593 // Set up timer to call the DoTimer() method repeatedly
594 // so events can be automatically advanced.
595 timer = new TTimer();
596 timer->Connect("Timeout()", "hdv_mainframe", this, "DoTimer()");
597 sleep_time = 250;
598 timer->Start(sleep_time, kFALSE);
599
600 // Finish up and map the window
601 SetWindowName("Hall-D Event Viewer");
602 SetIconName("HDView");
603 MapSubwindows();
604 Resize(GetDefaultSize());
605 MapWindow();
606
607 // Call Resize method of some group frames to get them to shrink down to smallest size
608 viewcontrols->Resize();
609 eventinfo->Resize();
610 eventcontrols->Resize();
611 inspectors->Resize();
612}
613
614//-------------------
615// ReadPreferences
616//-------------------
617void hdv_mainframe::ReadPreferences(void)
618{
619 // Preferences file is "${HOME}/.hdview2"
620 const char *home = getenv("HOME");
621 if(!home)return;
622
623 // Try and open file
624 string fname = string(home) + "/.hdview2";
625 ifstream ifs(fname.c_str());
626 if(!ifs.is_open())return;
627 cout<<"Reading preferences from \""<<fname<<"\" ..."<<endl;
628
629 // Loop over lines
630 char line[1024];
631 while(!ifs.eof()){
632 ifs.getline(line, 1024);
633 if(strlen(line)==0)continue;
634 if(line[0] == '#')continue;
635 string str(line);
636
637 // Break line into tokens
638 vector<string> tokens;
639 string buf; // Have a buffer string
640 stringstream ss(str); // Insert the string into a stream
641 while (ss >> buf)tokens.push_back(buf);
642 if(tokens.size()<1)continue;
643
644 // Check first token to decide what to do
645 if(tokens[0] == "checkbutton"){
646 if(tokens.size()!=4)continue; // should be of form "checkbutton name = value" with white space on either side of the "="
647 map<string, TGCheckButton*>::iterator it = checkbuttons.find(tokens[1]);
648 if(it != checkbuttons.end()){
649 if(tokens[3] == "on")(it->second)->SetState(kButtonDown);
650 }
651 }
652
653 if(tokens[0] == "DTrackCandidate"){
654 if(tokens.size()!=3)continue; // should be of form "DTrackCandidate = tag" with white space on either side of the "="
655 default_candidate = tokens[2];
656 }
657
658 if(tokens[0] == "DTrackWireBased"){
659 if(tokens.size()!=3)continue; // should be of form "DTrackWireBased = tag" with white space on either side of the "="
660 default_track = tokens[2];
661 }
662
663 if(tokens[0] == "DTrackTimeBased"){
664 if(tokens.size()!=3)continue; // should be of form "DTrackTimeBased = tag" with white space on either side of the "="
665 default_track = tokens[2];
666 }
667
668 if(tokens[0] == "Reconstructed"){
669 if(tokens.size()!=3)continue; // should be of form "Reconstructed = Factory:tag" with white space on either side of the "="
670 default_reconstructed = tokens[2];
671 }
672
673 }
674
675 // close file
676 ifs.close();
677}
678
679//-------------------
680// SavePreferences
681//-------------------
682void hdv_mainframe::SavePreferences(void)
683{
684 // Preferences file is "${HOME}/.hdview2"
685 const char *home = getenv("HOME");
686 if(!home)return;
687
688 // Try deleting old file and creating new file
689 string fname = string(home) + "/.hdview2";
690 unlink(fname.c_str());
691 ofstream ofs(fname.c_str());
692 if(!ofs.is_open()){
693 cout<<"Unable to create preferences file \""<<fname<<"\"!"<<endl;
694 return;
695 }
696
697 // Write header
698 time_t t = time(NULL__null);
699 ofs<<"##### hdview2 preferences file ###"<<endl;
700 ofs<<"##### Auto-generated on "<<ctime(&t)<<endl;
701 ofs<<endl;
702
703 // Write all checkbuttons that are "on"
704 map<string, TGCheckButton*>::iterator iter;
705 for(iter=checkbuttons.begin(); iter!=checkbuttons.end(); iter++){
706 TGCheckButton *but = iter->second;
707 if(but->GetState() == kButtonDown){
708 ofs<<"checkbutton "<<(iter->first)<<" = on"<<endl;
709 }
710 }
711 ofs<<endl;
712
713 ofs<<"DTrackCandidate = "<<(candidatesfactory->GetTextEntry()->GetText())<<endl;
714 ofs<<"DTrackWireBased = "<<(wiretracksfactory->GetTextEntry()->GetText())<<endl;
715 ofs<<"DTrackTimeBased = "<<(timetracksfactory->GetTextEntry()->GetText())<<endl;
716 ofs<<"Reconstructed = "<<(reconfactory->GetTextEntry()->GetText())<<endl;
717
718 ofs<<endl;
719 ofs.close();
720 cout<<"Preferences written to \""<<fname<<"\""<<endl;
721}
722
723//-------------------
724// SetRange
725//-------------------
726void hdv_mainframe::SetRange(void)
727{
728 // The following is for the bug
729 //endviewA->GetCanvas()->Range(-1, -1, 1, 1);
730
731 // Set the ranges of all canvases based on
732 // the current units (x/y or r/phi) and the zoom,pan
733 // settings
734
735 if(coordinatetype==COORD_XY){
736 // define range in each direction in cm
737 double x_width = 350.0/zoom_factor;
738 double y_width = x_width;
739 double z_width = 2.0*x_width;
740 double xlo = x0 - x_width/2.0;
741 double xhi = x0 + x_width/2.0;
742 double ylo = y0 - y_width/2.0;
743 double yhi = y0 + y_width/2.0;
744 double zlo = z0 - z_width/2.0;
745 double zhi = z0 + z_width/2.0;
746
747 sideviewA->GetCanvas()->cd();
748 sideviewA->GetCanvas()->Range(zlo, xlo, zhi, xhi);
749 sideviewB->GetCanvas()->cd();
750 sideviewB->GetCanvas()->Range(zlo, ylo, zhi, yhi);
751
752 // Zoom in a little on the end views
753 double end_to_side_ratio=1.8;
754 xlo/=end_to_side_ratio;
755 xhi/=end_to_side_ratio;
756 ylo/=end_to_side_ratio;
757 yhi/=end_to_side_ratio;
758
759 endviewA->GetCanvas()->cd();
760 endviewA->GetCanvas()->Range(xlo, ylo, xhi, yhi);
761 endviewB->GetCanvas()->cd();
762 //endviewB->GetCanvas()->Range(xlo*1.3, ylo*1.3, xhi*1.3, yhi*1.3);
763 endviewB->GetCanvas()->Range(-158, -158, 158, 158);
764 endviewAmf->SetRange(xlo, ylo, xhi, yhi);
765 //endviewBmf->SetRange(xlo*1.3, ylo*1.3, xhi*1.3, yhi*1.3);
766 endviewBmf->SetRange(-158, -158, 158, 158);
767
768 }else{
769 // define range in each direction in cm, radians
770 double r_width = 400.0/zoom_factor;
771 double phi_width = 2.0*M_PI3.14159265358979323846/zoom_factor;
772 double z_width = 2.0*r_width/zoom_factor;
773 double rlo = r0 - r_width/2.0;
774 double rhi = r0 + r_width/2.0;
775 double philo = phi0 - phi_width/2.0;
Value stored to 'philo' during its initialization is never read
776 double phihi = phi0 + phi_width/2.0;
777 double zlo = z0 - z_width/2.0;
778 double zhi = z0 + z_width/2.0;
779
780 philo = -0.2;
781 phihi = 2.0*M_PI3.14159265358979323846+0.2;
782
783 sideviewA->GetCanvas()->cd();
784 sideviewA->GetCanvas()->Range(zlo, rlo, zhi, rhi);
785 sideviewB->GetCanvas()->cd();
786 sideviewB->GetCanvas()->Range(zlo, philo, zhi, phihi);
787
788 // Zoom in a little on the end views in A
789 endviewA->GetCanvas()->cd();
790 endviewA->GetCanvas()->Range(philo, rlo/2.5, phihi, rhi/2.5);
791 endviewB->GetCanvas()->cd();
792 endviewB->GetCanvas()->Range(philo, rlo/10.0, phihi, rhi/1.9);
793 endviewAmf->SetRange(philo, rlo/2.5, phihi, rhi/2.5);
794 endviewBmf->SetRange(philo, rlo/10.0, phihi, rhi/1.9);
795 }
796}
797
798//-------------------
799// DoQuit
800//-------------------
801void hdv_mainframe::DoQuit(void)
802{
803 SavePreferences();
804
805 japp->Quit();
806 japp->Fini();
807 delete japp;
808 japp = NULL__null;
809
810 // This is supposed to return from the Run() method in "main()"
811 // since we call SetReturnFromRun(true), but it doesn't seem to work.
812 gApplication->Terminate(0);
813}
814
815//-------------------
816// DoNext
817//-------------------
818void hdv_mainframe::DoNext(void)
819{
820 if(eventloop){
821 if(SKIP_EPICS_EVENTS){
822 while(true){
823 eventloop->OneEvent();
824 vector<const DEPICSvalue*> epicsvalues;
825 eventloop->Get(epicsvalues);
826 if(epicsvalues.empty()) break;
827 cout << "Skipping EPICS event " << eventloop->GetJEvent().GetEventNumber() << endl;
828 }
829 }else{
830 eventloop->OneEvent();
831 }
832 }
833}
834
835//-------------------
836// DoPrev
837//-------------------
838void hdv_mainframe::DoPrev(void)
839{
840 //eventloop->GotoEvent(current_eventnumber-1);
841 //eventloop->OneEvent();
842}
843
844//-------------------
845// DoStop
846//-------------------
847void hdv_mainframe::DoStop(void)
848{
849 GO = 0;
850}
851
852//-------------------
853// DoCont
854//-------------------
855void hdv_mainframe::DoCont(void)
856{
857 GO = 1;
858}
859
860//-------------------
861// DoTimer
862//-------------------
863void hdv_mainframe::DoTimer(void)
864{
865 /// This gets called periodically (value is set in constructor)
866 /// It is used to automatically call DoNext() periodically
867 /// so long as the global GO is set to 1.
868 if(GetCheckButton("continuous")){
869 DoNext();
870 if(sleep_time != (long)timer->GetTime())timer->SetTime(sleep_time);
871 }else{
872 if(sleep_time == 0)timer->SetTime(10);
873 }
874}
875
876//-------------------
877// DoOpenTrackInspector
878//-------------------
879void hdv_mainframe::DoOpenTrackInspector(void)
880{
881 if(trkmf==NULL__null){
882 trkmf = new trk_mainframe(this, NULL__null, 100, 100);
883 if(trkmf){
884 next->Connect("Clicked()","trk_mainframe", trkmf, "DoNewEvent()");
885 prev->Connect("Clicked()","trk_mainframe", trkmf, "DoNewEvent()");
886 }
887 }else{
888 trkmf->RaiseWindow();
889 trkmf->RequestFocus();
890 }
891}
892
893//-------------------
894// DoOpenOptionsWindow
895//-------------------
896void hdv_mainframe::DoOpenOptionsWindow(void)
897{
898 if(optionsmf==NULL__null){
899 optionsmf = new hdv_optionsframe(this, NULL__null, 100, 100);
900 }else{
901 optionsmf->MapWindow();
902 optionsmf->RaiseWindow();
903 optionsmf->RequestFocus();
904 }
905}
906//-------------------
907// DoOpenDebugerWindow
908//-------------------
909void hdv_mainframe::DoOpenDebugerWindow(void)
910{
911 if(debugermf==NULL__null){
912 debugermf = new hdv_debugerframe(this, NULL__null, 100, 100);
913 }else{
914 debugermf->MapWindow();
915 debugermf->RaiseWindow();
916 debugermf->RequestFocus();
917 DoUpdateTrackLabels();
918 }
919}
920//-------------------
921// DoOpenDebugerWindow
922//-------------------
923void hdv_mainframe::DoBcalDispFrame(void)
924{
925 if(bcaldispmf==NULL__null){
926 bcaldispmf = new TCanvas("BCALHitCanvas", "BCAL Hit Distribution", 1000, 600);
927 bcaldispmf->Divide(1,2);
928 }
929
930 DoUpdateBcalDisp();
931}
932//-------------------
933// DoOpenDebugerWindow
934//-------------------
935void hdv_mainframe::DoUpdateBcalDisp(void)
936{
937 gMYPROC->UpdateBcalDisp();
938
939}
940///-------------------
941// DoOpenFullListWindow
942//-------------------
943void hdv_mainframe::DoOpenFullListWindow(void)
944{
945 if(fulllistmf==NULL__null){
946 fulllistmf = new hdv_fulllistframe(this, NULL__null, 100, 100);
947 }else{
948 fulllistmf->MapWindow();
949 fulllistmf->RaiseWindow();
950 fulllistmf->RequestFocus();
951 DoUpdateTrackLabels();
952 }
953}
954
955//-------------------
956// DoOpenTOFInspector
957//-------------------
958void hdv_mainframe::DoOpenTOFInspector(void)
959{
960
961}
962
963//-------------------
964// DoOpenFCALInspector
965//-------------------
966void hdv_mainframe::DoOpenFCALInspector(void)
967{
968
969}
970
971//-------------------
972// DoOpenBCALInspector
973//-------------------
974void hdv_mainframe::DoOpenBCALInspector(void)
975{
976
977}
978
979//-------------------
980// DoClearTrackInspectorPointer
981//-------------------
982void hdv_mainframe::DoClearTrackInspectorPointer(void)
983{
984 trkmf = NULL__null;
985}
986
987//-------------------
988// DoClearOptionsWindowPointer
989//-------------------
990void hdv_mainframe::DoClearOptionsWindowPointer(void)
991{
992 optionsmf = NULL__null;
993}
994
995//-------------------
996// DoClearTOFInspectorPointer
997//-------------------
998void hdv_mainframe::DoClearTOFInspectorPointer(void)
999{
1000
1001}
1002
1003//-------------------
1004// DoClearFCALInspectorPointer
1005//-------------------
1006void hdv_mainframe::DoClearFCALInspectorPointer(void)
1007{
1008
1009}
1010
1011//-------------------
1012// DoClearBCALInspectorPointer
1013//-------------------
1014void hdv_mainframe::DoClearBCALInspectorPointer(void)
1015{
1016
1017}
1018
1019//-------------------
1020// DoEndViewAEvent
1021//-------------------
1022void hdv_mainframe::DoEndViewAEvent(TVirtualPad* pad, TObject* obj, Int_t event)
1023{
1024 // event is the mouse button pushed (1=left, 2=center, 3=right)
1025 // It seems we can't detect double clicks here.
1026 if(endviewAmf==NULL__null){
1027 endviewAmf = new hdv_endviewAframe(this, NULL__null, 100, 100);
1028 }else{
1029 endviewAmf->MapWindow();
1030 endviewAmf->RaiseWindow();
1031 endviewAmf->RequestFocus();
1032 DoMyRedraw();
1033 }
1034}
1035
1036
1037//-------------------
1038// DoEndViewBEvent
1039//-------------------
1040void hdv_mainframe::DoEndViewBEvent(TVirtualPad* pad, TObject* obj, Int_t event)
1041{
1042 // event is the mouse button pushed (1=left, 2=center, 3=right)
1043 // It seems we can't detect double clicks here.
1044 if(endviewBmf==NULL__null){
1045 endviewBmf = new hdv_endviewBframe(this, NULL__null, 100, 100);
1046 }else{
1047 endviewBmf->MapWindow();
1048 endviewBmf->RaiseWindow();
1049 endviewBmf->RequestFocus();
1050 DoMyRedraw();
1051 }
1052}
1053
1054//-------------------
1055// DoPanXpos
1056//-------------------
1057void hdv_mainframe::DoPanXpos(void)
1058{
1059 x0 += 50/zoom_factor;
1060 SetRange();
1061 DoMyRedraw();
1062}
1063
1064//-------------------
1065// DoPanXneg
1066//-------------------
1067void hdv_mainframe::DoPanXneg(void)
1068{
1069 x0 -= 50/zoom_factor;
1070 SetRange();
1071 DoMyRedraw();
1072}
1073
1074//-------------------
1075// DoPanYpos
1076//-------------------
1077void hdv_mainframe::DoPanYpos(void)
1078{
1079 y0 += 50/zoom_factor;
1080 SetRange();
1081 DoMyRedraw();
1082}
1083
1084//-------------------
1085// DoPanYneg
1086//-------------------
1087void hdv_mainframe::DoPanYneg(void)
1088{
1089 y0 -= 50/zoom_factor;
1090 SetRange();
1091 DoMyRedraw();
1092}
1093
1094//-------------------
1095// DoPanZpos
1096//-------------------
1097void hdv_mainframe::DoPanZpos(void)
1098{
1099 z0 += 50/zoom_factor;
1100 SetRange();
1101 DoMyRedraw();
1102}
1103
1104//-------------------
1105// DoPanZneg
1106//-------------------
1107void hdv_mainframe::DoPanZneg(void)
1108{
1109 z0 -= 50/zoom_factor;
1110 SetRange();
1111 DoMyRedraw();
1112}
1113
1114//-------------------
1115// DoZoomIn
1116//-------------------
1117void hdv_mainframe::DoZoomIn(void)
1118{
1119 zoom_factor*=1.25;
1120 SetRange();
1121 DoMyRedraw();
1122 //if(gMYPROC)gMYPROC->evnt(eventloop, current_eventnumber);
1123}
1124
1125//-------------------
1126// DoZoomOut
1127//-------------------
1128void hdv_mainframe::DoZoomOut(void)
1129{
1130 zoom_factor/=1.25;
1131 SetRange();
1132 DoMyRedraw();
1133 //if(gMYPROC)gMYPROC->evnt(eventloop, current_eventnumber);
1134}
1135
1136//-------------------
1137// DoReset
1138//-------------------
1139void hdv_mainframe::DoReset(void)
1140{
1141 x0 = 0.0;
1142 y0 = 0.0;
1143 z0 = 350.0;
1144 zoom_factor = 1.0;
1145 DoMyRedraw();
1146}
1147
1148
1149//-------------------
1150// DoMyRedraw
1151//-------------------
1152void hdv_mainframe::DoMyRedraw(void)
1153{
1154 // Make sure canvases have proper ranges
1155 SetRange();
1156
1157 // Delete any existing graphics objects
1158 for(unsigned int i=0; i<graphics_sideA.size(); i++)delete graphics_sideA[i];
1159 for(unsigned int i=0; i<graphics_sideB.size(); i++)delete graphics_sideB[i];
1160 for(unsigned int i=0; i<graphics_endA.size(); i++)delete graphics_endA[i];
1161 for(unsigned int i=0; i<graphics_endB.size(); i++)delete graphics_endB[i];
1162 graphics_sideA.clear();
1163 graphics_sideB.clear();
1164 graphics_endA.clear();
1165 graphics_endB.clear();
1166
1167
1168 // Draw detectors depending on coordinate system we're using
1169 if(coordinatetype == COORD_XY){
1170 DrawDetectorsXY(); // Draw Detectors
1171 }else{
1172 DrawDetectorsRPhi(); // Draw Detectors
1173 }
1174
1175 // Collect all hits for display
1176 gMYPROC->FillGraphics();
1177
1178 // put collected hits into appropriate views
1179 AddGraphicsSideA(gMYPROC->graphics_xz);
1180 AddGraphicsSideB(gMYPROC->graphics_yz);
1181 AddGraphicsEndB(gMYPROC->graphics_tof_hits);
1182
1183 // Draw detector hits and tracks for the correct coordinates in all views
1184 vector<MyProcessor::DGraphicSet>::iterator iter = gMYPROC->graphics.begin();
1185 for(; iter!=gMYPROC->graphics.end(); iter++){
1186
1187 if(iter->type==MyProcessor::kMarker){
1188 // Markers
1189 TPolyMarker *sA = new TPolyMarker();
1190 TPolyMarker *sB = new TPolyMarker();
1191 TPolyMarker *eA = new TPolyMarker();
1192 sA->SetMarkerColor(iter->color);
1193 sB->SetMarkerColor(iter->color);
1194 eA->SetMarkerColor(iter->color);
1195 sA->SetMarkerSize(iter->size);
1196 sB->SetMarkerSize(iter->size);
1197 eA->SetMarkerSize(iter->size);
1198 sA->SetMarkerStyle(iter->marker_style);
1199 sB->SetMarkerStyle(iter->marker_style);
1200 eA->SetMarkerStyle(iter->marker_style);
1201 FillPoly(sA, sB, eA, iter->points); // in hdv_mainframe.h
1202 }else{
1203 // Lines
1204 TPolyLine *sA = new TPolyLine();
1205 TPolyLine *sB = new TPolyLine();
1206 TPolyLine *eA = new TPolyLine();
1207 sA->SetLineColor(iter->color);
1208 sB->SetLineColor(iter->color);
1209 eA->SetLineColor(iter->color);
1210 sA->SetLineWidth((Width_t)iter->size);
1211 sB->SetLineWidth((Width_t)iter->size);
1212 eA->SetLineWidth((Width_t)iter->size);
1213 sA->SetFillStyle(0);
1214 sB->SetFillStyle(0);
1215 eA->SetFillStyle(0);
1216 FillPoly(sA, sB, eA, iter->points); // in hdv_mainframe.h
1217
1218 // Axial CDC wires will end up as having zero length in the end view
1219 // so we draw an additional marker in the end view for those cases.
1220 if(eA->GetN()==2){
1221 double *x = eA->GetX();
1222 double *y = eA->GetY();
1223 if(fabs(x[0]-x[1])<0.1 && fabs(y[0]==y[1])<0.1){
1224 TMarker *m = new TMarker(x[0], y[0], 8);
1225 m->SetMarkerColor(iter->color);
1226 m->SetMarkerSize(0.5);
1227 graphics_endA.push_back(m);
1228 }
1229 }
1230 }
1231 }
1232
1233 // Add in additional view-specific objects
1234 if(coordinatetype == COORD_XY){
1235 for(unsigned int i=0; i<gMYPROC->graphics_xyA.size(); i++){
1236 graphics_endA.push_back(gMYPROC->graphics_xyA[i]);
1237 }
1238 for(unsigned int i=0; i<gMYPROC->graphics_xyB.size(); i++){
1239 graphics_endB.push_back(gMYPROC->graphics_xyB[i]);
1240 }
1241 }
1242
1243 // Draw everything
1244 endviewA->GetCanvas()->cd(0);
1245 for(unsigned int i=0; i<graphics_endA.size(); i++){
1246 TPolyLine *l = dynamic_cast<TPolyLine*>(graphics_endA[i]);
1247 if(l && l->GetFillStyle()!=0){
1248 graphics_endA[i]->Draw("f");
1249 }else{
1250 graphics_endA[i]->Draw("");
1251 }
1252 }
1253 endviewA->GetCanvas()->Update();
1254 endviewAmf->DrawObjects(graphics_endA); // duplicate drawing of objects in big window
1255
1256 endviewB->GetCanvas()->cd(0);
1257 for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw("f");
1258 for(unsigned int i=0; i<graphics_endB.size(); i++)graphics_endB[i]->Draw();
1259 endviewB->GetCanvas()->Update();
1260 endviewBmf->DrawObjects(graphics_endB); // duplicate drawing of objects in big window
1261
1262 sideviewA->GetCanvas()->cd(0);
1263 for(unsigned int i=0; i<graphics_sideA.size(); i++)graphics_sideA[i]->Draw();
1264 sideviewA->GetCanvas()->Update();
1265 sideviewB->GetCanvas()->cd(0);
1266 for(unsigned int i=0; i<graphics_sideB.size(); i++)graphics_sideB[i]->Draw();
1267 sideviewB->GetCanvas()->Update();
1268
1269 // Update track labels
1270 DoUpdateTrackLabels();
1271}
1272
1273//-------------------
1274// DoSetDelay
1275//-------------------
1276void hdv_mainframe::DoSetDelay(Int_t id)
1277{
1278 stringstream ss;
1279 ss<<delay->GetSelectedEntry()->GetTitle();
1280 double seconds;
1281 ss>>seconds;
1282 sleep_time = (int)(1000.0*seconds);
1283 timer->SetTime(sleep_time);
1284}
1285
1286//-------------------
1287// DoSetCoordinates
1288//-------------------
1289void hdv_mainframe::DoSetCoordinates(Int_t id)
1290{
1291 coordinatetype = (coordsys_t)id;
1292}
1293
1294//-------------------
1295// DoUpdateTrackLabels
1296//-------------------
1297void hdv_mainframe::DoUpdateTrackLabels(void)
1298{
1299 gMYPROC->UpdateTrackLabels();
1300
1301 throwninfo->Resize();
1302 reconinfo->Resize();
1303}
1304
1305//-------------------
1306// DrawDetectorsXY
1307//-------------------
1308void hdv_mainframe::DrawDetectorsXY(void)
1309{
1310 //============== Side A
1311 {
1312 sideviewA->GetCanvas()->cd(0);
1313 sideviewA->GetCanvas()->Clear();
1314
1315
1316
1317 // ------ Target ------
1318 TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, -0.5, TARGET_Zmid+TARGET_Zlen/2.0, +0.5);
1319 target->SetFillColor(13);
1320 graphics_sideA.push_back(target);
1321
1322
1323 // ----- BCAL ------
1324 TBox *bcal1 = new TBox(BCAL_Zmin, BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, BCAL_Rmax);
1325 TBox *bcal2 = new TBox(BCAL_Zmin, -BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, -BCAL_Rmax);
1326 bcal1->SetFillColor(28);
1327 bcal2->SetFillColor(28);
1328 graphics_sideA.push_back(bcal1);
1329 graphics_sideA.push_back(bcal2);
1330
1331 // ----- CDC ------
1332 TBox *cdc1 = new TBox(CDC_Zmin, CDC_Rmin, CDC_Zmin + CDC_Zlen, CDC_Rmax);
1333 TBox *cdc2 = new TBox(CDC_Zmin, -CDC_Rmin, CDC_Zmin + CDC_Zlen, -CDC_Rmax);
1334 cdc1->SetFillColor(17);
1335 cdc2->SetFillColor(17);
1336 graphics_sideA.push_back(cdc1);
1337 graphics_sideA.push_back(cdc2);
1338
1339 // ----- FDC ------
1340 for(int i=0; i<4; i++){
1341 // Get FDC package positions from FDC library
1342 float zu = fdcwires[i*6][0]->origin.z();
1343 float zd = fdcwires[i*6+5][0]->origin.z();
1344 TBox *fdc1 = new TBox(zu, FDC_Rmin, zd, FDC_Rmax);
1345 TBox *fdc2 = new TBox(zu, -FDC_Rmin, zd, -FDC_Rmax);
1346 fdc1->SetFillColor(21);
1347 fdc2->SetFillColor(21);
1348 graphics_sideA.push_back(fdc1);
1349 graphics_sideA.push_back(fdc2);
1350 }
1351
1352 // ----- TOF ------
1353 TBox *tof1 = new TBox(TOF_Zmin, TOF_Rmin, TOF_Zmin+TOF_Zlen, TOF_Rmax);
1354 TBox *tof2 = new TBox(TOF_Zmin, -TOF_Rmin, TOF_Zmin+TOF_Zlen, -TOF_Rmax);
1355 tof1->SetFillColor(11);
1356 tof2->SetFillColor(11);
1357 graphics_sideA.push_back(tof1);
1358 graphics_sideA.push_back(tof2);
1359
1360 // ----- FCAL ------
1361 TBox *fcal1 = new TBox(FCAL_Zmin, FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, FCAL_Rmax);
1362 TBox *fcal2 = new TBox(FCAL_Zmin, -FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, -FCAL_Rmax);
1363 fcal1->SetFillColor(40);
1364 fcal2->SetFillColor(40);
1365 graphics_sideA.push_back(fcal1);
1366 graphics_sideA.push_back(fcal2);
1367
1368 // ------ scale ------
1369 DrawScale(sideviewA->GetCanvas(), graphics_sideA);
1370 }
1371
1372 //============== Side B
1373 {
1374 sideviewB->GetCanvas()->cd(0);
1375 sideviewB->GetCanvas()->Clear();
1376
1377 // Side B is exactly the same as side A so just copy it
1378 for(unsigned int i=0; i<graphics_sideA.size(); i++){
1379 graphics_sideB.push_back(graphics_sideA[i]->Clone());
1380 }
1381 }
1382
1383 //============== End A
1384 {
1385 endviewB->GetCanvas()->cd(0);
1386 endviewB->GetCanvas()->Clear();
1387
1388 // ----- BCAL ------
1389 TEllipse *bcal1 = new TEllipse(0.0, 0.0, BCAL_Rmax, BCAL_Rmax);
1390 TEllipse *bcal2 = new TEllipse(0.0, 0.0, BCAL_Rmin, BCAL_Rmin);
1391 bcal1->SetFillColor(0);
1392 bcal2->SetFillColor(0);
1393 graphics_endA.push_back(bcal1);
1394 graphics_endA.push_back(bcal2);
1395
1396 double dlayer1 = 0.5*(BCAL_MIDRAD-BCAL_Rmin)/(double)BCAL_LAYS1;
1397 //double dlayer2 = (BCAL_Rmax-BCAL_MIDRAD)/(double)BCAL_LAYS2;
1398 double dmodule = (double)TMath::TwoPi()/(double)BCAL_MODS;
1399 double dsector1 = dmodule/(double)BCAL_SECS1;
1400 double dsector2 = dmodule/(double)BCAL_SECS2;
1401
1402 // Create polygon for each readout segment for use in coloring hits
1403 if(GetCheckButton("bcal")){
1404 for(int imod=0; imod<BCAL_MODS; imod++){
1405 double mod_phi = (double)imod*dmodule -2.0*dsector1 + BCAL_PHI_SHIFT;
1406 double r_min=BCAL_Rmin;
1407 for(int ilay=0; ilay<BCAL_LAYS1; ilay++){
1408 r_min+=dlayer1*ilay;
1409 double r_max = r_min+(ilay+1)*dlayer1;
1410 for(int isec=0; isec<BCAL_SECS1; isec++){
1411 double phimin = mod_phi + (double)isec*dsector1;
1412 double phimax = phimin + dsector1;
1413
1414 double x[4], y[4];
1415 x[0] = r_min*cos(phimin);
1416 y[0] = r_min*sin(phimin);
1417 x[1] = r_max*cos(phimin);
1418 y[1] = r_max*sin(phimin);
1419 x[2] = r_max*cos(phimax);
1420 y[2] = r_max*sin(phimax);
1421 x[3] = r_min*cos(phimax);
1422 y[3] = r_min*sin(phimax);
1423
1424 TPolyLine *poly = new TPolyLine(4, x, y);
1425 poly->SetLineColor(12);
1426 poly->SetLineWidth(0);
1427 poly->SetFillColor(0);
1428 poly->SetFillStyle(0);
1429 int chan = (imod+1)*1000 + (ilay+1)*100 + (isec+1)*10;
1430 graphics_endA.push_back(poly);
1431 bcalblocks[chan] = poly; // record so we can set the color later
1432 }
1433
1434 for(int isec=0; isec<BCAL_SECS2; isec++){
1435 double phimin = mod_phi + (double)isec*dsector2;
1436 double phimax = phimin + dsector2;
1437
1438 double x[5], y[5];
1439 x[0] = BCAL_MIDRAD*cos(phimin);
1440 y[0] = BCAL_MIDRAD*sin(phimin);
1441 x[1] = BCAL_Rmax*cos(phimin);
1442 y[1] = BCAL_Rmax*sin(phimin);
1443 x[2] = BCAL_Rmax*cos(phimax);
1444 y[2] = BCAL_Rmax*sin(phimax);
1445 x[3] = BCAL_MIDRAD*cos(phimax);
1446 y[3] = BCAL_MIDRAD*sin(phimax);
1447 x[4] = x[0];
1448 y[4] = y[0];
1449 TPolyLine *poly = new TPolyLine(5, x, y);
1450 poly->SetLineColor(12);
1451 poly->SetLineWidth(1);
1452 poly->SetFillColor(0);
1453 poly->SetFillStyle(0);
1454 int chan = (int)((imod+1)*1000 + (ilay+1+BCAL_LAYS1)*100 + (isec+1)*10);
1455 graphics_endA.push_back(poly);
1456 bcalblocks[chan] = poly; // record so we can set the color later
1457 }
1458 }
1459 }
1460 }
1461 // Draw lines to identify boundaries of readout segments
1462 for(int imod=0; imod<BCAL_MODS; imod++){
1463 // Vertical(sector) boundaries
1464 double mod_phi = (double)imod*dmodule -2.0*dsector1 + BCAL_PHI_SHIFT;
1465 for(int isec=0; isec<BCAL_SECS1; isec++){
1466 double rmin = BCAL_Rmin;
1467 double rmax = BCAL_MIDRAD;
1468 double phi = mod_phi + (double)isec*dsector1;
1469
1470 TLine *l = new TLine(rmin*cos(phi), rmin*sin(phi), rmax*cos(phi), rmax*sin(phi));
1471 l->SetLineColor(isec==0 ? kBlack:12);
1472 l->SetLineWidth((Width_t)(isec==0 ? 2.5:1.0));
1473 graphics_endA.push_back(l);
1474 }
1475 for(int isec=0; isec<BCAL_SECS2; isec++){
1476 double rmin = BCAL_MIDRAD;
1477 double rmax = BCAL_Rmax;
1478 double phi = mod_phi + (double)isec*dsector2;
1479
1480 TLine *l = new TLine(rmin*cos(phi), rmin*sin(phi), rmax*cos(phi), rmax*sin(phi));
1481 l->SetLineColor(isec==0 ? kBlack:12);
1482 l->SetLineWidth((Width_t)(isec==0 ? 2.5:1.0));
1483 graphics_endA.push_back(l);
1484 }
1485
1486 // Horizontal(layer) boundaries
1487 double r=BCAL_Rmin;
1488 for(int ilay=0; ilay<BCAL_LAYS1; ilay++){
1489 r+=dlayer1*ilay;
1490 TLine *l = new TLine(r*cos(mod_phi), r*sin(mod_phi), r*cos(mod_phi+dmodule), r*sin(mod_phi+dmodule));
1491 l->SetLineColor(ilay==0 ? kBlack:12);
1492 l->SetLineWidth((Width_t)(ilay==0 ? 1.0:1.0));
1493 graphics_endA.push_back(l);
1494 }
1495
1496 TLine *l = new TLine(BCAL_MIDRAD*cos(mod_phi), BCAL_MIDRAD*sin(mod_phi), BCAL_MIDRAD*cos(mod_phi+dmodule), BCAL_MIDRAD*sin(mod_phi+dmodule));
1497 l->SetLineColor(12);
1498 l->SetLineWidth((Width_t)(1.0));
1499 graphics_endA.push_back(l);
1500 }
1501
1502 // ----- CDC ------
1503 TEllipse *cdc1 = new TEllipse(0.0, 0.0, CDC_Rmax, CDC_Rmax);
1504 TEllipse *cdc2 = new TEllipse(0.0, 0.0, CDC_Rmin, CDC_Rmin);
1505 cdc1->SetFillColor(17);
1506 cdc1->SetLineColor(17);
1507 cdc2->SetFillColor(10);
1508 graphics_endA.push_back(cdc1);
1509 graphics_endA.push_back(cdc2);
1510
1511 // ----- FDC ------
1512 TEllipse *fdc1 = new TEllipse(0.0, 0.0, FDC_Rmax, FDC_Rmax);
1513 TEllipse *fdc2 = new TEllipse(0.0, 0.0, FDC_Rmin, FDC_Rmin);
1514 fdc1->SetFillColor(21);
1515 fdc1->SetLineColor(21);
1516 fdc2->SetFillColor(10);
1517 fdc2->SetLineColor(10);
1518 graphics_endA.push_back(fdc1);
1519 graphics_endA.push_back(fdc2);
1520
1521
1522 /*
1523 // ------ Start counter ------
1524 double r_start=7.7;
1525 for (unsigned int i=0;i<30;i++){
1526 double phi_0=0.209*i;
1527 double phi_1=0.209*(i+1);
1528 TLine *l = new TLine(r_start*cos(phi_0), r_start*sin(phi_0),
1529 r_start*cos(phi_1), r_start*sin(phi_1));
1530 l->SetLineColor(10);
1531 l->SetLineWidth(2.);
1532 graphics_endA.push_back(l);
1533 }
1534 */
1535
1536 // ----- Start Counter -----
1537 // All units are in cm. These dimensions represent the geometry exactly.
1538 Double_t inner_radius = 7.7493; // Inner radius of the Start Counter
1539 Double_t outer_radius = 8.0493; // Outer radius of the Start Counter
1540 Double_t bottom_width = 1.6289; // Width of the bottom edge of scintillator
1541 Double_t top_width = 1.692; // Width of the top edge of scintillator
1542 Double_t dtr = 1.745329252e-02; // Conversion factor from degrees to radians
1543
1544 // 5 x and 5 y coordinates for each of the 30 paddles
1545 Double_t x_coords[31][5];
1546 Double_t y_coords[31][5];
1547
1548 // Initialize the x-coordinates of channel 0 (phi = [0, 12 deg] in hall coordinates)
1549 x_coords[0][0] = -outer_radius;
1550 x_coords[0][1] = -(outer_radius - top_width*sin(6.0*dtr));
1551 x_coords[0][2] = -(inner_radius - bottom_width*sin(6.0*dtr));
1552 x_coords[0][3] = -inner_radius;
1553 x_coords[0][4] = -outer_radius;
1554 // Initialize the x-coordinates of channel 0 (phi = [0, 12 deg] in hall coordinates)
1555 y_coords[0][0] = 0.0;
1556 y_coords[0][1] = top_width*cos(6.0*dtr);
1557 y_coords[0][2] = bottom_width*cos(6.0*dtr);
1558 y_coords[0][3] = 0.0;
1559 y_coords[0][4] = 0.0;
1560
1561 // Create an array of TPolyLine objects
1562 TPolyLine *ch_pline[30];
1563
1564 // Define array of points which define the individual scintillators
1565 for (int i = 1; i < 31; i++)
1566 {
1567 // Contruct the x-coordinates of the 30 scintillator paddles
1568 x_coords[i][0] = x_coords[i-1][1];
1569 x_coords[i][1] = x_coords[i-1][1] + top_width*sin((6.0 + 12.0*i)*dtr);
1570 x_coords[i][2] = x_coords[i-1][2] + bottom_width*sin((6.0 + 12.0*i)*dtr);
1571 x_coords[i][3] = x_coords[i-1][2];
1572 x_coords[i][4] = x_coords[i-1][1];
1573 // Construct the y-coordinates of the 30 scintillator paddles
1574 y_coords[i][0] = y_coords[i-1][1];
1575 y_coords[i][1] = y_coords[i-1][1] + top_width*cos((6.0 + 12.0*i)*dtr);
1576 y_coords[i][2] = y_coords[i-1][2] + bottom_width*cos((6.0 + 12.0*i)*dtr);
1577 y_coords[i][3] = y_coords[i-1][2];
1578 y_coords[i][4] = y_coords[i-1][1];
1579
1580 // Construct the TPolyLine objects that defines the paddles
1581 Double_t x[5] = {x_coords[i-1][0], x_coords[i-1][1], x_coords[i-1][2], x_coords[i-1][3], x_coords[i-1][4]};
1582 Double_t y[5] = {y_coords[i-1][0], y_coords[i-1][1], y_coords[i-1][2], y_coords[i-1][3], y_coords[i-1][4]};
1583 ch_pline[i-1] = new TPolyLine(5, x, y);
1584 ch_pline[i-1]->SetFillColor(18);
1585 ch_pline[i-1]->SetLineColor(1);
1586 ch_pline[i-1]->SetLineWidth(2);
1587 graphics_endA.push_back(ch_pline[i-1]);
1588 }
1589
1590 // ----- TARGET ------
1591 TEllipse *target = new TEllipse(0.0, 0.0, 0.5, 0.5);
1592 target->SetFillColor(13);
1593 graphics_endA.push_back(target);
1594
1595 // ------ scale ------
1596 DrawScale(endviewA->GetCanvas(), graphics_endA);
1597 }
1598
1599 //============== End B
1600 {
1601 endviewB->GetCanvas()->cd(0);
1602 endviewB->GetCanvas()->Clear();
1603
1604 // ----- FCAL ------
1605 // Get list of blocks. Loop over all getting x,y coordinates of corners for all active ones.
1606
1607 // Set up 4 2-D vectors that point from the center of a block to its
1608 // corners. This makes it easier to represent each corner as a vector
1609 // in lab corrdinate whch we can extract r, phi from.
1610 double blocksize = fcalgeom->blockSize();
1611 DVector2 shift[4];
1612 shift[0].Set(-blocksize/2, -blocksize/2); // these are ordered such that they
1613 shift[1].Set(-blocksize/2, +blocksize/2); // go in a clockwise manner. This
1614 shift[2].Set(+blocksize/2, +blocksize/2); // ensures the r/phi cooridinates also
1615 shift[3].Set(+blocksize/2, -blocksize/2); // define a single enclosed space
1616 fcalblocks.clear();
1617
1618 if(GetCheckButton("fcal")){
1619 for(int chan=0; chan<DFCALGeometry::kMaxChannels; chan++){
1620 int row = fcalgeom->row(chan);
1621 int col = fcalgeom->column(chan);
1622 if(!fcalgeom->isBlockActive(row, col))continue;
1623 double x[4], y[4];
1624 for(int i=0; i<4; i++){
1625 DVector2 pos = shift[i] + fcalgeom->positionOnFace(chan);
1626 x[i] = pos.X();
1627 y[i] = pos.Y();
1628 }
1629
1630 TPolyLine *poly = new TPolyLine(4, x, y);
1631 poly->SetFillColor(0);
1632 poly->SetLineColor(kBlack);
1633 graphics_endB.push_back(poly);
1634
1635 fcalblocks[chan] = poly; // record so we can set the color later
1636 }
1637 }
1638
1639 // ------- TOF ---------//
1640 tofblocks.clear();
1641 if(GetCheckButton("tof")){
1642
1643 TPolyLine *pmtPline[4][44] = {{ NULL__null }, { NULL__null }};
1644
1645 // 38 PMTs for the standard modules in each side
1646 Double_t pmtX[4][44][5];
1647 Double_t pmtY[4][44][5];
1648
1649 Double_t x[5];
1650 Double_t y[5];
1651
1652 // origin: 0:DOWN; 1:NORTH; 2:UP; 3:SOUTH
1653 Double_t position_x[4] = {-126,-126,-126,126};
1654 Double_t position_y[4] = {-126,-126,126,-126};
1655
1656 // PMTs from regular and half lenght modules with 6 cm x 14 cm
1657 Double_t step_x[4][5] = {{0,0,6,6,0},{0,-14,-14,0,0},{0,0,6,6,0},{0,14,14,0,0}};
1658 Double_t step_y[4][5] = {{0,-14,-14,0,0},{0,0,6,6,0},{0,14,14,0,0},{0,0,6,6,0}};
1659 Double_t step_xl[4][5] = {{0,0,3,3,0},{0,-20,-20,0,0},{0,0,3,3,0},{0,20,20,0,0}};
1660 Double_t step_yl[4][5] = {{0,-20,-20,0,0},{0,0,3,3,0},{0,20,20,0,0},{0,0,3,3,0}};
1661 Double_t step_X[4] = {6,0,6,0};
1662 Double_t step_Y[4] = {0,6,0,6};
1663 Double_t step_XL[4] = {3,0,3,0};
1664 Double_t step_YL[4] = {0,3,0,3};
1665
1666
1667 for (int sd=0; sd<4; sd++)
1668 {
1669 for (int i=0; i<44; i++)
1670 {
1671 for (int l=0; l<5; l++)
1672 {
1673 switch(l)
1674 {
1675 case 0:
1676 if (i == 19 || i == 20 || i == 23 || i == 24){
1677 pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l];
1678 pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l];
1679 }
1680 else{
1681 pmtX[sd][i][l]=position_x[sd] + step_x[sd][l];
1682 pmtY[sd][i][l]=position_y[sd] + step_y[sd][l];
1683 }
1684 break;
1685 case 1:
1686 if (i == 19 || i == 20 || i == 23 || i == 24){
1687 pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l];
1688 pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l];
1689 }
1690 else{
1691 pmtX[sd][i][l]=position_x[sd] + step_x[sd][l];
1692 pmtY[sd][i][l]=position_y[sd] + step_y[sd][l];
1693 }
1694 break;
1695 case 2:
1696 if (i == 19 || i == 20 || i == 23 || i == 24){
1697 pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l];
1698 pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l];
1699 }
1700 else{
1701 pmtX[sd][i][l]=position_x[sd] + step_x[sd][l];
1702 pmtY[sd][i][l]=position_y[sd] + step_y[sd][l];
1703 }
1704 break;
1705 case 3:
1706 if (i == 19 || i == 20 || i == 23 || i == 24){
1707 pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l];
1708 pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l];
1709 }
1710 else{
1711 pmtX[sd][i][l]=position_x[sd] + step_x[sd][l];
1712 pmtY[sd][i][l]=position_y[sd] + step_y[sd][l];
1713 }
1714 break;
1715 case 4:
1716 if (i == 19 || i == 20 || i == 23 || i == 24){
1717 pmtX[sd][i][l]=position_x[sd] + step_xl[sd][l];
1718 pmtY[sd][i][l]=position_y[sd] + step_yl[sd][l];
1719 }
1720 else{
1721 pmtX[sd][i][l]=position_x[sd] + step_x[sd][l];
1722 pmtY[sd][i][l]=position_y[sd] + step_y[sd][l];
1723 }
1724 break;
1725 }
1726 }
1727 if ( i == 19 || i == 20 || i == 23 || i == 24){
1728 position_x[sd] = position_x[sd] + step_XL[sd];
1729 position_y[sd] = position_y[sd] + step_YL[sd];
1730 }
1731 else{
1732 position_x[sd] = position_x[sd] + step_X[sd];
1733 position_y[sd] = position_y[sd] + step_Y[sd];
1734 }
1735 }
1736 }
1737
1738 for (int sd=0; sd<4; sd++) // for the 4 sides
1739 {
1740 for (int j=0; j<44; j++) // PMT for the standard modules
1741 {
1742 for (int q=0; q<5; q++)
1743 {
1744 x[q] = pmtX[sd][j][q];
1745 y[q] = pmtY[sd][j][q];
1746 }
1747 pmtPline[sd][j] = new TPolyLine(5,x,y);
1748 }
1749 }
1750
1751 int tof_count = 0;
1752 for (int sd=0; sd<4; sd++) // for the 4 sides
1753 {
1754 for (int j=0; j<44; j++)
1755 {
1756 pmtPline[sd][j]->SetFillColor(1);
1757 pmtPline[sd][j]->SetLineColor(41);
1758 pmtPline[sd][j]->SetLineWidth(2);
1759 tof_count++;
1760 graphics_endB.push_back(pmtPline[sd][j]);
1761 tofblocks[sd][tof_count] = pmtPline[sd][j];
1762 }
1763 tof_count = 0;
1764 }
1765
1766 } // close the if tof-check button
1767
1768 // ------ scale ------
1769 DrawScale(endviewB->GetCanvas(), graphics_endB);
1770 }
1771
1772 //=============== Draw axes arrows
1773 // (this is done here since the sideB graphics are copied from sideA)
1774 DrawAxes(sideviewA->GetCanvas(), graphics_sideA, "Z", "X");
1775 DrawAxes(sideviewB->GetCanvas(), graphics_sideB, "Z", "Y");
1776 DrawAxes(endviewA->GetCanvas(), graphics_endA, "X", "Y");
1777 DrawAxes(endviewB->GetCanvas(), graphics_endB, "X", "Y");
1778
1779
1780 //=============== Draw view labels
1781 DrawLabel(sideviewA->GetCanvas(), graphics_sideA, "top view (looking down from above detector)");
1782 DrawLabel(sideviewA->GetCanvas(), graphics_sideB, "side view from beam right (south)");
1783 DrawLabel(endviewA->GetCanvas(), graphics_endA, "BCAL view from downstream looking upstream");
1784 DrawLabel(endviewB->GetCanvas(), graphics_endB, "FCAL view from downstream looking upstream");
1785}
1786
1787//-------------------
1788// DrawDetectorsRPhi
1789//-------------------
1790void hdv_mainframe::DrawDetectorsRPhi(void)
1791{
1792 //============== Side A R vs. z
1793 {
1794 sideviewA->GetCanvas()->cd(0);
1795 sideviewA->GetCanvas()->Clear();
1796
1797 // ------ Target ------
1798 TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, 0.0, TARGET_Zmid+TARGET_Zlen/2.0, 0.5);
1799 target->SetFillColor(13);
1800 graphics_sideA.push_back(target);
1801
1802 // ----- BCAL ------
1803 TBox *bcal1 = new TBox(BCAL_Zmin, BCAL_Rmin, BCAL_Zmin+BCAL_Zlen, BCAL_Rmax);
1804 bcal1->SetFillColor(28);
1805 graphics_sideA.push_back(bcal1);
1806
1807 // ----- CDC ------
1808 TBox *cdc1 = new TBox(CDC_Zmin, CDC_Rmin, CDC_Zmin + CDC_Zlen, CDC_Rmax);
1809 cdc1->SetFillColor(17);
1810 graphics_sideA.push_back(cdc1);
1811
1812 // ----- FDC ------
1813 for(int i=0; i<4; i++){
1814 // Get FDC package positions from FDC library
1815 float zu = fdcwires[i*6][0]->origin.z();
1816 float zd = fdcwires[i*6+5][0]->origin.z();
1817 TBox *fdc1 = new TBox(zu, FDC_Rmin, zd, FDC_Rmax);
1818 fdc1->SetFillColor(21);
1819 graphics_sideA.push_back(fdc1);
1820 }
1821
1822 // ----- TOF ------
1823 TBox *tof1 = new TBox(TOF_Zmin, TOF_Rmin, TOF_Zmin+TOF_Zlen, TOF_Rmax);
1824 tof1->SetFillColor(11);
1825 graphics_sideA.push_back(tof1);
1826
1827 // ----- FCAL ------
1828 TBox *fcal1 = new TBox(FCAL_Zmin, FCAL_Rmin, FCAL_Zmin+FCAL_Zlen, FCAL_Rmax);
1829 fcal1->SetFillColor(40);
1830 graphics_sideA.push_back(fcal1);
1831
1832 // ------ scale ------
1833 DrawScale(endviewA->GetCanvas(), graphics_endA);
1834 }
1835
1836 //============== Side B Phi vs. z
1837 {
1838 sideviewB->GetCanvas()->cd(0);
1839 sideviewB->GetCanvas()->Clear();
1840
1841 // ------ Target ------
1842 TBox *target = new TBox(TARGET_Zmid-TARGET_Zlen/2.0, 0.0, TARGET_Zmid+TARGET_Zlen/2.0, 2.0*M_PI3.14159265358979323846);
1843 target->SetFillColor(13);
1844 graphics_sideB.push_back(target);
1845
1846 // ----- BCAL ------
1847 TBox *bcal1 = new TBox(BCAL_Zmin, 0.0, BCAL_Zmin+BCAL_Zlen, 2.0*M_PI3.14159265358979323846);
1848 bcal1->SetFillColor(28);
1849 graphics_sideB.push_back(bcal1);
1850
1851 // ----- CDC ------
1852 TBox *cdc1 = new TBox(CDC_Zmin, 0.0, CDC_Zmin + CDC_Zlen, 2.0*M_PI3.14159265358979323846);
1853 cdc1->SetFillColor(17);
1854 graphics_sideB.push_back(cdc1);
1855
1856 // ----- FDC ------
1857 for(int i=0; i<4; i++){
1858 // Get FDC package positions from FDC library
1859 float zu = fdcwires[i*6][0]->origin.z();
1860 float zd = fdcwires[i*6+5][0]->origin.z();
1861
1862 TBox *fdc1 = new TBox(zu, 0.0, zd, 2.0*M_PI3.14159265358979323846);
1863 fdc1->SetFillColor(21);
1864 graphics_sideB.push_back(fdc1);
1865 }
1866
1867 // ----- TOF ------
1868 TBox *tof1 = new TBox(TOF_Zmin, 0.0, TOF_Zmin+TOF_Zlen, 2.0*M_PI3.14159265358979323846);
1869 tof1->SetFillColor(11);
1870 graphics_sideB.push_back(tof1);
1871
1872 // ----- FCAL ------
1873 TBox *fcal1 = new TBox(FCAL_Zmin, 0.0, FCAL_Zmin+FCAL_Zlen, 2.0*M_PI3.14159265358979323846);
1874 fcal1->SetFillColor(40);
1875 graphics_sideB.push_back(fcal1);
1876
1877 // ------ scale ------
1878 DrawScale(endviewA->GetCanvas(), graphics_endA);
1879 }
1880
1881 //============== End A R vs. phi
1882 {
1883 endviewA->GetCanvas()->cd(0);
1884 endviewA->GetCanvas()->Clear();
1885
1886 // ----- BCAL ------
1887 TBox *bcal1 = new TBox(0.0, BCAL_Rmin, 2.0*M_PI3.14159265358979323846, BCAL_Rmax);
1888 bcal1->SetFillColor(28);
1889 graphics_endA.push_back(bcal1);
1890
1891 // ----- CDC ------
1892 TBox *cdc1 = new TBox(0.0, CDC_Rmin, 2.0*M_PI3.14159265358979323846, CDC_Rmax);
1893 cdc1->SetFillColor(17);
1894 graphics_endA.push_back(cdc1);
1895
1896 // ----- FDC ------
1897 TBox *fdc1 = new TBox(0.0, FDC_Rmin, 2.0*M_PI3.14159265358979323846, FDC_Rmax);
1898 fdc1->SetFillColor(21);
1899 graphics_endA.push_back(fdc1);
1900
1901 // ----- TARGET ------
1902 TBox *target = new TBox(0.0, 0.0, 2.0*M_PI3.14159265358979323846, 0.5);
1903 target->SetFillColor(13);
1904 graphics_endA.push_back(target);
1905
1906 }
1907
1908 //============== End B R vs. phi
1909 {
1910 endviewB->GetCanvas()->cd(0);
1911 endviewB->GetCanvas()->Clear();
1912
1913 // ----- FCAL ------
1914 // Get list of blocks. Loop over all getting x,y coordinates of corners for all active ones.
1915
1916 // Set up 4 2-D vectors that point from the center of a block to its
1917 // corners. This makes it easier to represent each corner as a vector
1918 // in lab corrdinate whch we can extract r, phi from.
1919 double blocksize = fcalgeom->blockSize();
1920 DVector2 shift[4];
1921 shift[0].Set(-blocksize/2, -blocksize/2); // these are ordered such that they
1922 shift[1].Set(-blocksize/2, +blocksize/2); // go in a clockwise manner. This
1923 shift[2].Set(+blocksize/2, +blocksize/2); // ensures the r/phi cooridinates also
1924 shift[3].Set(+blocksize/2, -blocksize/2); // define a single enclosed space
1925 fcalblocks.clear();
1926 for(int chan=0; chan<DFCALGeometry::kMaxChannels; chan++){
1927 int row = fcalgeom->row(chan);
1928 int col = fcalgeom->column(chan);
1929 if(!fcalgeom->isBlockActive(row, col))continue;
1930 double r[4], phi[4];
1931 for(int i=0; i<4; i++){
1932 DVector2 pos = shift[i] + fcalgeom->positionOnFace(chan);
1933 r[i] = pos.Mod();
1934 phi[i] = pos.Phi_0_2pi(pos.Phi());
1935 }
1936
1937 TPolyLine *poly = new TPolyLine(4, phi, r);
1938 poly->SetFillColor(18);
1939 poly->SetLineColor(kBlack);
1940 graphics_endB.push_back(poly);
1941
1942 fcalblocks[chan] = poly; // record so we can set the color later
1943 }
1944 }
1945
1946 //=============== Draw axes arrows
1947 DrawAxes(sideviewA->GetCanvas(), graphics_sideA, "Z", "R");
1948 DrawAxes(sideviewB->GetCanvas(), graphics_sideB, "Z", "#phi");
1949 DrawAxes(endviewA->GetCanvas(), graphics_endA, "#phi", "R");
1950 DrawAxes(endviewB->GetCanvas(), graphics_endB, "#phi", "R");
1951}
1952
1953//-------------------
1954// DrawAxes
1955//-------------------
1956void hdv_mainframe::DrawAxes(TCanvas *c, vector<TObject*> &graphics, const char *xlab, const char *ylab)
1957{
1958 /// Create arrows indicating x and y axes with labels on the specified canvas
1959 /// and add them to the specified container of graphics objects to be draw later.
1960 double x1 = c->GetX1();
1961 double x2 = c->GetX2();
1962 double y1 = c->GetY1();
1963 double y2 = c->GetY2();
1964 double deltax = x2-x1;
1965 deltax *= c->GetYsizeReal()/c->GetXsizeReal();
1966 double deltay = y2-y1;
1967 double xlo = x1+0.04*deltax;
1968 double xhi = xlo + 0.075*deltax;
1969 double ylo = y1+0.04*deltay;
1970 double yhi = ylo + 0.075*deltay;
1971 TArrow *yarrow = new TArrow(xlo, ylo, xlo, yhi, 0.02, ">");
1972 yarrow->SetLineWidth((Width_t)1.5);
1973 graphics.push_back(yarrow);
1974
1975 TLatex *ylabel = new TLatex(xlo, yhi+0.005*deltay, ylab);
1976 ylabel->SetTextAlign(21);
1977 graphics.push_back(ylabel);
1978
1979 TArrow *xarrow = new TArrow(xlo, ylo, xhi, ylo, 0.02, ">");
1980 xarrow->SetLineWidth((Width_t)1.5);
1981 graphics.push_back(xarrow);
1982
1983 TLatex *xlabel = new TLatex(xhi+0.005*deltax, ylo, xlab);
1984 xlabel->SetTextAlign(12);
1985 graphics.push_back(xlabel);
1986}
1987
1988//-------------------
1989// DrawScale
1990//-------------------
1991void hdv_mainframe::DrawScale(TCanvas *c, vector<TObject*> &graphics)
1992{
1993 /// Create a scale label on the specified canvas and add it
1994 /// to the specified container of graphics objects to be draw later.
1995 double x1 = c->GetX1();
1996 double x2 = c->GetX2();
1997 double y1 = c->GetY1();
1998 double y2 = c->GetY2();
1999 double deltax = x2-x1;
2000 double deltay = y2-y1;
2001 double p = floor(log(0.1*deltax)/log(10.0));
2002 double m = floor(0.1*deltax/pow(10.0, p) + 0.5);
2003 double xlo = x1+0.72*deltax;
2004 double xhi = xlo + m*pow(10.0, p);
2005 double y = y1+0.04*deltay;
2006 TArrow *arrow = new TArrow(xlo, y, xhi, y, 0.02, "|-|");
2007 arrow->SetLineWidth((Width_t)1.0);
2008 graphics.push_back(arrow);
2009
2010 const char *units="<out of range>";
2011 switch((int)p){
2012 case -5:
2013 units = "#mum";
2014 break;
2015 case -4:
2016 units = "#mum";
2017 break;
2018 case -3:
2019 m*=10.0;
2020 units = "#mum";
2021 break;
2022 case -2:
2023 m*=100.0;
2024 units="#mum";
2025 break;
2026 case -1:
2027 units="mm";
2028 break;
2029 case 0:
2030 units = "cm";
2031 break;
2032 case 1:
2033 m*=10.0;
2034 units = "cm";
2035 break;
2036 case 2:
2037 units = "m";
2038 break;
2039 case 3:
2040 m*=10.0;
2041 units = "m";
2042 break;
2043 case 4:
2044 m*=100.0;
2045 units = "m";
2046 break;
2047 case 5:
2048 units = "km";
2049 break;
2050 case 6:
2051 m*=10.0;
2052 units = "km";
2053 break;
2054 }
2055 char str[256];
2056 sprintf(str,"%d %s", (int)m, units);
2057 TLatex *label = new TLatex(xhi+0.01*deltax, y, str);
2058 label->SetTextAlign(12);
2059 graphics.push_back(label);
2060}
2061
2062//-------------------
2063// DrawLabel
2064//-------------------
2065void hdv_mainframe::DrawLabel(TCanvas *c, vector<TObject*> &graphics, const char *txt)
2066{
2067 /// Create label on top of the specified canvas
2068 /// and add it to the specified container of graphics
2069 /// objects to be drawn later.
2070 double x1 = c->GetX1();
2071 double x2 = c->GetX2();
2072 double y1 = c->GetY1();
2073 double y2 = c->GetY2();
2074 double deltax = x2-x1;
2075 double deltay = y2-y1;
2076 deltax *= c->GetYsizeReal()/c->GetXsizeReal();
2077 double x = x1 + 0.005*deltax;
2078 double y = y2 - 0.003*deltay;
2079
2080 TLatex *label = new TLatex(x, y, txt);
2081 label->SetTextAlign(13);
2082 label->SetTextSize(0.045);
2083 graphics.push_back(label);
2084}
2085
2086
2087//-------------------
2088// SetEvent
2089//-------------------
2090void hdv_mainframe::SetEvent(int id)
2091{
2092 if(!event)return;
2093
2094 char str[256];
2095 sprintf(str,"%5d", id);
2096 event->SetTitle(str);
2097 event->Draw();
2098}
2099
2100//-------------------
2101// SetSource
2102//-------------------
2103void hdv_mainframe::SetSource(string source)
2104{
2105 this->source->SetTitle(source.c_str());
2106 this->source->Draw();
2107}
2108
2109//-------------------
2110// SetCandidateFactories
2111//-------------------
2112void hdv_mainframe::SetCandidateFactories(vector<string> &facnames)
2113{
2114 /// Filter out the factories that provide "DTrackCandidate" objects
2115 /// and add their tags to the tracksfactory combobox.
2116 // Erase all current entries in the combobox and add back in
2117 // "<default>".
2118 candidatesfactory->RemoveAll();
2119 candidatesfactory->AddEntry("<default>", 0);
2120 candidatesfactory->GetTextEntry()->SetText("<default>");
2121 candidatesfactory->Select(0, kFALSE);
2122
2123 for(unsigned int i=0; i< facnames.size(); i++){
2124 string name = "DTrackCandidate:";
2125 string::size_type pos = facnames[i].find(name);
2126 if(pos==string::npos)continue;
2127 string tag = facnames[i];
2128 tag.erase(0, name.size());
2129 candidatesfactory->AddEntry(tag.c_str(), i);
2130 if(tag==default_candidate){
2131 candidatesfactory->Select(i, kTRUE);
2132 candidatesfactory->GetTextEntry()->SetText(tag.c_str());
2133 }
2134 }
2135}
2136
2137//-------------------
2138// SetWireBasedTrackFactories
2139//-------------------
2140void hdv_mainframe::SetWireBasedTrackFactories(vector<string> &facnames)
2141{
2142 /// Filter out the factories that provide "DTrackWireBased" objects
2143 /// and add their tags to the tracksfactory combobox.
2144
2145 // Erase all current entries in the combobox and add back in
2146 // "<default>".
2147 wiretracksfactory->RemoveAll();
2148 wiretracksfactory->AddEntry("<default>", 0);
2149 wiretracksfactory->GetTextEntry()->SetText("<default>");
2150 wiretracksfactory->Select(0, kFALSE);
2151
2152 for(unsigned int i=0; i< facnames.size(); i++){
2153 string name = "DTrackWireBased:";
2154 string::size_type pos = facnames[i].find(name);
2155 if(pos==string::npos)continue;
2156 string tag = facnames[i];
2157 tag.erase(0, name.size());
2158 wiretracksfactory->AddEntry(tag.c_str(), i+1);
2159 if(tag==default_track){
2160 wiretracksfactory->Select(i, kTRUE);
2161 wiretracksfactory->GetTextEntry()->SetText(tag.c_str());
2162 }
2163 }
2164}
2165
2166//-------------------
2167// SetTimeBasedTrackFactories
2168//-------------------
2169void hdv_mainframe::SetTimeBasedTrackFactories(vector<string> &facnames)
2170{
2171 /// Filter out the factories that provide "DTrackTimeBased" objects
2172 /// and add their tags to the timetracksfactory combobox.
2173
2174 // Erase all current entries in the combobox and add back in
2175 // "<default>".
2176 timetracksfactory->RemoveAll();
2177 timetracksfactory->AddEntry("<default>", 0);
2178 timetracksfactory->GetTextEntry()->SetText("<default>");
2179 timetracksfactory->Select(0, kFALSE);
2180
2181 for(unsigned int i=0; i< facnames.size(); i++){
2182 string name = "DTrackTimeBased:";
2183 string::size_type pos = facnames[i].find(name);
2184 if(pos==string::npos)continue;
2185 string tag = facnames[i];
2186 tag.erase(0, name.size());
2187 timetracksfactory->AddEntry(tag.c_str(), i+1);
2188 if(tag==default_track){
2189 timetracksfactory->Select(i, kTRUE);
2190 timetracksfactory->GetTextEntry()->SetText(tag.c_str());
2191 }
2192 }
2193}
2194
2195//-------------------
2196// SetChargedTrackFactories
2197//-------------------
2198void hdv_mainframe::SetChargedTrackFactories(vector<string> &facnames)
2199{
2200 /// Filter out the factories that provide "DChargedTrack" objects
2201 /// and add their tags to the chargedtracksfactory combobox.
2202
2203 // Erase all current entries in the combobox and add back in
2204 // "<default>".
2205 chargedtracksfactory->RemoveAll();
2206 chargedtracksfactory->AddEntry("<default>", 0);
2207 chargedtracksfactory->GetTextEntry()->SetText("<default>");
2208 chargedtracksfactory->Select(0, kFALSE);
2209
2210 for(unsigned int i=0; i< facnames.size(); i++){
2211 string name = "DChargedTrack:";
2212 string::size_type pos = facnames[i].find(name);
2213 if(pos==string::npos)continue;
2214 string tag = facnames[i];
2215 tag.erase(0, name.size());
2216 chargedtracksfactory->AddEntry(tag.c_str(), i+1);
2217 if(tag==default_track){
2218 chargedtracksfactory->Select(i, kTRUE);
2219 chargedtracksfactory->GetTextEntry()->SetText(tag.c_str());
2220 }
2221 }
2222}
2223
2224
2225
2226//-------------------
2227// SetReconstructedFactories
2228//-------------------
2229void hdv_mainframe::SetReconstructedFactories(vector<string> &facnames)
2230{
2231 /// Filter out the factories that provide "DTrack" objects
2232 /// and add them to the reconfactory combobox.
2233
2234 // Erase all current entries in the combobox and add back in
2235 // "<default>".
2236 int id =0;
2237 reconfactory->RemoveAll();
2238 reconfactory->AddEntry("DTrackTimeBased:", id++);
2239 reconfactory->Select(0, kFALSE);
2240 reconfactory->GetTextEntry()->SetText("DTrackTimeBased:");
2241
2242 // Add DTrackTimeBased factories
2243 for(unsigned int i=0; i< facnames.size(); i++){
2244 string name = "DTrackTimeBased:";
2245 string::size_type pos = facnames[i].find(name);
2246 if(pos==string::npos)continue;
2247 string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size());
2248 reconfactory->AddEntry(facnames[i].c_str(), id++);
2249 if(facnames[i]==default_reconstructed){
2250 reconfactory->Select(id-1, kTRUE);
2251 reconfactory->GetTextEntry()->SetText(facnames[i].c_str());
2252 }
2253 }
2254
2255 // Add DTrackWireBased factories
2256 reconfactory->AddEntry("DTrackWireBased:", id++);
2257 for(unsigned int i=0; i< facnames.size(); i++){
2258 string name = "DTrackWireBased:";
2259 string::size_type pos = facnames[i].find(name);
2260 if(pos==string::npos)continue;
2261 string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size());
2262 reconfactory->AddEntry(facnames[i].c_str(), id++);
2263 if(facnames[i]==default_reconstructed){
2264 reconfactory->Select(id-1, kTRUE);
2265 reconfactory->GetTextEntry()->SetText(facnames[i].c_str());
2266 }
2267 }
2268
2269 // Add DTrackCandidate factories
2270 reconfactory->AddEntry("DTrackCandidate:", id++);
2271 for(unsigned int i=0; i< facnames.size(); i++){
2272 string name = "DTrackCandidate:";
2273 string::size_type pos = facnames[i].find(name);
2274 if(pos==string::npos)continue;
2275 string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size());
2276 reconfactory->AddEntry(facnames[i].c_str(), id++);
2277 if(facnames[i]==default_reconstructed){
2278 reconfactory->Select(id-1, kTRUE);
2279 reconfactory->GetTextEntry()->SetText(facnames[i].c_str());
2280 }
2281 }
2282
2283
2284 // Add DNeutralTrack factories
2285 reconfactory->AddEntry("DNeutralParticle:", id++);
2286 for(unsigned int i=0; i< facnames.size(); i++){
2287 string name = "DNeutralParticle:";
2288 string::size_type pos = facnames[i].find(name);
2289 if(pos==string::npos)continue;
2290 string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size());
2291 reconfactory->AddEntry(facnames[i].c_str(), id++);
2292 if(facnames[i]==default_reconstructed){
2293 reconfactory->Select(id-1, kTRUE);
2294 reconfactory->GetTextEntry()->SetText(facnames[i].c_str());
2295 }
2296 }
2297
2298 // Add DChargedTrack factories
2299 reconfactory->AddEntry("DChargedTrack:", id++);
2300 for(unsigned int i=0; i< facnames.size(); i++){
2301 string name = "DChargedTrack:";
2302 string::size_type pos = facnames[i].find(name);
2303 if(pos==string::npos)continue;
2304 string tag = facnames[i].substr(name.size(), facnames[i].size()-name.size());
2305 reconfactory->AddEntry(facnames[i].c_str(), id++);
2306 if(facnames[i]==default_reconstructed){
2307 reconfactory->Select(id-1, kTRUE);
2308 reconfactory->GetTextEntry()->SetText(facnames[i].c_str());
2309 }
2310 }
2311
2312
2313}
2314
2315//-------------------
2316// GetCheckButton
2317//-------------------
2318bool hdv_mainframe::GetCheckButton(string who)
2319{
2320 map<string, TGCheckButton*>::iterator iter = checkbuttons.find(who);
2321 if(iter==checkbuttons.end())return false;
2322 return iter->second->GetState()==kButtonDown;
2323}
2324//-------------------
2325// AddCheckButtons
2326//-------------------
2327void hdv_mainframe::AddCheckButtons(map<string, TGCheckButton*> &checkbuttons)
2328{
2329 this->checkbuttons.insert(checkbuttons.begin(), checkbuttons.end());
2330}
2331
2332//-------------------
2333// GetFactoryTag
2334//-------------------
2335const char* hdv_mainframe::GetFactoryTag(string who)
2336{
2337 const char *tag = "";
2338
2339 if(who=="DTrackWireBased"){
2340 tag = wiretracksfactory->GetTextEntry()->GetTitle();
2341 //tag = wiretracksfactory->GetSelectedEntry()->GetTitle();
2342 }
2343 if(who=="DTrackCandidate"){
2344 tag = candidatesfactory->GetTextEntry()->GetTitle();
2345 //tag = candidatesfactory->GetSelectedEntry()->GetTitle();
2346 }
2347 if(who=="DTrackTimeBased"){
2348 tag = timetracksfactory->GetTextEntry()->GetTitle();
2349 //tag = timetracksfactory->GetSelectedEntry()->GetTitle();
2350 }
2351 if (who=="DChargedTrack"){
2352 tag=chargedtracksfactory->GetTextEntry()->GetTitle();
2353 }
2354 if(string(tag) == "<default>")tag = "";
2355
2356 return tag;
2357}
2358
2359//-------------------
2360// GetReconFactory
2361//-------------------
2362void hdv_mainframe::GetReconFactory(string &name, string &tag)
2363{
2364 string nametag(reconfactory->GetSelectedEntry()->GetTitle());
2365 string::size_type pos = nametag.find(":");
2366 name = nametag.substr(0, pos);
2367 tag = nametag.substr(pos+1, nametag.size()-(pos+1));
2368}
2369
2370//-------------------
2371// GetFCALPolyLine
2372//-------------------
2373TPolyLine* hdv_mainframe::GetFCALPolyLine(int channel)
2374{
2375 map<int, TPolyLine*>::iterator iter = fcalblocks.find(channel);
2376 if(iter==fcalblocks.end())return NULL__null;
2377 return iter->second;
2378}
2379
2380//-------------------
2381// GetFCALPolyLine
2382//-------------------
2383TPolyLine* hdv_mainframe::GetFCALPolyLine(float x, float y)
2384{
2385 if(!fcalgeom)return NULL__null;
2386 int row = fcalgeom->row(y);
2387 int column = fcalgeom->column(x);
2388 return GetFCALPolyLine(fcalgeom->channel(row, column));
2389}
2390
2391//-------------------
2392// GetTOFPolyLine
2393//-------------------
2394
2395TPolyLine* hdv_mainframe::GetTOFPolyLine(int translate_side, int tof_ch)
2396{
2397 map <int, map<int, TPolyLine*> >::iterator iter;
2398 iter = tofblocks.find(translate_side);
2399 map <int, TPolyLine*>::iterator iter2 = iter->second.find(tof_ch);
2400 if(iter2==iter->second.end())return NULL__null;
2401 return iter2->second;
2402}
2403
2404//-------------------
2405// GetBCALPolyLine
2406//-------------------
2407TPolyLine* hdv_mainframe::GetBCALPolyLine(int module, int layer, int sector)
2408{
2409 int chan = module*1000 + layer*100 + sector*10;
2410 map<int, TPolyLine*>::iterator iter = bcalblocks.find(chan);
2411 if(iter==bcalblocks.end()){
2412 _DBG_std::cerr<<"programs/Analysis/hdview2/hdv_mainframe.cc"
<<":"<<2412<<" "
<<"ERROR: No BCAL readout segment display poly for module="<<module<<" layer="<<layer<<" sector="<<sector<<endl;
2413 return NULL__null;
2414 }
2415 return iter->second;
2416}
2417
2418//-------------------
2419// AddGraphicsSideA
2420//-------------------
2421void hdv_mainframe::AddGraphicsSideA(vector<TObject*> &v)
2422{
2423 for(unsigned int i=0; i<v.size(); i++)graphics_sideA.push_back(v[i]);
2424}
2425
2426//-------------------
2427// AddGraphicsSideB
2428//-------------------
2429void hdv_mainframe::AddGraphicsSideB(vector<TObject*> &v)
2430{
2431 for(unsigned int i=0; i<v.size(); i++)graphics_sideB.push_back(v[i]);
2432}
2433
2434//-------------------
2435// AddGraphicsEndA
2436//-------------------
2437void hdv_mainframe::AddGraphicsEndA(vector<TObject*> &v)
2438{
2439 for(unsigned int i=0; i<v.size(); i++)graphics_endA.push_back(v[i]);
2440}
2441
2442//-------------------
2443// AddGraphicsEndB
2444//-------------------
2445void hdv_mainframe::AddGraphicsEndB(vector<TObject*> &v)
2446{
2447 for(unsigned int i=0; i<v.size(); i++)graphics_endB.push_back(v[i]);
2448}