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 Member Functions | Private Attributes
PizeroMCTruthFinder Class Reference

#include <PizeroMCTruthFinder.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 16 of file PizeroMCTruthFinder.h.

Constructor & Destructor Documentation

PizeroMCTruthFinder::PizeroMCTruthFinder ( )
PizeroMCTruthFinder::~PizeroMCTruthFinder ( )
virtual

Definition at line 16 of file PizeroMCTruthFinder.cc.

References gather_cfg::cout, theElectronMCTruthFinder_, and thePhotonMCTruthFinder_.

17 {
18 
21  std::cout << "~PizeroMCTruthFinder" << std::endl;
22 }
PhotonMCTruthFinder * thePhotonMCTruthFinder_
ElectronMCTruthFinder * theElectronMCTruthFinder_
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

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

Definition at line 179 of file PizeroMCTruthFinder.cc.

References gather_cfg::cout, and geantToIndex_.

Referenced by find().

180  {
181 
182 
183 unsigned nVtx = simVertices.size();
184 unsigned nTks = simTracks.size();
185 
186 // Empty event, do nothin'
187 if ( nVtx == 0 ) return;
188 
189 // create a map associating geant particle id and position in the
190 // event SimTrack vector
191 for( unsigned it=0; it<nTks; ++it ) {
192 geantToIndex_[ simTracks[it].trackId() ] = it;
193 std::cout << " PizeroMCTruthFinder::fill it " << it << " simTracks[it].trackId() " << simTracks[it].trackId() << std::endl;
194 
195 }
196 
197 
198 }
std::map< unsigned, unsigned > geantToIndex_
tuple cout
Definition: gather_cfg.py:121
std::vector< PizeroMCTruth > PizeroMCTruthFinder::find ( std::vector< SimTrack simTracks,
std::vector< SimVertex simVertices 
)

Definition at line 24 of file PizeroMCTruthFinder.cc.

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

Referenced by BeautifulSoup.Tag::_invert(), MCPizeroAnalyzer::analyze(), and BeautifulSoup.PageElement::insert().

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

Member Data Documentation

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

Definition at line 30 of file PizeroMCTruthFinder.h.

Referenced by fill().

ElectronMCTruthFinder* PizeroMCTruthFinder::theElectronMCTruthFinder_
private

Definition at line 32 of file PizeroMCTruthFinder.h.

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

PhotonMCTruthFinder* PizeroMCTruthFinder::thePhotonMCTruthFinder_
private

Definition at line 31 of file PizeroMCTruthFinder.h.

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