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 32 of file TrackingTruthValid.cc.

33  : runStandalone( conf.getParameter<bool>("runStandalone") )
34  , outputFile( conf.getParameter<std::string>( "outputFile" ) )
35  , dbe_( nullptr )
36  , 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 findQualityFiles::run.

21 {} ;

Member Function Documentation

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

Definition at line 82 of file TrackingTruthValid.cc.

References begin, end, 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().

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

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

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

Referenced by ~TrackingTruthValid().

183  {
184  //Only in standalone mode save local root file
185  if (runStandalone && !outputFile.empty() && dbe_ ){dbe_->save(outputFile);}
186 
187 }
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:2443

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().