CMS 3D CMS Logo

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 
36  dbe_ = edm::Service<DQMStore>().operator->();
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 }
TrackingParticleContainer
edm::RefVector< std::vector< TrackingParticle > > TrackingParticleContainer
Definition: TrackingTruthValid.cc:21
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::Handle::product
T const * product() const
Definition: Handle.h:70
TrackingTruthValid::meTPAllHits
MonitorElement * meTPAllHits
Definition: TrackingTruthValid.h:35
edm::Run
Definition: Run.h:45
g4t_iterator
TrackingParticle::g4t_iterator g4t_iterator
Definition: TrackingTruthValid.cc:24
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackingTruthValid::meTPMass
MonitorElement * meTPMass
Definition: TrackingTruthValid.h:31
CrossingFrame.h
TrackingVertex::g4v_iterator
std::vector< SimVertex >::const_iterator g4v_iterator
Definition: TrackingVertex.h:30
TrackingParticle::g4t_iterator
std::vector< SimTrack >::const_iterator g4t_iterator
Definition: TrackingParticle.h:41
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
g4v_iterator
TrackingVertex::g4v_iterator g4v_iterator
Definition: TrackingTruthValid.cc:27
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
DQMStore.h
TrackingTruthValid::TrackingTruthValid
TrackingTruthValid(const edm::ParameterSet &conf)
Definition: TrackingTruthValid.cc:29
EDAnalyzer.h
TrackingTruthValid::vec_TrackingParticle_Token_
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
Definition: TrackingTruthValid.h:46
edm::RefVector
Definition: EDProductfwd.h:27
genv_iterator
TrackingVertex::genv_iterator genv_iterator
Definition: TrackingTruthValid.cc:26
edm::Handle< TrackingParticleCollection >
genp_iterator
TrackingParticle::genp_iterator genp_iterator
Definition: TrackingTruthValid.cc:25
TrackingTruthValid::meTPProc
MonitorElement * meTPProc
Definition: TrackingTruthValid.h:34
MakerMacros.h
download_sqlite_cfg.outputFile
outputFile
Definition: download_sqlite_cfg.py:5
TrackingTruthValid::meTPlip
MonitorElement * meTPlip
Definition: TrackingTruthValid.h:44
MixCollection.h
Service.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
TrackingTruthValid::bookHistograms
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override
Definition: TrackingTruthValid.cc:35
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
dbe_
dqm::legacy::DQMStore * dbe_
Definition: PFJetBenchmarkAnalyzer.cc:77
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackingTruthValid::meTPEta
MonitorElement * meTPEta
Definition: TrackingTruthValid.h:38
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
TrackingTruthValid.h
ModuleDef.h
edm::Service
Definition: Service.h:30
dqm::impl::MonitorElement::setBinLabel
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)
Definition: MonitorElement.cc:771
TrackingTruthValid::dbe_
DQMStore * dbe_
Definition: TrackingTruthValid.h:30
edm::EventSetup
Definition: EventSetup.h:57
TrackingTruthValid::TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingTruthValid.h:16
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
TrackingTruthValid::meTPPhi
MonitorElement * meTPPhi
Definition: TrackingTruthValid.h:39
TrackingTruthValid::meTPCharge
MonitorElement * meTPCharge
Definition: TrackingTruthValid.h:32
TrackingParticle.h
TrackingTruthValid::meTPId
MonitorElement * meTPId
Definition: TrackingTruthValid.h:33
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
TrackingTruthValid::meTPMatchedHits
MonitorElement * meTPMatchedHits
Definition: TrackingTruthValid.h:36
edm::RefVectorIterator
Definition: EDProductfwd.h:33
TrackingTruthValid::meTPVtxY
MonitorElement * meTPVtxY
Definition: TrackingTruthValid.h:41
EventSetup.h
tp_iterator
TrackingParticleRefVector::iterator tp_iterator
Definition: TrackingTruthValid.cc:23
TrackingTruthValid::meTPPt
MonitorElement * meTPPt
Definition: TrackingTruthValid.h:37
dqm::implementation::IBooker
Definition: DQMStore.h:43
JetMETHLTOfflineSource_cfi.runStandalone
runStandalone
Definition: JetMETHLTOfflineSource_cfi.py:15
TrackingTruthValid::meTPVtxX
MonitorElement * meTPVtxX
Definition: TrackingTruthValid.h:40
HepMCProduct.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
TrackingTruthValid::meTPVtxZ
MonitorElement * meTPVtxZ
Definition: TrackingTruthValid.h:42
TrackingTruthValid::meTPtip
MonitorElement * meTPtip
Definition: TrackingTruthValid.h:43
TrackingTruthValid::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: TrackingTruthValid.cc:77
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98