CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DisplayManager.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <stdlib.h>
4 
6 
11 
13 
15 
24 
25 #include <TH2.h>
26 #include <TTree.h>
27 #include <TVector3.h>
28 #include <TH2F.h>
29 #include <TEllipse.h>
30 #include <TLine.h>
31 #include <TLatex.h>
32 #include <TList.h>
33 #include <TColor.h>
34 #include <TMath.h>
35 #include <TApplication.h>
36 
37 using namespace std;
38 
39 //________________________________________________________________
40 
42  const char* optfile ) :
43  em_(em),
44  options_(0),
45  maxERecHitEcal_(-1),
46  maxERecHitHcal_(-1),
47  maxERecHitHo_(-1),
48  isGraphicLoaded_(false),
49  shiftId_(SHIFTID) {
50 
51  readOptions( optfile );
52 
54  //TODOLIST: re_initialize if new option file- better in em
55  maxEvents_= em_->ev_->size();
56  createCanvas();
57 }
58 //________________________________________________________
60 {
61  reset();
62 }
63 
64 //________________________________________________________
65 void DisplayManager::readOptions( const char* optfile ) {
66 
67  try {
68  delete options_;
69  options_ = new IO(optfile);
70  }
71  catch( const string& err ) {
72  cout<<err<<endl;
73  return;
74  }
75 
76  drawHO_=true;
77  options_->GetOpt("display", "drawHO", drawHO_);
78 
79 
80 
81  viewSizeEtaPhi_.clear();
82  options_->GetOpt("display", "viewsize_etaphi", viewSizeEtaPhi_);
83  if(viewSizeEtaPhi_.size() != 2) {
84  cerr<<"PFRootEventManager::ReadOptions, bad display/viewsize_etaphi tag...using 700/350"
85  <<endl;
86  viewSizeEtaPhi_.clear();
87  viewSizeEtaPhi_.push_back(700);
88  viewSizeEtaPhi_.push_back(350);
89  }
90 
91  viewSize_.clear();
92  options_->GetOpt("display", "viewsize_xy", viewSize_);
93  if(viewSize_.size() != 2) {
94  cerr<<"PFRootEventManager::ReadOptions, bad display/viewsize_xy tag...using 700/350"
95  <<endl;
96  viewSize_.clear();
97  viewSize_.push_back(600);
98  viewSize_.push_back(600);
99  }
100 
101  clusterAttributes_.clear();
102  options_->GetOpt("display", "cluster_attributes", clusterAttributes_);
103  if(clusterAttributes_.size() != 7) {
104  cerr<<"PFRootEventManager::::ReadOptions, bad display/cluster_attributes tag...using 20 10 2 5"
105  <<endl;
106  clusterAttributes_.clear();
107  clusterAttributes_.push_back(2); //color
108  clusterAttributes_.push_back(5); // color if clusterPS
109  clusterAttributes_.push_back(20); // marker style
110  clusterAttributes_.push_back(1.0);
111  clusterAttributes_.push_back(6); //For ECAL
112  clusterAttributes_.push_back(9); //For HF_EM
113  clusterAttributes_.push_back(46); //For HO
114  }
115 
116  trackAttributes_.clear();
117  options_->GetOpt("display", "track_attributes", trackAttributes_);
118  if(trackAttributes_.size() != 4) {
119  cerr<<"PFRootEventManager::::ReadOptions, bad display/track_attributes tag...using 103 1 8 8"
120  <<endl;
121  trackAttributes_.clear();
122  trackAttributes_.push_back(103); //color Line and Marker
123  trackAttributes_.push_back(1); //line style
124  trackAttributes_.push_back(8); //Marker style
125  trackAttributes_.push_back(1.0); //Marker size
126  }
127  gsfAttributes_.clear();
128  options_->GetOpt("display", "gsf_attributes", gsfAttributes_);
129  if(gsfAttributes_.size() != 4) {
130  cerr<<"PFRootEventManager::::ReadOptions, bad display/gsf_attributes tag...using 105 1 8 8"
131  <<endl;
132  gsfAttributes_.clear();
133  gsfAttributes_.push_back(105); //color Line and Marker
134  gsfAttributes_.push_back(1); //line style
135  gsfAttributes_.push_back(8); //Marker style
136  gsfAttributes_.push_back(1.0); //Marker size
137  }
138  bremAttributes_.clear();
139  options_->GetOpt("display", "brem_attributes", bremAttributes_);
140  if(bremAttributes_.size() != 4) {
141  cerr<<"PFRootEventManager::::ReadOptions, bad display/gsf_attributes tag...using 106 1 8 8"
142  <<endl;
143  bremAttributes_.clear();
144  bremAttributes_.push_back(106); //color Line and Marker
145  bremAttributes_.push_back(1); //line style
146  bremAttributes_.push_back(8); //Marker style
147  bremAttributes_.push_back(1.0); //Marker size
148  }
149 
150  double attrScale = (drawHO_) ? 0.8 : 1.0;
151 
152  clusPattern_ = new TAttMarker( (int)clusterAttributes_[0],
153  (int)clusterAttributes_[2],
154  attrScale*clusterAttributes_[3]);
155 
156  clusPatternecal_ = new TAttMarker( (int)clusterAttributes_[4],
157  (int)clusterAttributes_[2],
158  attrScale*clusterAttributes_[3]);
159 
160  clusPatternhfem_ = new TAttMarker( (int)clusterAttributes_[5],
161  (int)clusterAttributes_[2],
162  attrScale*clusterAttributes_[3]);
163 
164  clusPatternho_ = new TAttMarker( (int)clusterAttributes_[6],
165  (int)clusterAttributes_[2],
166  attrScale*clusterAttributes_[3]);
167 
168  clusPSPattern_ = new TAttMarker( (int)clusterAttributes_[1],
169  (int)clusterAttributes_[2],
170  attrScale*clusterAttributes_[3]);
171  trackPatternL_ = new TAttLine( (int)trackAttributes_[0],
172  (int)trackAttributes_[1],
173  1);
174  trackPatternM_ = new TAttMarker( (int)trackAttributes_[0],
175  (int)trackAttributes_[2],
176  attrScale*trackAttributes_[3]);
177 
178  gsfPatternL_ = new TAttLine( (int)gsfAttributes_[0],
179  (int)gsfAttributes_[1],
180  1);
181  gsfPatternM_ = new TAttMarker( (int)gsfAttributes_[0],
182  (int)gsfAttributes_[2],
183  attrScale*gsfAttributes_[3]);
184 
185  bremPatternL_ = new TAttLine( (int)bremAttributes_[0],
186  (int)bremAttributes_[1],
187  1);
188  bremPatternM_ = new TAttMarker( (int)bremAttributes_[0],
189  (int)bremAttributes_[2],
190  attrScale*bremAttributes_[3]);
191 
192  genPartPattern_= new TAttMarker(kGreen-1,22,1.);
193 
194 
195  std::vector<float> simPartAttributes;
196 
197  simPartAttributes.clear();
198  options_->GetOpt("display", "simPart_attributes", simPartAttributes);
199  if(simPartAttributes.size() != 3) {
200  cerr<<"PFRootEventManager::::ReadOptions, bad display/simPart_attributes tag...using 103 1 8 8"
201  <<endl;
202  simPartAttributes.clear();
203  simPartAttributes.push_back(3); //color Line and Marker
204  simPartAttributes.push_back(2); //line style
205  simPartAttributes.push_back(0.6);
206  }
207 
208  int simColor = (int)simPartAttributes[0];
209  int simLStyle = (int)simPartAttributes[1];
210  float simMSize = attrScale*simPartAttributes[2];
211 
212  simPartPatternPhoton_ = new TAttMarker(simColor,3,simMSize);
213  simPartPatternElec_ = new TAttMarker(simColor,5,simMSize);
214  simPartPatternMuon_ = new TAttMarker(simColor,2,simMSize);
215  simPartPatternK_ = new TAttMarker(simColor,24,simMSize);
216  simPartPatternPi_ = new TAttMarker(simColor,25,simMSize);
217  simPartPatternProton_ = new TAttMarker(simColor,26,simMSize);
218  simPartPatternNeutron_= new TAttMarker(simColor,27,simMSize);
219  simPartPatternDefault_= new TAttMarker(simColor,30,simMSize);
220 
221  simPartPatternL_ = new TAttLine(simColor,simLStyle,1);
222  simPartPatternM_.resize(8);
223 
225 
226  drawHits_= true;
227  options_->GetOpt("display", "rechits",drawHits_);
228 
229  drawClus_ = true;
230  options_->GetOpt("display", "clusters",drawClus_);
231 
232  drawClusterL_ = false;
233  options_->GetOpt("display", "cluster_lines", drawClusterL_);
234 
235  drawTracks_ = true;
236  options_->GetOpt("display", "rectracks", drawTracks_);
237 
238  drawGsfTracks_ = true;
239  options_->GetOpt("display", "gsftracks", drawGsfTracks_);
240 
241  drawBrems_ = false;
242  options_->GetOpt("display", "brems", drawBrems_);
243 
244  drawParticles_ = true;
245  options_->GetOpt("display", "particles", drawParticles_);
246 
247  particlePtMin_ = -1;
248  options_->GetOpt("display", "particles_ptmin", particlePtMin_);
249 
250 
251  drawGenParticles_=false;
252  genParticlePtMin_ = 0;
253 
254 
255  trackPtMin_ = -1;
256  options_->GetOpt("display", "rectracks_ptmin", trackPtMin_);
257 
258  gsfPtMin_ = -1;
259  options_->GetOpt("display", "gsfrectracks_ptmin", gsfPtMin_);
260 
261  hitEnMin_ = -1;
262  options_->GetOpt("display","rechits_enmin",hitEnMin_);
263 
264  clusEnMin_ = -1;
265  options_->GetOpt("display","clusters_enmin",clusEnMin_);
266 
267 
268  drawPFBlocks_ = false;
269  options_->GetOpt("display","drawPFBlock",drawPFBlocks_);
270  //redrawWithoutHits_=false;
271 
272  zoomFactor_ = 10;
273  options_->GetOpt("display", "zoom_factor", zoomFactor_);
274 
275 }
276 
277 //________________________________________________________
279 {
280 
281  //TODOLIST: better TCanvas *displayView_[4]
282  displayView_.resize(NViews);
283  displayHist_.resize(NViews);
284 
285  // TODOLIST:Canvases size
286  // Add menu to mofify canvas size
287  // Add menu of views to be drawn
288 
289  displayView_[XY] = new TCanvas("displayXY_", "XY view",viewSize_[0], viewSize_[1]);
290  displayView_[RZ] = new TCanvas("displayRZ_", "RZ view",viewSize_[0], viewSize_[1]);
291  displayView_[EPE] = new TCanvas("displayEPE_", "eta/phi view, ECAL",viewSize_[0], viewSize_[1]);
292  displayView_[EPH] = new TCanvas("displayEPH_", "eta/phi view, HCAL",viewSize_[0], viewSize_[1]);
293  if (drawHO_) displayView_[EHO] = new TCanvas("displayEHO_", "eta/phi view, HO",viewSize_[0], viewSize_[1]);
294 
295  for (int viewType=0;viewType<NViews;++viewType) {
296  if (!drawHO_ && viewType==EHO) continue;
297  displayView_[viewType]->SetGrid(0, 0);
298  displayView_[viewType]->SetBottomMargin(0.14);
299  displayView_[viewType]->SetLeftMargin(0.15);
300  displayView_[viewType]->SetRightMargin(0.05);
301  displayView_[viewType]->ToggleToolBar();
302  }
303  // Draw support histogram
304  double zLow = -650.;
305  double zUp = +650.;
306  double rLow = -450.;
307  double rUp = +450.;
308 
309  if (!drawHO_) {zLow = -500.; zUp = +500.; rLow = -300.; rUp = +300.;}
310 
311  displayHist_[XY] = new TH2F("hdisplayHist_XY", "", 500, rLow, rUp,
312  500, rLow, rUp);
313  displayHist_[XY]->SetXTitle("X [cm]");
314  displayHist_[XY]->SetYTitle("Y [cm]");
315 
316  displayHist_[RZ] = new TH2F("hdisplayHist_RZ", "",500, zLow, zUp,
317  500, rLow, rUp);
318  displayHist_[RZ]->SetXTitle("Z [cm]");
319  displayHist_[RZ]->SetYTitle("R [cm]");
320 
321  displayHist_[EPE] = new TH2F("hdisplayHist_EP", "", 500, -5, 5,
322  500, -3.5, 3.5);
323  displayHist_[EPE]->SetXTitle("#eta");
324  displayHist_[EPE]->SetYTitle("#phi [rad]");
325 
327 
328  // displayHist_[EHO] = new TH2F("hdisplayHist_HO", "", 150, -1.5, 1.5,
329  // 500, -3.5, 3.5);
330  // displayHist_[EHO]->SetXTitle("#eta");
331  // displayHist_[EHO]->SetYTitle("#phi [rad]");
332 
334 
335  for (int viewType=0;viewType<NViews;++viewType){
336  if (!drawHO_ && viewType==EHO) continue;
337  displayHist_[viewType]->SetStats(kFALSE);
338  displayHist_[viewType]->GetYaxis()->SetTitleSize(0.06);
339  displayHist_[viewType]->GetYaxis()->SetTitleOffset(1.2);
340  displayHist_[viewType]->GetXaxis()->SetTitleSize(0.06);
341  displayHist_[viewType]->GetYaxis()->SetLabelSize(0.045);
342  displayHist_[viewType]->GetXaxis()->SetLabelSize(0.045);
343  }
344 
345  // Draw ECAL front face
346  frontFaceECALXY_.SetX1(0);
347  frontFaceECALXY_.SetY1(0);
350  frontFaceECALXY_.SetFillStyle(0);
351 
352  // Draw HCAL front face
353  frontFaceHCALXY_.SetX1(0);
354  frontFaceHCALXY_.SetY1(0);
357  frontFaceHCALXY_.SetFillStyle(0);
358 
359  if (drawHO_) {
360  // Draw HO front face
361  frontFaceHOXY_.SetX1(0);
362  frontFaceHOXY_.SetY1(0);
365  frontFaceHOXY_.SetFillStyle(0);
366  }
367 
368  // Draw ECAL side
373  frontFaceECALRZ_.SetFillStyle(0);
374  cout <<"End of DisplayManager::createCanvas()"<<endl;
375 
376 }
377 //_________________________________________________________________________
379  int ident,
380  double phi0)
381 {
382 
383  double eta = cluster.position().Eta();
384  double phi = cluster.position().Phi();
385 
386  // int type = cluster.type();
387  // if(algosToDisplay_.find(type) == algosToDisplay_.end() )
388  // return;
389 
390  // TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
391  // if( cutg && !cutg->IsInside( eta, phi ) ) return;
392 
393 
394  //int color = clusterAttributes_[2];
395  //if ( cluster.layer()==PFLayer::PS1 || cluster.layer()==PFLayer::PS2 )
396  // color = clusterAttributes_[3];
397 
398  //int markerSize = clusterAttributes_[1];
399  //int markerStyle = clusterAttributes_[0];
400 
401  int clusType=0;
402 
403  if ( cluster.layer()==PFLayer::PS1 || cluster.layer()==PFLayer::PS2 )
404  clusType=1;
405 
406  if ( cluster.layer()==PFLayer::ECAL_BARREL || cluster.layer()==PFLayer::ECAL_ENDCAP)
407  clusType=2;
408 
409  if ( cluster.layer()==PFLayer::HF_EM) clusType=3;
410 
411  if ( cluster.layer()==PFLayer::HCAL_BARREL2) clusType=4;
412 
413 
414 
415  const math::XYZPoint& xyzPos = cluster.position();
416 
417  GPFCluster *gc;
418 
419  for (int viewType=0;viewType<NViews;viewType++){
420  if (!drawHO_ && viewType==EHO) continue;
421  switch(viewType) {
422  case XY:
423  {
424  if (clusType==0) {
425  gc = new GPFCluster(this,
426  viewType,ident,
427  &cluster,
428  xyzPos.X(), xyzPos.Y(), clusPattern_);
429  } else if (clusType==1) {
430  gc = new GPFCluster(this,
431  viewType,ident,
432  &cluster,
433  xyzPos.X(), xyzPos.Y(), clusPSPattern_);
434 
435  } else if (clusType==2) {
436  gc = new GPFCluster(this,
437  viewType,ident,
438  &cluster,
439  xyzPos.X(), xyzPos.Y(), clusPatternecal_);
440  } else if (clusType==3) {
441  gc = new GPFCluster(this,
442  viewType,ident,
443  &cluster,
444  xyzPos.X(), xyzPos.Y(), clusPatternhfem_);
445  } else {
446  gc = new GPFCluster(this,
447  viewType,ident,
448  &cluster,
449  xyzPos.X(), xyzPos.Y(), clusPatternho_);
450  }
451  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
452  }
453  break;
454  case RZ:
455  {
456  double sign = 1.;
457  if (cos(phi0 - phi) < 0.)
458  sign = -1.;
459  if ( clusType==0) {
460  gc = new GPFCluster(this,
461  viewType,ident,
462  &cluster,
463  xyzPos.z(),sign*xyzPos.Rho(),
464  clusPattern_);
465  } else if (clusType==1) {
466  gc = new GPFCluster(this,
467  viewType,ident,
468  &cluster,
469  xyzPos.z(),sign*xyzPos.Rho(),
471  } else if (clusType==2) {
472  gc = new GPFCluster(this,
473  viewType,ident,
474  &cluster,
475  xyzPos.z(),sign*xyzPos.Rho(),
477  } else if (clusType==3) {
478  gc = new GPFCluster(this,
479  viewType,ident,
480  &cluster,
481  xyzPos.z(),sign*xyzPos.Rho(),
483 
484  } else {
485  gc = new GPFCluster(this,
486  viewType,ident,
487  &cluster,
488  xyzPos.z(),sign*xyzPos.Rho(),
490  }
491  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
492  }
493  break;
494  case EPE:
495  {
496  if( cluster.layer()<0 || cluster.layer()==PFLayer::HF_EM) {
497  if (clusType==2) {
498  gc = new GPFCluster(this,
499  viewType,ident,
500  &cluster,
501  eta,phi,
503  }
504  else if (clusType==3) {
505  gc = new GPFCluster(this,
506  viewType,ident,
507  &cluster,
508  eta,phi,
510  }
511  else {
512  gc = new GPFCluster(this,
513  viewType,ident,
514  &cluster,
515  eta,phi,
517  }
518 
519  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
520  }
521 
522  }
523  break;
524  case EPH:
525  {
526  if( cluster.layer()>0 && cluster.layer()!=PFLayer::HF_EM && cluster.layer()!=PFLayer::HCAL_BARREL2) {
527  if (clusType==0) {
528  gc = new GPFCluster(this,
529  viewType,ident,
530  &cluster,
531  eta,phi,clusPattern_);
532  }
533  else {
534  gc = new GPFCluster(this,
535  viewType,ident,
536  &cluster,
537  eta,phi,clusPSPattern_);
538  }
539 
540 
541  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
542  }
543  }
544  break;
545 
546  case EHO:
547  {
548  if( cluster.layer()>0 && cluster.layer()==PFLayer::HCAL_BARREL2) {
549  if (clusType==4) {
550  gc = new GPFCluster(this,
551  viewType,ident,
552  &cluster,
553  eta,phi,clusPatternho_);
554  }
555  else {
556  gc = new GPFCluster(this,
557  viewType,ident,
558  &cluster,
559  eta,phi,clusPSPattern_);
560  }
561 
562 
563  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
564  }
565  }
566  break;
567 
568  default :break;
569  }
570  }
571 }
572 //________________________________________________________________________________________
574  const std::vector<reco::PFTrajectoryPoint>& points,
575  int ident,double pt,double phi0, double sign, bool displayInitial,
576  int markerIndex)
577 {
578  //bool inside = false;
579  //TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
580  bool debug_createGpart = false;
581  // bool debug_createGpart = true;
582  for (int viewType=0;viewType<NViews;++viewType) {
583  if (!drawHO_ && viewType==EHO) continue;
584  // for (int viewType=0;viewType<4;++viewType) {
585  // reserving space. nb not all trajectory points are valid
586  vector<double> xPos;
587  xPos.reserve( points.size() );
588  vector<double> yPos;
589  yPos.reserve( points.size() );
590 
591  for(unsigned i=0; i<points.size(); i++) {
592 
593  if( !points[i].isValid() ) continue;
594 
595  const math::XYZPoint& xyzPos = points[i].position();
596 
597  double eta = xyzPos.Eta();
598  double phi = xyzPos.Phi();
599 
600  // always take momentum for the first point
601  // otherwise decay products from resonances will have wrong eta, phi
602  //calculated from position (0,0,0) (MDN 11 June 2008)
603  if( points[i].layer() == reco::PFTrajectoryPoint::ClosestApproach ) {
604 
605  // if( !displayInitial &&
606  // points[i].layer() == reco::PFTrajectoryPoint::ClosestApproach ) {
607  const math::XYZTLorentzVector& mom = points[i].momentum();
608  eta = mom.Eta();
609  phi = mom.Phi();
610  }
611 
612  //if( !cutg || cutg->IsInside( eta, phi ) )
613  // inside = true;
614 
615  switch(viewType) {
616  case XY:
617  xPos.push_back(xyzPos.X());
618  yPos.push_back(xyzPos.Y());
619  break;
620  case RZ:
621  xPos.push_back(xyzPos.Z());
622  yPos.push_back(sign*xyzPos.Rho());
623  break;
624  case EPE:
625  case EPH:
626  case EHO:
627  xPos.push_back( eta );
628  yPos.push_back( phi );
629  break;
630  default:break;
631  }
632  }
633  if (viewType == EPE && debug_createGpart) {
634  cout << " display PFsim eta/phi view ECAL" << endl;
635  cout << " nb of points for display " << xPos.size() << endl;
636  for(unsigned i=0; i<xPos.size(); i++) {
637  cout << " point " << i << " x/y " << xPos[i] <<"/" << yPos[i]<< endl;
638  }
639  }
640 
642  //if( !inside ) return;
643  //int color = 4;
644  GPFSimParticle *gc = new GPFSimParticle(this,
645  viewType, ident,
646  &ptc,
647  xPos.size(),&xPos[0],&yPos[0],
648  pt,
649  simPartPatternM_[markerIndex],
651  "pl");
652 
653  graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
654  //graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFSimParticle(this,viewType,ident,&ptc,xPos.size(),&xPos[0],&yPos[0],pt,simPartPattern_[indexMarker], "pl")));
655  }
656 }
657 //____________________________________________________________________
658 void DisplayManager::createGRecHit(reco::PFRecHit& rh,int ident, double maxe, double phi0, int color)
659 {
660 
661  double me = maxe;
662  double thresh = 0;
663  int layer = rh.layer();
664 
665 
666  switch(layer) {
668  thresh = em_->clusterAlgoECAL_.threshBarrel();
669  break;
671  thresh = em_->clusterAlgoECAL_.threshEndcap();
672  break;
675  thresh = em_->clusterAlgoHCAL_.threshBarrel();
676  break;
678  thresh = em_->clusterAlgoHCAL_.threshEndcap();
679  break;
680  case PFLayer::HF_HAD:
681  // how to handle a different threshold for HF?
682  thresh = em_->clusterAlgoHFHAD_.threshEndcap();
683  break;
684  case PFLayer::HF_EM:
685  // how to handle a different threshold for HF?
686  thresh = em_->clusterAlgoHFEM_.threshEndcap();
687  break;
688  case PFLayer::PS1:
689  case PFLayer::PS2:
690  me = -1;
691  thresh = em_->clusterAlgoPS_.threshBarrel();
692  break;
693  default:
694  {
695  cerr<<"DisplayManager::createGRecHit : manage other layers."
696  <<" GRechit notcreated."<<endl;
697  return;
698  }
699  }
700  if( rh.energy() < thresh ) return;
701 
702  //loop on all views
703  for(int viewType=0;viewType<NViews;++viewType) {
704  if (!drawHO_ && viewType==EHO) continue;
705 
706  bool isHCAL = (layer == PFLayer::HCAL_BARREL1 ||
707  // layer == PFLayer::HCAL_BARREL2 ||
708  layer == PFLayer::HCAL_ENDCAP ||
709  layer == PFLayer::HF_HAD);
710 
711  if( viewType == EPH &&
712  ! isHCAL) {
713  continue;
714  }
715  // on EPE view, draw only HCAL and preshower
716  if( viewType == EPE && (isHCAL || layer ==PFLayer::HCAL_BARREL2)) {
717  continue;
718  }
719 
720  if (viewType == EHO && layer !=PFLayer::HCAL_BARREL2) continue;
721 
722 
723  double rheta = rh.position().Eta();
724  double rhphi = rh.position().Phi();
725 
726  double sign = 1.;
727  if (cos(phi0 - rhphi) < 0.) sign = -1.;
728 
729 
730  double etaSize[4];
731  double phiSize[4];
732  double x[5];
733  double y[5];
734  double z[5];
735  double r[5];
736  double eta[5];
737  double phi[5];
738  double xprop[5];
739  double yprop[5];
740  double etaprop[5];
741  double phiprop[5];
742 
743 
744  const std::vector< math::XYZPoint >& corners = rh.getCornersXYZ();
745  assert(corners.size() == 4);
746  double propfact = 0.95; // so that the cells don't overlap ?
747  double ampl=0;
748  if(me>0) ampl = (log(rh.energy() + 1.)/log(me + 1.));
749  for ( unsigned jc=0; jc<4; ++jc ) {
750 
751  phiSize[jc] = rhphi-corners[jc].Phi();
752  etaSize[jc] = rheta-corners[jc].Eta();
753  if ( phiSize[jc] > 1. ) phiSize[jc] -= 2.*TMath::Pi();
754  if ( phiSize[jc] < -1. ) phiSize[jc]+= 2.*TMath::Pi();
755 
756  phiSize[jc] *= propfact;
757  etaSize[jc] *= propfact;
758 
759  math::XYZPoint cornerposxyz = corners[jc];
760 
761  x[jc] = cornerposxyz.X();
762  y[jc] = cornerposxyz.Y();
763  z[jc] = cornerposxyz.Z();
764  r[jc] = sign*cornerposxyz.Rho();
765  eta[jc] = rheta - etaSize[jc];
766  phi[jc] = rhphi - phiSize[jc];
767 
768 
769  // cell area is prop to log(E)
770  // not drawn for preshower.
771  // otherwise, drawn for eta/phi view, and for endcaps in xy view
772  if( layer != PFLayer::PS1 &&
773  layer != PFLayer::PS2 &&
774  ( viewType == EPE ||
775  viewType == EPH ||
776  viewType == EHO ||
777  ( viewType == XY &&
778  ( layer == PFLayer::ECAL_ENDCAP ||
779  layer == PFLayer::HCAL_ENDCAP ||
780  layer == PFLayer::HF_HAD
781  ) ) ) ) {
782 
783  math::XYZPoint centreXYZrot = rh.position();
784 
785  math::XYZPoint centertocorner(x[jc] - centreXYZrot.X(),
786  y[jc] - centreXYZrot.Y(),
787  0 );
788 
789  math::XYZPoint centertocornerep(eta[jc] - centreXYZrot.Eta(),
790  phi[jc] - centreXYZrot.Phi(),
791  0 );
792 
793 
794  // centertocorner -= centreXYZrot;
795  xprop[jc] = centreXYZrot.X() + centertocorner.X()*ampl;
796  yprop[jc] = centreXYZrot.Y() + centertocorner.Y()*ampl;
797 
798  etaprop[jc] = centreXYZrot.Eta() + centertocornerep.X()*ampl;
799  phiprop[jc] = centreXYZrot.Phi() + centertocornerep.Y()*ampl;
800  }
801  }//loop on jc
802 
803  if(layer == PFLayer::ECAL_BARREL ||
804  layer == PFLayer::HCAL_BARREL1 ||
805  layer == PFLayer::HCAL_BARREL2 || viewType == RZ) {
806 
807  // we are in the barrel. Determining which corners to shift
808  // away from the center to represent the cell energy
809 
810  int i1 = -1;
811  int i2 = -1;
812 
813  if(fabs(phiSize[1]-phiSize[0]) > 0.0001) {
814  if (viewType == XY) {
815  i1 = 2;
816  i2 = 3;
817  } else if (viewType == RZ) {
818  i1 = 1;
819  i2 = 2;
820  }
821  } else {
822  if (viewType == XY) {
823  i1 = 1;
824  i2 = 2;
825  } else if (viewType == RZ) {
826  i1 = 2;
827  i2 = 3;
828  }
829  }
830 
831  double signx=1.;
832  if(layer == PFLayer::HCAL_BARREL2) { signx=-1.;}
833 
834  x[i1] *= 1+signx*ampl/2.;
835  x[i2] *= 1+signx*ampl/2.;
836  y[i1] *= 1+signx*ampl/2.;
837  y[i2] *= 1+signx*ampl/2.;
838  z[i1] *= 1+signx*ampl/2.;
839  z[i2] *= 1+signx*ampl/2.;
840  r[i1] *= 1+signx*ampl/2.;
841  r[i2] *= 1+signx*ampl/2.;
842 
843  }
844 
845  x[4]=x[0];
846  y[4]=y[0]; // closing the polycell
847  z[4]=z[0];
848  r[4]=r[0]; // closing the polycell
849  eta[4]=eta[0];
850  phi[4]=phi[0]; // closing the polycell
851 
852  int npoints=5;
853 
854  switch( viewType ) {
855  case XY:
856  {
857  if(layer == PFLayer::ECAL_BARREL ||
858  layer == PFLayer::HCAL_BARREL1 ||
859  layer == PFLayer::HCAL_BARREL2) {
860  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,x,y,color,"f")));
861 
862  } else {
863  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,x,y,color,"l")));
864  if( ampl>0 ) { // not for preshower
865  xprop[4]=xprop[0];
866  yprop[4]=yprop[0]; // closing the polycell
867  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,xprop,yprop,color,"f")));
868  }
869  }
870  }
871  break;
872 
873  case RZ:
874  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,z,r,color,"f")));
875  break;
876 
877  case EPE:
878  {
879  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
880 
881  if( ampl>0 ) { // not for preshower
882  etaprop[4]=etaprop[0];
883  phiprop[4]=phiprop[0]; // closing the polycell
884  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
885  }
886  }
887  break;
888  case EPH:
889  {
890  if(layer == PFLayer::ECAL_BARREL ||
891  layer == PFLayer::HCAL_BARREL1) {
892  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
893 
894  if( ampl>0 ) { // not for preshower
895  etaprop[4]=etaprop[0];
896  phiprop[4]=phiprop[0]; // closing the polycell
897  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
898  }
899  }
900  }
901  break;
902 
903  case EHO:
904  {
905 
906  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
907  if(layer == PFLayer::HCAL_BARREL2) {
908  if( ampl>0 ) { // not for preshower
909  etaprop[4]=etaprop[0];
910  phiprop[4]=phiprop[0]; // closing the polycell
911  graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
912  }
913  }
914  }
915  break;
916 
917 
918 
919  default: break;
920  }//switch end
921 
922  } //loop on views
923 }
924 
925 //_________________________________________________________________________________________
927  const std::vector<reco::PFTrajectoryPoint>& points,
928  int ident,double pt,double phi0, double sign, bool displayInitial,
929  int linestyle,int kfgsfbrem)
930 {
931 
932  // bool inside = false;
933  //TCutG* cutg = (TCutG*) gROOT->FindObject("CUTG");
934 
935  for (int viewType=0;viewType<NViews;++viewType) {
936  if (!drawHO_ && viewType==EHO) continue;
937  // reserving space. nb not all trajectory points are valid
938  vector<double> xPos;
939  xPos.reserve( points.size() );
940  vector<double> yPos;
941  yPos.reserve( points.size() );
942 
943  for(unsigned i=0; i<points.size(); i++) {
944  if( !points[i].isValid() ) continue;
945 
946  const math::XYZPoint& xyzPos = points[i].position();
947  //muriel
948  //if(kfgsfbrem)
949  // std::cout << xyzPos << std::endl;
950  double eta = xyzPos.Eta();
951  double phi = xyzPos.Phi();
952 
953  if( !displayInitial &&
954  points[i].layer() == reco::PFTrajectoryPoint::ClosestApproach ) {
955  const math::XYZTLorentzVector& mom = points[i].momentum();
956  eta = mom.Eta();
957  phi = mom.Phi();
958  }
959 
960  //if( !cutg || cutg->IsInside( eta, phi ) )
961  // inside = true;
962 
963 
964  switch(viewType) {
965  case XY:
966  xPos.push_back(xyzPos.X());
967  yPos.push_back(xyzPos.Y());
968  break;
969  case RZ:
970  xPos.push_back(xyzPos.Z());
971  yPos.push_back(sign*xyzPos.Rho());
972  break;
973  case EPE:
974  case EPH:
975  case EHO:
976  xPos.push_back( eta );
977  yPos.push_back( phi );
978  break;
979  }
980  }
982  //if( !inside ) return;
983 
984  //fill map with graphic objects
985  GPFTrack *gt=0;
986  if(kfgsfbrem==0) {
987  gt = new GPFTrack(this,
988  viewType,ident,
989  &tr,
990  xPos.size(),&xPos[0],&yPos[0],pt,
992  }
993  else if (kfgsfbrem==1) {
994  // std::cout << " Creating the GSF track " << std::endl;
995  gt = new GPFTrack(this,
996  viewType,ident,
997  &tr,
998  xPos.size(),&xPos[0],&yPos[0],pt,
1000  }
1001  else if (kfgsfbrem==2) {
1002  // std::cout << " Creating the Brem " << std::endl;
1003  // std::cout<<"adr brem dans create:"<<&tr<<std::flush<<std::endl;
1004  gt = new GPFTrack(this,
1005  viewType,ident,
1006  &tr,
1007  xPos.size(),&xPos[0],&yPos[0],pt,
1009  }
1010  graphicMap_.insert(pair<int,GPFBase *> (ident, gt));
1011  }
1012 }
1013 
1014 
1016  reset();
1017  em_->processEvent(run, lumi, event);
1020  isGraphicLoaded_= true;
1021  displayAll();
1022 }
1023 
1024 
1025 //________________________________________________________
1026 void DisplayManager::display(int ientry)
1027 {
1028  if (ientry<0 || ientry>maxEvents_) {
1029  std::cerr<<"DisplayManager::no event matching criteria"<<std::endl;
1030  return;
1031  }
1032  reset();
1033  em_->processEntry(ientry);
1036  isGraphicLoaded_= true;
1037 
1038  displayAll();
1039 
1040 }
1041 //________________________________________________________________________________
1042 void DisplayManager::displayAll(bool noRedraw)
1043 {
1044 
1045  if (!isGraphicLoaded_) {
1046  std::cout<<" no Graphic Objects to draw"<<std::endl;
1047  return;
1048  }
1049  if (noRedraw) {
1050  for (int viewType=0;viewType<NViews;++viewType) {
1051  if (!drawHO_ && viewType==EHO) continue;
1052  displayView_[viewType]->cd();
1053  gPad->Clear();
1054  }
1055  //TODOLIST: add test on view to draw
1056  displayCanvas();
1057  }
1058 
1059  std::multimap<int,GPFBase *>::iterator p;
1060 
1061  for (p=graphicMap_.begin();p!=graphicMap_.end();p++) {
1062  int ident=p->first;
1063  int type=ident >> shiftId_;
1064  int view = p->second->getView();
1065 
1066  if (!drawHO_ && (view ==EHO || type==CLUSTERHOID || type==RECHITHOID)) continue;
1067 
1068  switch (type) {
1069  case CLUSTERECALID:
1070  case CLUSTERHCALID:
1071  case CLUSTERHOID:
1072  case CLUSTERHFEMID:
1073  case CLUSTERHFHADID:
1074  case CLUSTERPSID:
1075  case CLUSTERIBID:
1076  {
1077  // cout<<"displaying "<<type<<" "<<p->second->getEnergy()<<" "<<clusEnMin_<<" on view "<<view<<endl;
1078  if (drawClus_)
1079  if (p->second->getEnergy() > clusEnMin_) {
1080  displayView_[view]->cd();
1081  p->second->draw();
1082  }
1083  }
1084  break;
1085  case RECHITECALID:
1086  case RECHITHCALID:
1087  case RECHITHOID:
1088  case RECHITHFEMID:
1089  case RECHITHFHADID:
1090  case RECHITPSID:
1091  {
1092  if (!noRedraw) break;
1093  if (drawHits_)
1094  if(p->second->getEnergy() > hitEnMin_) {
1095  displayView_[view]->cd();
1096  p->second->draw();
1097  }
1098  break;
1099  }
1100  case RECTRACKID:
1101  {
1102  if (drawTracks_)
1103  if (p->second->getPt() > trackPtMin_) {
1104  displayView_[view]->cd();
1105  p->second->draw();
1106  }
1107  }
1108  break;
1109  case GSFRECTRACKID:
1110  {
1111  if (drawGsfTracks_)
1112  if (p->second->getPt() > gsfPtMin_) {
1113  displayView_[view]->cd();
1114  p->second->draw();
1115  }
1116  }
1117  break;
1118  case BREMID:
1119  {
1120  if (drawBrems_)
1121  {
1122  displayView_[view]->cd();
1123  p->second->draw();
1124  }
1125  }
1126  break;
1127  case SIMPARTICLEID:
1128  {
1129  if (drawParticles_)
1130  if (p->second->getPt() > particlePtMin_) {
1131  displayView_[view]->cd();
1132  p->second->draw();
1133  }
1134  }
1135  break;
1136  case GENPARTICLEID:
1137  {
1138  if (drawGenParticles_)
1139  if (p->second->getPt() > genParticlePtMin_)
1140  if (view == EPH || view ==EPE || view ==EHO) {
1141  displayView_[view]->cd();
1142  p->second->draw();
1143  }
1144  }
1145  break;
1146  default : std::cout<<"DisplayManager::displayAll()-- unknown object "<<std::endl;
1147  } //switch end
1148  } //for end
1149 
1150  for (int i=0;i<NViews;i++) {
1151  if (!drawHO_ && i==EHO) continue;
1152  displayView_[i]->cd();
1153  gPad->Modified();
1154  displayView_[i]->Update();
1155  }
1156 }
1157 //___________________________________________________________________________________
1159 {
1160  std::multimap<int,GPFBase *>::iterator p;
1161 
1162  for (p=graphicMap_.begin();p!=graphicMap_.end();p++) {
1163  int ident=p->first;
1164  int type=ident >> shiftId_;
1165  if (!drawHO_ && (type==CLUSTERHOID)) continue;
1166  switch (type) {
1167  case CLUSTERECALID: case CLUSTERHCALID: case CLUSTERHOID: case CLUSTERPSID: case CLUSTERIBID:
1168  {
1169  p->second->setNewStyle();
1170  p->second->setNewSize();
1171  p->second->setColor();
1172  }
1173  break;
1174  case RECTRACKID:
1175  {
1176  p->second->setColor();
1177  p->second->setNewStyle();
1178  p->second->setNewSize();
1179  }
1180  break;
1181  case SIMPARTICLEID:
1182  {
1183  }
1184  break;
1185  default : break;
1186  } //switch end
1187  } //for end
1188  displayAll(false);
1189 }
1190 //___________________________________________________________________________________
1192 {
1193  double zLow = -500.;
1194  double zUp = +500.;
1195  double rUp = +400.;
1196  if (!drawHO_) rUp=300.0;
1197  double etarng=(drawHO_) ? 1.19 : 1.39;
1198  double ratio =(drawHO_) ? 1.15 : 0.90;
1199  double scal = (drawHO_) ? 1.00 : 0.85;
1200 
1201  //TODOLIST : test wether view on/off
1202  //if (!displayView_[viewType] || !gROOT->GetListOfCanvases()->FindObject(displayView_[viewType]) ) {
1203  // assert(viewSize_.size() == 2);
1204 
1205 
1206 
1207  for (int viewType=0;viewType<NViews;++viewType) {
1208  if (!drawHO_ && viewType==EHO) continue;
1209  displayView_[viewType]->cd();
1210  displayHist_[viewType]->Draw();
1211  switch(viewType) {
1212  case XY:
1213  frontFaceECALXY_.Draw();
1214  frontFaceHCALXY_.Draw();
1215  frontFaceHOXY_.Draw();
1216  break;
1217  case RZ:
1218  {// Draw lines at different etas
1219  TLine l;
1220  l.SetLineColor(1);
1221  l.SetLineStyle(3);
1222  TLatex etaLeg;
1223  etaLeg.SetTextSize( (drawHO_) ? 0.03 : 0.02);
1224  float etaMin = -3.;
1225  float etaMax = +3.;
1226  float etaBin = 0.2;
1227  int nEtas = int((etaMax - etaMin)/0.2) + 1;
1228  for (int iEta = 0; iEta <= nEtas; iEta++) {
1229  float eta = etaMin + iEta*etaBin;
1230  float r = ratio*rUp;
1231  TVector3 etaImpact;
1232  etaImpact.SetPtEtaPhi(r, eta, 0.);
1233  etaLeg.SetTextAlign(21);
1234  if (eta <= -etarng) {
1235  etaImpact.SetXYZ(0.,scal*zLow*tan(etaImpact.Theta()),scal*zLow);
1236  etaLeg.SetTextAlign(31);
1237  } else if (eta >= etarng) {
1238  etaImpact.SetXYZ(0.,scal*zUp*tan(etaImpact.Theta()),scal*zUp);
1239  etaLeg.SetTextAlign(11);
1240  }
1241  if (drawHO_) {
1242  if (fabs(eta)<1.29) {
1243  etaLeg.SetTextSize(0.030);
1244  } else {
1245  etaLeg.SetTextSize(0.022);
1246  }
1247  }
1248  l.DrawLine(0., 0., etaImpact.Z(), etaImpact.Perp());
1249  etaLeg.DrawLatex(1.0*etaImpact.Z(), etaImpact.Perp(), Form("%2.1f", eta));
1250  }
1251  frontFaceECALRZ_.Draw();
1252  }
1253  break;
1254  default: break;
1255  } //end switch
1256  }
1257 }
1258 //________________________________________________________________________________
1260 {
1261  int eventNumber_=em_->eventNumber();
1262  display(++eventNumber_);
1263 }
1264 //_________________________________________________________________________________
1266 {
1267  bool ok=false;
1268  while (!ok && ientry<em_->ev_->size() ) {
1269  ok = em_->processEntry(ientry);
1270  ientry++;
1271  }
1273  if (ok) {
1274  reset();
1276  isGraphicLoaded_= true;
1277  displayAll();
1278  }
1279  else
1280  std::cerr<<"DisplayManager::dislayNextInteresting : no event matching criteria"<<std::endl;
1281 }
1282 //_________________________________________________________________________________
1284 {
1285  int eventNumber_=em_->eventNumber();
1286  display(--eventNumber_);
1287 }
1288 //______________________________________________________________________________
1290 {
1291  int size = selectedGObj_.size();
1292  bool toInitial=true;
1293  int color=0;
1294  for (int i=0;i<size;i++)
1295  drawGObject(selectedGObj_[i],color,toInitial);
1296 }
1297 //_______________________________________________________________________________
1299 {
1300  rubOutGPFBlock();
1301  selectedGObj_.clear();
1302  if (!drawPFBlocks_) return;
1303  int color=1;
1304  multimap<int,pair <int,int > >::const_iterator p;
1305  p= blockIdentsMap_.find(blockNb);
1306  if (p !=blockIdentsMap_.end()) {
1307  do {
1308  int ident=(p->second).first;
1309  drawGObject(ident,color,false);
1310  p++;
1311  } while (p!=blockIdentsMap_.upper_bound(blockNb));
1312  }
1313  else
1314  cout<<"DisplayManager::displayPFBlock :not found"<<endl;
1315 }
1316 //_______________________________________________________________________________
1317 void DisplayManager::drawGObject(int ident,int color,bool toInitial)
1318 {
1319  typedef std::multimap<int,GPFBase *>::const_iterator iter;
1320  iter p;
1321  std::pair<iter, iter > result = graphicMap_.equal_range(ident);
1322  if(result.first == graphicMap_.end()) {
1323  std::cout<<"pas d'objet avec cet ident: "<<ident<<std::flush<<std::endl;
1324  return;
1325  }
1326  p=result.first;
1327  while (p != result.second) {
1328  int view=p->second->getView();
1329  if (!drawHO_ && view ==EHO) continue;
1330  displayView_[view]->cd();
1331  if (toInitial) p->second->setInitialColor();
1332  else p->second->setColor(color);
1333  p->second->draw();
1334  gPad->Modified();
1335  // displayView_[view]->Update();
1336  if (!toInitial) selectedGObj_.push_back(ident);
1337  p++;
1338  }
1339 }
1340 //______________________________________________________________________________
1342 {
1344 }
1345 //______________________________________________________________________________
1347 {
1348  drawBrems_=state;
1349 }
1350 //_______________________________________________________________________________
1352 {
1353  int type=ident >> shiftId_; // defined in DisplayCommon.h
1354  if (drawHO_ || type!=RECHITHOID) {
1355  int color=1;
1356  if (type>15) {
1357  std ::cout<<"DisplayManager::findAndDraw :object Type unknown"<<std::endl;
1358  return;
1359  }
1360  if (drawPFBlocks_==0 ||
1361  type==RECHITECALID || type==RECHITHCALID || type==RECHITHOID ||
1362  type==RECHITHFEMID || type==RECHITHFHADID ||
1363  type==RECHITPSID || type==SIMPARTICLEID) {
1364  rubOutGPFBlock();
1365  selectedGObj_.clear();
1366  bool toInitial=false;
1367  drawGObject(ident,color,toInitial);
1368  if (type<HITTYPES) {
1369  //redrawWithoutHits_=true;
1370  displayAll(false);
1371  //redrawWithoutHits_=false;
1372  }
1373  }
1374  updateDisplay();
1375  }
1376 }
1377 //___________________________________________________________________________________
1379 {
1380  int blockNb=-1;
1381  int elemNb=-1;
1382  multimap<int, pair <int,int > >::const_iterator p;
1383  for (p=blockIdentsMap_.begin();p!=blockIdentsMap_.end();p++) {
1384  int id=(p->second).first;
1385  if (id == ident) {
1386  blockNb=p->first;
1387  elemNb=(p->second).second;
1388  break;
1389  }
1390  }
1391  if (blockNb > -1) {
1392  std::cout<<"this object is element "<<elemNb<<" of PFblock nb "<<blockNb<<std::endl;
1393  assert( blockNb < static_cast<int>(em_->blocks().size()) );
1394  const reco::PFBlock& block = em_->blocks()[blockNb];
1395  std::cout<<block<<std::endl;
1396  displayPFBlock(blockNb);
1397  }
1398  updateDisplay();
1399 }
1400 //_______________________________________________________________________
1402 {
1403  for (unsigned i=0;i<badBremsId_.size();i++)
1404  if (badBremsId_[i]==ident) return true;
1405  return false;
1406 }
1407 //_________________________________________________________________________
1408 
1410  for(unsigned i=0; i<displayView_.size(); i++) {
1411  if (!drawHO_ && i==EHO) continue;
1412  TPad* p = displayView_[i];
1413  assert( p );
1414  p->Modified();
1415  p->Update();
1416  }
1417 }
1418 
1419 
1420 //_________________________________________________________________________
1421 double DisplayManager::getMaxE(int layer) const
1422 {
1423 
1424  double maxe = -9999;
1425 
1426  // in which vector should we look for these rechits ?
1427 
1428  const reco::PFRecHitCollection* vec = 0;
1429  switch(layer) {
1430  case PFLayer::ECAL_ENDCAP:
1431  case PFLayer::ECAL_BARREL:
1432  vec = &(em_->rechitsECAL_);
1433  break;
1434  case PFLayer::HCAL_ENDCAP:
1435  case PFLayer::HCAL_BARREL1:
1436  // case PFLayer::HCAL_BARREL2:
1437  vec = &(em_->rechitsHCAL_);
1438  break;
1439  case PFLayer::HCAL_BARREL2:
1440  vec = &(em_->rechitsHO_);
1441  break;
1442 
1443  case PFLayer::HF_EM:
1444  vec = &(em_->rechitsHFEM_);
1445  break;
1446  case PFLayer::HF_HAD:
1447  vec = &(em_->rechitsHFHAD_);
1448  break;
1449  case PFLayer::PS1:
1450  case PFLayer::PS2:
1451  vec = &(em_->rechitsPS_);
1452  break;
1453  default:
1454  cerr<<"DisplayManager::getMaxE : manage other layers"<<endl;
1455  return maxe;
1456  }
1457 
1458  for( unsigned i=0; i<vec->size(); i++) {
1459  if( (*vec)[i].layer() != layer ) continue;
1460  if( (*vec)[i].energy() > maxe)
1461  maxe = (*vec)[i].energy();
1462  }
1463 
1464  return maxe;
1465 }
1466 //____________________________________________________________________________
1468 
1469  if( maxERecHitEcal_<0 ) {
1470  double maxeec = getMaxE( PFLayer::ECAL_ENDCAP );
1471  double maxeb = getMaxE( PFLayer::ECAL_BARREL );
1472  double maxehf = getMaxE( PFLayer::HF_EM );
1473  maxERecHitEcal_ = maxeec>maxeb ? maxeec:maxeb;
1475  // max of both barrel and endcap
1476  }
1477  return maxERecHitEcal_;
1478 }
1479 //_______________________________________________________________________________
1481 
1482  if(maxERecHitHcal_ < 0) {
1483  double maxehf = getMaxE( PFLayer::HF_HAD );
1484  double maxeec = getMaxE( PFLayer::HCAL_ENDCAP );
1485  double maxeb = getMaxE( PFLayer::HCAL_BARREL1 );
1486  maxERecHitHcal_ = maxeec>maxeb ? maxeec:maxeb;
1488  }
1489  return maxERecHitHcal_;
1490 }
1491 
1492 //_______________________________________________________________________________
1494 
1495  if(maxERecHitHo_ < 0) {
1497  }
1498  return maxERecHitHo_;
1499 }
1500 
1501 
1502 //________________________________________________________________________________________________
1504 {
1505 
1506  const HepMC::GenEvent* myGenEvent = em_->MCTruth_.GetEvent();
1507  if(!myGenEvent) return;
1508  for ( HepMC::GenEvent::particle_const_iterator piter = myGenEvent->particles_begin();
1509  piter != myGenEvent->particles_end();
1510  ++piter ) {
1511  HepMC::GenParticle* p = *piter;
1512 
1513  createGGenParticle(p);
1514  }
1515 }
1516 //____________________________________________________________________________
1518 {
1519  // these are the beam protons
1520  if ( !p->production_vertex() && p->pdg_id() == 2212 ) return;
1521 
1522  int partId = p->pdg_id();
1523 
1524  std::string name;
1525  std::string latexStringName;
1526 
1527  name = em_->getGenParticleName(partId,latexStringName);
1528  int barcode = p->barcode();
1529  int genPartId=(GENPARTICLEID<<shiftId_) | barcode;
1530 
1531 
1532 // int vertexId1 = 0;
1533 // vertexId1 = p->production_vertex()->barcode();
1534 
1535 // math::XYZVector vertex1 (p->production_vertex()->position().x(),
1536 // p->production_vertex()->position().y(),
1537 // p->production_vertex()->position().z());
1538 
1539  math::XYZTLorentzVector momentum1(p->momentum().px(),
1540  p->momentum().py(),
1541  p->momentum().pz(),
1542  p->momentum().e());
1543 
1544  double eta = momentum1.eta();
1545  if ( eta > +10. ) eta = +10.;
1546  if ( eta < -10. ) eta = -10.;
1547 
1548  double phi = momentum1.phi();
1549 
1550  double pt = momentum1.pt();
1551  double e = momentum1.e();
1552 
1553  //mother ?
1554 
1555  // Colin: the following line gives a segmentation fault when there is
1556  // no particles entering the production vertex.
1557 
1558  // const HepMC::GenParticle* mother =
1559  // *(p->production_vertex()->particles_in_const_begin());
1560 
1561  // protecting against this in the following way:
1562  const HepMC::GenParticle* mother = 0;
1563  if(p->production_vertex() &&
1564  p->production_vertex()->particles_in_size() ) {
1565  mother =
1566  *(p->production_vertex()->particles_in_const_begin());
1567  }
1568 
1569  // Colin: no need to declare this pointer in this context.
1570  // the declaration can be more local.
1571  // GPFGenParticle *gp;
1572 
1573  int modnViews = (drawHO_) ? NViews : NViews-1;
1574  if ( mother ) {
1575  int barcodeMother = mother->barcode();
1576  math::XYZTLorentzVector momentumMother(mother->momentum().px(),
1577  mother->momentum().py(),
1578  mother->momentum().pz(),
1579  mother->momentum().e());
1580  double etaMother = momentumMother.eta();
1581  if ( etaMother > +10. ) etaMother = +10.;
1582  if ( etaMother < -10. ) etaMother = -10.;
1583  double phiMother = momentumMother.phi();
1584 
1585 
1586  double x[2],y[2];
1587 
1588 
1589  x[0]=etaMother;x[1]=eta;
1590  y[0]=phiMother;y[1]=phi;
1591 
1592  for (int view = 2; view< modnViews; view++) {
1593  GPFGenParticle* gp = new GPFGenParticle(this,
1594  view, genPartId,
1595  x, y, //double *, double *
1596  e,pt,barcode,barcodeMother,
1597  genPartPattern_,
1598  name,latexStringName);
1599  graphicMap_.insert(pair<int,GPFBase *> (genPartId, gp));
1600  }
1601  }
1602  else { //no Mother
1603  for (int view = 2; view< modnViews; view++) {
1604  GPFGenParticle* gp = new GPFGenParticle(this,
1605  view, genPartId,
1606  eta, phi, //double double
1607  e,pt,barcode,
1609  name, latexStringName);
1610  graphicMap_.insert(pair<int,GPFBase *> (genPartId, gp));
1611  }
1612  }
1613 }
1614 //____________________________________________________________________________
1616 {
1617  double phi0=0;
1618 
1619  for(unsigned i=0; i<em_->clustersECAL_->size(); i++){
1620  //int clusId=(i<<shiftId_) | CLUSTERECALID;
1621  int clusId=(CLUSTERECALID<<shiftId_) | i;
1622  createGCluster( (*(em_->clustersECAL_))[i],clusId, phi0);
1623  }
1624  for(unsigned i=0; i<em_->clustersHCAL_->size(); i++) {
1625  //int clusId=(i<<shiftId_) | CLUSTERHCALID;
1626  int clusId=(CLUSTERHCALID<<shiftId_) | i;
1627  createGCluster( (*(em_->clustersHCAL_))[i],clusId, phi0);
1628  }
1629 
1630  if (drawHO_) {
1631  for(unsigned i=0; i<em_->clustersHO_->size(); i++) {
1632  //int clusId=(i<<shiftId_) | CLUSTERHOID;
1633  int clusId=(CLUSTERHOID<<shiftId_) | i;
1634  createGCluster( (*(em_->clustersHO_))[i],clusId, phi0);
1635  }
1636  }
1637 
1638  for(unsigned i=0; i<em_->clustersHFEM_->size(); i++) {
1639  //int clusId=(i<<shiftId_) | CLUSTERHFEMID;
1640  int clusId=(CLUSTERHFEMID<<shiftId_) | i;
1641  createGCluster( (*(em_->clustersHFEM_))[i],clusId, phi0);
1642  }
1643  for(unsigned i=0; i<em_->clustersHFHAD_->size(); i++) {
1644  //int clusId=(i<<shiftId_) | CLUSTERHFHADID;
1645  int clusId=(CLUSTERHFHADID<<shiftId_) | i;
1646  createGCluster( (*(em_->clustersHFHAD_))[i],clusId, phi0);
1647  }
1648  for(unsigned i=0; i<em_->clustersPS_->size(); i++){
1649  //int clusId=(i<<shiftId_) | CLUSTERPSID;
1650  int clusId=(CLUSTERPSID<<shiftId_) | i;
1651  createGCluster( (*(em_->clustersPS_))[i],clusId,phi0);
1652  }
1653 // for(unsigned i=0; i<em_->clustersIslandBarrel_.size(); i++) {
1654 // PFLayer::Layer layer = PFLayer::ECAL_BARREL;
1655 // //int clusId=(i<<shiftId_) | CLUSTERIBID;
1656 // int clusId=(CLUSTERIBID<<shiftId_) | i;
1657 
1658 // reco::PFCluster cluster( layer,
1659 // em_->clustersIslandBarrel_[i].energy(),
1660 // em_->clustersIslandBarrel_[i].x(),
1661 // em_->clustersIslandBarrel_[i].y(),
1662 // em_->clustersIslandBarrel_[i].z() );
1663 // createGCluster( cluster,clusId, phi0);
1664 // }
1665 }
1666 //_____________________________________________________________________
1668 {
1669 
1670  //selects Brems with no information in PFBlock.Those selected Brems are not displayed
1671 
1672  int size = em_->pfBlocks_->size();
1673  for (int ibl=0;ibl<size;ibl++) {
1675  for( iter =((*(em_->pfBlocks_))[ibl].elements()).begin();
1676  iter != ((*(em_->pfBlocks_))[ibl].elements()).end();iter++) {
1677  int ident=-1;
1678  reco::PFBlockElement::Type type = (*iter).type();
1679  if (type == reco::PFBlockElement::BREM) {
1680  std::multimap<double, unsigned> ecalElems;
1681 
1682  (*(em_->pfBlocks_))[ibl].associatedElements( (*iter).index(),(*(em_->pfBlocks_))[ibl].linkData(),
1683  ecalElems ,
1686 
1687 
1688  if (ecalElems.size()==0) {
1689  // std::cout<<" PfBlock Nb "<<ibl<<" -- brem elem "<<(*iter).index()<<"-type "<<(*iter).type()<<" not drawn"<<std::flush<<std::endl;
1690  const reco::PFBlockElementBrem * Brem = dynamic_cast<const reco::PFBlockElementBrem*>(&(*iter));
1691  reco::GsfPFRecTrackRef trackref = Brem->GsftrackRefPF();
1692  unsigned ind=trackref.key()*40+Brem->indTrajPoint();
1693  ident = (BREMID << shiftId_ ) | ind ;
1694  badBremsId_.push_back(ident);
1695  }
1696  }
1697  }
1698  }
1699 }
1700 //_____________________________________________________________________
1702 {
1703  int size = em_->pfBlocks_->size();
1704  for (int ibl=0;ibl<size;ibl++) {
1705  //int elemNb=((*(em_->pfBlocks_))[ibl].elements()).size();
1706  //std::cout<<"block "<<ibl<<":"<<elemNb<<" elements"<<std::flush<<std::endl;
1708  for( iter =((*(em_->pfBlocks_))[ibl].elements()).begin();
1709  iter != ((*(em_->pfBlocks_))[ibl].elements()).end();iter++) {
1710 
1711  //COLIN
1712 // std::cout<<"elem index "<<(*iter).index()<<"-type:"
1713 // <<(*iter).type()<<std::flush<<std::endl;
1714  int ident=-1;
1715 
1716  reco::PFBlockElement::Type type = (*iter).type();
1717  if (!drawHO_ && type==reco::PFBlockElement::HO) continue;
1718  switch (type) {
1720  assert(0);
1721  break;
1723  {
1724  reco::PFRecTrackRef trackref =(*iter).trackRefPF();
1725  assert( !trackref.isNull() );
1726  // std::cout<<" - key "<<trackref.key()<<std::flush<<std::endl<<std::endl;
1727  ident=(RECTRACKID <<shiftId_) | trackref.key();
1728  }
1729  break;
1731  {
1732  reco::PFClusterRef clusref=(*iter).clusterRef();
1733  assert( !clusref.isNull() );
1734  //std::cout<<"- key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1735  ident=(CLUSTERPSID <<shiftId_) |clusref.key();
1736  }
1737  break;
1739  {
1740  reco::PFClusterRef clusref=(*iter).clusterRef();
1741  assert( !clusref.isNull() );
1742  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1743  ident=(CLUSTERPSID <<shiftId_) |clusref.key();
1744  }
1745  break;
1747  {
1748  reco::PFClusterRef clusref=(*iter).clusterRef();
1749  assert( !clusref.isNull() );
1750  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1751  ident=(CLUSTERECALID <<shiftId_) |clusref.key();
1752  }
1753  break;
1755  {
1756  reco::PFClusterRef clusref=(*iter).clusterRef();
1757  assert( !clusref.isNull() );
1758  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1759  ident=(CLUSTERHCALID <<shiftId_) |clusref.key();
1760  }
1761  break;
1762 
1764  {
1765  reco::PFClusterRef clusref=(*iter).clusterRef();
1766  assert( !clusref.isNull() );
1767  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1768  ident=(CLUSTERHOID <<shiftId_) |clusref.key();
1769  }
1770  break;
1771 
1773  {
1774  reco::PFClusterRef clusref=(*iter).clusterRef();
1775  assert( !clusref.isNull() );
1776  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1777  ident=(CLUSTERHFEMID <<shiftId_) |clusref.key();
1778  }
1779  break;
1781  {
1782  reco::PFClusterRef clusref=(*iter).clusterRef();
1783  assert( !clusref.isNull() );
1784  //std::cout<<"key "<<clusref.key()<<std::flush<<std::endl<<std::endl;
1785  ident=(CLUSTERHFHADID <<shiftId_) |clusref.key();
1786  }
1787  break;
1789  {
1790  const reco::PFBlockElementGsfTrack * GsfEl =
1791  dynamic_cast<const reco::PFBlockElementGsfTrack*>(&(*iter));
1792 
1793  reco::GsfPFRecTrackRef trackref=GsfEl->GsftrackRefPF();
1794  assert( !trackref.isNull() );
1795  ident=(GSFRECTRACKID << shiftId_) | trackref.key();
1796  }
1797  break;
1799  {
1800  const reco::PFBlockElementBrem * Brem = dynamic_cast<const reco::PFBlockElementBrem*>(&(*iter));
1801  reco::GsfPFRecTrackRef trackref = Brem->GsftrackRefPF();
1802  unsigned index=trackref.key()*40+Brem->indTrajPoint();
1803  ident = (BREMID << shiftId_ ) | index ;
1804  if (findBadBremsId(ident)) ident=-1;
1805  }
1806  break;
1807 
1809  {
1810  const reco::PFBlockElementSuperCluster * sc = dynamic_cast<const reco::PFBlockElementSuperCluster*>(&(*iter));
1811  reco::SuperClusterRef scref = sc->superClusterRef();
1812  assert( !scref.isNull() );
1813  ident = (CLUSTERIBID << shiftId_ ) | scref.key();
1814  }
1815  break;
1816 
1817  default:
1818  std::cout<<"unknown PFBlock element of type "<<type<<std::endl;
1819  break;
1820  } //end switch
1821  pair <int, int> idElem;
1822  idElem.first=ident;
1823  idElem.second=(*iter).index();
1824  if (ident != -1) blockIdentsMap_.insert(pair<int,pair <int,int> > (ibl,idElem));
1825  } //end for elements
1826  } //end for blocks
1827 
1828 }
1829 //__________________________________________________________________________________
1831 {
1832  loadGClusters();
1833  loadGRecHits();
1834  loadGRecTracks();
1837  loadGPFBlocks();
1839 }
1840 //________________________________________________________
1842 {
1843  double phi0=0;
1844 
1845  double maxee = getMaxEEcal();
1846  double maxeh = getMaxEHcal();
1847  double maxe = maxee>maxeh ? maxee : maxeh;
1848 
1849  int color = TColor::GetColor(210,210,210);
1850  int seedcolor = TColor::GetColor(145,145,145);
1851  int specialcolor = TColor::GetColor(255,140,0);
1852 
1853  for(unsigned i=0; i<em_->rechitsECAL_.size(); i++) {
1854  int rhcolor = color;
1855  if( unsigned col = em_->clusterAlgoECAL_.color(i) ) {
1856  switch(col) {
1857  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1858  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1859  default:
1860  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1861  }
1862  }
1863  //int recHitId=(i<<shiftId_) | RECHITECALID;
1864  int recHitId=i;
1865  createGRecHit(em_->rechitsECAL_[i],recHitId, maxe, phi0, rhcolor);
1866  }
1867 
1868  for(unsigned i=0; i<em_->rechitsHCAL_.size(); i++) {
1869  int rhcolor = color;
1870  if(unsigned col = em_->clusterAlgoHCAL_.color(i) ) {
1871  switch(col) {
1872  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1873  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1874  default:
1875  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1876  }
1877  }
1878  //int recHitId=(i<<shiftId_) | RECHITHCALID;
1879  int recHitId=(RECHITHCALID <<shiftId_) | i;
1880  createGRecHit(em_->rechitsHCAL_[i],recHitId, maxe, phi0, rhcolor);
1881  }
1882 
1883  if (drawHO_) {
1884  for(unsigned i=0; i<em_->rechitsHO_.size(); i++) {
1885  int rhcolor = color;
1886  if(unsigned col = em_->clusterAlgoHO_.color(i) ) {
1887  switch(col) {
1888  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1889  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1890  default:
1891  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1892  }
1893  }
1894  //int recHitId=(i<<shiftId_) | RECHITHOID;
1895  int recHitId=(RECHITHOID <<shiftId_) | i;
1896  createGRecHit(em_->rechitsHO_[i],recHitId, 2*maxe, phi0, rhcolor);
1897  }
1898  }
1899 
1900  for(unsigned i=0; i<em_->rechitsHFEM_.size(); i++) {
1901  int rhcolor = color;
1902  if(unsigned col = em_->clusterAlgoHFEM_.color(i) ) {
1903  switch(col) {
1904  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1905  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1906  default:
1907  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1908  }
1909  }
1910  //int recHitId=(i<<shiftId_) | RECHITHFEMID;
1911  int recHitId=(RECHITHFEMID <<shiftId_) | i;
1912  createGRecHit(em_->rechitsHFEM_[i],recHitId, maxe, phi0, rhcolor);
1913  }
1914 
1915  for(unsigned i=0; i<em_->rechitsHFHAD_.size(); i++) {
1916  int rhcolor = color;
1917  if(unsigned col = em_->clusterAlgoHFHAD_.color(i) ) {
1918  switch(col) {
1919  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1920  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1921  default:
1922  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1923  }
1924  }
1925  //int recHitId=(i<<shiftId_) | RECHITHFHADID;
1926  int recHitId=(RECHITHFHADID <<shiftId_) | i;
1927  createGRecHit(em_->rechitsHFHAD_[i],recHitId, maxe, phi0, rhcolor);
1928  }
1929 
1930  for(unsigned i=0; i<em_->rechitsPS_.size(); i++) {
1931  int rhcolor = color;
1932  if( unsigned col = em_->clusterAlgoPS_.color(i) ) {
1933  switch(col) {
1934  case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
1935  case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
1936  default:
1937  cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
1938  }
1939  }
1940  //int recHitId=(i<<shiftId_) | RECHITPSID;
1941  int recHitId=(RECHITPSID<<shiftId_) | i;
1942 
1943  createGRecHit(em_->rechitsPS_[i],recHitId, maxe, phi0, rhcolor);
1944  }
1945 }
1946 //________________________________________________________________________
1948 {
1949  double phi0=0;
1950 
1951  int ind=-1;
1952  std::vector<reco::PFRecTrack>::iterator itRecTrack;
1953  for (itRecTrack = em_->recTracks_.begin(); itRecTrack != em_->recTracks_.end();itRecTrack++) {
1954  double sign = 1.;
1955  const reco::PFTrajectoryPoint& tpinitial
1956  = itRecTrack->extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach);
1957  double pt = tpinitial.momentum().Pt();
1958  //if( pt<em_->displayRecTracksPtMin_ ) continue;
1959 
1960  const reco::PFTrajectoryPoint& tpatecal
1961  = itRecTrack->trajectoryPoint(itRecTrack->nTrajectoryMeasurements() +
1963 
1964  if ( cos(phi0 - tpatecal.momentum().Phi()) < 0.)
1965  sign = -1.;
1966 
1967  const std::vector<reco::PFTrajectoryPoint>& points =
1968  itRecTrack->trajectoryPoints();
1969 
1970  int linestyle = itRecTrack->algoType();
1971  ind++;
1972  //int recTrackId=(ind<<shiftId_) | RECTRACKID;
1973  int recTrackId=(RECTRACKID <<shiftId_) | ind;
1974 
1975  createGTrack(*itRecTrack,points,recTrackId, pt, phi0, sign, false,linestyle);
1976  }
1977 }
1978 
1979 //________________________________________________________________________
1981 {
1982  double phi0=0;
1983 
1984  int ind=-1;
1985  int indbrem=-1;
1986 
1987  // allows not to draw Brems with no informations in PFBlocks
1988  retrieveBadBrems();
1989 
1990  std::vector<reco::GsfPFRecTrack>::iterator itRecTrack;
1991  for (itRecTrack = em_->gsfrecTracks_.begin(); itRecTrack != em_->gsfrecTracks_.end();itRecTrack++) {
1992  double sign = 1.;
1993  const reco::PFTrajectoryPoint& tpinitial
1994  = itRecTrack->extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach);
1995  double pt = tpinitial.momentum().Pt();
1996  //if( pt<em_->displayRecTracksPtMin_ ) continue;
1997 
1998  const reco::PFTrajectoryPoint& tpatecal
1999  = itRecTrack->trajectoryPoint(itRecTrack->nTrajectoryMeasurements() +
2001 
2002  if ( cos(phi0 - tpatecal.momentum().Phi()) < 0.)
2003  sign = -1.;
2004 
2005  const std::vector<reco::PFTrajectoryPoint>& points =
2006  itRecTrack->trajectoryPoints();
2007 
2008  int linestyle = itRecTrack->algoType();
2009  ind++;
2010  int recTrackId=(GSFRECTRACKID <<shiftId_) | ind;
2011 
2012  createGTrack(*itRecTrack,points,recTrackId, pt, phi0, sign, false,linestyle,1);
2013 
2014  // now the Brems - bad to copy, but problems otherwise
2015  std::vector<reco::PFBrem> brems=itRecTrack->PFRecBrem();
2016  unsigned nbrems=brems.size();
2017  for(unsigned ibrem=0;ibrem<nbrems;++ibrem)
2018  {
2019  unsigned indTrajPoint=brems[ibrem].indTrajPoint();
2020  if(indTrajPoint==99) continue;
2021  double signBrem = 1. ; // this is not the charge
2022  int linestyleBrem = brems[ibrem].algoType();
2023  indbrem++;
2024  // build the index by hand. Assume that there are less 40 Brems per GSF track (ultrasafe!)
2025  // make it from the GSF index and the brem index
2026  unsigned indexBrem= ind*40+brems[ibrem].indTrajPoint();
2027  int recTrackIdBrem=(BREMID << shiftId_ ) | indexBrem;
2028 
2029  //check if there is information on this brem in the PFBlock
2030  //before creating a graphic object
2031  if (!findBadBremsId(recTrackIdBrem)) {
2032 
2033  // the vertex is not stored, need to make it by hand
2034  std::vector<reco::PFTrajectoryPoint> pointsBrem;
2035  //the first two trajectory points are dummy; copy them
2036  pointsBrem.push_back(brems[ibrem].trajectoryPoints()[0]);
2037  pointsBrem.push_back(brems[ibrem].trajectoryPoints()[1]);
2038 
2039  // then get the vertex from the GSF track
2040  pointsBrem.push_back(itRecTrack->trajectoryPoint(indTrajPoint));
2041 
2042  unsigned ntp=brems[ibrem].trajectoryPoints().size();
2043  for(unsigned itp=2;itp<ntp;++itp)
2044  {
2045  pointsBrem.push_back(brems[ibrem].trajectoryPoints()[itp]);
2046  }
2047 
2048  double deltaP=brems[ibrem].DeltaP();
2049  const reco::PFTrajectoryPoint& tpatecalbrem
2050  = brems[ibrem].trajectoryPoint(brems[ibrem].nTrajectoryMeasurements() +
2052 
2053  if ( cos(phi0 - tpatecalbrem.momentum().Phi()) < 0.)
2054  signBrem = -1.; // again, not the charge
2055 
2056  createGTrack(brems[ibrem],pointsBrem,recTrackIdBrem,deltaP,phi0,signBrem,false,linestyleBrem,2);
2057  }
2058  }
2059  }
2060 
2061 }
2062 
2063 //___________________________________________________________________________
2065 {
2066  double phi0=0;
2067  // bool debug_loadGSim = true;
2068  unsigned simParticlesVSize = em_->trueParticles_.size();
2069 
2070  for(unsigned i=0; i<simParticlesVSize; i++) {
2071 
2072  const reco::PFSimParticle& ptc = em_->trueParticles_[i];
2073 
2074  const reco::PFTrajectoryPoint& tpinitial
2076 
2077  double pt = tpinitial.momentum().Pt();
2078  //if( pt<em_->getDisplayTrueParticlesPtMin()) continue;
2079 
2080  double sign = 1.;
2081  const reco::PFTrajectoryPoint& tpFirst = ptc.trajectoryPoint(0);
2082  if ( tpFirst.position().X() < 0. )
2083  sign = -1.;
2084  //double sign2 = 1.;
2085  // if position vector is 0,0,0: X component is undefined (MDN 11 June 2008)
2086  // const reco::PFTrajectoryPoint& tpFirst = ptc.trajectoryPoint(0);
2087  // if ( tpFirst.positionXYZ().X() < 0. )
2088  // sign2 = -1.;
2089 
2090  const std::vector<reco::PFTrajectoryPoint>& points =
2091  ptc.trajectoryPoints();
2092 
2093 
2094  int indexMarker;
2095  switch( std::abs(ptc.pdgCode() ) ) {
2096  case 22: indexMarker=0; break; // photons
2097  case 11: indexMarker=1; break; // electrons
2098  case 13: indexMarker=2; break; // muons
2099  case 130:
2100  case 321: indexMarker=3; break; // K
2101  case 211: indexMarker=4; break; // pi+/pi-
2102  case 2212: indexMarker=5; break; // protons
2103  case 2112: indexMarker=6; break; // neutrons
2104  default: indexMarker=7; break;
2105  }
2106 
2107  bool displayInitial=true;
2108  if( ptc.motherId() < 0 ) displayInitial=false;
2109  int partId=(SIMPARTICLEID << shiftId_) | i;
2110  createGPart(ptc, points,partId, pt, phi0, sign, displayInitial,indexMarker);
2111  //cout << " sign " << sign << " sign2 " << sign2 << endl;
2112  //if ( sign*sign2 <0 ) cout << " ++++++Warning sign*sign2 <0 ++++++++++++++++++ " << endl;
2113 
2114  }
2115 }
2116 //_____________________________________________________________________________
2118 {
2119  // look for the rechit with max e in ecal or hcal
2120  double maxe = -999;
2121  reco::PFRecHit* maxrh = 0;
2122 
2124  if(ecal) rechits = &(em_->rechitsECAL_);
2125  else rechits = &(em_->rechitsHCAL_);
2126  assert(rechits);
2127 
2128  for(unsigned i=0; i<(*rechits).size(); i++) {
2129 
2130  double energy = (*rechits)[i].energy();
2131 
2132  if(energy > maxe ) {
2133  maxe = energy;
2134  maxrh = &((*rechits)[i]);
2135  }
2136  }
2137 
2138  if(!maxrh) return;
2139 
2140  // center view on this rechit
2141 
2142 
2143  // get the cell size to set the eta and phi width
2144  // of the display window from one of the cells
2145 
2146  double phisize = -1;
2147  double etasize = -1;
2148  maxrh->size(phisize, etasize);
2149 
2150  double etagate = zoomFactor_ * etasize;
2151  double phigate = zoomFactor_ * phisize;
2152 
2153  double eta = maxrh->position().Eta();
2154  double phi = maxrh->position().Phi();
2155 
2156  if(displayHist_[EPE]) {
2157  displayHist_[EPE]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2158  displayHist_[EPE]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2159  displayView_[EPE]->Modified();
2160  displayView_[EPE]->Update();
2161  }
2162 
2163  if(displayHist_[EPH]) {
2164  displayHist_[EPH]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2165  displayHist_[EPH]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2166  displayView_[EPH]->Modified();
2167  displayView_[EPH]->Update();
2168  }
2169 
2170  if(drawHO_ && displayHist_[EHO]) {
2171  displayHist_[EHO]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2172  displayHist_[EHO]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2173  displayView_[EHO]->Modified();
2174  displayView_[EHO]->Update();
2175  }
2176 
2177 
2178 }
2179 //________________________________________________________________________________
2180 void DisplayManager::lookForGenParticle(unsigned barcode) {
2181 
2182  const HepMC::GenEvent* event = em_->MCTruth_.GetEvent();
2183  if(!event) {
2184  cerr<<"no GenEvent"<<endl;
2185  return;
2186  }
2187 
2188  const HepMC::GenParticle* particle = event->barcode_to_particle(barcode);
2189  if(!particle) {
2190  cerr<<"no particle with barcode "<<barcode<<endl;
2191  return;
2192  }
2193 
2194  math::XYZTLorentzVector momentum(particle->momentum().px(),
2195  particle->momentum().py(),
2196  particle->momentum().pz(),
2197  particle->momentum().e());
2198 
2199  double eta = momentum.Eta();
2200  double phi = momentum.phi();
2201 
2202  double phisize = 0.05;
2203  double etasize = 0.05;
2204 
2205  double etagate = zoomFactor_ * etasize;
2206  double phigate = zoomFactor_ * phisize;
2207 
2208  if(displayHist_[EPE]) {
2209  displayHist_[EPE]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2210  displayHist_[EPE]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2211  displayView_[EPE]->Modified();
2212  displayView_[EPE]->Update();
2213 
2214  }
2215  if(displayHist_[EPH]) {
2216  displayHist_[EPH]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2217  displayHist_[EPH]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2218  displayView_[EPH]->Modified();
2219  displayView_[EPH]->Update();
2220  }
2221 
2222  if(drawHO_ && displayHist_[EHO]) {
2223  displayHist_[EHO]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
2224  displayHist_[EHO]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
2225  displayView_[EHO]->Modified();
2226  displayView_[EHO]->Update();
2227  }
2228 
2229 }
2230 //_______________________________________________________________________
2231 void DisplayManager::printDisplay(const char* sdirectory ) const
2232 {
2233  string directory = sdirectory;
2234  if( directory.empty() ) {
2235  directory = "Event_";
2236  }
2237  char num[10];
2238  sprintf(num,"%d", eventNumber_);
2239  directory += num;
2240 
2241  string mkdir = "mkdir "; mkdir += directory;
2242  int code = system( mkdir.c_str() );
2243 
2244  if( code ) {
2245  cerr<<"cannot create directory "<<directory<<endl;
2246  return;
2247  }
2248 
2249  cout<<"Event display printed in directory "<<directory<<endl;
2250 
2251  directory += "/";
2252 
2253  for(unsigned iView=0; iView<displayView_.size(); iView++) {
2254  if( !displayView_[iView] ) continue;
2255 
2256  string name = directory;
2257  name += displayView_[iView]->GetName();
2258 
2259  cout<<displayView_[iView]->GetName()<<endl;
2260 
2261  string eps = name; eps += ".eps";
2262  displayView_[iView]->SaveAs( eps.c_str() );
2263 
2264  string png = name; png += ".png";
2265  displayView_[iView]->SaveAs( png.c_str() );
2266  }
2267 
2268  string txt = directory;
2269  txt += "event.txt";
2270  ofstream out( txt.c_str() );
2271  if( !out )
2272  cerr<<"cannot open "<<txt<<endl;
2273  em_->print( out );
2274 }
2275 //_____________________________________________________________________________
2277 {
2278  maxERecHitEcal_=-1;
2279  maxERecHitHcal_=-1;
2280  maxERecHitHo_=-1;
2281  isGraphicLoaded_= false;
2282 
2283  std::multimap<int,GPFBase *>::iterator p;
2284  for (p=graphicMap_.begin();p!=graphicMap_.end();p++)
2285  delete p->second;
2286  graphicMap_.clear();
2287 
2288  blockIdentsMap_.clear();
2289  selectedGObj_.clear();
2290  badBremsId_.clear();
2291 
2292 
2293 }
2294 //_______________________________________________________________________________
2296 {
2297  for( unsigned i=0; i<displayHist_.size(); i++) {
2298  // the corresponding view was not requested
2299  if( ! displayHist_[i] ) continue;
2300  displayHist_[i]->GetXaxis()->UnZoom();
2301  displayHist_[i]->GetYaxis()->UnZoom();
2302  }
2303  updateDisplay();
2304 }
2305 //_______________________________________________________________________________
2307 {
2308  simPartPatternM_.clear();
2317 }
2318 
2319 //_______________________________________________________________________________
2320 void DisplayManager::printGenParticleInfo(std::string name,int barcode,int barcodeMother)
2321 {
2322  const HepMC::GenEvent* myGenEvent = em_->MCTruth_.GetEvent();
2323  HepMC::GenParticle *p = myGenEvent->barcode_to_particle(barcode);
2324  std::cout<<"genParticle "<<name<<" with barcode "<<barcode<<std::flush<<std::endl;
2325  p->print();
2326  if (barcodeMother) {
2327  HepMC:: GenParticle *mother = myGenEvent->barcode_to_particle(barcodeMother);
2328  std::cout<<"mother particle with barcode "<<barcodeMother<<std::flush<<std::endl;
2329  mother->print();
2330  }
2331 }
void printGenParticleInfo(std::string name, int barcode, int barcodeMother)
PFLayer::Layer layer() const
cluster layer, see PFLayer.h in this directory
Definition: PFCluster.cc:81
void drawGObject(int ident, int color, bool toInitialColor)
const reco::PFBlockCollection & blocks() const
std::auto_ptr< reco::PFBlockCollection > pfBlocks_
reconstructed pfblocks
const double Pi
type
Definition: HCALResponse.h:22
const unsigned int SHIFTID
Definition: DisplayCommon.h:27
void displayAll(bool noRedraw=true)
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:123
std::string getGenParticleName(int partId, std::string &latexStringName) const
get name of genParticle
reconstructed track used as an input to particle flow
Definition: PFRecTrack.h:22
int i
Definition: DBlmapReader.cc:9
bool findBadBremsId(int ident)
PFClusterAlgo clusterAlgoHFEM_
clustering algorithm for HF, electro-magnetic layer
std::multimap< int, GPFBase * > graphicMap_
PFClusterAlgo clusterAlgoHO_
clustering algorithm for HO
General option file parser.
Definition: IO.h:28
double threshBarrel() const
getters -------------------------------------------------——
std::vector< TCanvas * > displayView_
vector of canvas for x/y or r/z display
void setNewAttrToSimParticles()
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
GsfPFRecTrackRef GsftrackRefPF() const
Long64_t size() const
Definition: ChainEvent.cc:311
std::vector< float > gsfAttributes_
TAttMarker * genPartPattern_
void createGCluster(const reco::PFCluster &cluster, int ident, double phi0=0.)
tuple lumi
Definition: fjr2json.py:35
const math::XYZPoint & position() const
cartesian position (x, y, z)
fwlite::ChainEvent * ev_
NEW: input event.
std::auto_ptr< reco::PFClusterCollection > clustersECAL_
TAttMarker * gsfPatternM_
TAttLine * trackPatternL_
void drawWithNewGraphicAttributes()
#define abs(x)
Definition: mlp_lapack.h:159
reco::PFRecHitCollection rechitsHFHAD_
void findBlock(int ident)
void lookForMaxRecHit(bool ecal)
look for rechit with max energy in ecal or hcal.
std::vector< TAttMarker * > simPartPatternM_
void lookForGenParticle(unsigned barcode)
look for particle with index i in MC truth.
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
TAttMarker * clusPatternhfem_
int pdgCode() const
Definition: PFSimParticle.h:35
std::auto_ptr< reco::PFClusterCollection > clustersHCAL_
PFClusterAlgo clusterAlgoECAL_
T eta() const
reco::PFRecTrackCollection recTracks_
unsigned int indTrajPoint() const
std::vector< float > trackAttributes_
TAttMarker * trackPatternM_
reco::PFRecHitCollection rechitsPS_
double z() const
z coordinate of cluster centroid
Definition: CaloCluster.h:157
double double double z
void createGPart(const reco::PFSimParticle &ptc, const std::vector< reco::PFTrajectoryPoint > &points, int ident, double pt, double phi0, double sign, bool displayInitial, int markerIndex)
TAttMarker * clusPSPattern_
bool GetOpt(const char *tag, const char *key, std::vector< T > &values) const
reads a vector of T
Definition: IO.h:106
void display(int ientry)
TAttMarker * simPartPatternPi_
void displayPFBlock(int blockNb)
reco::PFRecHitCollection rechitsHCAL_
PFRootEventManager * em_
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:102
U second(std::pair< T, U > const &p)
reco::PFSimParticleCollection trueParticles_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
const std::vector< math::XYZPoint > & getCornersXYZ() const
rechit corners
Definition: PFRecHit.h:144
double xPos
TAttMarker * clusPatternecal_
void print(std::ostream &out=std::cout, int maxNLines=-1) const
print information
TAttMarker * bremPatternM_
double particlePtMin_
bool isNull() const
Checks for null.
Definition: Ref.h:247
TBox frontFaceECALRZ_
ECAL in RZ view.
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
std::vector< int > selectedGObj_
graphic object containers
std::auto_ptr< reco::PFClusterCollection > clustersPS_
void enableDrawBrem(bool state)
TAttMarker * simPartPatternProton_
Point of closest approach from beam axis (initial point in the case of PFSimParticle) ...
DisplayManager(PFRootEventManager *em, const char *optfile)
void printDisplay(const char *directory="") const
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< int > badBremsId_
std::vector< float > bremAttributes_
void displayEvent(int run, int lumi, int event)
TEllipse frontFaceHOXY_
HO in XY view.
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
TAttMarker * simPartPatternPhoton_
PFClusterAlgo clusterAlgoHCAL_
clustering algorithm for HCAL
double threshEndcap() const
get endcap threshold
TAttMarker * simPartPatternElec_
std::vector< float > clusterAttributes_
double yPos
void size(double &deta, double &dphi) const
Definition: PFRecHit.cc:266
TAttMarker * clusPattern_
#define end
Definition: vmac.h:38
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:76
double maxERecHitEcal_
reco::GsfPFRecTrackCollection gsfrecTracks_
std::auto_ptr< reco::PFClusterCollection > clustersHO_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void createGTrack(reco::PFRecTrack &tr, const std::vector< reco::PFTrajectoryPoint > &points, int ident, double pt, double phi0, double sign, bool displayInitial, int linestyle, int kfgsfbrem=0)
bool first
Definition: L1TdeRCT.cc:94
void createGRecHit(reco::PFRecHit &rh, int ident, double maxe, double phi0=0., int color=4)
block
Formating index page&#39;s pieces.
Definition: Association.py:232
virtual bool processEntry(int entry)
process one entry (pass the TTree entry)
reco::PFRecHitCollection rechitsHFEM_
true particle for particle flow
Definition: PFSimParticle.h:19
TAttMarker * simPartPatternMuon_
void displayNextInteresting(int ientry)
std::multimap< int, std::pair< int, int > > blockIdentsMap_
tuple out
Definition: dbtoconf.py:99
const std::vector< reco::PFTrajectoryPoint > & trajectoryPoints() const
Definition: PFTrack.h:98
virtual bool processEvent(int run, int lumi, int event)
process one event (pass the CMS event number)
const math::XYZPoint & position() const
is seed ?
Definition: PFRecHit.h:135
reco::PFRecHitCollection rechitsHO_
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
const reco::PFTrajectoryPoint & trajectoryPoint(unsigned index) const
Definition: PFTrack.h:102
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:35
std::auto_ptr< reco::PFClusterCollection > clustersHFEM_
const int HITTYPES
Definition: DisplayCommon.h:28
std::auto_ptr< reco::PFClusterCollection > clustersHFHAD_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
static const float outerRadius(PFGeometry::Layers_t layer)
return outer radius of a given layer
Definition: PFGeometry.h:60
TEllipse frontFaceECALXY_
ECAL in XY view.
key_type key() const
Accessor for product key.
Definition: Ref.h:266
void enableDrawPFBlock(bool state)
long long int num
Definition: procUtils.cc:71
static const float innerRadius(PFGeometry::Layers_t layer)
return inner radius of a given layer
Definition: PFGeometry.h:56
PFClusterAlgo clusterAlgoPS_
clustering algorithm for PS
double getMaxE(int layer) const
TAttLine * gsfPatternL_
edm::HepMCProduct MCTruth_
TEllipse frontFaceHCALXY_
HCAL in XY view.
TAttLine * bremPatternL_
IO * options_
options file parser
char state
Definition: procUtils.cc:75
int motherId() const
Definition: PFSimParticle.h:41
#define begin
Definition: vmac.h:31
double energy() const
rechit energy
Definition: PFRecHit.h:105
void readOptions(const char *file)
DTRecHit1DPair & gt
void findAndDraw(int ident)
TAttLine * simPartPatternL_
void createGGenParticle(HepMC::GenParticle *p)
GsfPFRecTrackRef GsftrackRefPF() const
static const float innerZ(PFGeometry::Layers_t layer)
return inner position along z axis of a given layer
Definition: PFGeometry.h:64
virtual ~DisplayManager()
reco::PFRecHitCollection rechitsECAL_
tuple cout
Definition: gather_cfg.py:121
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
PFClusterAlgo clusterAlgoHFHAD_
clustering algorithm for HF, hadronic layer
Definition: DDAxes.h:10
ROOT interface to particle flow package.
TAttMarker * simPartPatternNeutron_
double genParticlePtMin_
unsigned color(unsigned rhi) const
std::vector< TH2F * > displayHist_
support histogram for x/y or r/z display.
tuple size
Write out results.
TAttMarker * simPartPatternK_
TAttMarker * simPartPatternDefault_
std::vector< int > viewSize_
display pad xy size for (x,y) or (r,z) display
std::vector< int > viewSizeEtaPhi_
display pad xy size for eta/phi view
double maxERecHitHcal_
TAttMarker * clusPatternho_
Definition: DDAxes.h:10
Block of elements.
Definition: PFBlock.h:30