CMS 3D CMS Logo

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