#include <PhotonsWithConversionsAnalyzer.h>
Public Member Functions | |
virtual void | analyze (const edm::Event &, const edm::EventSetup &) |
virtual void | beginJob () |
virtual void | endJob () |
PhotonsWithConversionsAnalyzer (const edm::ParameterSet &) | |
virtual | ~PhotonsWithConversionsAnalyzer () |
Private Member Functions | |
float | etaTransformation (float a, float b) |
Private Attributes | |
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_scEt_ |
TH1F * | h_scEta_ |
TH1F * | h_scPhi_ |
std::string | HepMCLabel |
int | nEvt_ |
int | nMatched_ |
int | nMCPho_ |
std::string | photonCollection_ |
std::string | photonCollectionProducer_ |
std::string | SimHitLabel |
std::string | SimTkLabel |
std::string | SimVtxLabel |
PhotonMCTruthFinder * | thePhotonMCTruthFinder_ |
Definition at line 23 of file PhotonsWithConversionsAnalyzer.h.
PhotonsWithConversionsAnalyzer::PhotonsWithConversionsAnalyzer | ( | const edm::ParameterSet & | pset | ) | [explicit] |
Definition at line 51 of file PhotonsWithConversionsAnalyzer.cc.
References edm::ParameterSet::getParameter().
{ photonCollectionProducer_ = pset.getParameter<std::string>("phoProducer"); photonCollection_ = pset.getParameter<std::string>("photonCollection"); // }
PhotonsWithConversionsAnalyzer::~PhotonsWithConversionsAnalyzer | ( | ) | [virtual] |
Definition at line 63 of file PhotonsWithConversionsAnalyzer.cc.
{ delete thePhotonMCTruthFinder_; }
void PhotonsWithConversionsAnalyzer::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 162 of file PhotonsWithConversionsAnalyzer.cc.
References conversions_cfi::conversions, gather_cfg::cout, delta, HLTFastRecoForTau_cff::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, HcalObjRepresent::Fill(), edm::Event::getByLabel(), i, edm::EventBase::id(), Geom::pi(), funct::pow(), edm::RefVector< C, T, F >::size(), mathSSE::sqrt(), testEve_cfg::tracks, and Geom::twoPi().
{ using namespace edm; const float etaPhiDistance=0.01; // Fiducial region //UNUSED const float TRK_BARL =0.9; //UNUSED const float BARL = 1.4442; // DAQ TDR p.290 //UNUSED const float END_LO = 1.566; //UNUSED const float END_HI = 2.5; // Electron mass //UNUSED const Float_t mElec= 0.000511; nEvt_++; LogInfo("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n"; // LogDebug("ConvertedPhotonAnalyzer") << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n"; std::cout << "ConvertedPhotonAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_ <<"\n"; Handle<reco::PhotonCollection> photonHandle; e.getByLabel(photonCollectionProducer_, photonCollection_ , photonHandle); const reco::PhotonCollection photonCollection = *(photonHandle.product()); std::cout << "ConvertedPhotonAnalyzer Photons with conversions collection size " << photonCollection.size() << "\n"; std::cout << " ConvertedPhotonAnalyzer Looking for MC truth " << "\n"; //get simtrack info std::vector<SimTrack> theSimTracks; std::vector<SimVertex> theSimVertices; edm::Handle<SimTrackContainer> SimTk; edm::Handle<SimVertexContainer> SimVtx; e.getByLabel("g4SimHits",SimTk); e.getByLabel("g4SimHits",SimVtx); theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end()); theSimVertices.insert(theSimVertices.end(),SimVtx->begin(),SimVtx->end()); std::vector<PhotonMCTruth> mcPhotons=thePhotonMCTruthFinder_->find (theSimTracks, theSimVertices); std::cout << " ConvertedPhotonAnalyzer mcPhotons size " << mcPhotons.size() << std::endl; // Loop over simulated photons //UNUSED int iDet=0; //UNUSED int iRadius=-1; //UNUSED int indPho=0; for ( std::vector<PhotonMCTruth>::const_iterator mcPho=mcPhotons.begin(); mcPho !=mcPhotons.end(); mcPho++) { float mcPhi= (*mcPho).fourMomentum().phi(); float mcEta= (*mcPho).fourMomentum().pseudoRapidity(); mcEta = etaTransformation(mcEta, (*mcPho).primaryVertex().z() ); if ( (*mcPho).fourMomentum().et() < 20 ) continue; // if ( ! ( fabs(mcEta) <= BARL || ( fabs(mcEta) >= END_LO && fabs(mcEta) <=END_HI ) ) ) { // continue; //} // all ecal fiducial region h_MCphoE_->Fill( (*mcPho).fourMomentum().e()); h_MCphoEta_->Fill( (*mcPho).fourMomentum().eta()); h_MCphoPhi_->Fill( (*mcPho).fourMomentum().phi()); // keep only visible conversions if ( (*mcPho).isAConversion() == 0 ) continue; nMCPho_++; h_MCConvEta_ ->Fill ( fabs( (*mcPho).fourMomentum().pseudoRapidity()) - 0.001); bool REJECTED; //std::cout << " ConvertedPhotonAnalyzer Starting loop over photon candidates " << "\n"; for( reco::PhotonCollection::const_iterator iPho = photonCollection.begin(); iPho != photonCollection.end(); iPho++) { REJECTED=false; // std::cout << " ConvertedPhotonAnalyzer Reco SC energy " << (*iPho).superCluster()->energy() << "\n"; float phiClu=(*iPho).superCluster()->phi(); float etaClu=(*iPho).superCluster()->eta(); float deltaPhi = phiClu-mcPhi; float deltaEta = etaClu-mcEta; if ( deltaPhi > Geom::pi() ) deltaPhi -= Geom::twoPi(); if ( deltaPhi < -Geom::pi() ) deltaPhi += Geom::twoPi(); deltaPhi=pow(deltaPhi,2); deltaEta=pow(deltaEta,2); float delta = deltaPhi+deltaEta ; if ( delta >= etaPhiDistance ) REJECTED=true; // if ( ! ( fabs(etaClu) <= BARL || ( fabs(etaClu) >= END_LO && fabs(etaClu) <=END_HI ) ) ) REJECTED=true; if ( REJECTED ) continue; std::cout << " MATCHED " << std::endl; nMatched_++; // std::cout << " ConvertedPhotonAnalyzer Matching candidate " << std::endl; // 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; h_ErecoEMC_->Fill( (*iPho).superCluster()->energy()/(*mcPho).fourMomentum().e()); h_deltaPhi_-> Fill ( (*iPho).superCluster()->position().phi()- mcPhi); h_deltaEta_-> Fill ( (*iPho).superCluster()->position().eta()- mcEta); h_scE_->Fill( (*iPho).superCluster()->energy() ); h_scEt_->Fill( (*iPho).superCluster()->energy()/cosh( (*iPho).superCluster()->position().eta()) ); h_scEta_->Fill( (*iPho).superCluster()->position().eta() ); h_scPhi_->Fill( (*iPho).superCluster()->position().phi() ); h_phoE_->Fill( (*iPho).energy() ); h_phoEta_->Fill( (*iPho).eta() ); h_phoPhi_->Fill( (*iPho).phi() ); if ( !(*iPho).hasConversionTracks() ) continue; // std::cout << " This photons has " << (*iPho).conversions().size() << " conversions candidates " << std::endl; reco::ConversionRefVector conversions = (*iPho).conversions(); //std::vector<reco::ConversionRef> conversions = (*iPho).conversions(); for (unsigned int i=0; i<conversions.size(); i++) { //std::cout << " Conversion candidate Energy " << (*iPho).energy() << " number of tracks " << conversions[i]->nTracks() << std::endl; std::vector< edm::RefToBase<reco::Track> > tracks = conversions[i]->tracks(); for (unsigned int i=0; i<tracks.size(); i++) { // std::cout << " ConvertedPhotonAnalyzer Reco Track charge " << tracks[i]->charge() << " Num of RecHits " << tracks[i]->recHitsSize() << " inner momentum " << sqrt ( tracks[i]->innerMomentum().Mag2() ) << "\n"; h2_tk_nHitsVsR_ -> Fill ( (*mcPho).vertex().perp(), tracks[i]->recHitsSize() ); h2_tk_inPtVsR_->Fill ( (*mcPho).vertex().perp(), sqrt( tracks[i]->innerMomentum().Mag2() ) ); } } } } }
void PhotonsWithConversionsAnalyzer::beginJob | ( | void | ) | [virtual] |
Reco - MC
Reimplemented from edm::EDAnalyzer.
Definition at line 71 of file PhotonsWithConversionsAnalyzer.cc.
{ nEvt_=0; nMCPho_=0; nMatched_=0; thePhotonMCTruthFinder_ = new PhotonMCTruthFinder(); edm::Service<TFileService> fs; h_ErecoEMC_ = fs->make<TH1F>("deltaE"," delta(reco-mc) energy",100,0.,2.); h_deltaPhi_ = fs->make<TH1F>("deltaPhi"," delta(reco-mc) phi",100,-0.1, 0.1); h_deltaEta_ = fs->make<TH1F>("deltaEta"," delta(reco-mc) eta",100,-0.05, 0.05); h_MCphoE_ = fs->make<TH1F>("MCphoE","MC photon energy",100,0.,100.); h_MCphoPhi_ = fs->make<TH1F>("MCphoPhi","MC photon phi",40,-3.14, 3.14); h_MCphoEta_ = fs->make<TH1F>("MCphoEta","MC photon eta",40,-3., 3.); h_MCConvE_ = fs->make<TH1F>("MCConvE","MC converted photon energy",100,0.,100.); h_MCConvPt_ = fs->make<TH1F>("MCConvPt","MC converted photon pt",100,0.,100.); h_MCConvEta_ = fs->make<TH1F>("MCConvEta","MC converted photon eta",50, 0., 2.5); h_scE_ = fs->make<TH1F>("scE","SC Energy ",100,0., 200.); h_scEt_ = fs->make<TH1F>("scEt","SC Et ",100,0., 200.); h_scEta_ = fs->make<TH1F>("scEta","SC Eta ",40,-3., 3.); h_scPhi_ = fs->make<TH1F>("scPhi","SC Phi ",40, -3.14, 3.14); // h_phoE_ = fs->make<TH1F>("phoE","Photon Energy ",100,0., 200.); h_phoEta_ = fs->make<TH1F>("phoEta","Photon Eta ",40,-3., 3.); h_phoPhi_ = fs->make<TH1F>("phoPhi","Photon Phi ",40, -3.14, 3.14); // Recontructed tracks from converted photon candidates h2_tk_nHitsVsR_ = fs->make<TH2F>("tknHitsVsR","Tracks Hits vs R ", 12,0.,120.,20,0.5, 20.5); h2_tk_inPtVsR_ = fs->make<TH2F>("tkInPtvsR","Tracks inner Pt vs R ", 12,0.,120.,100,0., 100.); return ; }
void PhotonsWithConversionsAnalyzer::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 324 of file PhotonsWithConversionsAnalyzer.cc.
References gather_cfg::cout.
{ // fOutputFile_->Write() ; // fOutputFile_->Close() ; edm::LogInfo("ConvertedPhotonAnalyzer") << "Analyzed " << nEvt_ << "\n"; // std::cout << "::endJob Analyzed " << nEvt_ << " events " << " with total " << nPho_ << " Photons " << "\n"; std::cout << "ConvertedPhotonAnalyzer::endJob Analyzed " << nEvt_ << " events " << "\n"; return ; }
float PhotonsWithConversionsAnalyzer::etaTransformation | ( | float | a, |
float | b | ||
) | [private] |
Definition at line 122 of file PhotonsWithConversionsAnalyzer.cc.
References ETA, etaBarrelEndcap, create_public_lumi_plots::log, PI, R_ECAL, funct::tan(), and Z_Endcap.
{ //---Definitions const float PI = 3.1415927; //UNUSED const float TWOPI = 2.0*PI; //---Definitions for ECAL const float R_ECAL = 136.5; const float Z_Endcap = 328.0; const float etaBarrelEndcap = 1.479; //---ETA correction float Theta = 0.0 ; float ZEcal = R_ECAL*sinh(EtaParticle)+Zvertex; if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal); if(Theta<0.0) Theta = Theta+PI ; float ETA = - log(tan(0.5*Theta)); if( fabs(ETA) > etaBarrelEndcap ) { float Zend = Z_Endcap ; if(EtaParticle<0.0 ) Zend = -Zend ; float Zlen = Zend - Zvertex ; float RR = Zlen/sinh(EtaParticle); Theta = atan(RR/Zend); if(Theta<0.0) Theta = Theta+PI ; ETA = - log(tan(0.5*Theta)); } //---Return the result return ETA; //---end }
TFile* PhotonsWithConversionsAnalyzer::fOutputFile_ [private] |
Definition at line 46 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::fOutputFileName_ [private] |
Definition at line 45 of file PhotonsWithConversionsAnalyzer.h.
TH2F* PhotonsWithConversionsAnalyzer::h2_tk_inPtVsR_ [private] |
Definition at line 93 of file PhotonsWithConversionsAnalyzer.h.
TH2F* PhotonsWithConversionsAnalyzer::h2_tk_nHitsVsR_ [private] |
Definition at line 91 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_deltaEta_ [private] |
Definition at line 64 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_deltaPhi_ [private] |
Definition at line 63 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_ErecoEMC_ [private] |
Definition at line 62 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCConvE_ [private] |
Definition at line 75 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCConvEta_ [private] |
Definition at line 77 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCConvPt_ [private] |
Definition at line 76 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCphoE_ [private] |
Definition at line 68 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCphoEta_ [private] |
Definition at line 70 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_MCphoPhi_ [private] |
Definition at line 69 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_phoE_ [private] |
Definition at line 86 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_phoEta_ [private] |
Definition at line 87 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_phoPhi_ [private] |
Definition at line 88 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_scE_ [private] |
Definition at line 81 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_scEt_ [private] |
Definition at line 82 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_scEta_ [private] |
Definition at line 83 of file PhotonsWithConversionsAnalyzer.h.
TH1F* PhotonsWithConversionsAnalyzer::h_scPhi_ [private] |
Definition at line 84 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::HepMCLabel [private] |
Definition at line 53 of file PhotonsWithConversionsAnalyzer.h.
int PhotonsWithConversionsAnalyzer::nEvt_ [private] |
Definition at line 49 of file PhotonsWithConversionsAnalyzer.h.
int PhotonsWithConversionsAnalyzer::nMatched_ [private] |
Definition at line 51 of file PhotonsWithConversionsAnalyzer.h.
int PhotonsWithConversionsAnalyzer::nMCPho_ [private] |
Definition at line 50 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::photonCollection_ [private] |
Definition at line 60 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::photonCollectionProducer_ [private] |
Definition at line 59 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::SimHitLabel [private] |
Definition at line 56 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::SimTkLabel [private] |
Definition at line 54 of file PhotonsWithConversionsAnalyzer.h.
std::string PhotonsWithConversionsAnalyzer::SimVtxLabel [private] |
Definition at line 55 of file PhotonsWithConversionsAnalyzer.h.
Definition at line 43 of file PhotonsWithConversionsAnalyzer.h.