CMS 3D CMS Logo

TrackingTruthValid.cc
Go to the documentation of this file.
13 
14 #include <cmath>
15 
17 
23 
25  : runStandalone(conf.getParameter<bool>("runStandalone")),
26  outputFile(conf.getParameter<std::string>("outputFile")),
27  dbe_(nullptr),
28  vec_TrackingParticle_Token_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("src"))) {}
29 
32  ibooker.setCurrentFolder("Tracking/TrackingMCTruth/TrackingParticle");
33 
34  meTPMass = ibooker.book1D("TPMass", "Tracking Particle Mass", 100, -1, +5.);
35  meTPCharge = ibooker.book1D("TPCharge", "Tracking Particle Charge", 10, -5, 5);
36  meTPId = ibooker.book1D("TPId", "Tracking Particle Id", 500, -5000, 5000);
37  meTPProc = ibooker.book1D("TPProc", "Tracking Particle Proc", 20, -0.5, 19.5);
38  meTPAllHits = ibooker.book1D("TPAllHits", "Tracking Particle All Hits", 200, -0.5, 199.5);
39  meTPMatchedHits = ibooker.book1D("TPMatchedHits", "Tracking Particle Matched Hits", 100, -0.5, 99.5);
40  meTPPt = ibooker.book1D("TPPt", "Tracking Particle Pt", 100, 0, 100.);
41  meTPEta = ibooker.book1D("TPEta", "Tracking Particle Eta", 100, -7., 7.);
42  meTPPhi = ibooker.book1D("TPPhi", "Tracking Particle Phi", 100, -4., 4);
43  meTPVtxX = ibooker.book1D("TPVtxX", "Tracking Particle VtxX", 100, -100, 100.);
44  meTPVtxY = ibooker.book1D("TPVtxY", "Tracking Particle VtxY", 100, -100, 100.);
45  meTPVtxZ = ibooker.book1D("TPVtxZ", "Tracking Particle VtxZ", 100, -100, 100.);
46  meTPtip = ibooker.book1D("TPtip", "Tracking Particle tip", 100, 0, 1000.);
47  meTPlip = ibooker.book1D("TPlip", "Tracking Particle lip", 100, 0, 100.);
48 
49  // Prepare Axes Labels for Processes
50  meTPProc->setBinLabel(1, "Undefined"); // value = 0
51  meTPProc->setBinLabel(2, "Unknown"); // value = 1
52  meTPProc->setBinLabel(3, "Primary"); // value = 2
53  meTPProc->setBinLabel(4, "Hadronic"); // value = 3
54  meTPProc->setBinLabel(5, "Decay"); // value = 4
55  meTPProc->setBinLabel(6, "Compton"); // value = 5
56  meTPProc->setBinLabel(7, "Annihilation"); // value = 6
57  meTPProc->setBinLabel(8, "EIoni"); // value = 7
58  meTPProc->setBinLabel(9, "HIoni"); // value = 8
59  meTPProc->setBinLabel(10, "MuIoni"); // value = 9
60  meTPProc->setBinLabel(11, "Photon"); // value = 10
61  meTPProc->setBinLabel(12, "MuPairProd"); // value = 11
62  meTPProc->setBinLabel(13, "Conversions"); // value = 12
63  meTPProc->setBinLabel(14, "EBrem"); // value = 13
64  meTPProc->setBinLabel(15, "SynchrotronRadiation"); // value = 14
65  meTPProc->setBinLabel(16, "MuBrem"); // value = 15
66  meTPProc->setBinLabel(17, "MuNucl"); // value = 16
67  meTPProc->setBinLabel(18, "");
68  meTPProc->setBinLabel(19, "");
69  meTPProc->setBinLabel(20, "");
70 }
71 
73  edm::Handle<TrackingParticleCollection> TruthTrackContainer;
74  // edm::Handle<TrackingVertexCollection> TruthVertexContainer;
75 
76  event.getByToken(vec_TrackingParticle_Token_, TruthTrackContainer);
77 
78  const TrackingParticleCollection *tPC = TruthTrackContainer.product();
79 
80  // Loop over TrackingParticle's
81  for (TrackingParticleCollection::const_iterator t = tPC->begin(); t != tPC->end(); ++t) {
82  // if(t -> trackerPSimHit().size() ==0) cout << " Track with 0 SimHit " <<
83  // endl;
84 
85  meTPMass->Fill(t->mass());
86  meTPCharge->Fill(t->charge());
87  meTPId->Fill(t->pdgId());
88  meTPPt->Fill(sqrt(t->momentum().perp2()));
89  meTPEta->Fill(t->momentum().eta());
90  meTPPhi->Fill(t->momentum().Phi());
91  //#warning "This file has been modified just to get it to compile without
92  // any regard as to whether it still functions as intended" #ifdef
93  // REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
94  // std::vector<PSimHit> trackerPSimHit( t->trackPSimHit(DetId::Tracker)
95  // );
96  //#endif
97  meTPAllHits->Fill(t->numberOfTrackerHits());
98  // get the process of the first hit
99  //#warning "This file has been modified just to get it to compile without
100  // any regard as to whether it still functions as intended" #ifdef
101  // REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
102  // if(trackerPSimHit.size() !=0) meTPProc->Fill(
103  // trackerPSimHit.front().processType());
104  //#endif
105 
106  // there is no more the PSimHits collection !!! how to deal w/ the
107  // processType ?
108  // if(t->numberOfTrackerHits() !=0) meTPProc->Fill(
109  // trackerPSimHit.front().processType());
110 
111  meTPMatchedHits->Fill(t->numberOfTrackerLayers());
112  meTPVtxX->Fill(t->vx());
113  meTPVtxY->Fill(t->vy());
114  meTPVtxZ->Fill(t->vz());
115  meTPtip->Fill(sqrt(t->vertex().perp2()));
116  meTPlip->Fill(t->vz());
117 
118  /*
119  // Compare momenta from sources
120  cout << "T.P. Track mass, Momentum, q , ID, & Event # "
121  << t -> mass() << " "
122  << t -> p4() << " " << t -> charge() << " "
123  << t -> pdgId() << " "
124  << t -> eventId().bunchCrossing() << "." << t -> eventId().event() <<
125  endl;
126 
127  if(t->mass() < 0) cout << "======= WARNING, this particle has negative mass: "
128  << t->mass()
129  << " and pdgId: " << t->pdgId() << endl;
130  if(t->pdgId() == 0) cout << "======= WARNING, this particle has pdgId = 0: "
131  << t->pdgId() << endl; cout << " Hits for this track: " << t ->
132  trackerPSimHit().size() << endl;
133  */
134 
135  /*
136  std::cout << std::endl << "### Tracking Particle ###" << std::endl;
137  std::cout << (*t) << std::endl;
138  std::cout << "\t Tracker: " << t->trackerPSimHit().size() << std::endl;
139  std::cout << "\t Muon: " << t->muonPSimHit().size() << std::endl;
140  std::cout << (*t) << std::endl;
141  */
142  } // End loop over TrackingParticle
143 
144  // Loop over TrackingVertex's
145  /*
146  cout << "Dumping sample vertex info" << endl;
147  for (TrackingVertexCollection::const_iterator v = tVC -> begin(); v != tVC ->
148  end(); ++v) { cout << " Vertex Position & Event #" << v -> position() << " "
149  << v -> eventId().bunchCrossing() << "." << v -> eventId().event() << endl;
150  cout << " Associated with " << v -> daughterTracks().size() << " tracks" <<
151  endl;
152  // Get Geant and HepMC positions
153  for (genv_iterator genV = v -> genVertices_begin(); genV != v ->
154  genVertices_end(); ++genV) { cout << " HepMC vertex position " <<
155  (*(*genV)).position() << endl;
156  }
157  for (g4v_iterator g4V = v -> g4Vertices_begin(); g4V != v ->
158  g4Vertices_end(); ++g4V) { cout << " Geant vertex position " <<
159  (*g4V).position() << endl;
160  // Probably empty all the time, currently
161  }
162 
163  // Loop over daughter track(s)
164  for (tp_iterator iTP = v -> daughterTracks_begin(); iTP != v ->
165  daughterTracks_end(); ++iTP) { cout << " Daughter starts: " <<
166  (*(*iTP)).vertex(); for (g4t_iterator g4T = (*(*iTP)).g4Track_begin(); g4T !=
167  (*(*iTP)).g4Track_end(); ++g4T) { cout << " p " << g4T->momentum();
168  }
169  cout << endl;
170  }
171 
172  // Loop over source track(s) (can be multiple since vertices are collapsed)
173  for (tp_iterator iTP = v -> sourceTracks_begin(); iTP != v ->
174  sourceTracks_end(); ++iTP) { cout << " Source starts: " <<
175  (*(*iTP)).vertex(); for (g4t_iterator g4T = (*iTP)->g4Track_begin(); g4T !=
176  (*iTP)->g4Track_end(); ++g4T) { cout << ", p " << g4T ->momentum();
177  }
178  cout << endl;
179  }
180  } // End loop over TrackingVertex
181  */
182 }
MonitorElement * meTPAllHits
MonitorElement * meTPVtxX
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
TrackingVertex::g4v_iterator g4v_iterator
std::vector< SimVertex >::const_iterator g4v_iterator
edm::RefVector< std::vector< TrackingParticle > > TrackingParticleContainer
MonitorElement * meTPtip
dqm::legacy::DQMStore * dbe_
T const * product() const
Definition: Handle.h:70
MonitorElement * meTPPhi
MonitorElement * meTPVtxZ
MonitorElement * meTPVtxY
TrackingParticle::genp_iterator genp_iterator
MonitorElement * meTPEta
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
void Fill(long long x)
TrackingVertex::genv_iterator genv_iterator
T sqrt(T t)
Definition: SSEVec.h:19
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override
std::vector< TrackingParticle > TrackingParticleCollection
MonitorElement * meTPProc
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< SimTrack >::const_iterator g4t_iterator
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * meTPMatchedHits
MonitorElement * meTPCharge
HLT enums.
TrackingParticleRefVector::iterator tp_iterator
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * meTPMass
MonitorElement * meTPlip
MonitorElement * meTPPt
Definition: event.py:1
Definition: Run.h:45
TrackingTruthValid(const edm::ParameterSet &conf)
MonitorElement * meTPId
TrackingParticle::g4t_iterator g4t_iterator