Bug Summary

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