#include <PhotonProducer.h>
Definition at line 39 of file PhotonProducer.h.
PhotonProducer::PhotonProducer | ( | const edm::ParameterSet & | ps | ) |
Definition at line 29 of file PhotonProducer.cc.
References barrelEcalHits_, conf_, endcapEcalHits_, energyCorrectionF, reco::get(), edm::ParameterSet::getParameter(), hcalTowers_, highEt_, hOverEConeSize_, minR9Barrel_, minR9Endcap_, PhotonCollection_, photonCoreProducer_, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, usePrimaryVertex_, and vertexProducer_.
: conf_(config) { // use onfiguration file to setup input/output collection names photonCoreProducer_ = conf_.getParameter<edm::InputTag>("photonCoreProducer"); barrelEcalHits_ = conf_.getParameter<edm::InputTag>("barrelEcalHits"); endcapEcalHits_ = conf_.getParameter<edm::InputTag>("endcapEcalHits"); vertexProducer_ = conf_.getParameter<std::string>("primaryVertexProducer"); hcalTowers_ = conf_.getParameter<edm::InputTag>("hcalTowers"); hOverEConeSize_ = conf_.getParameter<double>("hOverEConeSize"); highEt_ = conf_.getParameter<double>("highEt"); // R9 value to decide converted/unconverted minR9Barrel_ = conf_.getParameter<double>("minR9Barrel"); minR9Endcap_ = conf_.getParameter<double>("minR9Endcap"); usePrimaryVertex_ = conf_.getParameter<bool>("usePrimaryVertex"); runMIPTagger_ = conf_.getParameter<bool>("runMIPTagger"); edm::ParameterSet posCalcParameters = config.getParameter<edm::ParameterSet>("posCalcParameters"); posCalculator_ = PositionCalc(posCalcParameters); // Parameters for the position calculation: // std::map<std::string,double> providedParameters; // providedParameters.insert(std::make_pair("LogWeighted",conf_.getParameter<bool>("posCalc_logweight"))); //providedParameters.insert(std::make_pair("T0_barl",conf_.getParameter<double>("posCalc_t0_barl"))); //providedParameters.insert(std::make_pair("T0_endc",conf_.getParameter<double>("posCalc_t0_endc"))); //providedParameters.insert(std::make_pair("T0_endcPresh",conf_.getParameter<double>("posCalc_t0_endcPresh"))); //providedParameters.insert(std::make_pair("W0",conf_.getParameter<double>("posCalc_w0"))); //providedParameters.insert(std::make_pair("X0",conf_.getParameter<double>("posCalc_x0"))); //posCalculator_ = PositionCalc(providedParameters); // cut values for pre-selection preselCutValuesBarrel_.push_back(conf_.getParameter<double>("minSCEtBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("maxHoverEBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackSolidConeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackHollowConeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumSolidConeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumHollowConeBarrel")); preselCutValuesBarrel_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutBarrel")); // preselCutValuesEndcap_.push_back(conf_.getParameter<double>("minSCEtEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("maxHoverEEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackSolidConeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackHollowConeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumSolidConeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumHollowConeEndcap")); preselCutValuesEndcap_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutEndcap")); // energyCorrectionF = EcalClusterFunctionFactory::get()->create("EcalClusterEnergyCorrection", conf_); // Register the product produces< reco::PhotonCollection >(PhotonCollection_); }
PhotonProducer::~PhotonProducer | ( | ) |
Definition at line 93 of file PhotonProducer.cc.
References energyCorrectionF.
{ delete energyCorrectionF; }
void PhotonProducer::beginRun | ( | edm::Run & | r, |
edm::EventSetup const & | es | ||
) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 101 of file PhotonProducer.cc.
References conf_, edm::ParameterSet::getParameter(), PhotonIsolationCalculator::setup(), PhotonMIPHaloTagger::setup(), thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.
{ thePhotonIsolationCalculator_ = new PhotonIsolationCalculator(); edm::ParameterSet isolationSumsCalculatorSet = conf_.getParameter<edm::ParameterSet>("isolationSumsCalculatorSet"); thePhotonIsolationCalculator_->setup(isolationSumsCalculatorSet); thePhotonMIPHaloTagger_ = new PhotonMIPHaloTagger(); edm::ParameterSet mipVariableSet = conf_.getParameter<edm::ParameterSet>("mipVariableSet"); thePhotonMIPHaloTagger_->setup(mipVariableSet); }
void PhotonProducer::endRun | ( | edm::Run & | r, |
edm::EventSetup const & | theEventSetup | ||
) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 117 of file PhotonProducer.cc.
References thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.
{ delete thePhotonIsolationCalculator_; delete thePhotonMIPHaloTagger_; }
void PhotonProducer::fillPhotonCollection | ( | edm::Event & | evt, |
edm::EventSetup const & | es, | ||
const edm::Handle< reco::PhotonCoreCollection > & | photonCoreHandle, | ||
const CaloTopology * | topology, | ||
const EcalRecHitCollection * | ecalBarrelHits, | ||
const EcalRecHitCollection * | ecalEndcapHits, | ||
const edm::Handle< CaloTowerCollection > & | hcalTowersHandle, | ||
math::XYZPoint & | vtx, | ||
reco::PhotonCollection & | outputCollection, | ||
int & | iSC | ||
) | [private] |
fill shower shape block
Pre-selection loose isolation cuts
Definition at line 221 of file PhotonProducer.cc.
References PositionCalc::Calculate_Location(), EcalClusterTools::covariances(), reco::Photon::ShowerShape::e1x5, EcalClusterTools::e1x5(), reco::Photon::ShowerShape::e2x5, EcalClusterTools::e2x5Max(), reco::Photon::ShowerShape::e3x3, EcalClusterTools::e3x3(), reco::Photon::ShowerShape::e5x5, EcalClusterTools::e5x5(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, jptDQMConfig_cff::eMax, energyCorrectionF, geometry, EgammaTowerIsolation::getTowerESum(), EcalClusterFunctionBaseClass::getValue(), reco::Photon::ShowerShape::hcalDepth1OverEcal, reco::Photon::ShowerShape::hcalDepth2OverEcal, highEt_, hOverEConeSize_, EcalClusterTools::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, minR9Barrel_, minR9Endcap_, p4, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, edm::ESHandle< T >::product(), edm::Handle< T >::product(), runMIPTagger_, reco::Photon::ShowerShape::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), theCaloGeom_, thePhotonIsolationCalculator_, and thePhotonMIPHaloTagger_.
Referenced by produce().
{ const CaloGeometry* geometry = theCaloGeom_.product(); const CaloSubdetectorGeometry* subDetGeometry =0 ; const CaloSubdetectorGeometry* geometryES = theCaloGeom_->getSubdetectorGeometry(DetId::Ecal, EcalPreshower); const EcalRecHitCollection* hits = 0 ; std::vector<double> preselCutValues; float minR9=0; for(unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) { reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC)); reco::SuperClusterRef scRef=coreRef->superCluster(); const reco::SuperCluster* pClus=&(*scRef); iSC++; int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId(); subDetGeometry = theCaloGeom_->getSubdetectorGeometry(DetId::Ecal, subdet); if (subdet==EcalBarrel) { preselCutValues = preselCutValuesBarrel_; minR9=minR9Barrel_; hits= ecalBarrelHits; } else if (subdet==EcalEndcap) { preselCutValues = preselCutValuesEndcap_; minR9=minR9Endcap_; hits= ecalEndcapHits; } else { edm::LogWarning("")<<"PhotonProducer: do not know if it is a barrel or endcap SuperCluster" ; } // SC energy preselection if (scRef->energy()/cosh(scRef->eta()) <= preselCutValues[0] ) continue; // calculate HoE const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product(); EgammaTowerIsolation towerIso1(hOverEConeSize_,0.,0.,1,hcalTowersColl) ; EgammaTowerIsolation towerIso2(hOverEConeSize_,0.,0.,2,hcalTowersColl) ; double HoE1=towerIso1.getTowerESum(&(*scRef))/scRef->energy(); double HoE2=towerIso2.getTowerESum(&(*scRef))/scRef->energy(); // std::cout << " PhotonProducer " << HoE1 << " HoE2 " << HoE2 << std::endl; // std::cout << " PhotonProducer calcualtion of HoE1 " << HoE1 << " HoE2 " << HoE2 << std::endl; // recalculate position of seed BasicCluster taking shower depth for unconverted photon math::XYZPoint unconvPos = posCalculator_.Calculate_Location(scRef->seed()->hitsAndFractions(),hits,subDetGeometry,geometryES); float maxXtal = EcalClusterTools::eMax( *(scRef->seed()), &(*hits) ); float e1x5 = EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology)); float e2x5 = EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology)); float e3x3 = EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology)); float e5x5 = EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology)); std::vector<float> cov = EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology), geometry); float sigmaEtaEta = sqrt(cov[0]); std::vector<float> locCov = EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology)); float sigmaIetaIeta = sqrt(locCov[0]); float r9 =e3x3/(scRef->rawEnergy()); // compute position of ECAL shower math::XYZPoint caloPosition; double photonEnergy=0; if (r9>minR9) { caloPosition = unconvPos; // f(eta) correction to e5x5 double deltaE = energyCorrectionF->getValue(*pClus, 1); if (subdet==EcalBarrel) e5x5 = e5x5 * (1.0 + deltaE/scRef->rawEnergy() ); photonEnergy= e5x5 + scRef->preshowerEnergy() ; } else { caloPosition = scRef->position(); photonEnergy=scRef->energy(); } //std::cout << " dete " << subdet << " r9 " << r9 << " uncorrected e5x5 " << e5x5uncor << " corrected e5x5 " << e5x5 << " photon energy " << photonEnergy << std::endl; // compute momentum vector of photon from primary vertex and cluster position math::XYZVector direction = caloPosition - vtx; math::XYZVector momentum = direction.unit() * photonEnergy ; // Create candidate const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy ); reco::Photon newCandidate(p4, caloPosition, coreRef, vtx); // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator reco::Photon::FiducialFlags fiducialFlags; reco::Photon::IsolationVariables isolVarR03, isolVarR04; thePhotonIsolationCalculator_-> calculate ( &newCandidate,evt,es,fiducialFlags,isolVarR04, isolVarR03); newCandidate.setFiducialVolumeFlags( fiducialFlags ); newCandidate.setIsolationVariables(isolVarR04, isolVarR03 ); reco::Photon::ShowerShape showerShape; showerShape.e1x5= e1x5; showerShape.e2x5= e2x5; showerShape.e3x3= e3x3; showerShape.e5x5= e5x5; showerShape.maxEnergyXtal = maxXtal; showerShape.sigmaEtaEta = sigmaEtaEta; showerShape.sigmaIetaIeta = sigmaIetaIeta; showerShape.hcalDepth1OverEcal = HoE1; showerShape.hcalDepth2OverEcal = HoE2; newCandidate.setShowerShapeVariables ( showerShape ); // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger reco::Photon::MIPVariables mipVar ; if(subdet==EcalBarrel && runMIPTagger_ ) { thePhotonMIPHaloTagger_-> MIPcalculate( &newCandidate,evt,es,mipVar); newCandidate.setMIPVariables(mipVar); } bool isLooseEM=true; if ( newCandidate.pt() < highEt_) { if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=false; if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=false; if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=false; if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=false; if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=false; if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=false; if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=false; if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=false; } if ( isLooseEM) outputPhotonCollection.push_back(newCandidate); } }
void PhotonProducer::produce | ( | edm::Event & | evt, |
const edm::EventSetup & | es | ||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 127 of file PhotonProducer.cc.
References barrelEcalHits_, endcapEcalHits_, energyCorrectionF, fillPhotonCollection(), edm::EventSetup::get(), edm::Event::getByLabel(), hcalTowers_, EcalClusterFunctionBaseClass::init(), edm::InputTag::label(), PhotonCollection_, photonCoreProducer_, edm::ESHandle< T >::product(), edm::Event::put(), theCaloGeom_, theCaloTopo_, usePrimaryVertex_, GoodVertex_cfg::vertexCollection, and vertexProducer_.
{ using namespace edm; // nEvt_++; reco::PhotonCollection outputPhotonCollection; std::auto_ptr< reco::PhotonCollection > outputPhotonCollection_p(new reco::PhotonCollection); // Get the PhotonCore collection bool validPhotonCoreHandle=true; Handle<reco::PhotonCoreCollection> photonCoreHandle; theEvent.getByLabel(photonCoreProducer_,photonCoreHandle); if (!photonCoreHandle.isValid()) { edm::LogError("PhotonProducer") << "Error! Can't get the product "<<photonCoreProducer_.label(); validPhotonCoreHandle=false; } // Get EcalRecHits bool validEcalRecHits=true; Handle<EcalRecHitCollection> barrelHitHandle; EcalRecHitCollection barrelRecHits; theEvent.getByLabel(barrelEcalHits_, barrelHitHandle); if (!barrelHitHandle.isValid()) { edm::LogError("PhotonProducer") << "Error! Can't get the product "<<barrelEcalHits_.label(); validEcalRecHits=false; } if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.product()); Handle<EcalRecHitCollection> endcapHitHandle; theEvent.getByLabel(endcapEcalHits_, endcapHitHandle); EcalRecHitCollection endcapRecHits; if (!endcapHitHandle.isValid()) { edm::LogError("PhotonProducer") << "Error! Can't get the product "<<endcapEcalHits_.label(); validEcalRecHits=false; } if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.product()); // get Hcal towers collection Handle<CaloTowerCollection> hcalTowersHandle; theEvent.getByLabel(hcalTowers_, hcalTowersHandle); // get the geometry from the event setup: theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_); // // update energy correction function energyCorrectionF->init(theEventSetup); edm::ESHandle<CaloTopology> pTopology; theEventSetup.get<CaloTopologyRecord>().get(theCaloTopo_); const CaloTopology *topology = theCaloTopo_.product(); // Get the primary event vertex Handle<reco::VertexCollection> vertexHandle; reco::VertexCollection vertexCollection; bool validVertex=true; if ( usePrimaryVertex_ ) { theEvent.getByLabel(vertexProducer_, vertexHandle); if (!vertexHandle.isValid()) { edm::LogWarning("PhotonProducer") << "Error! Can't get the product primary Vertex Collection "<< "\n"; validVertex=false; } if (validVertex) vertexCollection = *(vertexHandle.product()); } math::XYZPoint vtx(0.,0.,0.); if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position(); int iSC=0; // index in photon collection // Loop over barrel and endcap SC collections and fill the photon collection if ( validPhotonCoreHandle) fillPhotonCollection(theEvent, theEventSetup, photonCoreHandle, topology, &barrelRecHits, &endcapRecHits, hcalTowersHandle, vtx, outputPhotonCollection, iSC); // put the product in the event edm::LogInfo("PhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n"; outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end()); theEvent.put( outputPhotonCollection_p, PhotonCollection_); }
edm::InputTag PhotonProducer::barrelEcalHits_ [private] |
Definition at line 70 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
edm::ParameterSet PhotonProducer::conf_ [private] |
Definition at line 90 of file PhotonProducer.h.
Referenced by beginRun(), and PhotonProducer().
std::string PhotonProducer::conversionCollection_ [private] |
Definition at line 76 of file PhotonProducer.h.
std::string PhotonProducer::conversionProducer_ [private] |
Definition at line 75 of file PhotonProducer.h.
edm::InputTag PhotonProducer::endcapEcalHits_ [private] |
Definition at line 71 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
Definition at line 109 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), PhotonProducer(), produce(), and ~PhotonProducer().
edm::InputTag PhotonProducer::hcalTowers_ [private] |
Definition at line 73 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
double PhotonProducer::highEt_ [private] |
Definition at line 81 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
double PhotonProducer::hOverEConeSize_ [private] |
Definition at line 78 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
double PhotonProducer::maxHOverE_ [private] |
Definition at line 79 of file PhotonProducer.h.
double PhotonProducer::minR9Barrel_ [private] |
Definition at line 82 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
double PhotonProducer::minR9Endcap_ [private] |
Definition at line 83 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
double PhotonProducer::minSCEt_ [private] |
Definition at line 80 of file PhotonProducer.h.
std::string PhotonProducer::PhotonCollection_ [private] |
Definition at line 68 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
Definition at line 69 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
std::string PhotonProducer::pixelSeedProducer_ [private] |
Definition at line 87 of file PhotonProducer.h.
PositionCalc PhotonProducer::posCalculator_ [private] |
Definition at line 92 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
std::vector<double> PhotonProducer::preselCutValuesBarrel_ [private] |
Definition at line 106 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
std::vector<double> PhotonProducer::preselCutValuesEndcap_ [private] |
Definition at line 107 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
bool PhotonProducer::runMIPTagger_ [private] |
Definition at line 84 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and PhotonProducer().
Definition at line 95 of file PhotonProducer.h.
Referenced by fillPhotonCollection(), and produce().
Definition at line 96 of file PhotonProducer.h.
Referenced by produce().
Definition at line 101 of file PhotonProducer.h.
Referenced by beginRun(), endRun(), and fillPhotonCollection().
Definition at line 104 of file PhotonProducer.h.
Referenced by beginRun(), endRun(), and fillPhotonCollection().
bool PhotonProducer::usePrimaryVertex_ [private] |
Definition at line 89 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().
bool PhotonProducer::validConversions_ [private] |
Definition at line 86 of file PhotonProducer.h.
bool PhotonProducer::validPixelSeeds_ [private] |
Definition at line 100 of file PhotonProducer.h.
std::string PhotonProducer::vertexProducer_ [private] |
Definition at line 88 of file PhotonProducer.h.
Referenced by PhotonProducer(), and produce().