CMS 3D CMS Logo

SimpleConvertedPhotonAnalyzer Class Reference

#include <RecoEgamma/Examples/plugins/SimpleConvertedPhotonAnalyzer.h>

Inheritance diagram for SimpleConvertedPhotonAnalyzer:

edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob (const edm::EventSetup &)
virtual void endJob ()
 SimpleConvertedPhotonAnalyzer (const edm::ParameterSet &)
virtual ~SimpleConvertedPhotonAnalyzer ()

Private Member Functions

float etaTransformation (float a, float b)

Private Attributes

std::string convertedPhotonCollection_
std::string convertedPhotonCollectionProducer_
TFile * fOutputFile_
std::string fOutputFileName_
TH2F * h2_tk_inPtVsR_
TH2F * h2_tk_nHitsVsR_
TH1F * h_deltaEta_
TH1F * h_deltaPhi_
TH1F * h_ErecoEMC_
TH1F * h_MCConvE_
TH1F * h_MCConvEta_
TH1F * h_MCConvPt_
TH1F * h_MCphoE_
TH1F * h_MCphoEta_
TH1F * h_MCphoPhi_
TH1F * h_phoE_
TH1F * h_phoEta_
TH1F * h_phoPhi_
TH1F * h_scE_
TH1F * h_scEta_
TH1F * h_scPhi_
std::string HepMCLabel
int nEvt_
int nMatched_
int nMCPho_
std::string SimHitLabel
std::string SimTkLabel
std::string SimVtxLabel
PhotonMCTruthFinderthePhotonMCTruthFinder_


Detailed Description

Definition at line 23 of file SimpleConvertedPhotonAnalyzer.h.


Constructor & Destructor Documentation

SimpleConvertedPhotonAnalyzer::SimpleConvertedPhotonAnalyzer ( const edm::ParameterSet pset  )  [explicit]

Definition at line 47 of file SimpleConvertedPhotonAnalyzer.cc.

References convertedPhotonCollection_, convertedPhotonCollectionProducer_, and edm::ParameterSet::getParameter().

00048    : fOutputFileName_( pset.getUntrackedParameter<string>("HistOutFile",std::string("TestConversions.root")) ),
00049      fOutputFile_(0)
00050 {
00051 
00052   convertedPhotonCollectionProducer_ = pset.getParameter<std::string>("phoProducer");
00053   convertedPhotonCollection_ = pset.getParameter<std::string>("convertedPhotonCollection");
00054   //
00055 
00056 
00057 }

SimpleConvertedPhotonAnalyzer::~SimpleConvertedPhotonAnalyzer (  )  [virtual]

Definition at line 61 of file SimpleConvertedPhotonAnalyzer.cc.

References thePhotonMCTruthFinder_.

00061                                                               {
00062 
00063 
00064   delete thePhotonMCTruthFinder_;
00065 
00066 }


Member Function Documentation

void SimpleConvertedPhotonAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup  
) [virtual]

Loop over recontructed photons

End loop over Reco particles

End loop over MC particles

Implements edm::EDAnalyzer.

Definition at line 156 of file SimpleConvertedPhotonAnalyzer.cc.

References convertedPhotonCollection_, convertedPhotonCollectionProducer_, GenMuonPlsPt100GeV_cfg::cout, deltaPhi(), lat::endl(), etaTransformation(), PhotonMCTruthFinder::find(), edm::Event::getByLabel(), h2_tk_inPtVsR_, h2_tk_nHitsVsR_, h_deltaEta_, h_deltaPhi_, h_ErecoEMC_, h_MCConvEta_, h_MCphoE_, h_MCphoEta_, h_MCphoPhi_, h_scE_, h_scEta_, h_scPhi_, i, edm::Event::id(), nEvt_, nMatched_, nMCPho_, Geom::pi(), funct::pow(), funct::sqrt(), thePhotonMCTruthFinder_, and Geom::twoPi().

00157 {
00158   
00159   
00160   using namespace edm;
00161   const float etaPhiDistance=0.01;
00162   // Fiducial region
00163   const float TRK_BARL =0.9;
00164   const float BARL = 1.4442; // DAQ TDR p.290
00165   const float END_LO = 1.566;
00166   const float END_HI = 2.5;
00167  // Electron mass
00168   const Float_t mElec= 0.000511;
00169 
00170 
00171   nEvt_++;  
00172   LogInfo("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n";
00173   //  LogDebug("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
00174   std::cout << "ConvertedPhotonAnalyzer Analyzing event number: "  << e.id() << " Global Counter " << nEvt_ <<"\n";
00175  
00176   
00178   Handle<reco::ConversionCollection> convertedPhotonHandle; 
00179   e.getByLabel(convertedPhotonCollectionProducer_, convertedPhotonCollection_ , convertedPhotonHandle);
00180   const reco::ConversionCollection phoCollection = *(convertedPhotonHandle.product());
00181   std::cout  << "ConvertedPhotonAnalyzer  Converted photon collection size " << phoCollection.size() << "\n";
00182 
00183 
00185   std::cout  << " ConvertedPhotonAnalyzer Looking for MC truth " << "\n";
00186   
00187   //get simtrack info
00188   std::vector<SimTrack> theSimTracks;
00189   std::vector<SimVertex> theSimVertices;
00190   
00191   edm::Handle<SimTrackContainer> SimTk;
00192   edm::Handle<SimVertexContainer> SimVtx;
00193   e.getByLabel("g4SimHits",SimTk);
00194   e.getByLabel("g4SimHits",SimVtx);
00195   
00196   theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
00197   theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end());
00198   
00199   std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks,  theSimVertices);  
00200   std::cout << " ConvertedPhotonAnalyzer mcPhotons size " <<  mcPhotons.size() << std::endl;
00201 
00202 
00203 
00204   // Loop over simulated photons
00205   int iDet=0;
00206   int iRadius=-1;
00207   int indPho=0;
00208 
00209   for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) {
00210     float mcPhi= (*mcPho).fourMomentum().phi();
00211     float mcEta= (*mcPho).fourMomentum().pseudoRapidity();
00212     mcEta = etaTransformation(mcEta, (*mcPho).primaryVertex().z() ); 
00213     
00214     if ( ! (  fabs(mcEta) <= BARL || ( fabs(mcEta) >= END_LO && fabs(mcEta) <=END_HI ) ) ) {
00215           continue;
00216     } // all ecal fiducial region
00217 
00218 
00219     std::cout << " ConvertedPhotonAnalyzer MC Photons before matching  " <<  std::endl;
00220     std::cout << " ConvertedPhotonAnalyzer Photons isAconversion " << (*mcPho).isAConversion() << " mcMatchingPhoton energy " << (*mcPho).fourMomentum().e()  << " conversion vertex R " << (*mcPho).vertex().perp() << " Z " <<  (*mcPho).vertex().z() <<  " x " << (*mcPho).vertex().x() << " y " <<(*mcPho).vertex().y()  << " z " << (*mcPho).vertex().z() <<  std::endl;
00221     std::cout << " ConvertedPhotonAnalyzer mcEta " << mcEta<< " mcPhi " << mcPhi <<  std::endl;
00222     
00223 
00224     h_MCphoE_->Fill(  (*mcPho).fourMomentum().e());
00225     h_MCphoEta_->Fill( (*mcPho).fourMomentum().eta());
00226     h_MCphoPhi_->Fill(  (*mcPho).fourMomentum().phi());
00227     
00228     
00229     
00230     // keep only visible conversions
00231     if (  (*mcPho).isAConversion() == 0 ) continue;
00232 
00233     
00234     nMCPho_++;
00235 
00236     h_MCConvEta_ ->Fill ( fabs( (*mcPho).fourMomentum().pseudoRapidity()) - 0.001);
00237     
00238     
00239     bool REJECTED;
00240 
00241 
00243     std::cout   << " ConvertedPhotonAnalyzer  Starting loop over photon candidates " << "\n";
00244     for( reco::ConversionCollection::const_iterator  iPho = phoCollection.begin(); iPho != phoCollection.end(); iPho++) {
00245       REJECTED=false;
00246       
00247       std::cout  << " ConvertedPhotonAnalyzer Reco SC energy " << (*iPho).caloCluster()[0]->energy() <<  "\n";
00248 
00249 
00250       
00251       float phiClu=(*iPho).caloCluster()[0]->phi();
00252       float etaClu=(*iPho).caloCluster()[0]->eta();
00253       float deltaPhi = phiClu-mcPhi;
00254       float deltaEta = etaClu-mcEta;
00255       
00256       
00257       if ( deltaPhi > Geom::pi()  ) deltaPhi -= Geom::twoPi();
00258       if ( deltaPhi < -Geom::pi() ) deltaPhi += Geom::twoPi();
00259       deltaPhi=pow(deltaPhi,2);
00260       deltaEta=pow(deltaEta,2);
00261       float delta =  deltaPhi+deltaEta ; 
00262       if (  delta >= etaPhiDistance  )  REJECTED=true;
00263       
00264 
00265       //      if ( ! (  fabs(etaClu) <= BARL || ( fabs(etaClu) >= END_LO && fabs(etaClu) <=END_HI ) ) ) REJECTED=true;
00266       
00267       if ( REJECTED ) continue;
00268       std::cout << " MATCHED " << std::endl;
00269       nMatched_++;
00270 
00271 
00272       std::cout << " ConvertedPhotonAnalyzer Matching candidate " << std::endl;
00273       
00274       std::cout << " ConvertedPhotonAnalyzer Photons isAconversion " << (*mcPho).isAConversion() << " mcMatchingPhoton energy " <<  (*mcPho).fourMomentum().e()  << " ConvertedPhotonAnalyzer conversion vertex R " <<  (*mcPho).vertex().perp() << " Z " <<  (*mcPho).vertex().z() <<  std::endl;
00275       
00276   
00277       h_ErecoEMC_->Fill(   (*iPho).caloCluster()[0]->energy()/(*mcPho).fourMomentum().e());
00278       h_deltaPhi_-> Fill ( (*iPho).caloCluster()[0]->position().phi()- mcPhi);
00279       h_deltaEta_-> Fill ( (*iPho).caloCluster()[0]->position().eta()- mcEta);
00280       
00281       h_scE_->Fill( (*iPho).caloCluster()[0]->energy() );
00282       h_scEta_->Fill( (*iPho).caloCluster()[0]->position().eta() );
00283       h_scPhi_->Fill( (*iPho).caloCluster()[0]->position().phi() );
00284       
00285       
00286       for (unsigned int i=0; i<(*iPho).tracks().size(); i++) {
00287         std::cout  << " ConvertedPhotonAnalyzer Reco Track charge " <<  (*iPho).tracks()[i]->charge() << "  Num of RecHits " << (*iPho).tracks()[i]->recHitsSize() << " inner momentum " <<  sqrt (  (*iPho).tracks()[i]->innerMomentum().Mag2() )  <<  "\n"; 
00288         
00289         
00290         h2_tk_nHitsVsR_ -> Fill (  (*mcPho).vertex().perp(), (*iPho).tracks()[i]->recHitsSize()   );
00291         h2_tk_inPtVsR_->Fill  (  (*mcPho).vertex().perp(),  sqrt( (*iPho).tracks()[i]->innerMomentum().Mag2() ) );
00292 
00293         
00294       }
00295       
00296       
00297 
00298 
00299 
00300 
00301 
00302 
00303       
00304     }   
00305 
00306   }
00307   
00308 
00309 }

void SimpleConvertedPhotonAnalyzer::beginJob ( const edm::EventSetup setup  )  [virtual]

Reco - MC

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file SimpleConvertedPhotonAnalyzer.cc.

References fOutputFile_, fOutputFileName_, h2_tk_inPtVsR_, h2_tk_nHitsVsR_, h_deltaEta_, h_deltaPhi_, h_ErecoEMC_, h_MCConvE_, h_MCConvEta_, h_MCConvPt_, h_MCphoE_, h_MCphoEta_, h_MCphoPhi_, h_phoE_, h_phoEta_, h_phoPhi_, h_scE_, h_scEta_, h_scPhi_, nEvt_, nMatched_, nMCPho_, and thePhotonMCTruthFinder_.

00070 {
00071 
00072 
00073   nEvt_=0;
00074   nMCPho_=0;
00075   nMatched_=0;
00076 
00077 
00078   thePhotonMCTruthFinder_ = new PhotonMCTruthFinder();
00079 
00080   fOutputFile_   = new TFile( fOutputFileName_.c_str(), "RECREATE" ) ;
00081 
00083   h_ErecoEMC_  = new TH1F("deltaE","    delta(reco-mc) energy",100,0.,2.);
00084   h_deltaPhi_ = new TH1F("deltaPhi","  delta(reco-mc) phi",100,-0.1, 0.1);
00085   h_deltaEta_ = new TH1F("deltaEta","  delta(reco-mc) eta",100,-0.05, 0.05);
00086   
00088   h_MCphoE_ = new TH1F("MCphoE","MC photon energy",100,0.,100.);
00089   h_MCphoPhi_ = new TH1F("MCphoPhi","MC photon phi",40,-3.14, 3.14);
00090   h_MCphoEta_ = new TH1F("MCphoEta","MC photon eta",40,-3., 3.);
00091 
00092 
00094   h_MCConvE_ = new TH1F("MCConvE","MC converted photon energy",100,0.,100.);
00095   h_MCConvPt_ = new TH1F("MCConvPt","MC converted photon pt",100,0.,100.);
00096   h_MCConvEta_ = new TH1F("MCConvEta","MC converted photon eta",50, 0., 2.5);
00097 
00099   h_scE_ = new TH1F("scE","Uncorrected converted photons : SC Energy ",100,0., 200.);
00100   h_scEta_ = new TH1F("scEta","Uncorrected converted photons:  SC Eta ",40,-3., 3.);
00101   h_scPhi_ = new TH1F("scPhi","Uncorrected converted photons: SC Phi ",40, -3.14, 3.14);
00102   //
00103   h_phoE_ = new TH1F("phoE","Uncorrected converted photons :  Energy ",100,0., 200.);
00104   h_phoEta_ = new TH1F("phoEta","Uncorrected converted photons:   Eta ",40,-3., 3.);
00105   h_phoPhi_ = new TH1F("phoPhi","Uncorrected converted photons:  Phi ",40,  -3.14, 3.14);
00106 
00107   // Recontructed tracks from converted photon candidates
00108   h2_tk_nHitsVsR_ = new TH2F("tknHitsVsR","Tracks Hits vs R  ", 12,0.,120.,20,0.5, 20.5);
00109   h2_tk_inPtVsR_ = new TH2F("tkInPtvsR","Tracks inner Pt vs R  ", 12,0.,120.,100,0., 100.);
00110 
00111   
00112   return ;
00113 }

void SimpleConvertedPhotonAnalyzer::endJob ( void   )  [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 314 of file SimpleConvertedPhotonAnalyzer.cc.

References GenMuonPlsPt100GeV_cfg::cout, fOutputFile_, and nEvt_.

00315 {
00316 
00317 
00318 
00319        
00320    fOutputFile_->Write() ;
00321    fOutputFile_->Close() ;
00322   
00323    edm::LogInfo("ConvertedPhotonAnalyzer") << "Analyzed " << nEvt_  << "\n";
00324    // std::cout  << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n";
00325    std::cout  << "ConvertedPhotonAnalyzer::endJob Analyzed " << nEvt_ << " events " << "\n";
00326    
00327    return ;
00328 }

float SimpleConvertedPhotonAnalyzer::etaTransformation ( float  a,
float  b 
) [private]

Definition at line 116 of file SimpleConvertedPhotonAnalyzer.cc.

References ETA, etaBarrelEndcap, funct::log(), PI, R_ECAL, funct::tan(), TWOPI, and Z_Endcap.

Referenced by analyze().

00116                                                                                            {
00117 
00118 //---Definitions
00119         const float PI    = 3.1415927;
00120         const float TWOPI = 2.0*PI;
00121 
00122 //---Definitions for ECAL
00123         const float R_ECAL           = 136.5;
00124         const float Z_Endcap         = 328.0;
00125         const float etaBarrelEndcap  = 1.479; 
00126    
00127 //---ETA correction
00128 
00129         float Theta = 0.0  ; 
00130         float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex;
00131 
00132         if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
00133         if(Theta<0.0) Theta = Theta+PI ;
00134         float ETA = - log(tan(0.5*Theta));
00135          
00136         if( fabs(ETA) > etaBarrelEndcap )
00137           {
00138            float Zend = Z_Endcap ;
00139            if(EtaParticle<0.0 )  Zend = -Zend ;
00140            float Zlen = Zend - Zvertex ;
00141            float RR = Zlen/sinh(EtaParticle); 
00142            Theta = atan(RR/Zend);
00143            if(Theta<0.0) Theta = Theta+PI ;
00144            ETA = - log(tan(0.5*Theta));               
00145           } 
00146 //---Return the result
00147         return ETA;
00148 //---end
00149 }


Member Data Documentation

std::string SimpleConvertedPhotonAnalyzer::convertedPhotonCollection_ [private]

Definition at line 60 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and SimpleConvertedPhotonAnalyzer().

std::string SimpleConvertedPhotonAnalyzer::convertedPhotonCollectionProducer_ [private]

Definition at line 59 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and SimpleConvertedPhotonAnalyzer().

TFile* SimpleConvertedPhotonAnalyzer::fOutputFile_ [private]

Definition at line 46 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob(), and endJob().

std::string SimpleConvertedPhotonAnalyzer::fOutputFileName_ [private]

Definition at line 45 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH2F* SimpleConvertedPhotonAnalyzer::h2_tk_inPtVsR_ [private]

Definition at line 92 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH2F* SimpleConvertedPhotonAnalyzer::h2_tk_nHitsVsR_ [private]

Definition at line 90 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_deltaEta_ [private]

Definition at line 64 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_deltaPhi_ [private]

Definition at line 63 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_ErecoEMC_ [private]

Definition at line 62 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvE_ [private]

Definition at line 75 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvEta_ [private]

Definition at line 77 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCConvPt_ [private]

Definition at line 76 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoE_ [private]

Definition at line 68 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoEta_ [private]

Definition at line 70 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_MCphoPhi_ [private]

Definition at line 69 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoE_ [private]

Definition at line 85 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoEta_ [private]

Definition at line 86 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_phoPhi_ [private]

Definition at line 87 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scE_ [private]

Definition at line 81 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scEta_ [private]

Definition at line 82 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

TH1F* SimpleConvertedPhotonAnalyzer::h_scPhi_ [private]

Definition at line 83 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

std::string SimpleConvertedPhotonAnalyzer::HepMCLabel [private]

Definition at line 53 of file SimpleConvertedPhotonAnalyzer.h.

int SimpleConvertedPhotonAnalyzer::nEvt_ [private]

Definition at line 49 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), beginJob(), and endJob().

int SimpleConvertedPhotonAnalyzer::nMatched_ [private]

Definition at line 51 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

int SimpleConvertedPhotonAnalyzer::nMCPho_ [private]

Definition at line 50 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), and beginJob().

std::string SimpleConvertedPhotonAnalyzer::SimHitLabel [private]

Definition at line 56 of file SimpleConvertedPhotonAnalyzer.h.

std::string SimpleConvertedPhotonAnalyzer::SimTkLabel [private]

Definition at line 54 of file SimpleConvertedPhotonAnalyzer.h.

std::string SimpleConvertedPhotonAnalyzer::SimVtxLabel [private]

Definition at line 55 of file SimpleConvertedPhotonAnalyzer.h.

PhotonMCTruthFinder* SimpleConvertedPhotonAnalyzer::thePhotonMCTruthFinder_ [private]

Definition at line 43 of file SimpleConvertedPhotonAnalyzer.h.

Referenced by analyze(), beginJob(), and ~SimpleConvertedPhotonAnalyzer().


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