CMS 3D CMS Logo

PizeroMCTruthFinder Class Reference

#include <RecoEgamma/EgammaMCTools/interface/PizeroMCTruthFinder.h>

List of all members.

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

Definition at line 8 of file PizeroMCTruthFinder.cc.

References theElectronMCTruthFinder_, and thePhotonMCTruthFinder_.

00008                                          {
00009 
00010   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
00011   theElectronMCTruthFinder_ = new ElectronMCTruthFinder();
00012 
00013 
00014 }

PizeroMCTruthFinder::~PizeroMCTruthFinder (  )  [virtual]

Definition at line 16 of file PizeroMCTruthFinder.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), theElectronMCTruthFinder_, and thePhotonMCTruthFinder_.

00017 {
00018 
00019   delete thePhotonMCTruthFinder_;
00020   delete theElectronMCTruthFinder_;
00021   std::cout << "~PizeroMCTruthFinder" << std::endl;
00022 }


Member Function Documentation

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

Definition at line 179 of file PizeroMCTruthFinder.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), geantToIndex_, and it.

Referenced by find().

00180                                       {
00181 
00182 
00183 unsigned nVtx = simVertices.size();
00184 unsigned nTks = simTracks.size();
00185 
00186 // Empty event, do nothin'
00187 if ( nVtx == 0 ) return;
00188 
00189 // create a map associating geant particle id and position in the 
00190 // event SimTrack vector
00191 for( unsigned it=0; it<nTks; ++it ) {
00192 geantToIndex_[ simTracks[it].trackId() ] = it;
00193 std::cout << " PizeroMCTruthFinder::fill it " << it << " simTracks[it].trackId() " <<  simTracks[it].trackId() << std::endl;
00194  
00195 }  
00196 
00197 
00198 }

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

Definition at line 24 of file PizeroMCTruthFinder.cc.

References funct::abs(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), fill(), PhotonMCTruthFinder::find(), SimVertex::parentIndex(), CoreSimVertex::position(), HLT_VtxMuL3::result, funct::sqrt(), and thePhotonMCTruthFinder_.

Referenced by MCPizeroAnalyzer::analyze().

00024                                                                                                                          {
00025   std::cout << "  PizeroMCTruthFinder::find " << std::endl;
00026 
00027   
00028   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);  
00029 
00030   std::vector<PizeroMCTruth> result;
00031   std::vector<PhotonMCTruth> photonsFromPizero;
00032   std::vector<ElectronMCTruth> electronsFromPizero;
00033 
00034   // Local variables  
00035   const int SINGLE=1;
00036   const int DOUBLE=2;
00037   const int PYTHIA=3;
00038   const int ELECTRON_FLAV=1;
00039   const int PIZERO_FLAV=2;
00040   const int PHOTON_FLAV=3;
00041   
00042   int ievtype=0;
00043   int ievflav=0;
00044   
00045   std::vector<SimTrack> pizeroTracks;
00046   SimVertex primVtx;   
00047   
00048     
00049   fill(theSimTracks,  theSimVertices);
00050   
00051   int iPV=-1;   
00052   int partType1=0;
00053   int partType2=0;
00054   std::vector<SimTrack>::iterator iFirstSimTk = theSimTracks.begin();
00055   if (  !(*iFirstSimTk).noVertex() ) {
00056     iPV =  (*iFirstSimTk).vertIndex();
00057     
00058     int vtxId =   (*iFirstSimTk).vertIndex();
00059     primVtx = theSimVertices[vtxId];
00060     
00061     partType1 = (*iFirstSimTk).type();
00062     std::cout <<  " Primary vertex id " << iPV << " first track type " << (*iFirstSimTk).type() << std::endl;  
00063   } else {
00064     std::cout << " First track has no vertex " << std::endl;
00065   }
00066   
00067   // HepLorentzVector primVtxPos= primVtx.position(); 
00068   math::XYZTLorentzVectorD primVtxPos(primVtx.position().x(),
00069                                       primVtx.position().y(),
00070                                       primVtx.position().z(),
00071                                       primVtx.position().e());          
00072 
00073   // Look at a second track
00074   iFirstSimTk++;
00075   if ( iFirstSimTk!=  theSimTracks.end() ) {
00076     
00077     if (  (*iFirstSimTk).vertIndex() == iPV) {
00078       partType2 = (*iFirstSimTk).type();  
00079       std::cout <<  " second track type " << (*iFirstSimTk).type() << " vertex " <<  (*iFirstSimTk).vertIndex() << std::endl;  
00080       
00081     } else {
00082       std::cout << " Only one kine track from Primary Vertex " << std::endl;
00083     }
00084   }
00085   
00086   int npv=0;
00087   
00088   for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk){
00089     if (  (*iSimTk).noVertex() ) continue;
00090 
00091     int vertexId = (*iSimTk).vertIndex();
00092     SimVertex vertex = theSimVertices[vertexId];
00093  
00094     std::cout << " Particle type " <<  (*iSimTk).type() << " Sim Track ID " << (*iSimTk).trackId() << " momentum " << (*iSimTk).momentum() <<  " vertex position " << vertex.position() << std::endl;  
00095 
00096     if ( (*iSimTk).vertIndex() == iPV ) {
00097       npv++;
00098       if ( fabs((*iSimTk).type() ) == 111) {
00099 
00100         std::cout << " Found a primary pizero with ID  " << (*iSimTk).trackId() << " momentum " << (*iSimTk).momentum() <<  std::endl;
00101         
00102         pizeroTracks.push_back( *iSimTk );
00103 
00104         // CLHEP::HepLorentzVector momentum = (*iSimTk).momentum();
00105         math::XYZTLorentzVectorD momentum((*iSimTk).momentum().x(),
00106                                       (*iSimTk).momentum().y(),
00107                                       (*iSimTk).momentum().z(),
00108                                       (*iSimTk).momentum().e());
00109 
00110 
00111       } 
00112     }
00113   }
00114  
00115   
00116   std::cout << " There are " << npv << " particles originating in the PV " << std::endl;
00117   
00118   if(npv > 4) {
00119     ievtype = PYTHIA;
00120   } else if(npv == 1) {
00121     if( abs(partType1) == 11 ) {
00122       ievtype = SINGLE; ievflav = ELECTRON_FLAV;
00123     } else if(partType1 == 111) {
00124       ievtype = SINGLE; ievflav = PIZERO_FLAV;
00125     } else if(partType1 == 22) {
00126       ievtype = SINGLE; ievflav = PHOTON_FLAV;
00127     }
00128   } else if(npv == 2) {
00129     if (  abs(partType1) == 11 && abs(partType2) == 11 ) {
00130       ievtype = DOUBLE; ievflav = ELECTRON_FLAV;
00131     } else if(partType1 == 111 && partType2 == 111)   {
00132       ievtype = DOUBLE; ievflav = PIZERO_FLAV;
00133     } else if(partType1 == 22 && partType2 == 22)   {
00134       ievtype = DOUBLE; ievflav = PHOTON_FLAV;
00135     }
00136   }
00137 
00138 
00139   
00140   for (std::vector<SimTrack>::iterator iPizTk = pizeroTracks.begin(); iPizTk != pizeroTracks.end(); ++iPizTk){
00141     std::cout << " Looping on the primary pizero pt  " << sqrt((*iPizTk).momentum().perp2()) << " pizero track ID " << (*iPizTk).trackId() << std::endl;
00142     
00143     photonsFromPizero.clear();
00144     std::cout << " mcPhotons.size " << mcPhotons.size() << std::endl;
00145     for ( std::vector<PhotonMCTruth>::iterator iPho=mcPhotons.begin(); iPho !=mcPhotons.end(); ++iPho ){
00146       int phoVtxIndex = (*iPho).vertexInd();
00147       SimVertex phoVtx = theSimVertices[phoVtxIndex];
00148       int phoParentInd= phoVtx.parentIndex();
00149       std::cout << " photon parent vertex index " << phoParentInd << std::endl;
00150       
00151       if ( phoParentInd  ==  (*iPizTk).trackId() )  {
00152         std::cout << "Matched Photon ID " << (*iPho).trackId() << "  vtx " << phoParentInd << " with pizero " << (*iPizTk).trackId() << std::endl;
00153         photonsFromPizero.push_back( *iPho);
00154         
00155       }
00156     }
00157     std::cout << " Photon matching the pizero vertex " << photonsFromPizero.size() <<std::endl;
00158     
00159     
00160     // build pizero MC thruth
00161     HepLorentzVector tmpMom( (*iPizTk).momentum().px(), (*iPizTk).momentum().py(),
00162                              (*iPizTk).momentum().pz(), (*iPizTk).momentum().e() ) ;
00163     HepLorentzVector tmpPos( primVtx.position().x(), primVtx.position().y(),
00164                              primVtx.position().z(), primVtx.position().t() ) ;
00165     result.push_back( PizeroMCTruth (  tmpMom, photonsFromPizero, tmpPos ) );
00166     
00167     
00168   }   // end loop over primary pizeros
00169 
00170     
00171   std::cout << " Pizero size " << result.size() <<  std::endl;
00172   
00173   
00174   return result;
00175 }


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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:09 2009 for CMSSW by  doxygen 1.5.4