00001 #include <iostream>
00002 #include <fstream>
00003 #include <stdlib.h>
00004
00005 #include "RecoParticleFlow/PFRootEvent/interface/IO.h"
00006
00007 #include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
00008 #include "RecoParticleFlow/PFTracking/interface/PFGeometry.h"
00009 #include "DataFormats/ParticleFlowReco/interface/PFBlockElement.h"
00010 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
00011
00012 #include "DataFormats/Math/interface/Point3D.h"
00013
00014 #include "DataFormats/FWLite/interface/ChainEvent.h"
00015
00016 #include "RecoParticleFlow/PFRootEvent/interface/PFRootEventManager.h"
00017 #include "RecoParticleFlow/PFRootEvent/interface/DisplayManager.h"
00018 #include "RecoParticleFlow/PFRootEvent/interface/GPFRecHit.h"
00019 #include "RecoParticleFlow/PFRootEvent/interface/GPFCluster.h"
00020 #include "RecoParticleFlow/PFRootEvent/interface/GPFTrack.h"
00021 #include "RecoParticleFlow/PFRootEvent/interface/GPFSimParticle.h"
00022 #include "RecoParticleFlow/PFRootEvent/interface/GPFGenParticle.h"
00023 #include "RecoParticleFlow/PFRootEvent/interface/GPFBase.h"
00024
00025 #include <TH2.h>
00026 #include <TTree.h>
00027 #include <TVector3.h>
00028 #include <TH2F.h>
00029 #include <TEllipse.h>
00030 #include <TLine.h>
00031 #include <TLatex.h>
00032 #include <TList.h>
00033 #include <TColor.h>
00034 #include <TMath.h>
00035 #include <TApplication.h>
00036
00037 using namespace std;
00038
00039
00040
00041 DisplayManager::DisplayManager(PFRootEventManager *em,
00042 const char* optfile ) :
00043 em_(em),
00044 options_(0),
00045 maxERecHitEcal_(-1),
00046 maxERecHitHcal_(-1),
00047 maxERecHitHo_(-1),
00048 isGraphicLoaded_(false),
00049 shiftId_(SHIFTID) {
00050
00051 readOptions( optfile );
00052
00053 eventNumber_ = em_->eventNumber();
00054
00055 maxEvents_= em_->ev_->size();
00056 createCanvas();
00057 }
00058
00059 DisplayManager::~DisplayManager()
00060 {
00061 reset();
00062 }
00063
00064
00065 void DisplayManager::readOptions( const char* optfile ) {
00066
00067 try {
00068 delete options_;
00069 options_ = new IO(optfile);
00070 }
00071 catch( const string& err ) {
00072 cout<<err<<endl;
00073 return;
00074 }
00075
00076 drawHO_=true;
00077 options_->GetOpt("display", "drawHO", drawHO_);
00078
00079
00080
00081 viewSizeEtaPhi_.clear();
00082 options_->GetOpt("display", "viewsize_etaphi", viewSizeEtaPhi_);
00083 if(viewSizeEtaPhi_.size() != 2) {
00084 cerr<<"PFRootEventManager::ReadOptions, bad display/viewsize_etaphi tag...using 700/350"
00085 <<endl;
00086 viewSizeEtaPhi_.clear();
00087 viewSizeEtaPhi_.push_back(700);
00088 viewSizeEtaPhi_.push_back(350);
00089 }
00090
00091 viewSize_.clear();
00092 options_->GetOpt("display", "viewsize_xy", viewSize_);
00093 if(viewSize_.size() != 2) {
00094 cerr<<"PFRootEventManager::ReadOptions, bad display/viewsize_xy tag...using 700/350"
00095 <<endl;
00096 viewSize_.clear();
00097 viewSize_.push_back(600);
00098 viewSize_.push_back(600);
00099 }
00100
00101 clusterAttributes_.clear();
00102 options_->GetOpt("display", "cluster_attributes", clusterAttributes_);
00103 if(clusterAttributes_.size() != 7) {
00104 cerr<<"PFRootEventManager::::ReadOptions, bad display/cluster_attributes tag...using 20 10 2 5"
00105 <<endl;
00106 clusterAttributes_.clear();
00107 clusterAttributes_.push_back(2);
00108 clusterAttributes_.push_back(5);
00109 clusterAttributes_.push_back(20);
00110 clusterAttributes_.push_back(1.0);
00111 clusterAttributes_.push_back(6);
00112 clusterAttributes_.push_back(9);
00113 clusterAttributes_.push_back(46);
00114 }
00115
00116 trackAttributes_.clear();
00117 options_->GetOpt("display", "track_attributes", trackAttributes_);
00118 if(trackAttributes_.size() != 4) {
00119 cerr<<"PFRootEventManager::::ReadOptions, bad display/track_attributes tag...using 103 1 8 8"
00120 <<endl;
00121 trackAttributes_.clear();
00122 trackAttributes_.push_back(103);
00123 trackAttributes_.push_back(1);
00124 trackAttributes_.push_back(8);
00125 trackAttributes_.push_back(1.0);
00126 }
00127 gsfAttributes_.clear();
00128 options_->GetOpt("display", "gsf_attributes", gsfAttributes_);
00129 if(gsfAttributes_.size() != 4) {
00130 cerr<<"PFRootEventManager::::ReadOptions, bad display/gsf_attributes tag...using 105 1 8 8"
00131 <<endl;
00132 gsfAttributes_.clear();
00133 gsfAttributes_.push_back(105);
00134 gsfAttributes_.push_back(1);
00135 gsfAttributes_.push_back(8);
00136 gsfAttributes_.push_back(1.0);
00137 }
00138 bremAttributes_.clear();
00139 options_->GetOpt("display", "brem_attributes", bremAttributes_);
00140 if(bremAttributes_.size() != 4) {
00141 cerr<<"PFRootEventManager::::ReadOptions, bad display/gsf_attributes tag...using 106 1 8 8"
00142 <<endl;
00143 bremAttributes_.clear();
00144 bremAttributes_.push_back(106);
00145 bremAttributes_.push_back(1);
00146 bremAttributes_.push_back(8);
00147 bremAttributes_.push_back(1.0);
00148 }
00149
00150 double attrScale = (drawHO_) ? 0.8 : 1.0;
00151
00152 clusPattern_ = new TAttMarker( (int)clusterAttributes_[0],
00153 (int)clusterAttributes_[2],
00154 attrScale*clusterAttributes_[3]);
00155
00156 clusPatternecal_ = new TAttMarker( (int)clusterAttributes_[4],
00157 (int)clusterAttributes_[2],
00158 attrScale*clusterAttributes_[3]);
00159
00160 clusPatternhfem_ = new TAttMarker( (int)clusterAttributes_[5],
00161 (int)clusterAttributes_[2],
00162 attrScale*clusterAttributes_[3]);
00163
00164 clusPatternho_ = new TAttMarker( (int)clusterAttributes_[6],
00165 (int)clusterAttributes_[2],
00166 attrScale*clusterAttributes_[3]);
00167
00168 clusPSPattern_ = new TAttMarker( (int)clusterAttributes_[1],
00169 (int)clusterAttributes_[2],
00170 attrScale*clusterAttributes_[3]);
00171 trackPatternL_ = new TAttLine( (int)trackAttributes_[0],
00172 (int)trackAttributes_[1],
00173 1);
00174 trackPatternM_ = new TAttMarker( (int)trackAttributes_[0],
00175 (int)trackAttributes_[2],
00176 attrScale*trackAttributes_[3]);
00177
00178 gsfPatternL_ = new TAttLine( (int)gsfAttributes_[0],
00179 (int)gsfAttributes_[1],
00180 1);
00181 gsfPatternM_ = new TAttMarker( (int)gsfAttributes_[0],
00182 (int)gsfAttributes_[2],
00183 attrScale*gsfAttributes_[3]);
00184
00185 bremPatternL_ = new TAttLine( (int)bremAttributes_[0],
00186 (int)bremAttributes_[1],
00187 1);
00188 bremPatternM_ = new TAttMarker( (int)bremAttributes_[0],
00189 (int)bremAttributes_[2],
00190 attrScale*bremAttributes_[3]);
00191
00192 genPartPattern_= new TAttMarker(kGreen-1,22,1.);
00193
00194
00195 std::vector<float> simPartAttributes;
00196
00197 simPartAttributes.clear();
00198 options_->GetOpt("display", "simPart_attributes", simPartAttributes);
00199 if(simPartAttributes.size() != 3) {
00200 cerr<<"PFRootEventManager::::ReadOptions, bad display/simPart_attributes tag...using 103 1 8 8"
00201 <<endl;
00202 simPartAttributes.clear();
00203 simPartAttributes.push_back(3);
00204 simPartAttributes.push_back(2);
00205 simPartAttributes.push_back(0.6);
00206 }
00207
00208 int simColor = (int)simPartAttributes[0];
00209 int simLStyle = (int)simPartAttributes[1];
00210 float simMSize = attrScale*simPartAttributes[2];
00211
00212 simPartPatternPhoton_ = new TAttMarker(simColor,3,simMSize);
00213 simPartPatternElec_ = new TAttMarker(simColor,5,simMSize);
00214 simPartPatternMuon_ = new TAttMarker(simColor,2,simMSize);
00215 simPartPatternK_ = new TAttMarker(simColor,24,simMSize);
00216 simPartPatternPi_ = new TAttMarker(simColor,25,simMSize);
00217 simPartPatternProton_ = new TAttMarker(simColor,26,simMSize);
00218 simPartPatternNeutron_= new TAttMarker(simColor,27,simMSize);
00219 simPartPatternDefault_= new TAttMarker(simColor,30,simMSize);
00220
00221 simPartPatternL_ = new TAttLine(simColor,simLStyle,1);
00222 simPartPatternM_.resize(8);
00223
00224 setNewAttrToSimParticles();
00225
00226 drawHits_= true;
00227 options_->GetOpt("display", "rechits",drawHits_);
00228
00229 drawClus_ = true;
00230 options_->GetOpt("display", "clusters",drawClus_);
00231
00232 drawClusterL_ = false;
00233 options_->GetOpt("display", "cluster_lines", drawClusterL_);
00234
00235 drawTracks_ = true;
00236 options_->GetOpt("display", "rectracks", drawTracks_);
00237
00238 drawGsfTracks_ = true;
00239 options_->GetOpt("display", "gsftracks", drawGsfTracks_);
00240
00241 drawBrems_ = false;
00242 options_->GetOpt("display", "brems", drawBrems_);
00243
00244 drawParticles_ = true;
00245 options_->GetOpt("display", "particles", drawParticles_);
00246
00247 particlePtMin_ = -1;
00248 options_->GetOpt("display", "particles_ptmin", particlePtMin_);
00249
00250
00251 drawGenParticles_=false;
00252 genParticlePtMin_ = 0;
00253
00254
00255 trackPtMin_ = -1;
00256 options_->GetOpt("display", "rectracks_ptmin", trackPtMin_);
00257
00258 gsfPtMin_ = -1;
00259 options_->GetOpt("display", "gsfrectracks_ptmin", gsfPtMin_);
00260
00261 hitEnMin_ = -1;
00262 options_->GetOpt("display","rechits_enmin",hitEnMin_);
00263
00264 clusEnMin_ = -1;
00265 options_->GetOpt("display","clusters_enmin",clusEnMin_);
00266
00267
00268 drawPFBlocks_ = false;
00269 options_->GetOpt("display","drawPFBlock",drawPFBlocks_);
00270
00271
00272 zoomFactor_ = 10;
00273 options_->GetOpt("display", "zoom_factor", zoomFactor_);
00274
00275 }
00276
00277
00278 void DisplayManager::createCanvas()
00279 {
00280
00281
00282 displayView_.resize(NViews);
00283 displayHist_.resize(NViews);
00284
00285
00286
00287
00288
00289 displayView_[XY] = new TCanvas("displayXY_", "XY view",viewSize_[0], viewSize_[1]);
00290 displayView_[RZ] = new TCanvas("displayRZ_", "RZ view",viewSize_[0], viewSize_[1]);
00291 displayView_[EPE] = new TCanvas("displayEPE_", "eta/phi view, ECAL",viewSize_[0], viewSize_[1]);
00292 displayView_[EPH] = new TCanvas("displayEPH_", "eta/phi view, HCAL",viewSize_[0], viewSize_[1]);
00293 if (drawHO_) displayView_[EHO] = new TCanvas("displayEHO_", "eta/phi view, HO",viewSize_[0], viewSize_[1]);
00294
00295 for (int viewType=0;viewType<NViews;++viewType) {
00296 if (!drawHO_ && viewType==EHO) continue;
00297 displayView_[viewType]->SetGrid(0, 0);
00298 displayView_[viewType]->SetBottomMargin(0.14);
00299 displayView_[viewType]->SetLeftMargin(0.15);
00300 displayView_[viewType]->SetRightMargin(0.05);
00301 displayView_[viewType]->ToggleToolBar();
00302 }
00303
00304 double zLow = -650.;
00305 double zUp = +650.;
00306 double rLow = -450.;
00307 double rUp = +450.;
00308
00309 if (!drawHO_) {zLow = -500.; zUp = +500.; rLow = -300.; rUp = +300.;}
00310
00311 displayHist_[XY] = new TH2F("hdisplayHist_XY", "", 500, rLow, rUp,
00312 500, rLow, rUp);
00313 displayHist_[XY]->SetXTitle("X [cm]");
00314 displayHist_[XY]->SetYTitle("Y [cm]");
00315
00316 displayHist_[RZ] = new TH2F("hdisplayHist_RZ", "",500, zLow, zUp,
00317 500, rLow, rUp);
00318 displayHist_[RZ]->SetXTitle("Z [cm]");
00319 displayHist_[RZ]->SetYTitle("R [cm]");
00320
00321 displayHist_[EPE] = new TH2F("hdisplayHist_EP", "", 500, -5, 5,
00322 500, -3.5, 3.5);
00323 displayHist_[EPE]->SetXTitle("#eta");
00324 displayHist_[EPE]->SetYTitle("#phi [rad]");
00325
00326 displayHist_[EPH] = displayHist_[EPE];
00327
00328
00329
00330
00331
00332
00333 if (drawHO_) displayHist_[EHO] = displayHist_[EPE];
00334
00335 for (int viewType=0;viewType<NViews;++viewType){
00336 if (!drawHO_ && viewType==EHO) continue;
00337 displayHist_[viewType]->SetStats(kFALSE);
00338 displayHist_[viewType]->GetYaxis()->SetTitleSize(0.06);
00339 displayHist_[viewType]->GetYaxis()->SetTitleOffset(1.2);
00340 displayHist_[viewType]->GetXaxis()->SetTitleSize(0.06);
00341 displayHist_[viewType]->GetYaxis()->SetLabelSize(0.045);
00342 displayHist_[viewType]->GetXaxis()->SetLabelSize(0.045);
00343 }
00344
00345
00346 frontFaceECALXY_.SetX1(0);
00347 frontFaceECALXY_.SetY1(0);
00348 frontFaceECALXY_.SetR1(PFGeometry::innerRadius(PFGeometry::ECALBarrel));
00349 frontFaceECALXY_.SetR2(PFGeometry::innerRadius(PFGeometry::ECALBarrel));
00350 frontFaceECALXY_.SetFillStyle(0);
00351
00352
00353 frontFaceHCALXY_.SetX1(0);
00354 frontFaceHCALXY_.SetY1(0);
00355 frontFaceHCALXY_.SetR1(PFGeometry::innerRadius(PFGeometry::HCALBarrel));
00356 frontFaceHCALXY_.SetR2(PFGeometry::innerRadius(PFGeometry::HCALBarrel));
00357 frontFaceHCALXY_.SetFillStyle(0);
00358
00359 if (drawHO_) {
00360
00361 frontFaceHOXY_.SetX1(0);
00362 frontFaceHOXY_.SetY1(0);
00363 frontFaceHOXY_.SetR1(PFGeometry::innerRadius(PFGeometry::HOBarrel));
00364 frontFaceHOXY_.SetR2(PFGeometry::outerRadius(PFGeometry::HOBarrel));
00365 frontFaceHOXY_.SetFillStyle(0);
00366 }
00367
00368
00369 frontFaceECALRZ_.SetX1(-1.*PFGeometry::innerZ(PFGeometry::ECALEndcap));
00370 frontFaceECALRZ_.SetY1(-1.*PFGeometry::innerRadius(PFGeometry::ECALBarrel));
00371 frontFaceECALRZ_.SetX2(PFGeometry::innerZ(PFGeometry::ECALEndcap));
00372 frontFaceECALRZ_.SetY2(PFGeometry::innerRadius(PFGeometry::ECALBarrel));
00373 frontFaceECALRZ_.SetFillStyle(0);
00374 cout <<"End of DisplayManager::createCanvas()"<<endl;
00375
00376 }
00377
00378 void DisplayManager::createGCluster(const reco::PFCluster& cluster,
00379 int ident,
00380 double phi0)
00381 {
00382
00383 double eta = cluster.position().Eta();
00384 double phi = cluster.position().Phi();
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401 int clusType=0;
00402
00403 if ( cluster.layer()==PFLayer::PS1 || cluster.layer()==PFLayer::PS2 )
00404 clusType=1;
00405
00406 if ( cluster.layer()==PFLayer::ECAL_BARREL || cluster.layer()==PFLayer::ECAL_ENDCAP)
00407 clusType=2;
00408
00409 if ( cluster.layer()==PFLayer::HF_EM) clusType=3;
00410
00411 if ( cluster.layer()==PFLayer::HCAL_BARREL2) clusType=4;
00412
00413
00414
00415 const math::XYZPoint& xyzPos = cluster.position();
00416
00417 GPFCluster *gc;
00418
00419 for (int viewType=0;viewType<NViews;viewType++){
00420 if (!drawHO_ && viewType==EHO) continue;
00421 switch(viewType) {
00422 case XY:
00423 {
00424 if (clusType==0) {
00425 gc = new GPFCluster(this,
00426 viewType,ident,
00427 &cluster,
00428 xyzPos.X(), xyzPos.Y(), clusPattern_);
00429 } else if (clusType==1) {
00430 gc = new GPFCluster(this,
00431 viewType,ident,
00432 &cluster,
00433 xyzPos.X(), xyzPos.Y(), clusPSPattern_);
00434
00435 } else if (clusType==2) {
00436 gc = new GPFCluster(this,
00437 viewType,ident,
00438 &cluster,
00439 xyzPos.X(), xyzPos.Y(), clusPatternecal_);
00440 } else if (clusType==3) {
00441 gc = new GPFCluster(this,
00442 viewType,ident,
00443 &cluster,
00444 xyzPos.X(), xyzPos.Y(), clusPatternhfem_);
00445 } else {
00446 gc = new GPFCluster(this,
00447 viewType,ident,
00448 &cluster,
00449 xyzPos.X(), xyzPos.Y(), clusPatternho_);
00450 }
00451 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00452 }
00453 break;
00454 case RZ:
00455 {
00456 double sign = 1.;
00457 if (cos(phi0 - phi) < 0.)
00458 sign = -1.;
00459 if ( clusType==0) {
00460 gc = new GPFCluster(this,
00461 viewType,ident,
00462 &cluster,
00463 xyzPos.z(),sign*xyzPos.Rho(),
00464 clusPattern_);
00465 } else if (clusType==1) {
00466 gc = new GPFCluster(this,
00467 viewType,ident,
00468 &cluster,
00469 xyzPos.z(),sign*xyzPos.Rho(),
00470 clusPSPattern_);
00471 } else if (clusType==2) {
00472 gc = new GPFCluster(this,
00473 viewType,ident,
00474 &cluster,
00475 xyzPos.z(),sign*xyzPos.Rho(),
00476 clusPatternecal_);
00477 } else if (clusType==3) {
00478 gc = new GPFCluster(this,
00479 viewType,ident,
00480 &cluster,
00481 xyzPos.z(),sign*xyzPos.Rho(),
00482 clusPatternhfem_);
00483
00484 } else {
00485 gc = new GPFCluster(this,
00486 viewType,ident,
00487 &cluster,
00488 xyzPos.z(),sign*xyzPos.Rho(),
00489 clusPatternho_);
00490 }
00491 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00492 }
00493 break;
00494 case EPE:
00495 {
00496 if( cluster.layer()<0 || cluster.layer()==PFLayer::HF_EM) {
00497 if (clusType==2) {
00498 gc = new GPFCluster(this,
00499 viewType,ident,
00500 &cluster,
00501 eta,phi,
00502 clusPatternecal_);
00503 }
00504 else if (clusType==3) {
00505 gc = new GPFCluster(this,
00506 viewType,ident,
00507 &cluster,
00508 eta,phi,
00509 clusPatternhfem_);
00510 }
00511 else {
00512 gc = new GPFCluster(this,
00513 viewType,ident,
00514 &cluster,
00515 eta,phi,
00516 clusPSPattern_);
00517 }
00518
00519 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00520 }
00521
00522 }
00523 break;
00524 case EPH:
00525 {
00526 if( cluster.layer()>0 && cluster.layer()!=PFLayer::HF_EM && cluster.layer()!=PFLayer::HCAL_BARREL2) {
00527 if (clusType==0) {
00528 gc = new GPFCluster(this,
00529 viewType,ident,
00530 &cluster,
00531 eta,phi,clusPattern_);
00532 }
00533 else {
00534 gc = new GPFCluster(this,
00535 viewType,ident,
00536 &cluster,
00537 eta,phi,clusPSPattern_);
00538 }
00539
00540
00541 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00542 }
00543 }
00544 break;
00545
00546 case EHO:
00547 {
00548 if( cluster.layer()>0 && cluster.layer()==PFLayer::HCAL_BARREL2) {
00549 if (clusType==4) {
00550 gc = new GPFCluster(this,
00551 viewType,ident,
00552 &cluster,
00553 eta,phi,clusPatternho_);
00554 }
00555 else {
00556 gc = new GPFCluster(this,
00557 viewType,ident,
00558 &cluster,
00559 eta,phi,clusPSPattern_);
00560 }
00561
00562
00563 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00564 }
00565 }
00566 break;
00567
00568 default :break;
00569 }
00570 }
00571 }
00572
00573 void DisplayManager::createGPart( const reco::PFSimParticle &ptc,
00574 const std::vector<reco::PFTrajectoryPoint>& points,
00575 int ident,double pt,double phi0, double sign, bool displayInitial,
00576 int markerIndex)
00577 {
00578
00579
00580 bool debug_createGpart = false;
00581
00582 for (int viewType=0;viewType<NViews;++viewType) {
00583 if (!drawHO_ && viewType==EHO) continue;
00584
00585
00586 vector<double> xPos;
00587 xPos.reserve( points.size() );
00588 vector<double> yPos;
00589 yPos.reserve( points.size() );
00590
00591 for(unsigned i=0; i<points.size(); i++) {
00592
00593 if( !points[i].isValid() ) continue;
00594
00595 const math::XYZPoint& xyzPos = points[i].position();
00596
00597 double eta = xyzPos.Eta();
00598 double phi = xyzPos.Phi();
00599
00600
00601
00602
00603 if( points[i].layer() == reco::PFTrajectoryPoint::ClosestApproach ) {
00604
00605
00606
00607 const math::XYZTLorentzVector& mom = points[i].momentum();
00608 eta = mom.Eta();
00609 phi = mom.Phi();
00610 }
00611
00612
00613
00614
00615 switch(viewType) {
00616 case XY:
00617 xPos.push_back(xyzPos.X());
00618 yPos.push_back(xyzPos.Y());
00619 break;
00620 case RZ:
00621 xPos.push_back(xyzPos.Z());
00622 yPos.push_back(sign*xyzPos.Rho());
00623 break;
00624 case EPE:
00625 case EPH:
00626 case EHO:
00627 xPos.push_back( eta );
00628 yPos.push_back( phi );
00629 break;
00630 default:break;
00631 }
00632 }
00633 if (viewType == EPE && debug_createGpart) {
00634 cout << " display PFsim eta/phi view ECAL" << endl;
00635 cout << " nb of points for display " << xPos.size() << endl;
00636 for(unsigned i=0; i<xPos.size(); i++) {
00637 cout << " point " << i << " x/y " << xPos[i] <<"/" << yPos[i]<< endl;
00638 }
00639 }
00640
00642
00643
00644 GPFSimParticle *gc = new GPFSimParticle(this,
00645 viewType, ident,
00646 &ptc,
00647 xPos.size(),&xPos[0],&yPos[0],
00648 pt,
00649 simPartPatternM_[markerIndex],
00650 simPartPatternL_,
00651 "pl");
00652
00653 graphicMap_.insert(pair<int,GPFBase *> (ident, gc));
00654
00655 }
00656 }
00657
00658 void DisplayManager::createGRecHit(reco::PFRecHit& rh,int ident, double maxe, double phi0, int color)
00659 {
00660
00661 double me = maxe;
00662 double thresh = 0;
00663 int layer = rh.layer();
00664
00665
00666 switch(layer) {
00667 case PFLayer::ECAL_BARREL:
00668 thresh = em_->clusterAlgoECAL_.threshBarrel();
00669 break;
00670 case PFLayer::ECAL_ENDCAP:
00671 thresh = em_->clusterAlgoECAL_.threshEndcap();
00672 break;
00673 case PFLayer::HCAL_BARREL1:
00674 case PFLayer::HCAL_BARREL2:
00675 thresh = em_->clusterAlgoHCAL_.threshBarrel();
00676 break;
00677 case PFLayer::HCAL_ENDCAP:
00678 thresh = em_->clusterAlgoHCAL_.threshEndcap();
00679 break;
00680 case PFLayer::HF_HAD:
00681
00682 thresh = em_->clusterAlgoHFHAD_.threshEndcap();
00683 break;
00684 case PFLayer::HF_EM:
00685
00686 thresh = em_->clusterAlgoHFEM_.threshEndcap();
00687 break;
00688 case PFLayer::PS1:
00689 case PFLayer::PS2:
00690 me = -1;
00691 thresh = em_->clusterAlgoPS_.threshBarrel();
00692 break;
00693 default:
00694 {
00695 cerr<<"DisplayManager::createGRecHit : manage other layers."
00696 <<" GRechit notcreated."<<endl;
00697 return;
00698 }
00699 }
00700 if( rh.energy() < thresh ) return;
00701
00702
00703 for(int viewType=0;viewType<NViews;++viewType) {
00704 if (!drawHO_ && viewType==EHO) continue;
00705
00706 bool isHCAL = (layer == PFLayer::HCAL_BARREL1 ||
00707
00708 layer == PFLayer::HCAL_ENDCAP ||
00709 layer == PFLayer::HF_HAD);
00710
00711 if( viewType == EPH &&
00712 ! isHCAL) {
00713 continue;
00714 }
00715
00716 if( viewType == EPE && (isHCAL || layer ==PFLayer::HCAL_BARREL2)) {
00717 continue;
00718 }
00719
00720 if (viewType == EHO && layer !=PFLayer::HCAL_BARREL2) continue;
00721
00722
00723 double rheta = rh.position().Eta();
00724 double rhphi = rh.position().Phi();
00725
00726 double sign = 1.;
00727 if (cos(phi0 - rhphi) < 0.) sign = -1.;
00728
00729
00730 double etaSize[4];
00731 double phiSize[4];
00732 double x[5];
00733 double y[5];
00734 double z[5];
00735 double r[5];
00736 double eta[5];
00737 double phi[5];
00738 double xprop[5];
00739 double yprop[5];
00740 double etaprop[5];
00741 double phiprop[5];
00742
00743
00744 const std::vector< math::XYZPoint >& corners = rh.getCornersXYZ();
00745 assert(corners.size() == 4);
00746 double propfact = 0.95;
00747 double ampl=0;
00748 if(me>0) ampl = (log(rh.energy() + 1.)/log(me + 1.));
00749 for ( unsigned jc=0; jc<4; ++jc ) {
00750
00751 phiSize[jc] = rhphi-corners[jc].Phi();
00752 etaSize[jc] = rheta-corners[jc].Eta();
00753 if ( phiSize[jc] > 1. ) phiSize[jc] -= 2.*TMath::Pi();
00754 if ( phiSize[jc] < -1. ) phiSize[jc]+= 2.*TMath::Pi();
00755
00756 phiSize[jc] *= propfact;
00757 etaSize[jc] *= propfact;
00758
00759 math::XYZPoint cornerposxyz = corners[jc];
00760
00761 x[jc] = cornerposxyz.X();
00762 y[jc] = cornerposxyz.Y();
00763 z[jc] = cornerposxyz.Z();
00764 r[jc] = sign*cornerposxyz.Rho();
00765 eta[jc] = rheta - etaSize[jc];
00766 phi[jc] = rhphi - phiSize[jc];
00767
00768
00769
00770
00771
00772 if( layer != PFLayer::PS1 &&
00773 layer != PFLayer::PS2 &&
00774 ( viewType == EPE ||
00775 viewType == EPH ||
00776 viewType == EHO ||
00777 ( viewType == XY &&
00778 ( layer == PFLayer::ECAL_ENDCAP ||
00779 layer == PFLayer::HCAL_ENDCAP ||
00780 layer == PFLayer::HF_HAD
00781 ) ) ) ) {
00782
00783 math::XYZPoint centreXYZrot = rh.position();
00784
00785 math::XYZPoint centertocorner(x[jc] - centreXYZrot.X(),
00786 y[jc] - centreXYZrot.Y(),
00787 0 );
00788
00789 math::XYZPoint centertocornerep(eta[jc] - centreXYZrot.Eta(),
00790 phi[jc] - centreXYZrot.Phi(),
00791 0 );
00792
00793
00794
00795 xprop[jc] = centreXYZrot.X() + centertocorner.X()*ampl;
00796 yprop[jc] = centreXYZrot.Y() + centertocorner.Y()*ampl;
00797
00798 etaprop[jc] = centreXYZrot.Eta() + centertocornerep.X()*ampl;
00799 phiprop[jc] = centreXYZrot.Phi() + centertocornerep.Y()*ampl;
00800 }
00801 }
00802
00803 if(layer == PFLayer::ECAL_BARREL ||
00804 layer == PFLayer::HCAL_BARREL1 ||
00805 layer == PFLayer::HCAL_BARREL2 || viewType == RZ) {
00806
00807
00808
00809
00810 int i1 = -1;
00811 int i2 = -1;
00812
00813 if(fabs(phiSize[1]-phiSize[0]) > 0.0001) {
00814 if (viewType == XY) {
00815 i1 = 2;
00816 i2 = 3;
00817 } else if (viewType == RZ) {
00818 i1 = 1;
00819 i2 = 2;
00820 }
00821 } else {
00822 if (viewType == XY) {
00823 i1 = 1;
00824 i2 = 2;
00825 } else if (viewType == RZ) {
00826 i1 = 2;
00827 i2 = 3;
00828 }
00829 }
00830
00831 double signx=1.;
00832 if(layer == PFLayer::HCAL_BARREL2) { signx=-1.;}
00833
00834 x[i1] *= 1+signx*ampl/2.;
00835 x[i2] *= 1+signx*ampl/2.;
00836 y[i1] *= 1+signx*ampl/2.;
00837 y[i2] *= 1+signx*ampl/2.;
00838 z[i1] *= 1+signx*ampl/2.;
00839 z[i2] *= 1+signx*ampl/2.;
00840 r[i1] *= 1+signx*ampl/2.;
00841 r[i2] *= 1+signx*ampl/2.;
00842
00843 }
00844
00845 x[4]=x[0];
00846 y[4]=y[0];
00847 z[4]=z[0];
00848 r[4]=r[0];
00849 eta[4]=eta[0];
00850 phi[4]=phi[0];
00851
00852 int npoints=5;
00853
00854 switch( viewType ) {
00855 case XY:
00856 {
00857 if(layer == PFLayer::ECAL_BARREL ||
00858 layer == PFLayer::HCAL_BARREL1 ||
00859 layer == PFLayer::HCAL_BARREL2) {
00860 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,x,y,color,"f")));
00861
00862 } else {
00863 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,x,y,color,"l")));
00864 if( ampl>0 ) {
00865 xprop[4]=xprop[0];
00866 yprop[4]=yprop[0];
00867 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,xprop,yprop,color,"f")));
00868 }
00869 }
00870 }
00871 break;
00872
00873 case RZ:
00874 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,z,r,color,"f")));
00875 break;
00876
00877 case EPE:
00878 {
00879 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
00880
00881 if( ampl>0 ) {
00882 etaprop[4]=etaprop[0];
00883 phiprop[4]=phiprop[0];
00884 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
00885 }
00886 }
00887 break;
00888 case EPH:
00889 {
00890 if(layer == PFLayer::ECAL_BARREL ||
00891 layer == PFLayer::HCAL_BARREL1) {
00892 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
00893
00894 if( ampl>0 ) {
00895 etaprop[4]=etaprop[0];
00896 phiprop[4]=phiprop[0];
00897 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
00898 }
00899 }
00900 }
00901 break;
00902
00903 case EHO:
00904 {
00905
00906 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,eta,phi,color,"l")));
00907 if(layer == PFLayer::HCAL_BARREL2) {
00908 if( ampl>0 ) {
00909 etaprop[4]=etaprop[0];
00910 phiprop[4]=phiprop[0];
00911 graphicMap_.insert(pair<int,GPFBase *> (ident,new GPFRecHit(this, viewType,ident,&rh,npoints,etaprop,phiprop,color,"f")));
00912 }
00913 }
00914 }
00915 break;
00916
00917
00918
00919 default: break;
00920 }
00921
00922 }
00923 }
00924
00925
00926 void DisplayManager::createGTrack( reco::PFRecTrack &tr,
00927 const std::vector<reco::PFTrajectoryPoint>& points,
00928 int ident,double pt,double phi0, double sign, bool displayInitial,
00929 int linestyle,int kfgsfbrem)
00930 {
00931
00932
00933
00934
00935 for (int viewType=0;viewType<NViews;++viewType) {
00936 if (!drawHO_ && viewType==EHO) continue;
00937
00938 vector<double> xPos;
00939 xPos.reserve( points.size() );
00940 vector<double> yPos;
00941 yPos.reserve( points.size() );
00942
00943 for(unsigned i=0; i<points.size(); i++) {
00944 if( !points[i].isValid() ) continue;
00945
00946 const math::XYZPoint& xyzPos = points[i].position();
00947
00948
00949
00950 double eta = xyzPos.Eta();
00951 double phi = xyzPos.Phi();
00952
00953 if( !displayInitial &&
00954 points[i].layer() == reco::PFTrajectoryPoint::ClosestApproach ) {
00955 const math::XYZTLorentzVector& mom = points[i].momentum();
00956 eta = mom.Eta();
00957 phi = mom.Phi();
00958 }
00959
00960
00961
00962
00963
00964 switch(viewType) {
00965 case XY:
00966 xPos.push_back(xyzPos.X());
00967 yPos.push_back(xyzPos.Y());
00968 break;
00969 case RZ:
00970 xPos.push_back(xyzPos.Z());
00971 yPos.push_back(sign*xyzPos.Rho());
00972 break;
00973 case EPE:
00974 case EPH:
00975 case EHO:
00976 xPos.push_back( eta );
00977 yPos.push_back( phi );
00978 break;
00979 }
00980 }
00982
00983
00984
00985 GPFTrack *gt=0;
00986 if(kfgsfbrem==0) {
00987 gt = new GPFTrack(this,
00988 viewType,ident,
00989 &tr,
00990 xPos.size(),&xPos[0],&yPos[0],pt,
00991 trackPatternM_,trackPatternL_,"pl");
00992 }
00993 else if (kfgsfbrem==1) {
00994
00995 gt = new GPFTrack(this,
00996 viewType,ident,
00997 &tr,
00998 xPos.size(),&xPos[0],&yPos[0],pt,
00999 gsfPatternM_,gsfPatternL_,"pl");
01000 }
01001 else if (kfgsfbrem==2) {
01002
01003
01004 gt = new GPFTrack(this,
01005 viewType,ident,
01006 &tr,
01007 xPos.size(),&xPos[0],&yPos[0],pt,
01008 bremPatternM_,bremPatternL_,"pl");
01009 }
01010 graphicMap_.insert(pair<int,GPFBase *> (ident, gt));
01011 }
01012 }
01013
01014
01015 void DisplayManager::displayEvent(int run, int lumi, int event) {
01016 reset();
01017 em_->processEvent(run, lumi, event);
01018 eventNumber_= em_->eventNumber();
01019 loadGraphicObjects();
01020 isGraphicLoaded_= true;
01021 displayAll();
01022 }
01023
01024
01025
01026 void DisplayManager::display(int ientry)
01027 {
01028 if (ientry<0 || ientry>maxEvents_) {
01029 std::cerr<<"DisplayManager::no event matching criteria"<<std::endl;
01030 return;
01031 }
01032 reset();
01033 em_->processEntry(ientry);
01034 eventNumber_= em_->eventNumber();
01035 loadGraphicObjects();
01036 isGraphicLoaded_= true;
01037
01038 displayAll();
01039
01040 }
01041
01042 void DisplayManager::displayAll(bool noRedraw)
01043 {
01044
01045 if (!isGraphicLoaded_) {
01046 std::cout<<" no Graphic Objects to draw"<<std::endl;
01047 return;
01048 }
01049 if (noRedraw) {
01050 for (int viewType=0;viewType<NViews;++viewType) {
01051 if (!drawHO_ && viewType==EHO) continue;
01052 displayView_[viewType]->cd();
01053 gPad->Clear();
01054 }
01055
01056 displayCanvas();
01057 }
01058
01059 std::multimap<int,GPFBase *>::iterator p;
01060
01061 for (p=graphicMap_.begin();p!=graphicMap_.end();p++) {
01062 int ident=p->first;
01063 int type=ident >> shiftId_;
01064 int view = p->second->getView();
01065
01066 if (!drawHO_ && (view ==EHO || type==CLUSTERHOID || type==RECHITHOID)) continue;
01067
01068 switch (type) {
01069 case CLUSTERECALID:
01070 case CLUSTERHCALID:
01071 case CLUSTERHOID:
01072 case CLUSTERHFEMID:
01073 case CLUSTERHFHADID:
01074 case CLUSTERPSID:
01075 case CLUSTERIBID:
01076 {
01077
01078 if (drawClus_)
01079 if (p->second->getEnergy() > clusEnMin_) {
01080 displayView_[view]->cd();
01081 p->second->draw();
01082 }
01083 }
01084 break;
01085 case RECHITECALID:
01086 case RECHITHCALID:
01087 case RECHITHOID:
01088 case RECHITHFEMID:
01089 case RECHITHFHADID:
01090 case RECHITPSID:
01091 {
01092 if (!noRedraw) break;
01093 if (drawHits_)
01094 if(p->second->getEnergy() > hitEnMin_) {
01095 displayView_[view]->cd();
01096 p->second->draw();
01097 }
01098 break;
01099 }
01100 case RECTRACKID:
01101 {
01102 if (drawTracks_)
01103 if (p->second->getPt() > trackPtMin_) {
01104 displayView_[view]->cd();
01105 p->second->draw();
01106 }
01107 }
01108 break;
01109 case GSFRECTRACKID:
01110 {
01111 if (drawGsfTracks_)
01112 if (p->second->getPt() > gsfPtMin_) {
01113 displayView_[view]->cd();
01114 p->second->draw();
01115 }
01116 }
01117 break;
01118 case BREMID:
01119 {
01120 if (drawBrems_)
01121 {
01122 displayView_[view]->cd();
01123 p->second->draw();
01124 }
01125 }
01126 break;
01127 case SIMPARTICLEID:
01128 {
01129 if (drawParticles_)
01130 if (p->second->getPt() > particlePtMin_) {
01131 displayView_[view]->cd();
01132 p->second->draw();
01133 }
01134 }
01135 break;
01136 case GENPARTICLEID:
01137 {
01138 if (drawGenParticles_)
01139 if (p->second->getPt() > genParticlePtMin_)
01140 if (view == EPH || view ==EPE || view ==EHO) {
01141 displayView_[view]->cd();
01142 p->second->draw();
01143 }
01144 }
01145 break;
01146 default : std::cout<<"DisplayManager::displayAll()-- unknown object "<<std::endl;
01147 }
01148 }
01149
01150 for (int i=0;i<NViews;i++) {
01151 if (!drawHO_ && i==EHO) continue;
01152 displayView_[i]->cd();
01153 gPad->Modified();
01154 displayView_[i]->Update();
01155 }
01156 }
01157
01158 void DisplayManager::drawWithNewGraphicAttributes()
01159 {
01160 std::multimap<int,GPFBase *>::iterator p;
01161
01162 for (p=graphicMap_.begin();p!=graphicMap_.end();p++) {
01163 int ident=p->first;
01164 int type=ident >> shiftId_;
01165 if (!drawHO_ && (type==CLUSTERHOID)) continue;
01166 switch (type) {
01167 case CLUSTERECALID: case CLUSTERHCALID: case CLUSTERHOID: case CLUSTERPSID: case CLUSTERIBID:
01168 {
01169 p->second->setNewStyle();
01170 p->second->setNewSize();
01171 p->second->setColor();
01172 }
01173 break;
01174 case RECTRACKID:
01175 {
01176 p->second->setColor();
01177 p->second->setNewStyle();
01178 p->second->setNewSize();
01179 }
01180 break;
01181 case SIMPARTICLEID:
01182 {
01183 }
01184 break;
01185 default : break;
01186 }
01187 }
01188 displayAll(false);
01189 }
01190
01191 void DisplayManager::displayCanvas()
01192 {
01193 double zLow = -500.;
01194 double zUp = +500.;
01195 double rUp = +400.;
01196 if (!drawHO_) rUp=300.0;
01197 double etarng=(drawHO_) ? 1.19 : 1.39;
01198 double ratio =(drawHO_) ? 1.15 : 0.90;
01199 double scal = (drawHO_) ? 1.00 : 0.85;
01200
01201
01202
01203
01204
01205
01206
01207 for (int viewType=0;viewType<NViews;++viewType) {
01208 if (!drawHO_ && viewType==EHO) continue;
01209 displayView_[viewType]->cd();
01210 displayHist_[viewType]->Draw();
01211 switch(viewType) {
01212 case XY:
01213 frontFaceECALXY_.Draw();
01214 frontFaceHCALXY_.Draw();
01215 frontFaceHOXY_.Draw();
01216 break;
01217 case RZ:
01218 {
01219 TLine l;
01220 l.SetLineColor(1);
01221 l.SetLineStyle(3);
01222 TLatex etaLeg;
01223 etaLeg.SetTextSize( (drawHO_) ? 0.03 : 0.02);
01224 float etaMin = -3.;
01225 float etaMax = +3.;
01226 float etaBin = 0.2;
01227 int nEtas = int((etaMax - etaMin)/0.2) + 1;
01228 for (int iEta = 0; iEta <= nEtas; iEta++) {
01229 float eta = etaMin + iEta*etaBin;
01230 float r = ratio*rUp;
01231 TVector3 etaImpact;
01232 etaImpact.SetPtEtaPhi(r, eta, 0.);
01233 etaLeg.SetTextAlign(21);
01234 if (eta <= -etarng) {
01235 etaImpact.SetXYZ(0.,scal*zLow*tan(etaImpact.Theta()),scal*zLow);
01236 etaLeg.SetTextAlign(31);
01237 } else if (eta >= etarng) {
01238 etaImpact.SetXYZ(0.,scal*zUp*tan(etaImpact.Theta()),scal*zUp);
01239 etaLeg.SetTextAlign(11);
01240 }
01241 if (drawHO_) {
01242 if (fabs(eta)<1.29) {
01243 etaLeg.SetTextSize(0.030);
01244 } else {
01245 etaLeg.SetTextSize(0.022);
01246 }
01247 }
01248 l.DrawLine(0., 0., etaImpact.Z(), etaImpact.Perp());
01249 etaLeg.DrawLatex(1.0*etaImpact.Z(), etaImpact.Perp(), Form("%2.1f", eta));
01250 }
01251 frontFaceECALRZ_.Draw();
01252 }
01253 break;
01254 default: break;
01255 }
01256 }
01257 }
01258
01259 void DisplayManager::displayNext()
01260 {
01261 int eventNumber_=em_->eventNumber();
01262 display(++eventNumber_);
01263 }
01264
01265 void DisplayManager::displayNextInteresting(int ientry)
01266 {
01267 bool ok=false;
01268 while (!ok && ientry<em_->ev_->size() ) {
01269 ok = em_->processEntry(ientry);
01270 ientry++;
01271 }
01272 eventNumber_ = em_->eventNumber();
01273 if (ok) {
01274 reset();
01275 loadGraphicObjects();
01276 isGraphicLoaded_= true;
01277 displayAll();
01278 }
01279 else
01280 std::cerr<<"DisplayManager::dislayNextInteresting : no event matching criteria"<<std::endl;
01281 }
01282
01283 void DisplayManager::displayPrevious()
01284 {
01285 int eventNumber_=em_->eventNumber();
01286 display(--eventNumber_);
01287 }
01288
01289 void DisplayManager::rubOutGPFBlock()
01290 {
01291 int size = selectedGObj_.size();
01292 bool toInitial=true;
01293 int color=0;
01294 for (int i=0;i<size;i++)
01295 drawGObject(selectedGObj_[i],color,toInitial);
01296 }
01297
01298 void DisplayManager::displayPFBlock(int blockNb)
01299 {
01300 rubOutGPFBlock();
01301 selectedGObj_.clear();
01302 if (!drawPFBlocks_) return;
01303 int color=1;
01304 multimap<int,pair <int,int > >::const_iterator p;
01305 p= blockIdentsMap_.find(blockNb);
01306 if (p !=blockIdentsMap_.end()) {
01307 do {
01308 int ident=(p->second).first;
01309 drawGObject(ident,color,false);
01310 p++;
01311 } while (p!=blockIdentsMap_.upper_bound(blockNb));
01312 }
01313 else
01314 cout<<"DisplayManager::displayPFBlock :not found"<<endl;
01315 }
01316
01317 void DisplayManager::drawGObject(int ident,int color,bool toInitial)
01318 {
01319 typedef std::multimap<int,GPFBase *>::const_iterator iter;
01320 iter p;
01321 std::pair<iter, iter > result = graphicMap_.equal_range(ident);
01322 if(result.first == graphicMap_.end()) {
01323 std::cout<<"pas d'objet avec cet ident: "<<ident<<std::flush<<std::endl;
01324 return;
01325 }
01326 p=result.first;
01327 while (p != result.second) {
01328 int view=p->second->getView();
01329 if (!drawHO_ && view ==EHO) continue;
01330 displayView_[view]->cd();
01331 if (toInitial) p->second->setInitialColor();
01332 else p->second->setColor(color);
01333 p->second->draw();
01334 gPad->Modified();
01335
01336 if (!toInitial) selectedGObj_.push_back(ident);
01337 p++;
01338 }
01339 }
01340
01341 void DisplayManager::enableDrawPFBlock(bool state)
01342 {
01343 drawPFBlocks_=state;
01344 }
01345
01346 void DisplayManager::enableDrawBrem(bool state)
01347 {
01348 drawBrems_=state;
01349 }
01350
01351 void DisplayManager::findAndDraw(int ident)
01352 {
01353 int type=ident >> shiftId_;
01354 if (drawHO_ || type!=RECHITHOID) {
01355 int color=1;
01356 if (type>15) {
01357 std ::cout<<"DisplayManager::findAndDraw :object Type unknown"<<std::endl;
01358 return;
01359 }
01360 if (drawPFBlocks_==0 ||
01361 type==RECHITECALID || type==RECHITHCALID || type==RECHITHOID ||
01362 type==RECHITHFEMID || type==RECHITHFHADID ||
01363 type==RECHITPSID || type==SIMPARTICLEID) {
01364 rubOutGPFBlock();
01365 selectedGObj_.clear();
01366 bool toInitial=false;
01367 drawGObject(ident,color,toInitial);
01368 if (type<HITTYPES) {
01369
01370 displayAll(false);
01371
01372 }
01373 }
01374 updateDisplay();
01375 }
01376 }
01377
01378 void DisplayManager::findBlock(int ident)
01379 {
01380 int blockNb=-1;
01381 int elemNb=-1;
01382 multimap<int, pair <int,int > >::const_iterator p;
01383 for (p=blockIdentsMap_.begin();p!=blockIdentsMap_.end();p++) {
01384 int id=(p->second).first;
01385 if (id == ident) {
01386 blockNb=p->first;
01387 elemNb=(p->second).second;
01388 break;
01389 }
01390 }
01391 if (blockNb > -1) {
01392 std::cout<<"this object is element "<<elemNb<<" of PFblock nb "<<blockNb<<std::endl;
01393 assert( blockNb < static_cast<int>(em_->blocks().size()) );
01394 const reco::PFBlock& block = em_->blocks()[blockNb];
01395 std::cout<<block<<std::endl;
01396 displayPFBlock(blockNb);
01397 }
01398 updateDisplay();
01399 }
01400
01401 bool DisplayManager::findBadBremsId(int ident)
01402 {
01403 for (unsigned i=0;i<badBremsId_.size();i++)
01404 if (badBremsId_[i]==ident) return true;
01405 return false;
01406 }
01407
01408
01409 void DisplayManager::updateDisplay() {
01410 for(unsigned i=0; i<displayView_.size(); i++) {
01411 if (!drawHO_ && i==EHO) continue;
01412 TPad* p = displayView_[i];
01413 assert( p );
01414 p->Modified();
01415 p->Update();
01416 }
01417 }
01418
01419
01420
01421 double DisplayManager::getMaxE(int layer) const
01422 {
01423
01424 double maxe = -9999;
01425
01426
01427
01428 const reco::PFRecHitCollection* vec = 0;
01429 switch(layer) {
01430 case PFLayer::ECAL_ENDCAP:
01431 case PFLayer::ECAL_BARREL:
01432 vec = &(em_->rechitsECAL_);
01433 break;
01434 case PFLayer::HCAL_ENDCAP:
01435 case PFLayer::HCAL_BARREL1:
01436
01437 vec = &(em_->rechitsHCAL_);
01438 break;
01439 case PFLayer::HCAL_BARREL2:
01440 vec = &(em_->rechitsHO_);
01441 break;
01442
01443 case PFLayer::HF_EM:
01444 vec = &(em_->rechitsHFEM_);
01445 break;
01446 case PFLayer::HF_HAD:
01447 vec = &(em_->rechitsHFHAD_);
01448 break;
01449 case PFLayer::PS1:
01450 case PFLayer::PS2:
01451 vec = &(em_->rechitsPS_);
01452 break;
01453 default:
01454 cerr<<"DisplayManager::getMaxE : manage other layers"<<endl;
01455 return maxe;
01456 }
01457
01458 for( unsigned i=0; i<vec->size(); i++) {
01459 if( (*vec)[i].layer() != layer ) continue;
01460 if( (*vec)[i].energy() > maxe)
01461 maxe = (*vec)[i].energy();
01462 }
01463
01464 return maxe;
01465 }
01466
01467 double DisplayManager::getMaxEEcal() {
01468
01469 if( maxERecHitEcal_<0 ) {
01470 double maxeec = getMaxE( PFLayer::ECAL_ENDCAP );
01471 double maxeb = getMaxE( PFLayer::ECAL_BARREL );
01472 double maxehf = getMaxE( PFLayer::HF_EM );
01473 maxERecHitEcal_ = maxeec>maxeb ? maxeec:maxeb;
01474 maxERecHitEcal_ = maxERecHitEcal_>maxehf ? maxERecHitEcal_:maxehf;
01475
01476 }
01477 return maxERecHitEcal_;
01478 }
01479
01480 double DisplayManager::getMaxEHcal() {
01481
01482 if(maxERecHitHcal_ < 0) {
01483 double maxehf = getMaxE( PFLayer::HF_HAD );
01484 double maxeec = getMaxE( PFLayer::HCAL_ENDCAP );
01485 double maxeb = getMaxE( PFLayer::HCAL_BARREL1 );
01486 maxERecHitHcal_ = maxeec>maxeb ? maxeec:maxeb;
01487 maxERecHitHcal_ = maxERecHitHcal_>maxehf ? maxERecHitHcal_:maxehf;
01488 }
01489 return maxERecHitHcal_;
01490 }
01491
01492
01493 double DisplayManager::getMaxEHo() {
01494
01495 if(maxERecHitHo_ < 0) {
01496 maxERecHitHo_ = getMaxE( PFLayer::HCAL_BARREL2 );
01497 }
01498 return maxERecHitHo_;
01499 }
01500
01501
01502
01503 void DisplayManager::loadGGenParticles()
01504 {
01505
01506 const HepMC::GenEvent* myGenEvent = em_->MCTruth_.GetEvent();
01507 if(!myGenEvent) return;
01508 for ( HepMC::GenEvent::particle_const_iterator piter = myGenEvent->particles_begin();
01509 piter != myGenEvent->particles_end();
01510 ++piter ) {
01511 HepMC::GenParticle* p = *piter;
01512
01513 createGGenParticle(p);
01514 }
01515 }
01516
01517 void DisplayManager::createGGenParticle(HepMC::GenParticle* p)
01518 {
01519
01520 if ( !p->production_vertex() && p->pdg_id() == 2212 ) return;
01521
01522 int partId = p->pdg_id();
01523
01524 std::string name;
01525 std::string latexStringName;
01526
01527 name = em_->getGenParticleName(partId,latexStringName);
01528 int barcode = p->barcode();
01529 int genPartId=(GENPARTICLEID<<shiftId_) | barcode;
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539 math::XYZTLorentzVector momentum1(p->momentum().px(),
01540 p->momentum().py(),
01541 p->momentum().pz(),
01542 p->momentum().e());
01543
01544 double eta = momentum1.eta();
01545 if ( eta > +10. ) eta = +10.;
01546 if ( eta < -10. ) eta = -10.;
01547
01548 double phi = momentum1.phi();
01549
01550 double pt = momentum1.pt();
01551 double e = momentum1.e();
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562 const HepMC::GenParticle* mother = 0;
01563 if(p->production_vertex() &&
01564 p->production_vertex()->particles_in_size() ) {
01565 mother =
01566 *(p->production_vertex()->particles_in_const_begin());
01567 }
01568
01569
01570
01571
01572
01573 int modnViews = (drawHO_) ? NViews : NViews-1;
01574 if ( mother ) {
01575 int barcodeMother = mother->barcode();
01576 math::XYZTLorentzVector momentumMother(mother->momentum().px(),
01577 mother->momentum().py(),
01578 mother->momentum().pz(),
01579 mother->momentum().e());
01580 double etaMother = momentumMother.eta();
01581 if ( etaMother > +10. ) etaMother = +10.;
01582 if ( etaMother < -10. ) etaMother = -10.;
01583 double phiMother = momentumMother.phi();
01584
01585
01586 double x[2],y[2];
01587
01588
01589 x[0]=etaMother;x[1]=eta;
01590 y[0]=phiMother;y[1]=phi;
01591
01592 for (int view = 2; view< modnViews; view++) {
01593 GPFGenParticle* gp = new GPFGenParticle(this,
01594 view, genPartId,
01595 x, y,
01596 e,pt,barcode,barcodeMother,
01597 genPartPattern_,
01598 name,latexStringName);
01599 graphicMap_.insert(pair<int,GPFBase *> (genPartId, gp));
01600 }
01601 }
01602 else {
01603 for (int view = 2; view< modnViews; view++) {
01604 GPFGenParticle* gp = new GPFGenParticle(this,
01605 view, genPartId,
01606 eta, phi,
01607 e,pt,barcode,
01608 genPartPattern_,
01609 name, latexStringName);
01610 graphicMap_.insert(pair<int,GPFBase *> (genPartId, gp));
01611 }
01612 }
01613 }
01614
01615 void DisplayManager::loadGClusters()
01616 {
01617 double phi0=0;
01618
01619 for(unsigned i=0; i<em_->clustersECAL_->size(); i++){
01620
01621 int clusId=(CLUSTERECALID<<shiftId_) | i;
01622 createGCluster( (*(em_->clustersECAL_))[i],clusId, phi0);
01623 }
01624 for(unsigned i=0; i<em_->clustersHCAL_->size(); i++) {
01625
01626 int clusId=(CLUSTERHCALID<<shiftId_) | i;
01627 createGCluster( (*(em_->clustersHCAL_))[i],clusId, phi0);
01628 }
01629
01630 if (drawHO_) {
01631 for(unsigned i=0; i<em_->clustersHO_->size(); i++) {
01632
01633 int clusId=(CLUSTERHOID<<shiftId_) | i;
01634 createGCluster( (*(em_->clustersHO_))[i],clusId, phi0);
01635 }
01636 }
01637
01638 for(unsigned i=0; i<em_->clustersHFEM_->size(); i++) {
01639
01640 int clusId=(CLUSTERHFEMID<<shiftId_) | i;
01641 createGCluster( (*(em_->clustersHFEM_))[i],clusId, phi0);
01642 }
01643 for(unsigned i=0; i<em_->clustersHFHAD_->size(); i++) {
01644
01645 int clusId=(CLUSTERHFHADID<<shiftId_) | i;
01646 createGCluster( (*(em_->clustersHFHAD_))[i],clusId, phi0);
01647 }
01648 for(unsigned i=0; i<em_->clustersPS_->size(); i++){
01649
01650 int clusId=(CLUSTERPSID<<shiftId_) | i;
01651 createGCluster( (*(em_->clustersPS_))[i],clusId,phi0);
01652 }
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665 }
01666
01667 void DisplayManager::retrieveBadBrems()
01668 {
01669
01670
01671
01672 int size = em_->pfBlocks_->size();
01673 for (int ibl=0;ibl<size;ibl++) {
01674 edm::OwnVector< reco::PFBlockElement >::const_iterator iter;
01675 for( iter =((*(em_->pfBlocks_))[ibl].elements()).begin();
01676 iter != ((*(em_->pfBlocks_))[ibl].elements()).end();iter++) {
01677 int ident=-1;
01678 reco::PFBlockElement::Type type = (*iter).type();
01679 if (type == reco::PFBlockElement::BREM) {
01680 std::multimap<double, unsigned> ecalElems;
01681
01682 (*(em_->pfBlocks_))[ibl].associatedElements( (*iter).index(),(*(em_->pfBlocks_))[ibl].linkData(),
01683 ecalElems ,
01684 reco::PFBlockElement::ECAL,
01685 reco::PFBlock::LINKTEST_ALL );
01686
01687
01688 if (ecalElems.size()==0) {
01689
01690 const reco::PFBlockElementBrem * Brem = dynamic_cast<const reco::PFBlockElementBrem*>(&(*iter));
01691 reco::GsfPFRecTrackRef trackref = Brem->GsftrackRefPF();
01692 unsigned ind=trackref.key()*40+Brem->indTrajPoint();
01693 ident = (BREMID << shiftId_ ) | ind ;
01694 badBremsId_.push_back(ident);
01695 }
01696 }
01697 }
01698 }
01699 }
01700
01701 void DisplayManager::loadGPFBlocks()
01702 {
01703 int size = em_->pfBlocks_->size();
01704 for (int ibl=0;ibl<size;ibl++) {
01705
01706
01707 edm::OwnVector< reco::PFBlockElement >::const_iterator iter;
01708 for( iter =((*(em_->pfBlocks_))[ibl].elements()).begin();
01709 iter != ((*(em_->pfBlocks_))[ibl].elements()).end();iter++) {
01710
01711
01712
01713
01714 int ident=-1;
01715
01716 reco::PFBlockElement::Type type = (*iter).type();
01717 if (!drawHO_ && type==reco::PFBlockElement::HO) continue;
01718 switch (type) {
01719 case reco::PFBlockElement::NONE :
01720 assert(0);
01721 break;
01722 case reco::PFBlockElement::TRACK:
01723 {
01724 reco::PFRecTrackRef trackref =(*iter).trackRefPF();
01725 assert( !trackref.isNull() );
01726
01727 ident=(RECTRACKID <<shiftId_) | trackref.key();
01728 }
01729 break;
01730 case reco::PFBlockElement::PS1:
01731 {
01732 reco::PFClusterRef clusref=(*iter).clusterRef();
01733 assert( !clusref.isNull() );
01734
01735 ident=(CLUSTERPSID <<shiftId_) |clusref.key();
01736 }
01737 break;
01738 case reco::PFBlockElement::PS2:
01739 {
01740 reco::PFClusterRef clusref=(*iter).clusterRef();
01741 assert( !clusref.isNull() );
01742
01743 ident=(CLUSTERPSID <<shiftId_) |clusref.key();
01744 }
01745 break;
01746 case reco::PFBlockElement::ECAL:
01747 {
01748 reco::PFClusterRef clusref=(*iter).clusterRef();
01749 assert( !clusref.isNull() );
01750
01751 ident=(CLUSTERECALID <<shiftId_) |clusref.key();
01752 }
01753 break;
01754 case reco::PFBlockElement::HCAL:
01755 {
01756 reco::PFClusterRef clusref=(*iter).clusterRef();
01757 assert( !clusref.isNull() );
01758
01759 ident=(CLUSTERHCALID <<shiftId_) |clusref.key();
01760 }
01761 break;
01762
01763 case reco::PFBlockElement::HO:
01764 {
01765 reco::PFClusterRef clusref=(*iter).clusterRef();
01766 assert( !clusref.isNull() );
01767
01768 ident=(CLUSTERHOID <<shiftId_) |clusref.key();
01769 }
01770 break;
01771
01772 case reco::PFBlockElement::HFEM:
01773 {
01774 reco::PFClusterRef clusref=(*iter).clusterRef();
01775 assert( !clusref.isNull() );
01776
01777 ident=(CLUSTERHFEMID <<shiftId_) |clusref.key();
01778 }
01779 break;
01780 case reco::PFBlockElement::HFHAD:
01781 {
01782 reco::PFClusterRef clusref=(*iter).clusterRef();
01783 assert( !clusref.isNull() );
01784
01785 ident=(CLUSTERHFHADID <<shiftId_) |clusref.key();
01786 }
01787 break;
01788 case reco::PFBlockElement::GSF:
01789 {
01790 const reco::PFBlockElementGsfTrack * GsfEl =
01791 dynamic_cast<const reco::PFBlockElementGsfTrack*>(&(*iter));
01792
01793 reco::GsfPFRecTrackRef trackref=GsfEl->GsftrackRefPF();
01794 assert( !trackref.isNull() );
01795 ident=(GSFRECTRACKID << shiftId_) | trackref.key();
01796 }
01797 break;
01798 case reco::PFBlockElement::BREM:
01799 {
01800 const reco::PFBlockElementBrem * Brem = dynamic_cast<const reco::PFBlockElementBrem*>(&(*iter));
01801 reco::GsfPFRecTrackRef trackref = Brem->GsftrackRefPF();
01802 unsigned index=trackref.key()*40+Brem->indTrajPoint();
01803 ident = (BREMID << shiftId_ ) | index ;
01804 if (findBadBremsId(ident)) ident=-1;
01805 }
01806 break;
01807
01808 case reco::PFBlockElement::SC:
01809 {
01810 const reco::PFBlockElementSuperCluster * sc = dynamic_cast<const reco::PFBlockElementSuperCluster*>(&(*iter));
01811 reco::SuperClusterRef scref = sc->superClusterRef();
01812 assert( !scref.isNull() );
01813 ident = (CLUSTERIBID << shiftId_ ) | scref.key();
01814 }
01815 break;
01816
01817 default:
01818 std::cout<<"unknown PFBlock element of type "<<type<<std::endl;
01819 break;
01820 }
01821 pair <int, int> idElem;
01822 idElem.first=ident;
01823 idElem.second=(*iter).index();
01824 if (ident != -1) blockIdentsMap_.insert(pair<int,pair <int,int> > (ibl,idElem));
01825 }
01826 }
01827
01828 }
01829
01830 void DisplayManager::loadGraphicObjects()
01831 {
01832 loadGClusters();
01833 loadGRecHits();
01834 loadGRecTracks();
01835 loadGGsfRecTracks();
01836 loadGSimParticles();
01837 loadGPFBlocks();
01838 loadGGenParticles();
01839 }
01840
01841 void DisplayManager::loadGRecHits()
01842 {
01843 double phi0=0;
01844
01845 double maxee = getMaxEEcal();
01846 double maxeh = getMaxEHcal();
01847 double maxe = maxee>maxeh ? maxee : maxeh;
01848
01849 int color = TColor::GetColor(210,210,210);
01850 int seedcolor = TColor::GetColor(145,145,145);
01851 int specialcolor = TColor::GetColor(255,140,0);
01852
01853 for(unsigned i=0; i<em_->rechitsECAL_.size(); i++) {
01854 int rhcolor = color;
01855 if( unsigned col = em_->clusterAlgoECAL_.color(i) ) {
01856 switch(col) {
01857 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01858 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01859 default:
01860 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01861 }
01862 }
01863
01864 int recHitId=i;
01865 createGRecHit(em_->rechitsECAL_[i],recHitId, maxe, phi0, rhcolor);
01866 }
01867
01868 for(unsigned i=0; i<em_->rechitsHCAL_.size(); i++) {
01869 int rhcolor = color;
01870 if(unsigned col = em_->clusterAlgoHCAL_.color(i) ) {
01871 switch(col) {
01872 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01873 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01874 default:
01875 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01876 }
01877 }
01878
01879 int recHitId=(RECHITHCALID <<shiftId_) | i;
01880 createGRecHit(em_->rechitsHCAL_[i],recHitId, maxe, phi0, rhcolor);
01881 }
01882
01883 if (drawHO_) {
01884 for(unsigned i=0; i<em_->rechitsHO_.size(); i++) {
01885 int rhcolor = color;
01886 if(unsigned col = em_->clusterAlgoHO_.color(i) ) {
01887 switch(col) {
01888 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01889 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01890 default:
01891 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01892 }
01893 }
01894
01895 int recHitId=(RECHITHOID <<shiftId_) | i;
01896 createGRecHit(em_->rechitsHO_[i],recHitId, 2*maxe, phi0, rhcolor);
01897 }
01898 }
01899
01900 for(unsigned i=0; i<em_->rechitsHFEM_.size(); i++) {
01901 int rhcolor = color;
01902 if(unsigned col = em_->clusterAlgoHFEM_.color(i) ) {
01903 switch(col) {
01904 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01905 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01906 default:
01907 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01908 }
01909 }
01910
01911 int recHitId=(RECHITHFEMID <<shiftId_) | i;
01912 createGRecHit(em_->rechitsHFEM_[i],recHitId, maxe, phi0, rhcolor);
01913 }
01914
01915 for(unsigned i=0; i<em_->rechitsHFHAD_.size(); i++) {
01916 int rhcolor = color;
01917 if(unsigned col = em_->clusterAlgoHFHAD_.color(i) ) {
01918 switch(col) {
01919 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01920 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01921 default:
01922 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01923 }
01924 }
01925
01926 int recHitId=(RECHITHFHADID <<shiftId_) | i;
01927 createGRecHit(em_->rechitsHFHAD_[i],recHitId, maxe, phi0, rhcolor);
01928 }
01929
01930 for(unsigned i=0; i<em_->rechitsPS_.size(); i++) {
01931 int rhcolor = color;
01932 if( unsigned col = em_->clusterAlgoPS_.color(i) ) {
01933 switch(col) {
01934 case PFClusterAlgo::SEED: rhcolor = seedcolor; break;
01935 case PFClusterAlgo::SPECIAL: rhcolor = specialcolor; break;
01936 default:
01937 cerr<<"DisplayManager::loadGRecHits: unknown color"<<endl;
01938 }
01939 }
01940
01941 int recHitId=(RECHITPSID<<shiftId_) | i;
01942
01943 createGRecHit(em_->rechitsPS_[i],recHitId, maxe, phi0, rhcolor);
01944 }
01945 }
01946
01947 void DisplayManager::loadGRecTracks()
01948 {
01949 double phi0=0;
01950
01951 int ind=-1;
01952 std::vector<reco::PFRecTrack>::iterator itRecTrack;
01953 for (itRecTrack = em_->recTracks_.begin(); itRecTrack != em_->recTracks_.end();itRecTrack++) {
01954 double sign = 1.;
01955 const reco::PFTrajectoryPoint& tpinitial
01956 = itRecTrack->extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach);
01957 double pt = tpinitial.momentum().Pt();
01958
01959
01960 const reco::PFTrajectoryPoint& tpatecal
01961 = itRecTrack->trajectoryPoint(itRecTrack->nTrajectoryMeasurements() +
01962 reco::PFTrajectoryPoint::ECALEntrance );
01963
01964 if ( cos(phi0 - tpatecal.momentum().Phi()) < 0.)
01965 sign = -1.;
01966
01967 const std::vector<reco::PFTrajectoryPoint>& points =
01968 itRecTrack->trajectoryPoints();
01969
01970 int linestyle = itRecTrack->algoType();
01971 ind++;
01972
01973 int recTrackId=(RECTRACKID <<shiftId_) | ind;
01974
01975 createGTrack(*itRecTrack,points,recTrackId, pt, phi0, sign, false,linestyle);
01976 }
01977 }
01978
01979
01980 void DisplayManager::loadGGsfRecTracks()
01981 {
01982 double phi0=0;
01983
01984 int ind=-1;
01985 int indbrem=-1;
01986
01987
01988 retrieveBadBrems();
01989
01990 std::vector<reco::GsfPFRecTrack>::iterator itRecTrack;
01991 for (itRecTrack = em_->gsfrecTracks_.begin(); itRecTrack != em_->gsfrecTracks_.end();itRecTrack++) {
01992 double sign = 1.;
01993 const reco::PFTrajectoryPoint& tpinitial
01994 = itRecTrack->extrapolatedPoint(reco::PFTrajectoryPoint::ClosestApproach);
01995 double pt = tpinitial.momentum().Pt();
01996
01997
01998 const reco::PFTrajectoryPoint& tpatecal
01999 = itRecTrack->trajectoryPoint(itRecTrack->nTrajectoryMeasurements() +
02000 reco::PFTrajectoryPoint::ECALEntrance );
02001
02002 if ( cos(phi0 - tpatecal.momentum().Phi()) < 0.)
02003 sign = -1.;
02004
02005 const std::vector<reco::PFTrajectoryPoint>& points =
02006 itRecTrack->trajectoryPoints();
02007
02008 int linestyle = itRecTrack->algoType();
02009 ind++;
02010 int recTrackId=(GSFRECTRACKID <<shiftId_) | ind;
02011
02012 createGTrack(*itRecTrack,points,recTrackId, pt, phi0, sign, false,linestyle,1);
02013
02014
02015 std::vector<reco::PFBrem> brems=itRecTrack->PFRecBrem();
02016 unsigned nbrems=brems.size();
02017 for(unsigned ibrem=0;ibrem<nbrems;++ibrem)
02018 {
02019 unsigned indTrajPoint=brems[ibrem].indTrajPoint();
02020 if(indTrajPoint==99) continue;
02021 double signBrem = 1. ;
02022 int linestyleBrem = brems[ibrem].algoType();
02023 indbrem++;
02024
02025
02026 unsigned indexBrem= ind*40+brems[ibrem].indTrajPoint();
02027 int recTrackIdBrem=(BREMID << shiftId_ ) | indexBrem;
02028
02029
02030
02031 if (!findBadBremsId(recTrackIdBrem)) {
02032
02033
02034 std::vector<reco::PFTrajectoryPoint> pointsBrem;
02035
02036 pointsBrem.push_back(brems[ibrem].trajectoryPoints()[0]);
02037 pointsBrem.push_back(brems[ibrem].trajectoryPoints()[1]);
02038
02039
02040 pointsBrem.push_back(itRecTrack->trajectoryPoint(indTrajPoint));
02041
02042 unsigned ntp=brems[ibrem].trajectoryPoints().size();
02043 for(unsigned itp=2;itp<ntp;++itp)
02044 {
02045 pointsBrem.push_back(brems[ibrem].trajectoryPoints()[itp]);
02046 }
02047
02048 double deltaP=brems[ibrem].DeltaP();
02049 const reco::PFTrajectoryPoint& tpatecalbrem
02050 = brems[ibrem].trajectoryPoint(brems[ibrem].nTrajectoryMeasurements() +
02051 reco::PFTrajectoryPoint::ECALEntrance );
02052
02053 if ( cos(phi0 - tpatecalbrem.momentum().Phi()) < 0.)
02054 signBrem = -1.;
02055
02056 createGTrack(brems[ibrem],pointsBrem,recTrackIdBrem,deltaP,phi0,signBrem,false,linestyleBrem,2);
02057 }
02058 }
02059 }
02060
02061 }
02062
02063
02064 void DisplayManager::loadGSimParticles()
02065 {
02066 double phi0=0;
02067
02068 unsigned simParticlesVSize = em_->trueParticles_.size();
02069
02070 for(unsigned i=0; i<simParticlesVSize; i++) {
02071
02072 const reco::PFSimParticle& ptc = em_->trueParticles_[i];
02073
02074 const reco::PFTrajectoryPoint& tpinitial
02075 = ptc.extrapolatedPoint( reco::PFTrajectoryPoint::ClosestApproach );
02076
02077 double pt = tpinitial.momentum().Pt();
02078
02079
02080 double sign = 1.;
02081 const reco::PFTrajectoryPoint& tpFirst = ptc.trajectoryPoint(0);
02082 if ( tpFirst.position().X() < 0. )
02083 sign = -1.;
02084
02085
02086
02087
02088
02089
02090 const std::vector<reco::PFTrajectoryPoint>& points =
02091 ptc.trajectoryPoints();
02092
02093
02094 int indexMarker;
02095 switch( std::abs(ptc.pdgCode() ) ) {
02096 case 22: indexMarker=0; break;
02097 case 11: indexMarker=1; break;
02098 case 13: indexMarker=2; break;
02099 case 130:
02100 case 321: indexMarker=3; break;
02101 case 211: indexMarker=4; break;
02102 case 2212: indexMarker=5; break;
02103 case 2112: indexMarker=6; break;
02104 default: indexMarker=7; break;
02105 }
02106
02107 bool displayInitial=true;
02108 if( ptc.motherId() < 0 ) displayInitial=false;
02109 int partId=(SIMPARTICLEID << shiftId_) | i;
02110 createGPart(ptc, points,partId, pt, phi0, sign, displayInitial,indexMarker);
02111
02112
02113
02114 }
02115 }
02116
02117 void DisplayManager::lookForMaxRecHit(bool ecal)
02118 {
02119
02120 double maxe = -999;
02121 reco::PFRecHit* maxrh = 0;
02122
02123 reco::PFRecHitCollection* rechits = 0;
02124 if(ecal) rechits = &(em_->rechitsECAL_);
02125 else rechits = &(em_->rechitsHCAL_);
02126 assert(rechits);
02127
02128 for(unsigned i=0; i<(*rechits).size(); i++) {
02129
02130 double energy = (*rechits)[i].energy();
02131
02132 if(energy > maxe ) {
02133 maxe = energy;
02134 maxrh = &((*rechits)[i]);
02135 }
02136 }
02137
02138 if(!maxrh) return;
02139
02140
02141
02142
02143
02144
02145
02146 double phisize = -1;
02147 double etasize = -1;
02148 maxrh->size(phisize, etasize);
02149
02150 double etagate = zoomFactor_ * etasize;
02151 double phigate = zoomFactor_ * phisize;
02152
02153 double eta = maxrh->position().Eta();
02154 double phi = maxrh->position().Phi();
02155
02156 if(displayHist_[EPE]) {
02157 displayHist_[EPE]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02158 displayHist_[EPE]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02159 displayView_[EPE]->Modified();
02160 displayView_[EPE]->Update();
02161 }
02162
02163 if(displayHist_[EPH]) {
02164 displayHist_[EPH]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02165 displayHist_[EPH]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02166 displayView_[EPH]->Modified();
02167 displayView_[EPH]->Update();
02168 }
02169
02170 if(drawHO_ && displayHist_[EHO]) {
02171 displayHist_[EHO]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02172 displayHist_[EHO]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02173 displayView_[EHO]->Modified();
02174 displayView_[EHO]->Update();
02175 }
02176
02177
02178 }
02179
02180 void DisplayManager::lookForGenParticle(unsigned barcode) {
02181
02182 const HepMC::GenEvent* event = em_->MCTruth_.GetEvent();
02183 if(!event) {
02184 cerr<<"no GenEvent"<<endl;
02185 return;
02186 }
02187
02188 const HepMC::GenParticle* particle = event->barcode_to_particle(barcode);
02189 if(!particle) {
02190 cerr<<"no particle with barcode "<<barcode<<endl;
02191 return;
02192 }
02193
02194 math::XYZTLorentzVector momentum(particle->momentum().px(),
02195 particle->momentum().py(),
02196 particle->momentum().pz(),
02197 particle->momentum().e());
02198
02199 double eta = momentum.Eta();
02200 double phi = momentum.phi();
02201
02202 double phisize = 0.05;
02203 double etasize = 0.05;
02204
02205 double etagate = zoomFactor_ * etasize;
02206 double phigate = zoomFactor_ * phisize;
02207
02208 if(displayHist_[EPE]) {
02209 displayHist_[EPE]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02210 displayHist_[EPE]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02211 displayView_[EPE]->Modified();
02212 displayView_[EPE]->Update();
02213
02214 }
02215 if(displayHist_[EPH]) {
02216 displayHist_[EPH]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02217 displayHist_[EPH]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02218 displayView_[EPH]->Modified();
02219 displayView_[EPH]->Update();
02220 }
02221
02222 if(drawHO_ && displayHist_[EHO]) {
02223 displayHist_[EHO]->GetXaxis()->SetRangeUser(eta-etagate, eta+etagate);
02224 displayHist_[EHO]->GetYaxis()->SetRangeUser(phi-phigate, phi+phigate);
02225 displayView_[EHO]->Modified();
02226 displayView_[EHO]->Update();
02227 }
02228
02229 }
02230
02231 void DisplayManager::printDisplay(const char* sdirectory ) const
02232 {
02233 string directory = sdirectory;
02234 if( directory.empty() ) {
02235 directory = "Event_";
02236 }
02237 char num[10];
02238 sprintf(num,"%d", eventNumber_);
02239 directory += num;
02240
02241 string mkdir = "mkdir "; mkdir += directory;
02242 int code = system( mkdir.c_str() );
02243
02244 if( code ) {
02245 cerr<<"cannot create directory "<<directory<<endl;
02246 return;
02247 }
02248
02249 cout<<"Event display printed in directory "<<directory<<endl;
02250
02251 directory += "/";
02252
02253 for(unsigned iView=0; iView<displayView_.size(); iView++) {
02254 if( !displayView_[iView] ) continue;
02255
02256 string name = directory;
02257 name += displayView_[iView]->GetName();
02258
02259 cout<<displayView_[iView]->GetName()<<endl;
02260
02261 string eps = name; eps += ".eps";
02262 displayView_[iView]->SaveAs( eps.c_str() );
02263
02264 string png = name; png += ".png";
02265 displayView_[iView]->SaveAs( png.c_str() );
02266 }
02267
02268 string txt = directory;
02269 txt += "event.txt";
02270 ofstream out( txt.c_str() );
02271 if( !out )
02272 cerr<<"cannot open "<<txt<<endl;
02273 em_->print( out );
02274 }
02275
02276 void DisplayManager::reset()
02277 {
02278 maxERecHitEcal_=-1;
02279 maxERecHitHcal_=-1;
02280 maxERecHitHo_=-1;
02281 isGraphicLoaded_= false;
02282
02283 std::multimap<int,GPFBase *>::iterator p;
02284 for (p=graphicMap_.begin();p!=graphicMap_.end();p++)
02285 delete p->second;
02286 graphicMap_.clear();
02287
02288 blockIdentsMap_.clear();
02289 selectedGObj_.clear();
02290 badBremsId_.clear();
02291
02292
02293 }
02294
02295 void DisplayManager::unZoom()
02296 {
02297 for( unsigned i=0; i<displayHist_.size(); i++) {
02298
02299 if( ! displayHist_[i] ) continue;
02300 displayHist_[i]->GetXaxis()->UnZoom();
02301 displayHist_[i]->GetYaxis()->UnZoom();
02302 }
02303 updateDisplay();
02304 }
02305
02306 void DisplayManager::setNewAttrToSimParticles()
02307 {
02308 simPartPatternM_.clear();
02309 simPartPatternM_.push_back(simPartPatternPhoton_);
02310 simPartPatternM_.push_back(simPartPatternElec_);
02311 simPartPatternM_.push_back(simPartPatternMuon_);
02312 simPartPatternM_.push_back(simPartPatternK_);
02313 simPartPatternM_.push_back(simPartPatternPi_);
02314 simPartPatternM_.push_back(simPartPatternProton_);
02315 simPartPatternM_.push_back(simPartPatternNeutron_);
02316 simPartPatternM_.push_back(simPartPatternDefault_);
02317 }
02318
02319
02320 void DisplayManager::printGenParticleInfo(std::string name,int barcode,int barcodeMother)
02321 {
02322 const HepMC::GenEvent* myGenEvent = em_->MCTruth_.GetEvent();
02323 HepMC::GenParticle *p = myGenEvent->barcode_to_particle(barcode);
02324 std::cout<<"genParticle "<<name<<" with barcode "<<barcode<<std::flush<<std::endl;
02325 p->print();
02326 if (barcodeMother) {
02327 HepMC:: GenParticle *mother = myGenEvent->barcode_to_particle(barcodeMother);
02328 std::cout<<"mother particle with barcode "<<barcodeMother<<std::flush<<std::endl;
02329 mother->print();
02330 }
02331 }