CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
TrackingTruthValid Class Reference

#include <TrackingTruthValid.h>

Inheritance diagram for TrackingTruthValid:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
void beginJob (const edm::ParameterSet &conf)
 
void endJob ()
 
 TrackingTruthValid (const edm::ParameterSet &conf)
 
 ~TrackingTruthValid ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

edm::ParameterSet conf_
 
DQMStoredbe_
 
MonitorElementmeTPAllHits
 
MonitorElementmeTPCharge
 
MonitorElementmeTPEta
 
MonitorElementmeTPId
 
MonitorElementmeTPlip
 
MonitorElementmeTPMass
 
MonitorElementmeTPMatchedHits
 
MonitorElementmeTPPhi
 
MonitorElementmeTPProc
 
MonitorElementmeTPPt
 
MonitorElementmeTPtip
 
MonitorElementmeTPVtxX
 
MonitorElementmeTPVtxY
 
MonitorElementmeTPVtxZ
 
std::string outputFile
 
edm::InputTag src_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 20 of file TrackingTruthValid.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file TrackingTruthValid.cc.

References dbe_, edm::ParameterSet::getParameter(), cmsCodeRules.cppFunctionSkipper::operator, and download_sqlite_cfg::outputFile.

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

Definition at line 25 of file TrackingTruthValid.h.

25 {} ;

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 85 of file TrackingTruthValid.cc.

References begin, end, edm::Handle< T >::product(), mathSSE::sqrt(), matplotRender::t, and DetId::Tracker.

85  {
86  using namespace std;
87 
88  edm::Handle<TrackingParticleCollection> TruthTrackContainer ;
89  // edm::Handle<TrackingVertexCollection> TruthVertexContainer;
90 
91 
92  event.getByLabel(src_,TruthTrackContainer );
93 
94  // event.getByLabel(src_,TruthVertexContainer);
95 
96  // std::cout << "Using Collection " << src_ << std::endl;
97 
98  const TrackingParticleCollection *tPC = TruthTrackContainer.product();
99 
100  // const TrackingVertexCollection *tVC = TruthVertexContainer.product();
101 
102  /*
103  // Get and print HepMC event for comparison
104  edm::Handle<edm::HepMCProduct> hepMC;
105  event.getByLabel("source",hepMC);
106  const edm::HepMCProduct *mcp = hepMC.product();
107  // const HepMC::GenEvent *genEvent = mcp -> GetEvent();
108  */
109 
110  // cout << "Found " << tPC -> size() << " tracks and " << tVC -> size() << " vertices." <<endl;
111 
112 
113 // Loop over TrackingParticle's
114 
115  for (TrackingParticleCollection::const_iterator t = tPC -> begin(); t != tPC -> end(); ++t) {
116  //if(t -> trackerPSimHit().size() ==0) cout << " Track with 0 SimHit " << endl;
117 
118 
119  meTPMass->Fill(t->mass());
120 
121  meTPCharge->Fill(t->charge() );
122 
123  meTPId->Fill(t->pdgId());
124 
125  meTPPt->Fill(sqrt(t->momentum().perp2()));
126 
127  meTPEta->Fill(t->momentum().eta());
128 
129  meTPPhi->Fill(t->momentum().Phi());
130  std::vector<PSimHit> trackerPSimHit( t->trackPSimHit(DetId::Tracker) );
131  meTPAllHits->Fill(trackerPSimHit.size());
132  //get the process of the first hit
133  if(trackerPSimHit.size() !=0) meTPProc->Fill( trackerPSimHit.front().processType());
134  meTPMatchedHits->Fill(t->matchedHit());
135  meTPVtxX->Fill(t->vx());
136  meTPVtxY->Fill(t->vy());
137  meTPVtxZ->Fill(t->vz());
138  meTPtip->Fill(sqrt(t->vertex().perp2()));
139  meTPlip->Fill(t->vz());
140 
141  /*
142  // Compare momenta from sources
143  cout << "T.P. Track mass, Momentum, q , ID, & Event # "
144  << t -> mass() << " "
145  << t -> p4() << " " << t -> charge() << " "
146  << t -> pdgId() << " "
147  << t -> eventId().bunchCrossing() << "." << t -> eventId().event() << endl;
148 
149  if(t->mass() < 0) cout << "======= WARNING, this particle has negative mass: " << t->mass()
150  << " and pdgId: " << t->pdgId() << endl;
151  if(t->pdgId() == 0) cout << "======= WARNING, this particle has pdgId = 0: " << t->pdgId() << endl;
152  cout << " Hits for this track: " << t -> trackerPSimHit().size() << endl;
153  */
154 
155  /*
156  std::cout << std::endl << "### Tracking Particle ###" << std::endl;
157  std::cout << (*t) << std::endl;
158  std::cout << "\t Tracker: " << t->trackerPSimHit().size() << std::endl;
159  std::cout << "\t Muon: " << t->muonPSimHit().size() << std::endl;
160  std::cout << (*t) << std::endl;
161  */
162  } // End loop over TrackingParticle
163 
164  // Loop over TrackingVertex's
165  /*
166  cout << "Dumping sample vertex info" << endl;
167  for (TrackingVertexCollection::const_iterator v = tVC -> begin(); v != tVC -> end(); ++v) {
168  cout << " Vertex Position & Event #" << v -> position() << " " << v -> eventId().bunchCrossing() << "." << v -> eventId().event() << endl;
169  cout << " Associated with " << v -> daughterTracks().size() << " tracks" << endl;
170  // Get Geant and HepMC positions
171  for (genv_iterator genV = v -> genVertices_begin(); genV != v -> genVertices_end(); ++genV) {
172  cout << " HepMC vertex position " << (*(*genV)).position() << endl;
173  }
174  for (g4v_iterator g4V = v -> g4Vertices_begin(); g4V != v -> g4Vertices_end(); ++g4V) {
175  cout << " Geant vertex position " << (*g4V).position() << endl;
176  // Probably empty all the time, currently
177  }
178 
179  // Loop over daughter track(s)
180  for (tp_iterator iTP = v -> daughterTracks_begin(); iTP != v -> daughterTracks_end(); ++iTP) {
181  cout << " Daughter starts: " << (*(*iTP)).vertex();
182  for (g4t_iterator g4T = (*(*iTP)).g4Track_begin(); g4T != (*(*iTP)).g4Track_end(); ++g4T) {
183  cout << " p " << g4T->momentum();
184  }
185  cout << endl;
186  }
187 
188  // Loop over source track(s) (can be multiple since vertices are collapsed)
189  for (tp_iterator iTP = v -> sourceTracks_begin(); iTP != v -> sourceTracks_end(); ++iTP) {
190  cout << " Source starts: " << (*(*iTP)).vertex();
191  for (g4t_iterator g4T = (*iTP)->g4Track_begin(); g4T != (*iTP)->g4Track_end(); ++g4T) {
192  cout << ", p " << g4T ->momentum();
193  }
194  cout << endl;
195  }
196  } // End loop over TrackingVertex
197  */
198 
199 
200 }
MonitorElement * meTPAllHits
MonitorElement * meTPVtxX
MonitorElement * meTPtip
MonitorElement * meTPPhi
MonitorElement * meTPVtxZ
MonitorElement * meTPVtxY
void Fill(long long x)
MonitorElement * meTPEta
T sqrt(T t)
Definition: SSEVec.h:28
MonitorElement * meTPProc
#define end
Definition: vmac.h:38
MonitorElement * meTPMatchedHits
T const * product() const
Definition: Handle.h:74
MonitorElement * meTPCharge
#define begin
Definition: vmac.h:31
std::vector< TrackingParticle > TrackingParticleCollection
MonitorElement * meTPMass
MonitorElement * meTPlip
MonitorElement * meTPPt
MonitorElement * meTPId
void TrackingTruthValid::beginJob ( const edm::ParameterSet conf)

Definition at line 35 of file TrackingTruthValid.cc.

35 {}
void TrackingTruthValid::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 202 of file TrackingTruthValid.cc.

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

202  {
203 
204  if ( outputFile.size() != 0 && dbe_ ) dbe_->save(outputFile);
205 
206 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898

Member Data Documentation

edm::ParameterSet TrackingTruthValid::conf_
private

Definition at line 34 of file TrackingTruthValid.h.

DQMStore* TrackingTruthValid::dbe_
private

Definition at line 33 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPAllHits
private

Definition at line 42 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPCharge
private

Definition at line 39 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPEta
private

Definition at line 45 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPId
private

Definition at line 40 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPlip
private

Definition at line 51 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPMass
private

Definition at line 38 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPMatchedHits
private

Definition at line 43 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPPhi
private

Definition at line 46 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPProc
private

Definition at line 41 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPPt
private

Definition at line 44 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPtip
private

Definition at line 50 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPVtxX
private

Definition at line 47 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPVtxY
private

Definition at line 48 of file TrackingTruthValid.h.

MonitorElement* TrackingTruthValid::meTPVtxZ
private

Definition at line 49 of file TrackingTruthValid.h.

std::string TrackingTruthValid::outputFile
private

Definition at line 35 of file TrackingTruthValid.h.

edm::InputTag TrackingTruthValid::src_
private

Definition at line 36 of file TrackingTruthValid.h.