CMS 3D CMS Logo

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

#include <PizeroMCTruthFinder.h>

Public Member Functions

std::vector< PizeroMCTruthfind (const std::vector< SimTrack > &simTracks, const std::vector< SimVertex > &simVertices)
 
 PizeroMCTruthFinder ()
 
virtual ~PizeroMCTruthFinder ()
 

Private Member Functions

void fill (const std::vector< SimTrack > &theSimTracks, const std::vector< SimVertex > &theSimVertices)
 

Private Attributes

std::map< unsigned, unsigned > geantToIndex_
 
ElectronMCTruthFindertheElectronMCTruthFinder_
 
PhotonMCTruthFinderthePhotonMCTruthFinder_
 

Detailed Description

Definition at line 15 of file PizeroMCTruthFinder.h.

Constructor & Destructor Documentation

◆ PizeroMCTruthFinder()

PizeroMCTruthFinder::PizeroMCTruthFinder ( )

◆ ~PizeroMCTruthFinder()

PizeroMCTruthFinder::~PizeroMCTruthFinder ( )
virtual

Definition at line 12 of file PizeroMCTruthFinder.cc.

12  {
15  std::cout << "~PizeroMCTruthFinder" << std::endl;
16 }

References gather_cfg::cout, theElectronMCTruthFinder_, and thePhotonMCTruthFinder_.

Member Function Documentation

◆ fill()

void PizeroMCTruthFinder::fill ( const std::vector< SimTrack > &  theSimTracks,
const std::vector< SimVertex > &  theSimVertices 
)
private

Definition at line 160 of file PizeroMCTruthFinder.cc.

160  {
161  unsigned nVtx = simVertices.size();
162  unsigned nTks = simTracks.size();
163 
164  // Empty event, do nothin'
165  if (nVtx == 0)
166  return;
167 
168  // create a map associating geant particle id and position in the
169  // event SimTrack vector
170  for (unsigned it = 0; it < nTks; ++it) {
171  geantToIndex_[simTracks[it].trackId()] = it;
172  std::cout << " PizeroMCTruthFinder::fill it " << it << " simTracks[it].trackId() " << simTracks[it].trackId()
173  << std::endl;
174  }
175 }

References gather_cfg::cout, geantToIndex_, TrackCandidateProducer_cfi::simTracks, and HGCalValidator_cfi::simVertices.

Referenced by find().

◆ find()

std::vector< PizeroMCTruth > PizeroMCTruthFinder::find ( const std::vector< SimTrack > &  simTracks,
const std::vector< SimVertex > &  simVertices 
)

Definition at line 18 of file PizeroMCTruthFinder.cc.

19  {
20  std::cout << " PizeroMCTruthFinder::find " << std::endl;
21 
22  std::vector<PhotonMCTruth> mcPhotons = thePhotonMCTruthFinder_->find(theSimTracks, theSimVertices);
23 
24  std::vector<PizeroMCTruth> result;
25  std::vector<PhotonMCTruth> photonsFromPizero;
26  std::vector<ElectronMCTruth> electronsFromPizero;
27 
28  // Local variables
29  //const int SINGLE=1;
30  //const int DOUBLE=2;
31  //const int PYTHIA=3;
32  //const int ELECTRON_FLAV=1;
33  //const int PIZERO_FLAV=2;
34  //const int PHOTON_FLAV=3;
35 
36  //int ievtype=0;
37  //int ievflav=0;
38 
39  std::vector<SimTrack> pizeroTracks;
40  SimVertex primVtx;
41 
42  fill(theSimTracks, theSimVertices);
43 
44  int iPV = -1;
45  //int partType1=0;
46  //int partType2=0;
47  std::vector<SimTrack>::const_iterator iFirstSimTk = theSimTracks.begin();
48  if (!(*iFirstSimTk).noVertex()) {
49  iPV = (*iFirstSimTk).vertIndex();
50 
51  int vtxId = (*iFirstSimTk).vertIndex();
52  primVtx = theSimVertices[vtxId];
53 
54  //partType1 = (*iFirstSimTk).type();
55  std::cout << " Primary vertex id " << iPV << " first track type " << (*iFirstSimTk).type() << std::endl;
56  } else {
57  std::cout << " First track has no vertex " << std::endl;
58  }
59 
60  // CLHEP::HepLorentzVector primVtxPos= primVtx.position();
61  math::XYZTLorentzVectorD primVtxPos(
62  primVtx.position().x(), primVtx.position().y(), primVtx.position().z(), primVtx.position().e());
63 
64  // Look at a second track
65  iFirstSimTk++;
66  if (iFirstSimTk != theSimTracks.end()) {
67  if ((*iFirstSimTk).vertIndex() == iPV) {
68  //partType2 = (*iFirstSimTk).type();
69  std::cout << " second track type " << (*iFirstSimTk).type() << " vertex " << (*iFirstSimTk).vertIndex()
70  << std::endl;
71 
72  } else {
73  std::cout << " Only one kine track from Primary Vertex " << std::endl;
74  }
75  }
76 
77  int npv = 0;
78 
79  for (std::vector<SimTrack>::const_iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk) {
80  if ((*iSimTk).noVertex())
81  continue;
82 
83  int vertexId = (*iSimTk).vertIndex();
84  SimVertex vertex = theSimVertices[vertexId];
85 
86  std::cout << " Particle type " << (*iSimTk).type() << " Sim Track ID " << (*iSimTk).trackId() << " momentum "
87  << (*iSimTk).momentum() << " vertex position " << vertex.position() << std::endl;
88 
89  if ((*iSimTk).vertIndex() == iPV) {
90  npv++;
91  if (std::abs((*iSimTk).type()) == 111) {
92  std::cout << " Found a primary pizero with ID " << (*iSimTk).trackId() << " momentum " << (*iSimTk).momentum()
93  << std::endl;
94 
95  pizeroTracks.push_back(*iSimTk);
96 
97  // CLHEP::HepLorentzVector momentum = (*iSimTk).momentum();
98  math::XYZTLorentzVectorD momentum(
99  (*iSimTk).momentum().x(), (*iSimTk).momentum().y(), (*iSimTk).momentum().z(), (*iSimTk).momentum().e());
100  }
101  }
102  }
103 
104  std::cout << " There are " << npv << " particles originating in the PV " << std::endl;
105 
106  //if(npv > 4) {
107  // ievtype = PYTHIA;
108  //} else if(npv == 1) {
109  // if( std::abs(partType1) == 11 ) {
110  // ievtype = SINGLE; ievflav = ELECTRON_FLAV;
111  // } else if(partType1 == 111) {
112  // ievtype = SINGLE; ievflav = PIZERO_FLAV;
113  // } else if(partType1 == 22) {
114  // ievtype = SINGLE; ievflav = PHOTON_FLAV;
115  // }
116  //} else if(npv == 2) {
117  // if ( std::abs(partType1) == 11 && std::abs(partType2) == 11 ) {
118  // ievtype = DOUBLE; ievflav = ELECTRON_FLAV;
119  // } else if(partType1 == 111 && partType2 == 111) {
120  // ievtype = DOUBLE; ievflav = PIZERO_FLAV;
121  // } else if(partType1 == 22 && partType2 == 22) {
122  // ievtype = DOUBLE; ievflav = PHOTON_FLAV;
123  // }
124  //}
125 
126  for (std::vector<SimTrack>::iterator iPizTk = pizeroTracks.begin(); iPizTk != pizeroTracks.end(); ++iPizTk) {
127  std::cout << " Looping on the primary pizero pt " << sqrt((*iPizTk).momentum().perp2()) << " pizero track ID "
128  << (*iPizTk).trackId() << std::endl;
129 
130  photonsFromPizero.clear();
131  std::cout << " mcPhotons.size " << mcPhotons.size() << std::endl;
132  for (std::vector<PhotonMCTruth>::iterator iPho = mcPhotons.begin(); iPho != mcPhotons.end(); ++iPho) {
133  int phoVtxIndex = (*iPho).vertexInd();
134  SimVertex phoVtx = theSimVertices[phoVtxIndex];
135  unsigned int phoParentInd = phoVtx.parentIndex();
136  std::cout << " photon parent vertex index " << phoParentInd << std::endl;
137 
138  if (phoParentInd == (*iPizTk).trackId()) {
139  std::cout << "Matched Photon ID " << (*iPho).trackId() << " vtx " << phoParentInd << " with pizero "
140  << (*iPizTk).trackId() << std::endl;
141  photonsFromPizero.push_back(*iPho);
142  }
143  }
144  std::cout << " Photon matching the pizero vertex " << photonsFromPizero.size() << std::endl;
145 
146  // build pizero MC thruth
147  CLHEP::HepLorentzVector tmpMom(
148  (*iPizTk).momentum().px(), (*iPizTk).momentum().py(), (*iPizTk).momentum().pz(), (*iPizTk).momentum().e());
149  CLHEP::HepLorentzVector tmpPos(
150  primVtx.position().x(), primVtx.position().y(), primVtx.position().z(), primVtx.position().t());
151  result.push_back(PizeroMCTruth(tmpMom, photonsFromPizero, tmpPos));
152 
153  } // end loop over primary pizeros
154 
155  std::cout << " Pizero size " << result.size() << std::endl;
156 
157  return result;
158 }

References funct::abs(), gather_cfg::cout, fill(), PhotonMCTruthFinder::find(), SimVertex::parentIndex(), CoreSimVertex::position(), mps_fire::result, mathSSE::sqrt(), thePhotonMCTruthFinder_, and bphysicsOniaDQM_cfi::vertex.

Referenced by MCPizeroAnalyzer::analyze().

Member Data Documentation

◆ geantToIndex_

std::map<unsigned, unsigned> PizeroMCTruthFinder::geantToIndex_
private

Definition at line 26 of file PizeroMCTruthFinder.h.

Referenced by fill().

◆ theElectronMCTruthFinder_

ElectronMCTruthFinder* PizeroMCTruthFinder::theElectronMCTruthFinder_
private

Definition at line 28 of file PizeroMCTruthFinder.h.

Referenced by PizeroMCTruthFinder(), and ~PizeroMCTruthFinder().

◆ thePhotonMCTruthFinder_

PhotonMCTruthFinder* PizeroMCTruthFinder::thePhotonMCTruthFinder_
private

Definition at line 27 of file PizeroMCTruthFinder.h.

Referenced by find(), PizeroMCTruthFinder(), and ~PizeroMCTruthFinder().

SimVertex
Definition: SimVertex.h:5
SimVertex::parentIndex
int parentIndex() const
Definition: SimVertex.h:29
PizeroMCTruthFinder::theElectronMCTruthFinder_
ElectronMCTruthFinder * theElectronMCTruthFinder_
Definition: PizeroMCTruthFinder.h:28
math::XYZTLorentzVectorD
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PizeroMCTruthFinder::geantToIndex_
std::map< unsigned, unsigned > geantToIndex_
Definition: PizeroMCTruthFinder.h:26
TrackCandidateProducer_cfi.simTracks
simTracks
Definition: TrackCandidateProducer_cfi.py:15
PhotonMCTruthFinder::find
std::vector< PhotonMCTruth > find(const std::vector< SimTrack > &simTracks, const std::vector< SimVertex > &simVertices)
Definition: PhotonMCTruthFinder.cc:17
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PhotonMCTruthFinder
Definition: PhotonMCTruthFinder.h:20
PizeroMCTruthFinder::thePhotonMCTruthFinder_
PhotonMCTruthFinder * thePhotonMCTruthFinder_
Definition: PizeroMCTruthFinder.h:27
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
CoreSimVertex::position
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
PizeroMCTruthFinder::fill
void fill(const std::vector< SimTrack > &theSimTracks, const std::vector< SimVertex > &theSimVertices)
Definition: PizeroMCTruthFinder.cc:160
mps_fire.result
result
Definition: mps_fire.py:303
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalValidator_cfi.simVertices
simVertices
Definition: HGCalValidator_cfi.py:43
PizeroMCTruth
Definition: PizeroMCTruth.h:19
ElectronMCTruthFinder
Definition: ElectronMCTruthFinder.h:13