CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
TrackingTruthValid Class Reference

#include <TrackingTruthValid.h>

Inheritance diagram for TrackingTruthValid:
one::DQMEDAnalyzer< T > one::dqmimplementation::DQMBaseClass< T... >

Public Types

typedef std::vector< TrackingParticleTrackingParticleCollection
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) override
 
void endJob () override
 
 TrackingTruthValid (const edm::ParameterSet &conf)
 
 ~TrackingTruthValid () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< T >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Private Attributes

DQMStoredbe_
 
MonitorElementmeTPAllHits
 
MonitorElementmeTPCharge
 
MonitorElementmeTPEta
 
MonitorElementmeTPId
 
MonitorElementmeTPlip
 
MonitorElementmeTPMass
 
MonitorElementmeTPMatchedHits
 
MonitorElementmeTPPhi
 
MonitorElementmeTPProc
 
MonitorElementmeTPPt
 
MonitorElementmeTPtip
 
MonitorElementmeTPVtxX
 
MonitorElementmeTPVtxY
 
MonitorElementmeTPVtxZ
 
std::string outputFile
 
bool runStandalone
 
edm::EDGetTokenT< TrackingParticleCollectionvec_TrackingParticle_Token_
 

Detailed Description

Definition at line 15 of file TrackingTruthValid.h.

Member Typedef Documentation

Definition at line 17 of file TrackingTruthValid.h.

Constructor & Destructor Documentation

TrackingTruthValid::TrackingTruthValid ( const edm::ParameterSet conf)
explicit

Definition at line 30 of file TrackingTruthValid.cc.

31  : runStandalone(conf.getParameter<bool>("runStandalone")),
32  outputFile(conf.getParameter<std::string>("outputFile")),
33  dbe_(nullptr),
34  vec_TrackingParticle_Token_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("src"))) {}
T getParameter(std::string const &) const
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
TrackingTruthValid::~TrackingTruthValid ( )
inlineoverride

Definition at line 21 of file TrackingTruthValid.h.

References analyze(), bookHistograms(), endJob(), and writedatasetfile::run.

21 {};

Member Function Documentation

void TrackingTruthValid::analyze ( const edm::Event event,
const edm::EventSetup c 
)
override

Definition at line 78 of file TrackingTruthValid.cc.

References MonitorElement::Fill(), meTPAllHits, meTPCharge, meTPEta, meTPId, meTPlip, meTPMass, meTPMatchedHits, meTPPhi, meTPPt, meTPtip, meTPVtxX, meTPVtxY, meTPVtxZ, edm::Handle< T >::product(), mathSSE::sqrt(), lumiQTWidget::t, and vec_TrackingParticle_Token_.

Referenced by ~TrackingTruthValid().

78  {
79  edm::Handle<TrackingParticleCollection> TruthTrackContainer;
80  // edm::Handle<TrackingVertexCollection> TruthVertexContainer;
81 
82  event.getByToken(vec_TrackingParticle_Token_, TruthTrackContainer);
83 
84  const TrackingParticleCollection *tPC = TruthTrackContainer.product();
85 
86  // Loop over TrackingParticle's
87  for (TrackingParticleCollection::const_iterator t = tPC->begin(); t != tPC->end(); ++t) {
88  // if(t -> trackerPSimHit().size() ==0) cout << " Track with 0 SimHit " <<
89  // endl;
90 
91  meTPMass->Fill(t->mass());
92  meTPCharge->Fill(t->charge());
93  meTPId->Fill(t->pdgId());
94  meTPPt->Fill(sqrt(t->momentum().perp2()));
95  meTPEta->Fill(t->momentum().eta());
96  meTPPhi->Fill(t->momentum().Phi());
97  //#warning "This file has been modified just to get it to compile without
98  // any regard as to whether it still functions as intended" #ifdef
99  // REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
100  // std::vector<PSimHit> trackerPSimHit( t->trackPSimHit(DetId::Tracker)
101  // );
102  //#endif
103  meTPAllHits->Fill(t->numberOfTrackerHits());
104  // get the process of the first hit
105  //#warning "This file has been modified just to get it to compile without
106  // any regard as to whether it still functions as intended" #ifdef
107  // REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
108  // if(trackerPSimHit.size() !=0) meTPProc->Fill(
109  // trackerPSimHit.front().processType());
110  //#endif
111 
112  // there is no more the PSimHits collection !!! how to deal w/ the
113  // processType ?
114  // if(t->numberOfTrackerHits() !=0) meTPProc->Fill(
115  // trackerPSimHit.front().processType());
116 
117  meTPMatchedHits->Fill(t->numberOfTrackerLayers());
118  meTPVtxX->Fill(t->vx());
119  meTPVtxY->Fill(t->vy());
120  meTPVtxZ->Fill(t->vz());
121  meTPtip->Fill(sqrt(t->vertex().perp2()));
122  meTPlip->Fill(t->vz());
123 
124  /*
125  // Compare momenta from sources
126  cout << "T.P. Track mass, Momentum, q , ID, & Event # "
127  << t -> mass() << " "
128  << t -> p4() << " " << t -> charge() << " "
129  << t -> pdgId() << " "
130  << t -> eventId().bunchCrossing() << "." << t -> eventId().event() <<
131  endl;
132 
133  if(t->mass() < 0) cout << "======= WARNING, this particle has negative mass: "
134  << t->mass()
135  << " and pdgId: " << t->pdgId() << endl;
136  if(t->pdgId() == 0) cout << "======= WARNING, this particle has pdgId = 0: "
137  << t->pdgId() << endl; cout << " Hits for this track: " << t ->
138  trackerPSimHit().size() << endl;
139  */
140 
141  /*
142  std::cout << std::endl << "### Tracking Particle ###" << std::endl;
143  std::cout << (*t) << std::endl;
144  std::cout << "\t Tracker: " << t->trackerPSimHit().size() << std::endl;
145  std::cout << "\t Muon: " << t->muonPSimHit().size() << std::endl;
146  std::cout << (*t) << std::endl;
147  */
148  } // End loop over TrackingParticle
149 
150  // Loop over TrackingVertex's
151  /*
152  cout << "Dumping sample vertex info" << endl;
153  for (TrackingVertexCollection::const_iterator v = tVC -> begin(); v != tVC ->
154  end(); ++v) { cout << " Vertex Position & Event #" << v -> position() << " "
155  << v -> eventId().bunchCrossing() << "." << v -> eventId().event() << endl;
156  cout << " Associated with " << v -> daughterTracks().size() << " tracks" <<
157  endl;
158  // Get Geant and HepMC positions
159  for (genv_iterator genV = v -> genVertices_begin(); genV != v ->
160  genVertices_end(); ++genV) { cout << " HepMC vertex position " <<
161  (*(*genV)).position() << endl;
162  }
163  for (g4v_iterator g4V = v -> g4Vertices_begin(); g4V != v ->
164  g4Vertices_end(); ++g4V) { cout << " Geant vertex position " <<
165  (*g4V).position() << endl;
166  // Probably empty all the time, currently
167  }
168 
169  // Loop over daughter track(s)
170  for (tp_iterator iTP = v -> daughterTracks_begin(); iTP != v ->
171  daughterTracks_end(); ++iTP) { cout << " Daughter starts: " <<
172  (*(*iTP)).vertex(); for (g4t_iterator g4T = (*(*iTP)).g4Track_begin(); g4T !=
173  (*(*iTP)).g4Track_end(); ++g4T) { cout << " p " << g4T->momentum();
174  }
175  cout << endl;
176  }
177 
178  // Loop over source track(s) (can be multiple since vertices are collapsed)
179  for (tp_iterator iTP = v -> sourceTracks_begin(); iTP != v ->
180  sourceTracks_end(); ++iTP) { cout << " Source starts: " <<
181  (*(*iTP)).vertex(); for (g4t_iterator g4T = (*iTP)->g4Track_begin(); g4T !=
182  (*iTP)->g4Track_end(); ++g4T) { cout << ", p " << g4T ->momentum();
183  }
184  cout << endl;
185  }
186  } // End loop over TrackingVertex
187  */
188 }
MonitorElement * meTPAllHits
std::vector< TrackingParticle > TrackingParticleCollection
MonitorElement * meTPVtxX
MonitorElement * meTPtip
MonitorElement * meTPPhi
MonitorElement * meTPVtxZ
MonitorElement * meTPVtxY
void Fill(long long x)
MonitorElement * meTPEta
edm::EDGetTokenT< TrackingParticleCollection > vec_TrackingParticle_Token_
T sqrt(T t)
Definition: SSEVec.h:18
T const * product() const
Definition: Handle.h:74
MonitorElement * meTPMatchedHits
MonitorElement * meTPCharge
MonitorElement * meTPMass
MonitorElement * meTPlip
MonitorElement * meTPPt
MonitorElement * meTPId
void TrackingTruthValid::bookHistograms ( DQMStore::IBooker ibooker,
const edm::Run run,
const edm::EventSetup es 
)
override

Definition at line 36 of file TrackingTruthValid.cc.

References DQMStore::IBooker::book1D(), dbe_, meTPAllHits, meTPCharge, meTPEta, meTPId, meTPlip, meTPMass, meTPMatchedHits, meTPPhi, meTPProc, meTPPt, meTPtip, meTPVtxX, meTPVtxY, meTPVtxZ, Utilities::operator, MonitorElement::setBinLabel(), and DQMStore::IBooker::setCurrentFolder().

Referenced by ~TrackingTruthValid().

36  {
38  ibooker.setCurrentFolder("Tracking/TrackingMCTruth/TrackingParticle");
39 
40  meTPMass = ibooker.book1D("TPMass", "Tracking Particle Mass", 100, -1, +5.);
41  meTPCharge = ibooker.book1D("TPCharge", "Tracking Particle Charge", 10, -5, 5);
42  meTPId = ibooker.book1D("TPId", "Tracking Particle Id", 500, -5000, 5000);
43  meTPProc = ibooker.book1D("TPProc", "Tracking Particle Proc", 20, -0.5, 19.5);
44  meTPAllHits = ibooker.book1D("TPAllHits", "Tracking Particle All Hits", 200, -0.5, 199.5);
45  meTPMatchedHits = ibooker.book1D("TPMatchedHits", "Tracking Particle Matched Hits", 100, -0.5, 99.5);
46  meTPPt = ibooker.book1D("TPPt", "Tracking Particle Pt", 100, 0, 100.);
47  meTPEta = ibooker.book1D("TPEta", "Tracking Particle Eta", 100, -7., 7.);
48  meTPPhi = ibooker.book1D("TPPhi", "Tracking Particle Phi", 100, -4., 4);
49  meTPVtxX = ibooker.book1D("TPVtxX", "Tracking Particle VtxX", 100, -100, 100.);
50  meTPVtxY = ibooker.book1D("TPVtxY", "Tracking Particle VtxY", 100, -100, 100.);
51  meTPVtxZ = ibooker.book1D("TPVtxZ", "Tracking Particle VtxZ", 100, -100, 100.);
52  meTPtip = ibooker.book1D("TPtip", "Tracking Particle tip", 100, 0, 1000.);
53  meTPlip = ibooker.book1D("TPlip", "Tracking Particle lip", 100, 0, 100.);
54 
55  // Prepare Axes Labels for Processes
56  meTPProc->setBinLabel(1, "Undefined"); // value = 0
57  meTPProc->setBinLabel(2, "Unknown"); // value = 1
58  meTPProc->setBinLabel(3, "Primary"); // value = 2
59  meTPProc->setBinLabel(4, "Hadronic"); // value = 3
60  meTPProc->setBinLabel(5, "Decay"); // value = 4
61  meTPProc->setBinLabel(6, "Compton"); // value = 5
62  meTPProc->setBinLabel(7, "Annihilation"); // value = 6
63  meTPProc->setBinLabel(8, "EIoni"); // value = 7
64  meTPProc->setBinLabel(9, "HIoni"); // value = 8
65  meTPProc->setBinLabel(10, "MuIoni"); // value = 9
66  meTPProc->setBinLabel(11, "Photon"); // value = 10
67  meTPProc->setBinLabel(12, "MuPairProd"); // value = 11
68  meTPProc->setBinLabel(13, "Conversions"); // value = 12
69  meTPProc->setBinLabel(14, "EBrem"); // value = 13
70  meTPProc->setBinLabel(15, "SynchrotronRadiation"); // value = 14
71  meTPProc->setBinLabel(16, "MuBrem"); // value = 15
72  meTPProc->setBinLabel(17, "MuNucl"); // value = 16
73  meTPProc->setBinLabel(18, "");
74  meTPProc->setBinLabel(19, "");
75  meTPProc->setBinLabel(20, "");
76 }
MonitorElement * meTPAllHits
MonitorElement * meTPVtxX
MonitorElement * meTPtip
MonitorElement * meTPPhi
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)
MonitorElement * meTPVtxZ
MonitorElement * meTPVtxY
MonitorElement * meTPEta
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * meTPProc
MonitorElement * meTPMatchedHits
MonitorElement * meTPCharge
MonitorElement * meTPMass
MonitorElement * meTPlip
MonitorElement * meTPPt
MonitorElement * meTPId
void TrackingTruthValid::endJob ( void  )
override

Definition at line 190 of file TrackingTruthValid.cc.

References dbe_, outputFile, runStandalone, and DQMStore::save().

Referenced by ~TrackingTruthValid().

190  {
191  // Only in standalone mode save local root file
192  if (runStandalone && !outputFile.empty() && dbe_) {
193  dbe_->save(outputFile);
194  }
195 }
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2465

Member Data Documentation

DQMStore* TrackingTruthValid::dbe_
private

Definition at line 32 of file TrackingTruthValid.h.

Referenced by bookHistograms(), and endJob().

MonitorElement* TrackingTruthValid::meTPAllHits
private

Definition at line 37 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPCharge
private

Definition at line 34 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPEta
private

Definition at line 40 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPId
private

Definition at line 35 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPlip
private

Definition at line 46 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPMass
private

Definition at line 33 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPMatchedHits
private

Definition at line 38 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPPhi
private

Definition at line 41 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPProc
private

Definition at line 36 of file TrackingTruthValid.h.

Referenced by bookHistograms().

MonitorElement* TrackingTruthValid::meTPPt
private

Definition at line 39 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPtip
private

Definition at line 45 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPVtxX
private

Definition at line 42 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPVtxY
private

Definition at line 43 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

MonitorElement* TrackingTruthValid::meTPVtxZ
private

Definition at line 44 of file TrackingTruthValid.h.

Referenced by analyze(), and bookHistograms().

std::string TrackingTruthValid::outputFile
private

Definition at line 30 of file TrackingTruthValid.h.

Referenced by endJob().

bool TrackingTruthValid::runStandalone
private

Definition at line 29 of file TrackingTruthValid.h.

Referenced by endJob().

edm::EDGetTokenT<TrackingParticleCollection> TrackingTruthValid::vec_TrackingParticle_Token_
private

Definition at line 48 of file TrackingTruthValid.h.

Referenced by analyze().