23 std::vector<PhotonMCTruth>
result;
32 const int ELECTRON_FLAV=1;
33 const int PIZERO_FLAV=2;
34 const int PHOTON_FLAV=3;
40 std::vector<SimTrack*> photonTracks;
42 std::vector<SimTrack> trkFromConversion;
43 std::vector<ElectronMCTruth> electronsFromConversions;
47 fill(theSimTracks, theSimVertices);
50 if ( theSimTracks.size() != 0 ) {
55 std::vector<SimTrack>::iterator iFirstSimTk = theSimTracks.begin();
56 if ( !(*iFirstSimTk).noVertex() ) {
57 iPV = (*iFirstSimTk).vertIndex();
59 int vtxId = (*iFirstSimTk).vertIndex();
60 primVtx = theSimVertices[vtxId];
64 partType1 = (*iFirstSimTk).type();
81 if ( iFirstSimTk!= theSimTracks.end() ) {
83 if ( (*iFirstSimTk).vertIndex() == iPV) {
84 partType2 = (*iFirstSimTk).type();
98 for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk){
99 if ( (*iSimTk).noVertex() )
continue;
102 int vertexId = (*iSimTk).vertIndex();
103 SimVertex vertex = theSimVertices[vertexId];
106 if ( (*iSimTk).vertIndex() == iPV ) {
108 if ( (*iSimTk).type() == 22) {
112 photonTracks.push_back( &(*iSimTk) );
124 }
else if(npv == 1) {
126 ievtype = SINGLE; ievflav = ELECTRON_FLAV;
127 }
else if(partType1 == 111) {
128 ievtype = SINGLE; ievflav = PIZERO_FLAV;
129 }
else if(partType1 == 22) {
130 ievtype = SINGLE; ievflav = PHOTON_FLAV;
132 }
else if(npv == 2) {
134 ievtype = DOUBLE; ievflav = ELECTRON_FLAV;
135 }
else if(partType1 == 111 && partType2 == 111) {
136 ievtype = DOUBLE; ievflav = PIZERO_FLAV;
137 }
else if(partType1 == 22 && partType2 == 22) {
138 ievtype = DOUBLE; ievflav = PHOTON_FLAV;
145 int phoMotherType=-1;
146 int phoMotherVtxIndex=-1;
148 if( ievflav == PHOTON_FLAV || ievflav== PIZERO_FLAV || ievtype == PYTHIA ) {
156 for (std::vector<SimTrack>::iterator iPhoTk = theSimTracks.begin(); iPhoTk != theSimTracks.end(); ++iPhoTk){
158 trkFromConversion.clear();
159 electronsFromConversions.clear();
161 if ( (*iPhoTk).type() != 22 )
continue;
162 int photonVertexIndex= (*iPhoTk).vertIndex();
163 int phoTrkId= (*iPhoTk).trackId();
167 SimVertex vertex = theSimVertices[ photonVertexIndex];
172 std::map<unsigned, unsigned >::iterator association =
geantToIndex_.find( motherGeantId );
174 phoMotherId = association->second;
175 phoMotherType = phoMotherId == -1 ? 0 : theSimTracks[phoMotherId].type();
179 if ( phoMotherType == 111 || phoMotherType == 221 || phoMotherType == 331 ) {
189 for (std::vector<SimTrack>::iterator iEleTk = theSimTracks.begin(); iEleTk != theSimTracks.end(); ++iEleTk){
190 if ( (*iEleTk).noVertex() )
continue;
191 if ( (*iEleTk).vertIndex() == iPV )
continue;
192 if (
std::abs((*iEleTk).type()) != 11 )
continue;
194 int vertexId = (*iEleTk).vertIndex();
195 SimVertex vertex = theSimVertices[vertexId];
203 std::map<unsigned, unsigned >::iterator association =
geantToIndex_.find( motherGeantId );
205 motherId = association->second;
212 std::vector<CLHEP::Hep3Vector> bremPos;
213 std::vector<CLHEP::HepLorentzVector> pBrem;
214 std::vector<float> xBrem;
216 if ( theSimTracks[motherId].trackId() == (*iPhoTk).trackId() ) {
222 trkFromConversion.push_back( (*iEleTk ) );
224 float remainingEnergy =trLast.
momentum().e();
228 (*iEleTk).momentum().y(),
229 (*iEleTk).momentum().z(),
230 (*iEleTk).momentum().e());
232 unsigned int eleId = (*iEleTk).trackId();
233 int eleVtxIndex= (*iEleTk).vertIndex();
240 for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk){
242 if ( (*iSimTk).noVertex() )
continue;
243 if ( (*iSimTk).vertIndex() == iPV )
continue;
247 int vertexId1 = (*iSimTk).vertIndex();
248 SimVertex vertex1 = theSimVertices[vertexId1];
250 SimVertex vertex2 = theSimVertices[vertexId2];
255 if( ( vertexId1 == vertexId2 ) && ( (*iSimTk).type() == (*iEleTk).type() ) && trLast.
type() == 22 ) {
264 float eLoss = remainingEnergy - ( (*iSimTk).momentum() + trLast.
momentum()).
e();
271 std::map<unsigned, unsigned >::iterator association =
geantToIndex_.find( motherGeantId );
273 motherId = association->second;
277 if (theSimTracks[motherId].trackId() == eleId ) {
280 eleId= (*iSimTk).trackId();
281 remainingEnergy = (*iSimTk).momentum().e();
282 motherMomentum = (*iSimTk).momentum();
285 pBrem.push_back( CLHEP::HepLorentzVector(trLast.
momentum().px(),
289 bremPos.push_back( CLHEP::HepLorentzVector(vertex1.
position().x(),
293 xBrem.push_back(eLoss);
311 CLHEP::HepLorentzVector tmpEleMom(primEleMom.px(),primEleMom.py(),
312 primEleMom.pz(),primEleMom.e() );
313 CLHEP::HepLorentzVector tmpVtxPos(primVtxPos.x(),primVtxPos.y(),
314 primVtxPos.z(),primVtxPos.t() );
315 electronsFromConversions.push_back (
317 xBrem, tmpVtxPos , (*iEleTk) ) ) ;
333 CLHEP::HepLorentzVector phoMotherMom(0.,0.,0.,0.);
334 CLHEP::HepLorentzVector phoMotherVtx(0.,0.,0.,0.);
336 if ( phoMotherId >= 0) {
338 phoMotherVtxIndex = theSimTracks[phoMotherId].vertIndex();
339 SimVertex motherVtx = theSimVertices[ phoMotherVtxIndex];
345 phoMotherMom.setPx( theSimTracks[phoMotherId].momentum().
x());
346 phoMotherMom.setPy( theSimTracks[phoMotherId].momentum().
y());
347 phoMotherMom.setPz( theSimTracks[phoMotherId].momentum().
z() );
348 phoMotherMom.setE( theSimTracks[phoMotherId].momentum().
t());
351 phoMotherVtx.setX ( motherVtxPosition.x());
352 phoMotherVtx.setY ( motherVtxPosition.y());
353 phoMotherVtx.setZ ( motherVtxPosition.z());
354 phoMotherVtx.setT ( motherVtxPosition.t());
359 if ( electronsFromConversions.size() > 0 ) {
365 int convVtxId =electronsFromConversions[0].vertexInd();
366 SimVertex convVtx = theSimVertices[convVtxId];
375 CLHEP::HepLorentzVector tmpPhoMom( (*iPhoTk).momentum().px(), (*iPhoTk).momentum().py(),
376 (*iPhoTk).momentum().pz(), (*iPhoTk).momentum().e() ) ;
377 CLHEP::HepLorentzVector tmpVertex( vtxPosition.x(), vtxPosition.y(), vtxPosition.z(), vtxPosition.t() );
378 CLHEP::HepLorentzVector tmpPrimVtx( primVtxPos.x(), primVtxPos.y(), primVtxPos.z(), primVtxPos.t() ) ;
382 result.push_back(
PhotonMCTruth(isAconversion, tmpPhoMom, photonVertexIndex, phoTrkId, phoMotherType,phoMotherMom, phoMotherVtx, tmpVertex,
383 tmpPrimVtx, electronsFromConversions ));
388 CLHEP::HepLorentzVector vtxPosition(0.,0.,0.,0.);
389 CLHEP::HepLorentzVector tmpPhoMom( (*iPhoTk).momentum().px(), (*iPhoTk).momentum().py(),
390 (*iPhoTk).momentum().pz(), (*iPhoTk).momentum().e() ) ;
391 CLHEP::HepLorentzVector tmpPrimVtx( primVtxPos.x(), primVtxPos.y(), primVtxPos.z(), primVtxPos.t() ) ;
393 result.push_back(
PhotonMCTruth(isAconversion, tmpPhoMom, photonVertexIndex, phoTrkId, phoMotherType, phoMotherMom, phoMotherVtx, vtxPosition,
394 tmpPrimVtx, electronsFromConversions ));
420 unsigned nVtx = simVertices.size();
421 unsigned nTks = simTracks.size();
426 if ( nVtx == 0 )
return;
430 for(
unsigned it=0; it<nTks; ++it ) {
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
void fill(std::vector< SimTrack > &theSimTracks, std::vector< SimVertex > &theSimVertices)
std::map< unsigned, unsigned > geantToIndex_
const math::XYZTLorentzVectorD & position() const
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
std::vector< PhotonMCTruth > find(std::vector< SimTrack > simTracks, std::vector< SimVertex > simVertices)
int type() const
particle type (HEP PDT convension)
const math::XYZTLorentzVectorD & momentum() const
particle info...
perl if(1 lt scalar(@::datatypes))