Bug Summary

File:programs/Analysis/hdview2/MyProcessor.cc
Location:line 1965, column 3
Description:Value stored to 'mass' is never read

Annotated Source Code

1// Author: David Lawrence June 25, 2004
2//
3//
4// MyProcessor.cc
5//
6
7#include <iostream>
8#include <vector>
9#include <string>
10using namespace std;
11
12#include <TLorentzVector.h>
13#include <TLorentzRotation.h>
14#include <TEllipse.h>
15#include <TArc.h>
16#include <TBox.h>
17#include <TLine.h>
18#include <TText.h>
19#include <TVector3.h>
20#include <TColor.h>
21
22#include <particleType.h>
23#include "hdview2.h"
24#include "hdv_mainframe.h"
25#include "hdv_debugerframe.h"
26#include "MyProcessor.h"
27#include "TRACKING/DTrackHit.h"
28#include "TRACKING/DQuickFit.h"
29#include "TRACKING/DMagneticFieldStepper.h"
30#include "TRACKING/DTrackCandidate_factory.h"
31#include "TRACKING/DMCTrackHit.h"
32#include "TRACKING/DMCThrown.h"
33#include "TRACKING/DTrackWireBased.h"
34#include "TRACKING/DTrackTimeBased.h"
35#include "PID/DChargedTrack.h"
36#include "TRACKING/DReferenceTrajectory.h"
37#include "JANA/JGeometry.h"
38#include "TRACKING/DMCTrajectoryPoint.h"
39#include "FCAL/DFCALHit.h"
40#include "TOF/DTOFGeometry.h"
41#include "TOF/DTOFHit.h"
42#include "TOF/DTOFTDCDigiHit.h"
43#include "TOF/DTOFDigiHit.h"
44#include "TOF/DTOFPaddleHit.h"
45#include "TOF/DTOFPoint.h"
46#include "FDC/DFDCGeometry.h"
47#include "CDC/DCDCTrackHit.h"
48#include "FDC/DFDCPseudo.h"
49#include "FDC/DFDCIntersection.h"
50#include "HDGEOMETRY/DGeometry.h"
51#include "FCAL/DFCALGeometry.h"
52#include "FCAL/DFCALHit.h"
53#include "PID/DNeutralParticle.h"
54#include "PID/DNeutralShower.h"
55#include "BCAL/DBCALHit.h"
56#include "BCAL/DBCALIncidentParticle.h"
57#include "TOF/DTOFPoint.h"
58#include "START_COUNTER/DSCHit.h"
59#include "DVector2.h"
60
61extern hdv_mainframe *hdvmf;
62
63// These are declared in hdv_mainframe.cc, but as static so we need to do it here as well (yechh!)
64static float FCAL_Zmin = 622.8;
65static float FCAL_Rmin = 6.0;
66static float FCAL_Rmax = 212.0/2.0;
67static float BCAL_Rmin = 65.0;
68static float BCAL_Zlen = 390.0;
69static float BCAL_Zmin = 212.0 - BCAL_Zlen/2.0;
70
71
72static vector<vector <DFDCWire *> >fdcwires;
73
74
75bool DMCTrajectoryPoint_track_cmp(const DMCTrajectoryPoint *a,const DMCTrajectoryPoint *b){
76 // sort by track number and then by particle type, then by z-coordinate
77 // (yes, I saw the same track number have different particle types!)
78 if(a->track != b->track)return a->track < b->track;
79 if(a->part != b->part )return a->part < b->part;
80 return a->z < b->z;
81}
82
83
84MyProcessor *gMYPROC=NULL__null;
85
86//------------------------------------------------------------------
87// MyProcessor
88//------------------------------------------------------------------
89MyProcessor::MyProcessor()
90{
91 Bfield = NULL__null;
92 loop = NULL__null;
93
94 // Tell factory to keep around a few density histos
95 //gPARMS->SetParameter("TRKFIND:MAX_DEBUG_BUFFERS", 16);
96
97 RMAX_INTERIOR = 65.0;
98 RMAX_EXTERIOR = 88.0;
99 gPARMS->SetDefaultParameter("RT:RMAX_INTERIOR", RMAX_INTERIOR, "cm track drawing Rmax inside solenoid region");
100 gPARMS->SetDefaultParameter("RT:RMAX_EXTERIOR", RMAX_EXTERIOR, "cm track drawing Rmax outside solenoid region");
101
102 gMYPROC = this;
103}
104
105//------------------------------------------------------------------
106// ~MyProcessor
107//------------------------------------------------------------------
108MyProcessor::~MyProcessor()
109{
110
111}
112
113//------------------------------------------------------------------
114// init
115//------------------------------------------------------------------
116jerror_t MyProcessor::init(void)
117{
118 // Make sure detectors have been drawn
119 //if(!drew_detectors)DrawDetectors();
120
121
122
123 vector<JEventLoop*> loops = app->GetJEventLoops();
124 if(loops.size()>0){
125
126 vector<string> facnames;
127 loops[0]->GetFactoryNames(facnames);
128
129 hdvmf = new hdv_mainframe(gClient->GetRoot(), 1400, 700);
130 hdvmf->SetCandidateFactories(facnames);
131 hdvmf->SetWireBasedTrackFactories(facnames);
132 hdvmf->SetTimeBasedTrackFactories(facnames);
133 hdvmf->SetReconstructedFactories(facnames);
134 hdvmf->SetChargedTrackFactories(facnames);
135 fulllistmf = hdvmf->GetFullListFrame();
136 debugermf = hdvmf->GetDebugerFrame();
137 BCALHitCanvas = hdvmf->GetBcalDispFrame();
138
139 if (BCALHitCanvas){
140 BCALHitMatrixU = new TH2F("BCALHitMatrixU","BCAL Hits Upstream", 48*4+2, -1.5, 192.5, 10, 0., 10.);
141 BCALHitMatrixD = new TH2F("BCALHitMatrixD","BCAL Hits Downstream",48*4+2, -1.5, 192.5, 10, 0., 10.);
142 BCALParticles = new TH2F("BCALParticles","BCAL Hits Downstream",(48*4+2)*4, -1.87, 361.87, 1, 0., 1.);
143 BCALHitMatrixU->SetStats(0);
144 BCALHitMatrixD->SetStats(0);
145 BCALParticles->SetStats(0);
146 BCALHitMatrixU->GetXaxis()->SetTitle("Sector number");
147 BCALHitMatrixD->GetXaxis()->SetTitle("Sector number");
148 BCALParticles->GetXaxis()->SetTitle("Phi angle [deg]");
149 }
150 }
151
152 return NOERROR;
153}
154
155//------------------------------------------------------------------
156// brun
157//------------------------------------------------------------------
158jerror_t MyProcessor::brun(JEventLoop *eventloop, int32_t runnumber)
159{
160
161 // Read in Magnetic field map
162 DApplication* dapp = dynamic_cast<DApplication*>(eventloop->GetJApplication());
163 Bfield = dapp->GetBfield(runnumber);
164 const DGeometry *dgeom = dapp->GetDGeometry(runnumber);
165 dgeom->GetFDCWires(fdcwires);
166
167 RootGeom = dapp->GetRootGeom(runnumber);
168 geom = dapp->GetDGeometry(runnumber);
169
170 MATERIAL_MAP_MODEL="DGeometry";
171 gPARMS->SetDefaultParameter("TRKFIT:MATERIAL_MAP_MODEL", MATERIAL_MAP_MODEL);
172
173 eventloop->GetCalib("PID/photon_track_matching", photon_track_matching);
174 DELTA_R_FCAL = photon_track_matching["DELTA_R_FCAL"];
175
176 return NOERROR;
177}
178
179//------------------------------------------------------------------
180// evnt
181//------------------------------------------------------------------
182jerror_t MyProcessor::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
183{
184 if(!eventLoop)return NOERROR;
185 loop = eventLoop;
186 last_jevent.FreeEvent();
187 last_jevent = loop->GetJEvent();
188
189 string source = "<no source>";
190 if(last_jevent.GetJEventSource())source = last_jevent.GetJEventSource()->GetSourceName();
191
192 cout<<"----------- New Event "<<eventnumber<<" -------------"<<endl;
193 hdvmf->SetEvent(eventnumber);
194 hdvmf->SetSource(source.c_str());
195 hdvmf->DoMyRedraw();
196
197 return NOERROR;
198}
199
200//------------------------------------------------------------------
201// FillGraphics
202//------------------------------------------------------------------
203void MyProcessor::FillGraphics(void)
204{
205 /// Create "graphics" objects for this event given the current GUI settings.
206 ///
207 /// This method will create DGraphicSet objects that represent tracks, hits,
208 /// and showers for the event. It creates objects for both hits and
209 /// reconstructed entities. The "graphics" objects created here are
210 /// really just collections of 3D space points with flags indicating
211 /// whether they should be drawn as markers or lines and with what
212 /// color and size. The actual graphics objects are created for the
213 /// various views of the detector in hdv_mainframe.
214
215 graphics.clear();
216 graphics_xyA.clear(); // The objects placed in these will be deleted by hdv_mainframe
217 graphics_xyB.clear(); // The objects placed in these will be deleted by hdv_mainframe
218 graphics_xz.clear(); // The objects placed in these will be deleted by hdv_mainframe
219 graphics_yz.clear(); // The objects placed in these will be deleted by hdv_mainframe
220 graphics_tof_hits.clear(); // The objects placed in these will be deleted by hdv_mainframe
221
222 if(!loop)return;
223
224 vector<const DSCHit *>schits;
225 loop->Get(schits);
226 vector<const DTrackCandidate*> trCand;
227 loop->Get(trCand);
228 vector<const DTrackTimeBased*> trTB;
229 loop->Get(trTB);
230 vector<const DTrackWireBased*> trWB;
231 loop->Get(trWB);
232 hdv_debugerframe *p = hdvmf->GetDebugerFrame();
233 p->SetNTrCand(trCand.size());
234 p->SetNTrWireBased(trWB.size());
235 p->SetNTrTimeBased(trTB.size());
236
237 if (BCALHitCanvas) {
238 vector<const DBCALHit*> locBcalHits;
239 loop->Get(locBcalHits);
240 BCALHitMatrixU->Reset();
241 BCALHitMatrixD->Reset();
242 for (unsigned int k=0;k<locBcalHits.size();k++){
243
244 const DBCALHit* hit = locBcalHits[k];
245 float idxY = (float)hit->layer-1;
246 float idxX = (float) (hit->sector-1 + (hit->module-1)*4);
247 if (hit->end == DBCALGeometry::kUpstream){
248 if (hit->layer==1){
249 BCALHitMatrixU->Fill(idxX,idxY,hit->E);
250 } else if (hit->layer==2){
251 BCALHitMatrixU->Fill(idxX,idxY,hit->E);
252 BCALHitMatrixU->Fill(idxX,idxY+1.,hit->E);
253 } else if (hit->layer==3){
254 BCALHitMatrixU->Fill(idxX,idxY+1,hit->E);
255 BCALHitMatrixU->Fill(idxX,idxY+2.,hit->E);
256 BCALHitMatrixU->Fill(idxX,idxY+3.,hit->E);
257 } else if (hit->layer==4){
258 BCALHitMatrixU->Fill(idxX,idxY+3,hit->E);
259 BCALHitMatrixU->Fill(idxX,idxY+4.,hit->E);
260 BCALHitMatrixU->Fill(idxX,idxY+5.,hit->E);
261 BCALHitMatrixU->Fill(idxX,idxY+6.,hit->E);
262 }
263 } else {
264 if (hit->layer==1){
265 BCALHitMatrixD->Fill(idxX,idxY,hit->E);
266 } else if (hit->layer==2){
267 BCALHitMatrixD->Fill(idxX,idxY,hit->E);
268 BCALHitMatrixD->Fill(idxX,idxY+1.,hit->E);
269 } else if (hit->layer==3){
270 BCALHitMatrixD->Fill(idxX,idxY+1,hit->E);
271 BCALHitMatrixD->Fill(idxX,idxY+2.,hit->E);
272 BCALHitMatrixD->Fill(idxX,idxY+3.,hit->E);
273 } else if (hit->layer==4){
274 BCALHitMatrixD->Fill(idxX,idxY+3,hit->E);
275 BCALHitMatrixD->Fill(idxX,idxY+4.,hit->E);
276 BCALHitMatrixD->Fill(idxX,idxY+5.,hit->E);
277 BCALHitMatrixD->Fill(idxX,idxY+6.,hit->E);
278 }
279 }
280 }
281
282 vector<const DBCALIncidentParticle*> locBcalParticles;
283 loop->Get(locBcalParticles);
284 BCALParticles->Reset();
285 BCALPLables.clear();
286 for (unsigned int k=0;k<locBcalParticles.size();k++){
287 const DBCALIncidentParticle* part = locBcalParticles[k];
288
289 float p = TMath::Sqrt(part->px*part->px + part->py*part->py + part->pz*part->pz);
290 float phi=999;
291 if (part->x!=0){
292 phi = TMath::ATan(TMath::Abs(part->y/part->x));
293 //cout<<phi<<" "<<part->y<<" / "<< part->x<<endl;
294 if (part->y>0){
295 if (part->x<0.){
296 phi = 3.1415926 - phi;
297 }
298 } else {
299 if (part->x<0){
300 phi += 3.1415926;
301 } else {
302 phi = 3.1415926*2. - phi;
303 }
304 }
305
306 phi = phi*180./3.1415926;
307 }
308 //cout<<phi<<" "<<p<<endl;
309 BCALParticles->Fill(phi,0.5,p);
310 char l[20];
311 sprintf(l,"%d",part->ptype);
312 TText *t = new TText(phi,1.01,l);
313 t->SetTextSize(0.08);
314 t->SetTextFont(72);
315 t->SetTextAlign(21);
316 BCALPLables.push_back(t);
317 }
318
319 BCALHitCanvas->Clear();
320 BCALHitCanvas->Divide(1,3);
321 BCALHitCanvas->cd(1);
322 if (BCALHitMatrixU->GetMaximum() > 1000) {
323 BCALHitMatrixU->Scale(0.001); // Scale histogram to GeV
324 BCALHitMatrixU->GetZaxis()->SetTitle("Energy (GeV)");
325 printf("scaling to GeV\n");
326 } else {
327 BCALHitMatrixU->GetZaxis()->SetTitle("Energy (MeV)");
328 }
329 BCALHitMatrixU->Draw("colz");
330 BCALHitCanvas->cd(2);
331 if (BCALHitMatrixD->GetMaximum() > 1000) {
332 BCALHitMatrixD->Scale(0.001); // Scale histogram to GeV
333 BCALHitMatrixD->GetZaxis()->SetTitle("Energy (GeV)");
334 } else {
335 BCALHitMatrixU->GetZaxis()->SetTitle("Energy (MeV)");
336 }
337 BCALHitMatrixD->Draw("colz");
338 BCALHitCanvas->cd(3);
339 BCALParticles->Draw("colz");
340 for (unsigned int n=0;n<BCALPLables.size();n++){
341 BCALPLables[n]->Draw("same");
342 }
343 BCALHitCanvas->Update();
344 }
345
346
347 // BCAL hits
348 if(hdvmf->GetCheckButton("bcal")){
349 vector<const DBCALHit*> bcalhits;
350 loop->Get(bcalhits);
351
352 for(unsigned int i=0; i<bcalhits.size(); i++){
353 const DBCALHit *hit = bcalhits[i];
354 TPolyLine *poly = hdvmf->GetBCALPolyLine(hit->module, hit->layer, hit->sector);
355
356 if(!poly)continue;
357
358 // The aim is to have a log scale in energy
359 double E = 1000.0*hit->E; // Energy in MeV
360 double logE = log10(E);
361 // 3 = 1 GeV, 0 = 1 MeV, use range 0 through 4
362 // 0-1 White-Yellow
363 // 1-2 Yellow-Red
364 // 2-3 Red-Cyan
365 // 3-4 Cyan-Blue
366
367 float r,g,b;
368 if (E<1){
369 r = 1.;
370 g = 1.;
371 b = 1.;
372 } else {
373 if (logE<1){
374 r = 1.;
375 g = 1.;
376 b = 1.-logE;
377 } else {
378 if (logE<2){
379 r = 1.;
380 g = 1.-(logE-1);
381 b = 0.;
382 } else {
383 if (logE<3){
384 r = 1.;
385 g = 0.;
386 b = 1.-(logE-2);
387 } else {
388 if (logE<4){
389 r = 1.-(logE-3);
390 g = 0.;
391 b = 1.;
392 } else {
393 r = 0;
394 g = 1.;
395 b = 0.;
396 //printf("High BCAL cell reconstructed energy: E=%.1f MeV\n",E);
397 }
398 }
399 }
400 }
401 }
402 if (r<0||g<0||b<0||r>1||g>1||b>1) printf("color error (r,g,b)=(%f,%f,%f)\n",r,g,b);
403
404 poly->SetFillColor(TColor::GetColor(r,g,b));
405 poly->SetLineColor(TColor::GetColor(r,g,b));
406 poly->SetLineWidth(1);
407 poly->SetFillStyle(1001);
408 }
409 }
410
411 // FCAL hits
412 if(hdvmf->GetCheckButton("fcal")){
413 vector<const DFCALHit*> fcalhits;
414 loop->Get(fcalhits);
415
416 for(unsigned int i=0; i<fcalhits.size(); i++){
417 const DFCALHit *hit = fcalhits[i];
418 TPolyLine *poly = hdvmf->GetFCALPolyLine(hit->x, hit->y);
419 if(!poly)continue;
420
421#if 0
422 double a = hit->E/0.005;
423 double f = sqrt(a>1.0 ? 1.0:a<0.0 ? 0.0:a);
424 double grey = 0.8;
425 double s = 1.0 - f;
426
427 float r = s*grey;
428 float g = s*grey;
429 float b = f*(1.0-grey) + grey;
430#endif
431
432 // The aim is to have a log scale in energy (see BCAL)
433 double E = 1000*hit->E; // Change Energy to MeV
434 if(E<0.0) continue;
435 double logE = log10(E);
436
437 float r,g,b;
438 if (logE<0){
439 r = 1.;
440 g = 1.;
441 b = 1.;
442 } else {
443 if (logE<1){
444 r = 1.;
445 g = 1.;
446 b = 1.-logE;
447 } else {
448 if (logE<2){
449 r = 1.;
450 g = 1.-(logE-1);
451 b = 0.;
452 } else {
453 if (logE<3){
454 r = 1.;
455 g = 0.;
456 b = 1.-(logE-2);
457 } else {
458 if (logE<4){
459 r = 1.-(logE-3);
460 g = 0.;
461 b = 1.;
462 } else {
463 r = 0;
464 g = 0;
465 b = 0;
466 }
467 }
468 }
469 }
470 }
471 poly->SetFillColor(TColor::GetColor(r,g,b));
472 }
473 }
474 // TOF hits
475 if(hdvmf->GetCheckButton("tof")){
476
477 double hit_north[45];
478 double hit_south[45];
479 double hit_up[45];
480 double hit_down[45];
481
482 memset(hit_north,0,sizeof(hit_north));
483 memset(hit_south,0,sizeof(hit_south));
484 memset(hit_up,0,sizeof(hit_up));
485 memset(hit_down,0,sizeof(hit_down));
486
487 vector<const DTOFHit*> tofhits;
488 loop->Get(tofhits);
489
490 for(unsigned int i=0; i<tofhits.size(); i++){
491 const DTOFHit *tof_hit = tofhits[i];
492
493 int plane = tof_hit->plane;
494 int bar = tof_hit->bar;
495 int end = tof_hit->end;
496 float t = tof_hit->t;
497
498 int translate_side;
499 TPolyLine *pmtPline;
500
501
502 // Flash the PMTs that do have fADC hits
503
504 /*
505 double dE_padd = 0.2/5.2E5 * 40000;
506 double thold = 0.2/5.2E5 * 115;
507 if (tof_hit->has_fADC && (tof_hit->dE - dE_padd > thold)){
508 */
509
510 if (tof_hit->has_fADC){
511 switch(plane)
512 {
513 case 0:
514 if(end == 1){
515 //cout << "Down : " << bar << endl;
516 translate_side = 0;
517 pmtPline = hdvmf->GetTOFPolyLine(translate_side, bar);
518 pmtPline->SetFillColor(2);
519 }
520 else if(end == 0){
521 //cout << "Up : " << bar << endl;
522 translate_side = 2;
523 pmtPline = hdvmf->GetTOFPolyLine(translate_side, bar);
524 pmtPline->SetFillColor(2);
525 }
526 else{
527 cerr << "Out of range TOF end" << endl;
528 }
529 break;
530 case 1:
531 if(end == 0){
532 //cout << "North : " << bar << endl;
533 translate_side = 3;
534 pmtPline = hdvmf->GetTOFPolyLine(translate_side, bar);
535 pmtPline->SetFillColor(2);
536 }
537 else if(end == 1){
538 //cout << "South : " << bar << endl;
539 translate_side = 1;
540 pmtPline = hdvmf->GetTOFPolyLine(translate_side, bar);
541 pmtPline->SetFillColor(2);
542 }
543 else{
544 cerr << "Out of range TOF end" << endl;
545 }
546 break;
547 default:
548 cerr << "Out of range TOF plane" << endl;
549 exit(0);
550 } // close the switch plane loop
551 } // if for the fADC
552
553 // Draw the position from the events that do have tdc hits
554 // with the current status of the TOFHit object those hits appear with no match from the fADC
555 //Float_t hit_dist;
556
557 if (tof_hit->has_TDC){
558 switch(plane)
559 {
560 case 0:
561 if(end == 1){
562 if (hit_down[bar]<=0 || (t < hit_down[bar]) ){
563 hit_down[bar] = t;
564 }
565 }
566 else if(end == 0){
567 if (hit_up[bar]<=0 || (t < hit_up[bar]) ){
568 hit_up[bar] = t;
569 }
570 }
571 else{
572 cerr << "Out of range TOF end" << endl;
573 }
574 break;
575 case 1:
576 if(end == 0){
577 if (hit_north[bar]<=0 || (t < hit_north[bar]) ){
578 hit_north[bar] = t;
579 }
580 }
581 else if(end == 1){
582 if (hit_south[bar]<=0 || (t < hit_south[bar]) ){
583 hit_south[bar] = t;
584 }
585 }
586 else{
587 cerr << "Out of range TOF end" << endl;
588 }
589 break;
590 default:
591 cerr << "Out of range TOF plane" << endl;
592 exit(0);
593 }
594
595 } // close the switch if there is a TDC Hit
596
597 } // close the for TOFHit object
598
599 // Draw the TDC Points here
600
601 Float_t hit_dist;
602 Float_t distY_Horz = -126; // Horizontal plane start counting from the Bottom to Top
603 Float_t distX_Vert = -126; // Vertical plane start counting from the South to North
604 int tdc_hits = 0;
605
606 for(Int_t i_tdc = 1; i_tdc <= 44; i_tdc++){
607 if ( i_tdc == 20 || i_tdc == 21 || i_tdc == 24 || i_tdc == 25 ){
608 distY_Horz = distY_Horz + 1.5;
609 distX_Vert = distX_Vert + 1.5;
610 }
611 else{
612 distY_Horz = distY_Horz + 3.0;
613 distX_Vert = distX_Vert + 3.0;
614 }
615 if(hit_north[i_tdc] > 0 && hit_south[i_tdc] > 0){
616 hit_dist = (15.2*(Float_t(hit_south[i_tdc] - hit_north[i_tdc])/2));
617 TArc *tdc_cir = new TArc(hit_dist,distY_Horz,2);
618 tdc_cir->SetFillColor(kGreen);
619
620 graphics_tof_hits.push_back(tdc_cir);
621 tdc_hits++;
622 }
623 if(hit_up[i_tdc] > 0 && hit_down[i_tdc] > 0){
624 hit_dist = (15.2*(Float_t(hit_down[i_tdc] - hit_up[i_tdc])/2) );
625 TArc *tdc_cir = new TArc(distX_Vert,hit_dist,2);
626 tdc_cir->SetFillColor(kBlue);
627
628 graphics_tof_hits.push_back(tdc_cir);
629 tdc_hits++;
630 }
631 if ( i_tdc == 20 || i_tdc == 21 || i_tdc == 24 || i_tdc == 25 ){
632 distY_Horz = distY_Horz + 1.5;
633 distX_Vert = distX_Vert + 1.5;
634 }
635 else{
636 distY_Horz = distY_Horz + 3.0;
637 distX_Vert = distX_Vert + 3.0;
638 }
639 }
640
641 } // close the if check button for the TOF
642
643 // Start counter hits
644 for (unsigned int i=0;i<schits.size();i++){
645 DGraphicSet gset(6,kLine,2.0);
646 double r_start=7.7493;
647 double phi0=0.2094395*(schits[i]->sector-1); // span 12 deg in phi
648 double phi1=0.2094395*(schits[i]->sector);
649 TVector3 point1(r_start*cos(phi0),r_start*sin(phi0),38.75);
650 gset.points.push_back(point1); // upstream end of sctraight section of scint
651 TVector3 point2(r_start*cos(phi1),r_start*sin(phi1),38.75);
652 gset.points.push_back(point2);
653 TVector3 point3(r_start*cos(phi1),r_start*sin(phi1),78.215);
654 gset.points.push_back(point3); // downstream end of sctraight section of scint
655 TVector3 point4(r_start*cos(phi0),r_start*sin(phi0),78.215);
656 gset.points.push_back(point4);
657 TVector3 point5(r_start*cos(phi0),r_start*sin(phi0),38.75);
658 gset.points.push_back(point5);
659
660 /*
661 // ST dimensions
662 Double_t dtr = 1.74532925e-02; // Conversion factor from degrees to radians
663 Double_t st_straight = 39.465; // Distance of the straight section along scintillator path
664 Double_t st_arc_angle = 18.5; // Angle of the bend arc
665 Double_t st_arc_radius = 12.0; // Radius of the bend arc
666 Double_t st_to_beam = 7.74926; // Distance from beam to bottom side of scintillator paddle
667 Double_t st_len_cone = 16.056; // Length of the cone section along scintillator path
668 Double_t st_thickness = 0.3; // Thickness of the scintillator paddles
669 Double_t st_beam_to_arc_radius = 4.25; // Distance from the beam line to the arc radius
670
671 // Nose Arrays
672 Double_t tp_nose_z[5];
673 Double_t tp_nose_y[5];
674 Double_t bm_nose_z[5];
675 Double_t bm_nose_y[5];
676
677 // Offsets for Hall coordinates
678 Double_t z_center = 65.0; // Target Center (0,0,65)
679 Double_t us_end_pt = -26.25; // Distance of upstream end relative to target
680 Double_t ds_end_pt = 97.4; // Distance of downstream end relative
681
682 // Top start counter paddle straight section
683 TPolyLine *top_paddle_straight;
684 Double_t tp_straight_z[5] = {us_end_pt + z_center, us_end_pt + z_center, us_end_pt + st_straight + z_center, us_end_pt + st_straight + z_center, us_end_pt + z_center};
685 Double_t tp_straight_y[5] = {st_to_beam, st_to_beam + st_thickness, st_to_beam + st_thickness, st_to_beam, st_to_beam};
686 */
687 graphics.push_back(gset);
688 }
689
690 // CDC hits
691 if(hdvmf->GetCheckButton("cdc")){
692 vector<const DCDCTrackHit*> cdctrackhits;
693 loop->Get(cdctrackhits);
694
695 for(unsigned int i=0; i<cdctrackhits.size(); i++){
696 const DCDCWire *wire = cdctrackhits[i]->wire;
697
698 int color = (cdctrackhits[i]->tdrift>-20 && cdctrackhits[i]->tdrift<800) ? kCyan:kYellow;
699 DGraphicSet gset(color, kLine, 1.0);
700 DVector3 dpoint=wire->origin-(wire->L/2.0)*wire->udir;
701 TVector3 tpoint(dpoint.X(),dpoint.Y(),dpoint.Z());
702 gset.points.push_back(tpoint);
703 dpoint=wire->origin+(wire->L/2.0)*wire->udir;
704 tpoint.SetXYZ(dpoint.X(),dpoint.Y(),dpoint.Z());
705 gset.points.push_back(tpoint);
706 graphics.push_back(gset);
707
708 // Rings for drift times.
709 // NOTE: These are not perfect since they still have TOF in them
710 if(hdvmf->GetCheckButton("cdcdrift") && fabs(wire->stereo)<0.05){
711 double x = wire->origin.X();
712 double y = wire->origin.Y();
713 double dist1 = cdctrackhits[i]->dist;
714 TEllipse *e = new TEllipse(x, y, dist1, dist1);
715 e->SetLineColor(38);
716 e->SetFillStyle(0);
717 graphics_xyA.push_back(e);
718
719 double dist2 = dist1 - 4.0*55.0E-4; // what if our TOF was 4ns?
720 e = new TEllipse(x, y, dist2, dist2);
721 e->SetLineColor(38);
722 e->SetFillStyle(0);
723 graphics_xyA.push_back(e);
724 }
725 }
726 }
727
728 // FDC wire
729 if(hdvmf->GetCheckButton("fdcwire")){
730 vector<const DFDCHit*> fdchits;
731 loop->Get(fdchits);
732
733 for(unsigned int i=0; i<fdchits.size(); i++){
734 const DFDCHit *fdchit = fdchits[i];
735 if(fdchit->type!=0)continue;
736 const DFDCWire *wire =fdcwires[fdchit->gLayer-1][fdchit->element-1];
737 if(!wire){
738 _DBG_std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<738<<" "
<<"Couldn't find wire for gLayer="<<fdchit->gLayer<<" and element="<<fdchit->element<<endl;
739 continue;
740 }
741
742 // Wire
743 int color = (fdchit->t>-50 && fdchit->t<2000) ? kCyan:kYellow;
744 DGraphicSet gset(color, kLine, 1.0);
745 DVector3 dpoint=wire->origin-(wire->L/2.0)*wire->udir;
746 TVector3 tpoint(dpoint.X(),dpoint.Y(),dpoint.Z());
747 gset.points.push_back(tpoint);
748 dpoint=wire->origin+(wire->L/2.0)*wire->udir;
749 tpoint.SetXYZ(dpoint.X(),dpoint.Y(),dpoint.Z());
750 gset.points.push_back(tpoint);
751 graphics.push_back(gset);
752 }
753 }
754
755 // FDC intersection hits
756 if(hdvmf->GetCheckButton("fdcintersection")){
757 vector<const DFDCIntersection*> fdcints;
758 loop->Get(fdcints);
759 DGraphicSet gsetp(46, kMarker, 0.5);
760
761 for(unsigned int i=0; i<fdcints.size(); i++){
762 TVector3 tpos(fdcints[i]->pos.X(),fdcints[i]->pos.Y(),
763 fdcints[i]->pos.Z());
764 gsetp.points.push_back(tpos);
765 }
766 graphics.push_back(gsetp);
767 }
768
769 // FDC psuedo hits
770 if(hdvmf->GetCheckButton("fdcpseudo")){
771 vector<const DFDCPseudo*> fdcpseudos;
772 loop->Get(fdcpseudos);
773 DGraphicSet gsetp(38, kMarker, 0.5);
774
775 for(unsigned int i=0; i<fdcpseudos.size(); i++){
776 const DFDCWire *wire = fdcpseudos[i]->wire;
777
778 // Pseudo point
779 TVector3 pos(fdcpseudos[i]->xy.X(),
780 fdcpseudos[i]->xy.Y(), wire->origin.Z());
781 gsetp.points.push_back(pos);
782 }
783 graphics.push_back(gsetp);
784 }
785
786 // DMCThrown
787 if(hdvmf->GetCheckButton("thrown")){
788 vector<const DMCThrown*> mcthrown;
789 loop->Get(mcthrown);
790 for(unsigned int i=0; i<mcthrown.size(); i++){
791 int color=14;
792 double size=1.5;
793 if(mcthrown[i]->charge()==0.0) color = kGreen;
794 if(mcthrown[i]->charge() >0.0) color = kBlue;
795 if(mcthrown[i]->charge() <0.0) color = kRed;
796 switch(mcthrown[i]->type){
797 case Gamma:
798 case Positron:
799 case Electron:
800 size = 1.0;
801 break;
802 case Pi0:
803 case PiPlus:
804 case PiMinus:
805 size = 2.0;
806 break;
807 case Neutron:
808 case Proton:
809 case AntiProton:
810 size = 3.0;
811 break;
812 }
813 AddKinematicDataTrack(mcthrown[i], color, size);
814 }
815 }
816
817 // CDC Truth points
818 if(hdvmf->GetCheckButton("cdctruth")){
819 vector<const DMCTrackHit*> mctrackhits;
820 loop->Get(mctrackhits);
821 DGraphicSet gset(12, kMarker, 0.5);
822 for(unsigned int i=0; i<mctrackhits.size(); i++){
823 const DMCTrackHit *hit = mctrackhits[i];
824 if(hit->system != SYS_CDC)continue;
825
826 TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z);
827 gset.points.push_back(pos);
828 }
829 graphics.push_back(gset);
830 }
831
832 // FDC Truth points
833 if(hdvmf->GetCheckButton("fdctruth")){
834 vector<const DMCTrackHit*> mctrackhits;
835 loop->Get(mctrackhits);
836 DGraphicSet gset(12, kMarker, 0.5);
837 for(unsigned int i=0; i<mctrackhits.size(); i++){
838 const DMCTrackHit *hit = mctrackhits[i];
839 if(hit->system != SYS_FDC)continue;
840
841 TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z);
842 gset.points.push_back(pos);
843 }
844 graphics.push_back(gset);
845 }
846
847 // Track Hits for Track Candidates and Candidate trajectory in Debuger Window
848 for(unsigned int n=0; n<trCand.size(); n++){
849 if (n>9)
850 break;
851 char str1[128];
852 sprintf(str1,"Candidate%d",n+1);
853
854 if(hdvmf->GetCheckButton(str1)){
855
856 int color = n+1;
857 if (color > 4)
858 color++;
859 if (color > 6)
860 color++;
861
862 AddKinematicDataTrack(trCand[n], color, 1.5);
863
864 vector<const DCDCTrackHit*> cdctrackhits;
865 trCand[n]->Get(cdctrackhits);
866 for(unsigned int i=0; i<cdctrackhits.size(); i++){
867 const DCDCWire *wire = cdctrackhits[i]->wire;
868 DGraphicSet gset(color, kLine, 1.0);
869 DVector3 dpoint=wire->origin-(wire->L/2.0)*wire->udir;
870 TVector3 tpoint(dpoint.X(),dpoint.Y(),dpoint.Z());
871 gset.points.push_back(tpoint);
872 dpoint=wire->origin+(wire->L/2.0)*wire->udir;
873 tpoint.SetXYZ(dpoint.X(),dpoint.Y(),dpoint.Z());
874 gset.points.push_back(tpoint);
875 graphics.push_back(gset);
876
877 } // end loop of cdc hits of track candidate
878 vector<const DFDCPseudo*> fdcpseudos;
879 trCand[n]->Get(fdcpseudos);
880 DGraphicSet gsetp(color, kMarker, 0.5);
881
882 for(unsigned int i=0; i<fdcpseudos.size(); i++){
883 const DFDCWire *wire = fdcpseudos[i]->wire;
884
885 // Pseudo point
886 TVector3 pos(fdcpseudos[i]->xy.X(),
887 fdcpseudos[i]->xy.Y(), wire->origin.Z());
888 gsetp.points.push_back(pos);
889 }
890 graphics.push_back(gsetp);
891
892 }
893 }
894
895 // Wire Based Track Hits and trajectory for Debuger Window
896 for(unsigned int n=0; n<trWB.size(); n++){
897 if (n>=MaxWireTracks21)
898 break;
899 char str1[128];
900 sprintf(str1,"WireBased%d",n+1);
901
902 if(hdvmf->GetCheckButton(str1)){
903
904 int color = trWB[n]->candidateid;
905 if (color > 4)
906 color++;
907 if (color > 6)
908 color++;
909
910 AddKinematicDataTrack(trWB[n], color, 1.5);
911
912 vector<const DCDCTrackHit*> cdctrackhits;
913 trWB[n]->Get(cdctrackhits);
914 for(unsigned int i=0; i<cdctrackhits.size(); i++){
915 const DCDCWire *wire = cdctrackhits[i]->wire;
916 DGraphicSet gset(color, kLine, 1.0);
917 DVector3 dpoint=wire->origin-(wire->L/2.0)*wire->udir;
918 TVector3 tpoint(dpoint.X(),dpoint.Y(),dpoint.Z());
919 gset.points.push_back(tpoint);
920 dpoint=wire->origin+(wire->L/2.0)*wire->udir;
921 tpoint.SetXYZ(dpoint.X(),dpoint.Y(),dpoint.Z());
922 gset.points.push_back(tpoint);
923 graphics.push_back(gset);
924
925 } // end loop of cdc hits of track candidate
926 vector<const DFDCPseudo*> fdcpseudos;
927 trWB[n]->Get(fdcpseudos);
928 DGraphicSet gsetp(color, kMarker, 0.5);
929
930 for(unsigned int i=0; i<fdcpseudos.size(); i++){
931 const DFDCWire *wire = fdcpseudos[i]->wire;
932
933 // Pseudo point
934 TVector3 pos(fdcpseudos[i]->xy.X(),
935 fdcpseudos[i]->xy.Y(), wire->origin.Z());
936 gsetp.points.push_back(pos);
937 }
938 graphics.push_back(gsetp);
939
940 }
941 }
942
943 // Time Based Track Hits and trajectory for Debuger Window
944 for(unsigned int n=0; n<trTB.size(); n++){
945 if (n>=MaxTimeTracks21)
946 break;
947 char str1[128];
948 sprintf(str1,"TimeBased%d",n+1);
949
950 if(hdvmf->GetCheckButton(str1)){
951
952 int color = trTB[n]->candidateid;
953 if (color > 4)
954 color++;
955 if (color > 6)
956 color++;
957
958 AddKinematicDataTrack(trTB[n], color, 1.5);
959
960 vector<const DCDCTrackHit*> cdctrackhits;
961 trTB[n]->Get(cdctrackhits);
962 for(unsigned int i=0; i<cdctrackhits.size(); i++){
963 const DCDCWire *wire = cdctrackhits[i]->wire;
964 DGraphicSet gset(color, kLine, 1.0);
965 DVector3 dpoint=wire->origin-(wire->L/2.0)*wire->udir;
966 TVector3 tpoint(dpoint.X(),dpoint.Y(),dpoint.Z());
967 gset.points.push_back(tpoint);
968 dpoint=wire->origin+(wire->L/2.0)*wire->udir;
969 tpoint.SetXYZ(dpoint.X(),dpoint.Y(),dpoint.Z());
970 gset.points.push_back(tpoint);
971 graphics.push_back(gset);
972
973 } // end loop of cdc hits of track candidate
974 vector<const DFDCPseudo*> fdcpseudos;
975 trTB[n]->Get(fdcpseudos);
976 DGraphicSet gsetp(color, kMarker, 0.5);
977
978 for(unsigned int i=0; i<fdcpseudos.size(); i++){
979 const DFDCWire *wire = fdcpseudos[i]->wire;
980
981 // Pseudo point
982 TVector3 pos(fdcpseudos[i]->xy.X(),
983 fdcpseudos[i]->xy.Y(), wire->origin.Z());
984 gsetp.points.push_back(pos);
985 }
986 graphics.push_back(gsetp);
987
988 }
989 }
990
991 // TOF reconstructed points
992 if (hdvmf->GetCheckButton("tof")){
993 vector<const DTOFPoint *>tofpoints;
994 loop->Get(tofpoints);
995 DGraphicSet gset(kRed, kMarker, 0.5);
996 for(unsigned int i=0; i<tofpoints.size(); i++){
997 const DTOFPoint *hit = tofpoints[i];
998 TVector3 pos(hit->pos.x(),hit->pos.y(),hit->pos.z());
999 gset.points.push_back(pos);
1000 }
1001 graphics.push_back(gset);
1002 }
1003
1004 // TOF Truth points
1005 if(hdvmf->GetCheckButton("toftruth")){
1006 vector<const DMCTrackHit*> mctrackhits;
1007 loop->Get(mctrackhits);
1008 DGraphicSet gset(kBlack, kMarker, 0.5);
1009 for(unsigned int i=0; i<mctrackhits.size(); i++){
1010 const DMCTrackHit *hit = mctrackhits[i];
1011 if(hit->system != SYS_TOF)continue;
1012
1013 TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z);
1014 gset.points.push_back(pos);
1015 }
1016 graphics.push_back(gset);
1017 }
1018
1019 // BCAL Truth points
1020 if(hdvmf->GetCheckButton("bcaltruth")){
1021 vector<const DMCTrackHit*> mctrackhits;
1022 loop->Get(mctrackhits);
1023 DGraphicSet gset(kBlack, kMarker, 1.0);
1024 for(unsigned int i=0; i<mctrackhits.size(); i++){
1025 const DMCTrackHit *hit = mctrackhits[i];
1026 if(hit->system != SYS_BCAL)continue;
1027
1028 TVector3 pos(hit->r*cos(hit->phi), hit->r*sin(hit->phi), hit->z);
1029 gset.points.push_back(pos);
1030
1031 TMarker *m = new TMarker(pos.X(), pos.Y(), 2);
1032 graphics_xyA.push_back(m);
1033 }
1034 //graphics.push_back(gset);
1035 }
1036
1037 // FCAL Truth points
1038 if(hdvmf->GetCheckButton("fcaltruth")){
1039 vector<const DFCALGeometry*> fcalgeometries;
1040 vector<const DFCALHit*> mcfcalhits;
1041 loop->Get(fcalgeometries);
1042 loop->Get(mcfcalhits, "TRUTH");
1043 if(fcalgeometries.size()>0){
1044 const DFCALGeometry *fgeom = fcalgeometries[0];
1045
1046 DGraphicSet gset(kBlack, kMarker, 0.25);
1047 for(unsigned int i=0; i<mcfcalhits.size(); i++){
1048 const DFCALHit *hit = mcfcalhits[i];
1049
1050 DVector2 pos_face = fgeom->positionOnFace(hit->row, hit->column);
1051 TVector3 pos(pos_face.X(), pos_face.Y(), FCAL_Zmin);
1052 gset.points.push_back(pos);
1053
1054 TMarker *m = new TMarker(pos.X(), pos.Y(), 2);
1055 //m->SetColor(kGreen);
1056 //m->SetLineWidth(1);
1057 graphics_xyB.push_back(m);
1058
1059 TMarker *m1 = new TMarker(pos.Z(), pos.X(), 2);
1060 graphics_xz.push_back(m1);
1061 TMarker *m2 = new TMarker(pos.Z(), pos.Y(), 2);
1062 graphics_yz.push_back(m2);
1063 }
1064 //graphics.push_back(gset);
1065 }
1066 }
1067
1068 // BCAL reconstructed photons
1069 if(hdvmf->GetCheckButton("recon_photons_bcal")){
1070 vector<const DNeutralParticle*> neutrals;
1071 loop->Get(neutrals);
1072
1073 DGraphicSet gset(kYellow+2, kMarker, 1.25);
1074 gset.marker_style=21;
1075 for(unsigned int i=0; i<neutrals.size(); i++){
1076 vector<const DNeutralShower*> locNeutralShowers;
1077 neutrals[i]->GetT(locNeutralShowers);
1078 DetectorSystem_t locDetectorSystem = locNeutralShowers[0]->dDetectorSystem;
1079 if(locDetectorSystem == SYS_BCAL){
1080 TVector3 pos( locNeutralShowers[0]->dSpacetimeVertex.X(),
1081 locNeutralShowers[0]->dSpacetimeVertex.Y(),
1082 locNeutralShowers[0]->dSpacetimeVertex.Z());
1083 gset.points.push_back(pos);
1084
1085 double dist2 = 2.0 + 5.0*locNeutralShowers[0]->dEnergy;
1086 TEllipse *e = new TEllipse(pos.X(), pos.Y(), dist2, dist2);
1087 e->SetLineColor(kGreen);
1088 e->SetFillStyle(0);
1089 e->SetLineWidth(2);
1090 graphics_xyA.push_back(e);
1091 }
1092 }
1093 //graphics.push_back(gset);
1094 }
1095
1096 // FCAL reconstructed photons
1097 if(hdvmf->GetCheckButton("recon_photons_fcal")){
1098 vector<const DNeutralParticle*> neutrals;
1099 loop->Get(neutrals);
1100 DGraphicSet gset(kOrange, kMarker, 1.25);
1101 gset.marker_style=2;
1102 for(unsigned int i=0; i<neutrals.size(); i++){
1103 vector<const DNeutralShower*> locNeutralShowers;
1104 neutrals[i]->GetT(locNeutralShowers);
1105 DetectorSystem_t locDetectorSystem = locNeutralShowers[0]->dDetectorSystem;
1106 if(locDetectorSystem == SYS_FCAL){
1107
1108 TVector3 pos( locNeutralShowers[0]->dSpacetimeVertex.X(),
1109 locNeutralShowers[0]->dSpacetimeVertex.Y(),
1110 locNeutralShowers[0]->dSpacetimeVertex.Z());
1111 gset.points.push_back(pos);
1112
1113 double dist2 = 2.0 + 10.0*locNeutralShowers[0]->dEnergy;
1114 TEllipse *e = new TEllipse(pos.X(), pos.Y(), dist2, dist2);
1115 e->SetLineColor(kGreen);
1116 e->SetFillStyle(0);
1117 e->SetLineWidth(2);
1118 graphics_xyB.push_back(e);
1119
1120 TEllipse *e1 = new TEllipse(pos.Z(), pos.X(), dist2, dist2);
1121 e1->SetLineColor(kGreen);
1122 e1->SetFillStyle(0);
1123 e1->SetLineWidth(2);
1124 graphics_xz.push_back(e1);
1125 TEllipse *e2 = new TEllipse(pos.Z(), pos.Y(), dist2, dist2);
1126 e2->SetLineColor(kGreen);
1127 e2->SetFillStyle(0);
1128 e2->SetLineWidth(2);
1129 graphics_yz.push_back(e2);
1130
1131 }
1132 }
1133 //graphics.push_back(gset);
1134 }
1135
1136 // Reconstructed photons matched with tracks
1137 if(hdvmf->GetCheckButton("recon_photons_track_match")){
1138 vector<const DChargedTrack*> ctracks;
1139 loop->Get(ctracks);
1140 for(unsigned int i=0; i<ctracks.size(); i++){
1141 const DChargedTrack *locCTrack = ctracks[i];
1142 vector<const DNeutralShower*> locNeutralShowers;
1143 locCTrack->GetT(locNeutralShowers);
1144
1145 if (!locNeutralShowers.size()) continue;
1146
1147
1148 // Decide if this hit BCAL of FCAL based on z of position on calorimeter
1149 bool is_bcal = (locNeutralShowers[0]->dDetectorSystem == SYS_BCAL );
1150
1151 // Draw on all frames except FCAL frame
1152 DGraphicSet gset(kRed, kMarker, 1.25);
1153 gset.marker_style = is_bcal ? 22:3;
1154 TVector3 tpos( locNeutralShowers[0]->dSpacetimeVertex.X(),
1155 locNeutralShowers[0]->dSpacetimeVertex.Y(),
1156 locNeutralShowers[0]->dSpacetimeVertex.Z());
1157 gset.points.push_back(tpos);
1158 graphics.push_back(gset);
1159
1160 // For BCAL hits, don't draw them on FCAL pane
1161 if(is_bcal)continue;
1162
1163 // Draw on FCAL pane
1164 double dist2 = 2.0 + 2.0*locNeutralShowers[0]->dEnergy;
1165 TEllipse *e = new TEllipse(tpos.X(), tpos.Y(), dist2, dist2);
1166 e->SetLineColor(gset.color);
1167 e->SetFillStyle(0);
1168 e->SetLineWidth(1);
1169 TMarker *m = new TMarker(tpos.X(), tpos.Y(), gset.marker_style);
1170 m->SetMarkerColor(gset.color);
1171 m->SetMarkerSize(1.75);
1172 graphics_xyB.push_back(e);
1173 graphics_xyB.push_back(m);
1174 }
1175 }
1176
1177 // FCAL and BCAL thrown photon projections
1178 if(hdvmf->GetCheckButton("thrown_photons_fcal") || hdvmf->GetCheckButton("thrown_photons_bcal")){
1179 vector<const DMCThrown*> throwns;
1180 loop->Get(throwns);
1181 DGraphicSet gset(kSpring, kMarker, 1.25);
1182 for(unsigned int i=0; i<throwns.size(); i++){
1183 const DMCThrown *thrown = throwns[i];
1184 if(thrown->charge()!=0.0)continue;
1185
1186 // This may seem a little funny, but it saves swimming the reference trajectory
1187 // multiple times. The GetIntersectionWithCalorimeter() method will find the
1188 // intersection point of the photon with whichever calorimeter it actually hits
1189 // or if it doesn't hit either of them. Then, we decide to draw the marker based
1190 // on whether the flag is set to draw the calorimeter it hit or not.
1191 DVector3 pos;
1192 DetectorSystem_t who;
1193 GetIntersectionWithCalorimeter(thrown, pos, who);
1194
1195 if(who!=SYS_FCAL && who!=SYS_BCAL)continue;
1196 if(who==SYS_FCAL && !hdvmf->GetCheckButton("thrown_photons_fcal"))continue;
1197 if(who==SYS_BCAL && !hdvmf->GetCheckButton("thrown_photons_bcal"))continue;
1198 TVector3 tpos(pos.X(),pos.Y(),pos.Z());
1199 gset.points.push_back(tpos);
1200
1201 // Only draw on FCAL pane if photon hits FCAL
1202 if(who==SYS_BCAL)continue;
1203
1204 double dist2 = 2.0 + 2.0*thrown->energy();
1205 TEllipse *e = new TEllipse(pos.X(), pos.Y(), dist2, dist2);
1206 e->SetLineColor(kSpring);
1207 e->SetFillStyle(0);
1208 e->SetLineWidth(4);
1209 graphics_xyB.push_back(e);
1210 }
1211 graphics.push_back(gset);
1212 }
1213
1214 // FCAL and BCAL thrown charged particle projections
1215 if(hdvmf->GetCheckButton("thrown_charged_fcal") || hdvmf->GetCheckButton("thrown_charged_bcal")){
1216 vector<const DMCThrown*> throwns;
1217 loop->Get(throwns);
1218
1219 for(unsigned int i=0; i<throwns.size(); i++){
1220 const DMCThrown *thrown = throwns[i];
1221 if(thrown->charge()==0.0)continue;
1222
1223 // This may seem a little funny, but it saves swimming the reference trajectory
1224 // multiple times. The GetIntersectionWithCalorimeter() method will find the
1225 // intersection point of the photon with whichever calorimeter it actually hits
1226 // or if it doesn't hit either of them. Then, we decide to draw the marker based
1227 // on whether the flag is set to draw the calorimeter it hit or not.
1228 DVector3 pos;
1229 DetectorSystem_t who;
1230 GetIntersectionWithCalorimeter(thrown, pos, who);
1231
1232 if(who!=SYS_FCAL && who!=SYS_BCAL)continue;
1233 if(who==SYS_FCAL && !hdvmf->GetCheckButton("thrown_charged_fcal"))continue;
1234 if(who==SYS_BCAL && !hdvmf->GetCheckButton("thrown_charged_bcal"))continue;
1235
1236 DGraphicSet gset(thrown->charge()>0.0 ? kBlue:kRed, kMarker, 1.25);
1237 TVector3 tpos(pos.X(),pos.Y(),pos.Z());
1238 gset.points.push_back(tpos);
1239 graphics.push_back(gset);
1240
1241 //double dist2 = 6.0 + 2.0*thrown->momentum().Mag();
1242 double dist2 = DELTA_R_FCAL;
1243 TEllipse *e = new TEllipse(pos.X(), pos.Y(), dist2, dist2);
1244 e->SetLineColor(thrown->charge()>0.0 ? kBlue:kRed);
1245 e->SetFillStyle(0);
1246 e->SetLineWidth(4);
1247 graphics_xyB.push_back(e);
1248 }
1249 }
1250
1251 // FCAL and BCAL reconstructed charged particle projections
1252 if(hdvmf->GetCheckButton("recon_charged_bcal") || hdvmf->GetCheckButton("recon_charged_fcal")){
1253
1254 // Here we used the full time-based track list, even though it includes multiple
1255 // hypotheses for each candidate. This is because currently, the photon/track
1256 // matching code in PID/DPhoton_factory.cc uses the DTrackTimeBased objects and
1257 // the current purpose of drawing these is to see matching of reconstructed
1258 // charged tracks with calorimeter clusters.
1259 vector<const DTrackTimeBased*> tracks;
1260 loop->Get(tracks, hdvmf->GetFactoryTag("DTrackTimeBased"));
1261
1262 for(unsigned int i=0; i<tracks.size(); i++){
1263 const DTrackTimeBased *track = tracks[i];
1264
1265 // See notes for above sections
1266 DVector3 pos;
1267 DetectorSystem_t who;
1268 GetIntersectionWithCalorimeter(track, pos, who);
1269
1270 if(who!=SYS_FCAL && who!=SYS_BCAL)continue;
1271 if(who==SYS_FCAL && !hdvmf->GetCheckButton("recon_charged_fcal"))continue;
1272 if(who==SYS_BCAL && !hdvmf->GetCheckButton("recon_charged_bcal"))continue;
1273
1274 DGraphicSet gset(track->charge()>0.0 ? kBlue:kRed, kMarker, 1.25);
1275 TVector3 tpos(pos.X(),pos.Y(),pos.Z());
1276 gset.points.push_back(tpos);
1277 graphics.push_back(gset);
1278
1279 if(who==SYS_BCAL)continue; // Don't draw tracks hitting BCAL on FCAL pane
1280
1281 //double dist2 = 6.0 + 2.0*track->momentum().Mag();
1282 double dist2 = DELTA_R_FCAL;
1283 TEllipse *e = new TEllipse(pos.X(), pos.Y(), dist2, dist2);
1284 e->SetLineColor(track->charge()>0.0 ? kBlue:kRed);
1285 e->SetFillStyle(0);
1286 e->SetLineWidth(4);
1287 graphics_xyB.push_back(e);
1288 }
1289 }
1290
1291 // DMCTrajectoryPoints
1292 if(hdvmf->GetCheckButton("trajectories")){
1293 vector<const DMCTrajectoryPoint*> mctrajectorypoints;
1294 loop->Get(mctrajectorypoints);
1295 //sort(mctrajectorypoints.begin(), mctrajectorypoints.end(), DMCTrajectoryPoint_track_cmp);
1296
1297 poly_type drawtype = hdvmf->GetCheckButton("trajectories_lines") ? kLine:kMarker;
1298 double drawsize = hdvmf->GetCheckButton("trajectories_lines") ? 1.0:0.3;
1299 DGraphicSet gset(kBlack, drawtype, drawsize);
1300 //gset.marker_style = 7;
1301 TVector3 last_point;
1302 int last_track=-1;
1303 int last_part=-1;
1304 for(unsigned int i=0; i<mctrajectorypoints.size(); i++){
1305 const DMCTrajectoryPoint *pt = mctrajectorypoints[i];
1306
1307 switch(pt->part){
1308 case Gamma:
1309 if(!hdvmf->GetCheckButton("trajectories_photon"))continue;
1310 break;
1311 case Electron:
1312 if(!hdvmf->GetCheckButton("trajectories_electron"))continue;
1313 break;
1314 case Positron:
1315 if(!hdvmf->GetCheckButton("trajectories_positron"))continue;
1316 break;
1317 case Proton:
1318 if(!hdvmf->GetCheckButton("trajectories_proton"))continue;
1319 break;
1320 case Neutron:
1321 if(!hdvmf->GetCheckButton("trajectories_neutron"))continue;
1322 break;
1323 case PiPlus:
1324 if(!hdvmf->GetCheckButton("trajectories_piplus"))continue;
1325 break;
1326 case PiMinus:
1327 if(!hdvmf->GetCheckButton("trajectories_piminus"))continue;
1328 break;
1329 default:
1330 if(!hdvmf->GetCheckButton("trajectories_other"))continue;
1331 break;
1332 }
1333
1334 TVector3 v(pt->x, pt->y, pt->z);
1335
1336 if(i>0){
1337 //if((v-last_point).Mag() > 10.0){
1338 if(pt->track!=last_track || pt->part!=last_part){
1339 if(hdvmf->GetCheckButton("trajectories_colors")){
1340 switch(last_part){
1341 case Gamma:
1342 gset.color = kOrange;
1343 break;
1344 case Electron:
1345 case PiMinus:
1346 gset.color = kRed+2;
1347 break;
1348 case Positron:
1349 case Proton:
1350 case PiPlus:
1351 gset.color = kBlue+1;
1352 break;
1353 case Neutron:
1354 gset.color = kGreen+2;
1355 break;
1356 default:
1357 gset.color = kBlack;
1358 break;
1359 }
1360 }else{
1361 gset.color = kBlack;
1362 }
1363 graphics.push_back(gset);
1364 gset.points.clear();
1365 }
1366 }
1367
1368 gset.points.push_back(v);
1369 last_point = v;
1370 last_track = pt->track;
1371 last_part = pt->part;
1372 }
1373
1374 if(hdvmf->GetCheckButton("trajectories_colors")){
1375 switch(last_part){
1376 case Gamma:
1377 gset.color = kOrange;
1378 break;
1379 case Electron:
1380 case PiMinus:
1381 gset.color = kRed+2;
1382 break;
1383 case Positron:
1384 case Proton:
1385 case PiPlus:
1386 gset.color = kBlue+1;
1387 break;
1388 case Neutron:
1389 gset.color = kGreen+2;
1390 break;
1391 default:
1392 gset.color = kBlack;
1393 break;
1394 }
1395 }else{
1396 gset.color = kBlack;
1397 }
1398 graphics.push_back(gset);
1399 }
1400
1401 // DTrackCandidate
1402 if(hdvmf->GetCheckButton("candidates")){
1403 vector<const DTrackCandidate*> trackcandidates;
1404 loop->Get(trackcandidates, hdvmf->GetFactoryTag("DTrackCandidate"));
1405 for(unsigned int i=0; i<trackcandidates.size(); i++){
1406 int color=i+1;
1407 double size=2.0;
1408 //if(trackcandidates[i]->charge() >0.0) color += 100; // lighter shade
1409 //if(trackcandidates[i]->charge() <0.0) color += 150; // darker shade
1410 AddKinematicDataTrack(trackcandidates[i], color, size);
1411 }
1412 }
1413
1414 // DTrackWireBased
1415 if(hdvmf->GetCheckButton("wiretracks")){
1416 vector<const DTrackWireBased*> wiretracks;
1417 loop->Get(wiretracks, hdvmf->GetFactoryTag("DTrackWireBased"));
1418 for(unsigned int i=0; i<wiretracks.size(); i++){
1419 AddKinematicDataTrack(wiretracks[i], (wiretracks[i]->charge()>0.0 ? kBlue:kRed)+2, 1.25);
1420 }
1421 }
1422
1423 // DTrackTimeBased
1424 if(hdvmf->GetCheckButton("timetracks")){
1425 vector<const DTrackTimeBased*> timetracks;
1426 loop->Get(timetracks, hdvmf->GetFactoryTag("DTrackTimeBased"));
1427 for(unsigned int i=0; i<timetracks.size(); i++){
1428 AddKinematicDataTrack(timetracks[i], (timetracks[i]->charge()>0.0 ? kBlue:kRed)+0, 1.00);
1429 }
1430 }
1431
1432 // DChargedTrack
1433 if(hdvmf->GetCheckButton("chargedtracks")){
1434 vector<const DChargedTrack*> chargedtracks;
1435 loop->Get(chargedtracks, hdvmf->GetFactoryTag("DChargedTrack"));
1436 for(unsigned int i=0; i<chargedtracks.size(); i++){
1437 int color=kViolet-3;
1438 double size=1.25;
1439 if (chargedtracks[i]->Get_Charge() > 0) color=kMagenta;
1440
1441 if (chargedtracks[i]->Get_BestFOM()->mass() > 0.9) size=2.5;
1442 AddKinematicDataTrack(chargedtracks[i]->Get_BestFOM(),color,size);
1443 }
1444 }
1445
1446 // DNeutralParticles
1447 if(hdvmf->GetCheckButton("neutrals")){
1448 vector<const DNeutralParticle*> photons;
1449 loop->Get(photons, hdvmf->GetFactoryTag("DNeutralParticle"));
1450
1451 for(unsigned int i=0; i<photons.size(); i++){
1452 int color = kBlack;
1453 vector<const DNeutralShower*> locNeutralShowers;
1454 photons[i]->GetT(locNeutralShowers);
1455 DetectorSystem_t locDetSys = locNeutralShowers[0]->dDetectorSystem;
1456 if(locDetSys==SYS_FCAL)color = kOrange;
1457 if(locDetSys==SYS_BCAL)color = kYellow+2;
1458 //if(locDetSys==DPhoton::kCharge)color = kRed;
1459 AddKinematicDataTrack(photons[i]->Get_BestFOM(), color, 1.00);
1460 }
1461 }
1462}
1463void MyProcessor::UpdateBcalDisp(void)
1464{
1465 BCALHitCanvas = hdvmf->GetBcalDispFrame();
1466 BCALHitMatrixU = new TH2F("BCALHitMatrixU","BCAL Hits Upstream Energy;Sector number;Layer;Energy (MeV)", 48*4+2, -1.5, 192.5, 10, 0., 10.);
1467 BCALHitMatrixD = new TH2F("BCALHitMatrixD","BCAL Hits Downstream Energy;Sector number;Layer;Energy (MeV)",48*4+2, -1.5, 192.5, 10, 0., 10.);
1468 BCALParticles = new TH2F("BCALParticles","BCAL Particle Hits Type;Phi angle [deg];;Particle Momentum",(48*4+2)*4, -1.87, 361.87, 1, 0., 1.);
1469 BCALHitMatrixU->SetStats(0);
1470 BCALHitMatrixD->SetStats(0);
1471 BCALParticles->SetStats(0);
1472 Float_t size = 0.06;
1473 BCALHitMatrixU->GetXaxis()->SetTitleSize(size);
1474 BCALHitMatrixU->GetXaxis()->SetTitleOffset(0.8);
1475 BCALHitMatrixU->GetXaxis()->SetLabelSize(size);
1476 BCALHitMatrixU->GetYaxis()->SetTitleSize(size);
1477 BCALHitMatrixU->GetYaxis()->SetTitleOffset(0.4);
1478 BCALHitMatrixU->GetYaxis()->SetLabelSize(size);
1479 BCALHitMatrixU->GetZaxis()->SetTitleSize(size);
1480 BCALHitMatrixU->GetZaxis()->SetTitleOffset(0.4);
1481 BCALHitMatrixU->GetZaxis()->SetLabelSize(size);
1482 BCALHitMatrixD->GetXaxis()->SetTitleSize(size);
1483 BCALHitMatrixD->GetXaxis()->SetTitleOffset(0.8);
1484 BCALHitMatrixD->GetXaxis()->SetLabelSize(size);
1485 BCALHitMatrixD->GetYaxis()->SetTitleSize(size);
1486 BCALHitMatrixD->GetYaxis()->SetTitleOffset(0.4);
1487 BCALHitMatrixD->GetYaxis()->SetLabelSize(size);
1488 BCALHitMatrixD->GetZaxis()->SetTitleSize(size);
1489 BCALHitMatrixD->GetZaxis()->SetTitleOffset(0.4);
1490 BCALHitMatrixD->GetZaxis()->SetLabelSize(size);
1491 BCALParticles->GetXaxis()->SetTitleSize(size);
1492 BCALParticles->GetXaxis()->SetTitleOffset(0.8);
1493 BCALParticles->GetXaxis()->SetLabelSize(size);
1494 BCALParticles->GetYaxis()->SetTitleSize(size);
1495 BCALParticles->GetYaxis()->SetTitleOffset(0.4);
1496 BCALParticles->GetYaxis()->SetLabelSize(size);
1497 BCALParticles->GetZaxis()->SetTitleSize(size);
1498 BCALParticles->GetZaxis()->SetTitleOffset(0.4);
1499 BCALParticles->GetZaxis()->SetLabelSize(size);
1500
1501 if (BCALHitCanvas) {
1502 vector<const DBCALHit*> locBcalHits;
1503 loop->Get(locBcalHits);
1504 BCALHitMatrixU->Reset();
1505 BCALHitMatrixD->Reset();
1506 for (unsigned int k=0;k<locBcalHits.size();k++){
1507
1508 const DBCALHit* hit = locBcalHits[k];
1509 float idxY = (float)hit->layer-1;
1510 float idxX = (float) (hit->sector-1 + (hit->module-1)*4);
1511 if (hit->end == DBCALGeometry::kUpstream){
1512 if (hit->layer==1){
1513 BCALHitMatrixU->Fill(idxX,idxY,hit->E);
1514 } else if (hit->layer==2){
1515 BCALHitMatrixU->Fill(idxX,idxY,hit->E);
1516 BCALHitMatrixU->Fill(idxX,idxY+1.,hit->E);
1517 } else if (hit->layer==3){
1518 BCALHitMatrixU->Fill(idxX,idxY+1,hit->E);
1519 BCALHitMatrixU->Fill(idxX,idxY+2.,hit->E);
1520 BCALHitMatrixU->Fill(idxX,idxY+3.,hit->E);
1521 } else if (hit->layer==4){
1522 BCALHitMatrixU->Fill(idxX,idxY+3,hit->E);
1523 BCALHitMatrixU->Fill(idxX,idxY+4.,hit->E);
1524 BCALHitMatrixU->Fill(idxX,idxY+5.,hit->E);
1525 BCALHitMatrixU->Fill(idxX,idxY+6.,hit->E);
1526 }
1527 } else {
1528 if (hit->layer==1){
1529 BCALHitMatrixD->Fill(idxX,idxY,hit->E);
1530 } else if (hit->layer==2){
1531 BCALHitMatrixD->Fill(idxX,idxY,hit->E);
1532 BCALHitMatrixD->Fill(idxX,idxY+1.,hit->E);
1533 } else if (hit->layer==3){
1534 BCALHitMatrixD->Fill(idxX,idxY+1,hit->E);
1535 BCALHitMatrixD->Fill(idxX,idxY+2.,hit->E);
1536 BCALHitMatrixD->Fill(idxX,idxY+3.,hit->E);
1537 } else if (hit->layer==4){
1538 BCALHitMatrixD->Fill(idxX,idxY+3,hit->E);
1539 BCALHitMatrixD->Fill(idxX,idxY+4.,hit->E);
1540 BCALHitMatrixD->Fill(idxX,idxY+5.,hit->E);
1541 BCALHitMatrixD->Fill(idxX,idxY+6.,hit->E);
1542 }
1543 }
1544 }
1545
1546 vector<const DBCALIncidentParticle*> locBcalParticles;
1547 loop->Get(locBcalParticles);
1548 BCALParticles->Reset();
1549 BCALPLables.clear();
1550 for (unsigned int k=0;k<locBcalParticles.size();k++){
1551
1552 const DBCALIncidentParticle* part = locBcalParticles[k];
1553
1554 float p = TMath::Sqrt(part->px*part->px + part->py*part->py + part->pz*part->pz);
1555
1556 float phi=999;
1557 if (part->x!=0){
1558 phi = TMath::ATan(TMath::Abs(part->y/part->x));
1559 //cout<<phi<<" "<<part->y<<" / "<< part->x<<endl;
1560 if (part->y>0){
1561 if (part->x<0.){
1562 phi = 3.1415926 - phi;
1563 }
1564 } else {
1565 if (part->x<0){
1566 phi += 3.1415926;
1567 } else {
1568 phi = 3.1415926*2. - phi;
1569 }
1570 }
1571
1572 phi = phi*180./3.1415926;
1573 }
1574 BCALParticles->Fill(phi,0.5,p);
1575 char l[20];
1576 sprintf(l,"%d",part->ptype);
1577 TText *t = new TText(phi,1.01,l);
1578 t->SetTextSize(0.08);
1579 t->SetTextFont(72);
1580 t->SetTextAlign(21);
1581 BCALPLables.push_back(t);
1582 }
1583
1584
1585 BCALHitCanvas->Clear();
1586 BCALHitCanvas->Divide(1,3);
1587 BCALHitCanvas->cd(1);
1588 BCALHitMatrixU->Draw("colz");
1589 BCALHitCanvas->cd(2);
1590 BCALHitMatrixD->Draw("colz");
1591 BCALHitCanvas->cd(3);
1592 BCALParticles->Draw("colz");
1593 for (unsigned int n=0;n<BCALPLables.size();n++){
1594 BCALPLables[n]->Draw("same");
1595 }
1596 BCALHitCanvas->Update();
1597 }
1598
1599}
1600//------------------------------------------------------------------
1601// UpdateTrackLabels
1602//------------------------------------------------------------------
1603void MyProcessor::UpdateTrackLabels(void)
1604{
1605 // Get the label pointers
1606 string name, tag;
1607 map<string, vector<TGLabel*> > &thrownlabs = hdvmf->GetThrownLabels();
1608 map<string, vector<TGLabel*> > &reconlabs = hdvmf->GetReconstructedLabels();
1609 hdvmf->GetReconFactory(name, tag);
1610
1611 // Get Thrown particles
1612 vector<const DMCThrown*> throwns;
1613 if(loop)loop->Get(throwns);
1614
1615 // Get the track info as DKinematicData objects
1616 vector<const DKinematicData*> trks;
1617 vector<const DKinematicData*> TrksCand;
1618 vector<const DTrackWireBased*> TrksWireBased;
1619 vector<const DTrackTimeBased*> TrksTimeBased;
1620 vector<const DTrackCandidate*> cand;
1621 if(loop)loop->Get(cand);
1622 for(unsigned int i=0; i<cand.size(); i++)TrksCand.push_back(cand[i]);
1623
1624 if(loop)loop->Get(TrksWireBased);
1625 if(loop)loop->Get(TrksTimeBased);
1626
1627 if(name=="DChargedTrack"){
1628 vector<const DChargedTrack*> chargedtracks;
1629 if(loop)loop->Get(chargedtracks, tag.c_str());
1630 for(unsigned int i=0; i<chargedtracks.size(); i++){
1631 trks.push_back(chargedtracks[i]->Get_BestFOM());
1632 }
1633 }
1634 if(name=="DTrackTimeBased"){
1635 vector<const DTrackTimeBased*> timetracks;
1636 if(loop)loop->Get(timetracks, tag.c_str());
1637 for(unsigned int i=0; i<timetracks.size(); i++)trks.push_back(timetracks[i]);
1638 }
1639 if(name=="DTrackWireBased"){
1640 vector<const DTrackWireBased*> wiretracks;
1641 if(loop)loop->Get(wiretracks, tag.c_str());
1642 for(unsigned int i=0; i<wiretracks.size(); i++)trks.push_back(wiretracks[i]);
1643 }
1644 if(name=="DTrackCandidate"){
1645 vector<const DTrackCandidate*> candidates;
1646 if(loop)loop->Get(candidates, tag.c_str());
1647 for(unsigned int i=0; i<candidates.size(); i++)trks.push_back(candidates[i]);
1648 }
1649 if(name=="DNeutralParticle"){
1650 vector<const DNeutralParticle*> photons;
1651 if(loop)loop->Get(photons, tag.c_str());
1652 for(unsigned int i=0; i<photons.size(); i++) {
1653 trks.push_back(photons[i]->Get_BestFOM());
1654 }
1655 }
1656
1657 // Clear all labels (i.e. draw ---- in them)
1658 map<string, vector<TGLabel*> >::iterator iter;
1659 for(iter=reconlabs.begin(); iter!=reconlabs.end(); iter++){
1660 vector<TGLabel*> &labs = iter->second;
1661 for(unsigned int i=1; i<labs.size(); i++){
1662 labs[i]->SetText("--------");
1663 }
1664 }
1665 for(iter=thrownlabs.begin(); iter!=thrownlabs.end(); iter++){
1666 vector<TGLabel*> &labs = iter->second;
1667 for(unsigned int i=1; i<labs.size(); i++){
1668 labs[i]->SetText("--------");
1669 }
1670 }
1671
1672 // Loop over thrown particles and fill in labels
1673 int ii=0;
1674 for(unsigned int i=0; i<throwns.size(); i++){
1675 const DMCThrown *trk = throwns[i];
1676 if(trk->type==0)continue;
1677 int row = thrownlabs["trk"].size()-(ii++)-1;
1678 if(row<1)break;
1679
1680 stringstream trkno, type, p, theta, phi, z;
1681 trkno<<setprecision(4)<<i+1;
1682 thrownlabs["trk"][row]->SetText(trkno.str().c_str());
1683
1684 thrownlabs["type"][row]->SetText(ParticleType((Particle_t)trk->type));
1685
1686 p<<setprecision(4)<<trk->momentum().Mag();
1687 thrownlabs["p"][row]->SetText(p.str().c_str());
1688
1689 theta<<setprecision(4)<<trk->momentum().Theta()*TMath::RadToDeg();
1690 thrownlabs["theta"][row]->SetText(theta.str().c_str());
1691
1692 double myphi = trk->momentum().Phi();
1693 if(myphi<0.0)myphi+=2.0*M_PI3.14159265358979323846;
1694 phi<<setprecision(4)<<myphi;
1695 thrownlabs["phi"][row]->SetText(phi.str().c_str());
1696
1697 z<<setprecision(4)<<trk->position().Z();
1698 thrownlabs["z"][row]->SetText(z.str().c_str());
1699 }
1700
1701 // Loop over tracks and fill in labels
1702 for(unsigned int i=0; i<trks.size(); i++){
1703 const DKinematicData *trk = trks[i];
1704 int row = reconlabs["trk"].size()-i-1;
1705 if(row<1)break;
1706
1707 stringstream trkno, type, p, theta, phi, z, chisq_per_dof, Ndof,cand;
1708 stringstream fom;
1709 trkno<<setprecision(4)<<i+1;
1710 reconlabs["trk"][row]->SetText(trkno.str().c_str());
1711
1712 double mass = trk->mass();
1713 if(fabs(mass-0.13957)<1.0E-4)type<<"pi";
1714 else if(fabs(mass-0.93827)<1.0E-4)type<<"proton";
1715 else if(fabs(mass-0.493677)<1.0E-4)type<<"K";
1716 else if(fabs(mass-0.000511)<1.0E-4)type<<"e";
1717 else if (fabs(mass)<1.e-4 && fabs(trk->charge())<1.e-4) type << "gamma";
1718 else type<<"q=";
1719 if (fabs(trk->charge())>1.e-4){
1720 type<<(trk->charge()>0 ? "+":"-");
1721 }
1722 reconlabs["type"][row]->SetText(type.str().c_str());
1723
1724 p<<setprecision(4)<<trk->momentum().Mag();
1725 reconlabs["p"][row]->SetText(p.str().c_str());
1726
1727 theta<<setprecision(4)<<trk->momentum().Theta()*TMath::RadToDeg();
1728 reconlabs["theta"][row]->SetText(theta.str().c_str());
1729
1730 phi<<setprecision(4)<<trk->momentum().Phi()*TMath::RadToDeg();
1731 reconlabs["phi"][row]->SetText(phi.str().c_str());
1732
1733 z<<setprecision(4)<<trk->position().Z();
1734 reconlabs["z"][row]->SetText(z.str().c_str());
1735
1736 // Get chisq and Ndof for DTrackTimeBased or DTrackWireBased objects
1737 const DTrackTimeBased *timetrack=dynamic_cast<const DTrackTimeBased*>(trk);
1738 const DTrackWireBased *track=dynamic_cast<const DTrackWireBased*>(trk);
1739
1740 const DTrackCandidate *candidate=dynamic_cast<const DTrackCandidate*>(trk);
1741 const DChargedTrackHypothesis *chargedtrack=dynamic_cast<const DChargedTrackHypothesis *>(trk);
1742
1743 if(timetrack){
1744 chisq_per_dof<<setprecision(4)<<timetrack->chisq/timetrack->Ndof;
1745 Ndof<<timetrack->Ndof;
1746 fom << timetrack->FOM;
1747 }else if(track){
1748 chisq_per_dof<<setprecision(4)<<track->chisq/track->Ndof;
1749 Ndof<<track->Ndof;
1750 fom << "N/A";
1751 }else if (candidate){
1752 chisq_per_dof<<setprecision(4)<<candidate->chisq/candidate->Ndof;
1753 Ndof<<candidate->Ndof;
1754 fom << "N/A";
1755 }
1756 else if (chargedtrack){
1757 chisq_per_dof<<setprecision(4)<<chargedtrack->dChiSq_Track/chargedtrack->dNDF_Track;
1758 Ndof<<chargedtrack->dNDF_Track;
1759 fom << chargedtrack->dFOM;
1760 }
1761 else{
1762 chisq_per_dof << "--------";
1763 Ndof << "--------";
1764 fom << "--------";
1765 }
1766
1767 reconlabs["chisq/Ndof"][row]->SetText(chisq_per_dof.str().c_str());
1768 reconlabs["Ndof"][row]->SetText(Ndof.str().c_str());
1769 reconlabs["FOM"][row]->SetText(fom.str().c_str());
1770
1771 if (timetrack){
1772 cand << timetrack->candidateid;
1773 }
1774 else if (track){
1775 cand << track->candidateid;
1776 }
1777 else {
1778 cand << "--------";
1779 }
1780 reconlabs["cand"][row]->SetText(cand.str().c_str());
1781 }
1782
1783 // Have the pop-up window with the full particle list update it's labels
1784 fulllistmf->UpdateTrackLabels(throwns, trks);
1785 debugermf->SetTrackCandidates(TrksCand);
1786 debugermf->SetTrackWireBased(TrksWireBased);
1787 debugermf->SetTrackTimeBased(TrksTimeBased);
1788 debugermf->UpdateTrackLabels();
1789}
1790
1791//------------------------------------------------------------------
1792// AddKinematicDataTrack
1793//------------------------------------------------------------------
1794void MyProcessor::AddKinematicDataTrack(const DKinematicData* kd, int color, double size)
1795{
1796 // Create a reference trajectory with the given kinematic data and swim
1797 // it through the detector.
1798 DReferenceTrajectory rt(Bfield);
1799 rt.Rmax_interior = RMAX_INTERIOR;
1800 rt.Rmax_exterior = RMAX_EXTERIOR;
1801
1802 if(MATERIAL_MAP_MODEL=="DRootGeom"){
1803 rt.SetDRootGeom(RootGeom);
1804 rt.SetDGeometry(NULL__null);
1805 }else if(MATERIAL_MAP_MODEL=="DGeometry"){
1806 rt.SetDRootGeom(NULL__null);
1807 rt.SetDGeometry(geom);
1808 }else if(MATERIAL_MAP_MODEL!="NONE"){
1809 _DBG_std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<1809<<" "
<<"WARNING: Invalid value for TRKFIT:MATERIAL_MAP_MODEL (=\""<<MATERIAL_MAP_MODEL<<"\")"<<endl;
1810 }
1811
1812 rt.SetMass(kd->mass());
1813 rt.Swim(kd->position(), kd->momentum(), kd->charge());
1814
1815 // Create a new graphics set and fill it with all of the trajectory points
1816 DGraphicSet gset(color, kLine, size);
1817 DReferenceTrajectory::swim_step_t *step = rt.swim_steps;
1818 for(int i=0; i<rt.Nswim_steps; i++, step++){
1819 TVector3 tpoint(step->origin.X(),step->origin.Y(),step->origin.Z());
1820 gset.points.push_back(tpoint);
1821 }
1822
1823 // Push the graphics set onto the stack
1824 graphics.push_back(gset);
1825}
1826
1827//------------------------------------------------------------------
1828// GetIntersectionWithCalorimeter
1829//------------------------------------------------------------------
1830void MyProcessor::GetIntersectionWithCalorimeter(const DKinematicData* kd, DVector3 &pos, DetectorSystem_t &who)
1831{
1832 // Create a reference trajectory with the given kinematic data and swim
1833 // it through the detector.
1834 DReferenceTrajectory rt(Bfield);
1835 rt.Rmax_interior = RMAX_INTERIOR;
1836 rt.Rmax_exterior = RMAX_EXTERIOR;
1837
1838 if(MATERIAL_MAP_MODEL=="DRootGeom"){
1839 rt.SetDRootGeom(RootGeom);
1840 rt.SetDGeometry(NULL__null);
1841 }else if(MATERIAL_MAP_MODEL=="DGeometry"){
1842 rt.SetDRootGeom(NULL__null);
1843 rt.SetDGeometry(geom);
1844 }else if(MATERIAL_MAP_MODEL!="NONE"){
1845 _DBG_std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<1845<<" "
<<"WARNING: Invalid value for TRKFIT:MATERIAL_MAP_MODEL (=\""<<MATERIAL_MAP_MODEL<<"\")"<<endl;
1846 }
1847
1848 rt.SetMass(kd->mass());
1849 rt.Swim(kd->position(), kd->momentum(), kd->charge());
1850
1851 // Find intersection with FCAL
1852 DVector3 pos_fcal;
1853 double s_fcal = 1.0E6;
1854 DVector3 origin(0.0, 0.0, FCAL_Zmin);
1855 DVector3 norm(0.0, 0.0, -1.0);
1856 //rt.GetIntersectionWithPlane(origin, norm, pos_fcal, &s_fcal); // This gives different answer than below!
1857 DVector3 p_at_intersection;
1858 rt.GetIntersectionWithPlane(origin, norm, pos_fcal, p_at_intersection, &s_fcal, NULL__null, NULL__null, SYS_FCAL);
1859 if(pos_fcal.Perp()<FCAL_Rmin || pos_fcal.Perp()>FCAL_Rmax || !isfinite(pos_fcal.Z()))s_fcal = 1.0E6;
1860
1861 // Find intersection with BCAL
1862 DVector3 pos_bcal;
1863 double s_bcal = 1.0E6;
1864 rt.GetIntersectionWithRadius(BCAL_Rmin, pos_bcal, &s_bcal);
1865 if(pos_bcal.Z()<BCAL_Zmin || pos_bcal.Z()>(BCAL_Zmin+BCAL_Zlen) || !isfinite(pos_bcal.Z()))s_bcal = 1.0E6;
1866
1867 if(s_fcal>10000.0 && s_bcal>10000.0){
1868 // neither calorimeter hit
1869 who = SYS_NULL;
1870 pos.SetXYZ(0.0,0.0,0.0);
1871 }else if(s_fcal<s_bcal){
1872 // FCAL hit
1873 who = SYS_FCAL;
1874 pos = pos_fcal;
1875 }else{
1876 // BCAL hit
1877 who = SYS_BCAL;
1878 pos = pos_bcal;
1879 }
1880}
1881
1882//------------------------------------------------------------------
1883// GetFactoryNames
1884//------------------------------------------------------------------
1885void MyProcessor::GetFactoryNames(vector<string> &facnames)
1886{
1887 vector<JEventLoop*> loops = app->GetJEventLoops();
1888 if(loops.size()>0){
1889 vector<string> facnames;
1890 loops[0]->GetFactoryNames(facnames);
1891 }
1892}
1893
1894//------------------------------------------------------------------
1895// GetFactories
1896//------------------------------------------------------------------
1897void MyProcessor::GetFactories(vector<JFactory_base*> &factories)
1898{
1899 vector<JEventLoop*> loops = app->GetJEventLoops();
1900 if(loops.size()>0){
1901 factories = loops[0]->GetFactories();
1902 }
1903}
1904
1905//------------------------------------------------------------------
1906// GetNrows
1907//------------------------------------------------------------------
1908unsigned int MyProcessor::GetNrows(const string &factory, string tag)
1909{
1910 vector<JEventLoop*> loops = app->GetJEventLoops();
1911 if(loops.size()>0){
1912 // Here is something a little tricky. The GetFactory() method of JEventLoop
1913 // gets the factory of the specified data name and tag, but without trying
1914 // to substitute a user-specified tag (a'la -PDEFTAG:XXX=YYY) as is done
1915 // on normal Get() method calls. Therefore, we have to check for the default
1916 // tags ourselves and substitute it "by hand".
1917 if(tag==""){
1918 map<string,string> default_tags = loops[0]->GetDefaultTags();
1919 map<string, string>::const_iterator iter = default_tags.find(factory);
1920 if(iter!=default_tags.end())tag = iter->second.c_str();
1921 }
1922 JFactory_base *fac = loops[0]->GetFactory(factory, tag.c_str());
1923
1924 // Since calling GetNrows will cause the program to quit if there is
1925 // not a valid event, then first check that there is one before calling it
1926 if(loops[0]->GetJEvent().GetJEventSource() == NULL__null)return 0;
1927
1928 return fac==NULL__null ? 0:(unsigned int)fac->GetNrows();
1929 }
1930
1931 return 0;
1932}
1933
1934//------------------------------------------------------------------
1935// GetDReferenceTrajectory
1936//------------------------------------------------------------------
1937void MyProcessor::GetDReferenceTrajectory(string dataname, string tag, unsigned int index, DReferenceTrajectory* &rt, vector<const DCDCTrackHit*> &cdchits)
1938{
1939_DBG__std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<1939<<std::endl
;
1940 // initialize rt to NULL in case we don't find the one requested
1941 rt = NULL__null;
1942 cdchits.clear();
1943
1944 // Get pointer to the JEventLoop so we can get at the data
1945 vector<JEventLoop*> loops = app->GetJEventLoops();
1946 if(loops.size()==0)return;
1947 JEventLoop* &loop = loops[0];
1948
1949 // Variables to hold track parameters
1950 DVector3 pos, mom(0,0,0);
1951 double q=0.0;
1952 double mass;
1953
1954 // Find the specified track
1955 if(dataname=="DChargedTrack"){
1956 vector<const DChargedTrack*> chargedtracks;
1957 vector<const DTrackTimeBased*> timebasedtracks;
1958 loop->Get(chargedtracks, tag.c_str());
1959 if(index>=chargedtracks.size())return;
1960 q = chargedtracks[index]->Get_Charge();
1961 pos = chargedtracks[index]->Get_BestFOM()->position();
1962 mom = chargedtracks[index]->Get_BestFOM()->momentum();
1963 chargedtracks[index]->Get_BestFOM()->GetT(timebasedtracks);
1964 timebasedtracks[0]->Get(cdchits);
1965 mass = chargedtracks[index]->Get_BestFOM()->mass();
Value stored to 'mass' is never read
1966 }
1967
1968 if(dataname=="DTrackTimeBased"){
1969 vector<const DTrackTimeBased*> timetracks;
1970 loop->Get(timetracks, tag.c_str());
1971 if(index>=timetracks.size())return;
1972 q = timetracks[index]->charge();
1973 pos = timetracks[index]->position();
1974 mom = timetracks[index]->momentum();
1975 timetracks[index]->Get(cdchits);
1976 mass = timetracks[index]->mass();
1977 }
1978
1979 if(dataname=="DTrackWireBased"){
1980 vector<const DTrackWireBased*> wiretracks;
1981 loop->Get(wiretracks, tag.c_str());
1982 if(index>=wiretracks.size())return;
1983 q = wiretracks[index]->charge();
1984 pos = wiretracks[index]->position();
1985 mom = wiretracks[index]->momentum();
1986 wiretracks[index]->Get(cdchits);
1987 mass = wiretracks[index]->mass();
1988 }
1989
1990 if(dataname=="DTrackCandidate"){
1991 vector<const DTrackCandidate*> tracks;
1992 loop->Get(tracks, tag.c_str());
1993 if(index>=tracks.size())return;
1994 q = tracks[index]->charge();
1995 pos = tracks[index]->position();
1996 mom = tracks[index]->momentum();
1997 tracks[index]->Get(cdchits);
1998 mass = tracks[index]->mass();
1999 }
2000
2001 if(dataname=="DMCThrown"){
2002 vector<const DMCThrown*> tracks;
2003 loop->Get(tracks, tag.c_str());
2004 if(index>=tracks.size())return;
2005 const DMCThrown *t = tracks[index];
2006 q = t->charge();
2007 pos = t->position();
2008 mom = t->momentum();
2009 tracks[index]->Get(cdchits);
2010 mass = tracks[index]->mass();
2011_DBG_std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<2011<<" "
<<"mass="<<mass<<endl;
2012 }
2013
2014 // Make sure we found a charged particle we can track
2015 if(q==0.0 || mom.Mag()<0.01)return;
2016
2017 // Create a new DReference trajectory object. The caller takes
2018 // ownership of this and so they are responsible for deleting it.
2019 rt = new DReferenceTrajectory(Bfield);
2020 rt->Rmax_interior = RMAX_INTERIOR;
2021 rt->Rmax_exterior = RMAX_EXTERIOR;
2022 if(MATERIAL_MAP_MODEL=="DRootGeom"){
2023 rt->SetDRootGeom(RootGeom);
2024 rt->SetDGeometry(NULL__null);
2025 }else if(MATERIAL_MAP_MODEL=="DGeometry"){
2026 rt->SetDRootGeom(NULL__null);
2027 rt->SetDGeometry(geom);
2028 }else if(MATERIAL_MAP_MODEL!="NONE"){
2029 _DBG_std::cerr<<"programs/Analysis/hdview2/MyProcessor.cc"<<
":"<<2029<<" "
<<"WARNING: Invalid value for TRKFIT:MATERIAL_MAP_MODEL (=\""<<MATERIAL_MAP_MODEL<<"\")"<<endl;
2030 }
2031 rt->Swim(pos, mom, q);
2032}
2033
2034//------------------------------------------------------------------
2035// GetAllWireHits
2036//------------------------------------------------------------------
2037void MyProcessor::GetAllWireHits(vector<pair<const DCoordinateSystem*,double> > &allhits)
2038{
2039 /// Argument is vector of pairs that contain a pointer to the
2040 /// DCoordinateSystem representing a wire and a double that
2041 /// represents the drift distance. To get info on the specific
2042 /// wire, one needs to attempt a dynamic_cast to both a DCDCWire
2043 /// and a DFDCWire and access the parameters of whichever one succeeds.
2044
2045 // Get pointer to the JEventLoop so we can get at the data
2046 vector<JEventLoop*> loops = app->GetJEventLoops();
2047 if(loops.size()==0)return;
2048 JEventLoop* &loop = loops[0];
2049
2050 // Get CDC wire hits
2051 vector<const DCDCTrackHit*> cdchits;
2052 loop->Get(cdchits);
2053 for(unsigned int i=0; i<cdchits.size(); i++){
2054 pair<const DCoordinateSystem*,double> hit;
2055 hit.first = cdchits[i]->wire;
2056 hit.second = cdchits[i]->dist;
2057 allhits.push_back(hit);
2058 }
2059
2060 // Get FDC wire hits
2061 vector<const DFDCPseudo*> fdchits;
2062 loop->Get(fdchits);
2063 for(unsigned int i=0; i<fdchits.size(); i++){
2064 pair<const DCoordinateSystem*,double> hit;
2065 hit.first = fdchits[i]->wire;
2066 hit.second = 0.0055*fdchits[i]->time;
2067 allhits.push_back(hit);
2068 }
2069}
2070
2071
2072