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