diff --git a/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.cxx b/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.cxx index cc864402902fffb217ee86ff02e34bea7ad8a4fe..042917967217b840cdcdc3d3124624a60009ad73 100755 --- a/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.cxx +++ b/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.cxx @@ -7,6 +7,79 @@ #include "MonitorElectronAlgorithm.h" +#include "xAODPrimitives/IsolationType.h" + +#include <unordered_map> + +namespace { + enum Regions : int { BARREL=0, CRACK, ENDCAP, FORWARD, NREGIONS }; + + Regions GetRegion(Float_t eta) { + Float_t aeta = std::abs(eta); + const Float_t barrelEtaUpper = 1.37; + const Float_t endCapEtaLower = 1.52; + const Float_t endCapEtaUpper = 2.47; + const Float_t crackEtaLower = barrelEtaUpper; + const Float_t crackEtaUpper = endCapEtaLower; + + if (aeta < barrelEtaUpper) { + return BARREL; + } + if (aeta > endCapEtaLower && aeta < endCapEtaUpper) { + return ENDCAP; + } + if (aeta > crackEtaLower && aeta < crackEtaUpper) { + return CRACK; + } + + // Out of acceptance. + return NREGIONS; + } + + template <typename ...T> + void fillMonitorElectron( + const MonitorElectronAlgorithm &alg, + T ...monitoreds + ) { + alg.fill("MonitorElectron", {monitoreds...}); + } + + float isolationValueFloat( + const xAOD::Electron &electron, + const xAOD::Iso::IsolationType &info, + float deflt = -999. + ) { + float dummy(0); + return (electron.isolationValue(dummy, info) ? dummy : deflt); + } + + float showerShapeValueFloat( + const xAOD::Electron &electron, + const xAOD::EgammaParameters::ShowerShapeType &info, + float deflt = -999. + ) { + float dummy(0); + return (electron.showerShapeValue(dummy, info) ? dummy : deflt); + } + + float trackCaloMatchValueFloat( + const xAOD::Electron &electron, + const xAOD::EgammaParameters::TrackCaloMatchType &info, + float deflt = -999. + ) { + float dummy(0); + return (electron.trackCaloMatchValue(dummy, info) ? dummy : deflt); + } + + float divideOr(float numerator, float denominator, float deflt = -999.) { + if (denominator == 0) { + return deflt; + } + + return numerator / denominator; + } +} + MonitorElectronAlgorithm::MonitorElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ) :AthMonitorAlgorithm(name,pSvcLocator) { @@ -14,358 +87,164 @@ MonitorElectronAlgorithm::MonitorElectronAlgorithm( const std::string& name, ISv MonitorElectronAlgorithm::~MonitorElectronAlgorithm() = default; - StatusCode MonitorElectronAlgorithm::initialize() { - using namespace Monitored; - ATH_CHECK( AthMonitorAlgorithm::initialize() ); - ATH_CHECK( m_ParticleContainerKey.initialize() ); - ATH_CHECK( m_ElectronIsolationKey.initialize() ); - - return StatusCode::SUCCESS; + using namespace Monitored; + ATH_CHECK( AthMonitorAlgorithm::initialize() ); + ATH_CHECK( m_ParticleContainerKey.initialize() ); + ATH_CHECK( m_ElectronIsolationKey.initialize() ); + return StatusCode::SUCCESS; } StatusCode MonitorElectronAlgorithm::fillHistograms( const EventContext& ctx ) const { - using namespace Monitored; + using namespace Monitored; + using namespace xAOD::EgammaHelpers; - // Only monitor good LAr Events : - - xAOD::EventInfo::EventFlagErrorState error_state = GetEventInfo(ctx)->errorState(xAOD::EventInfo::LAr); - if (error_state==xAOD::EventInfo::Error) { - ATH_MSG_DEBUG("LAr event data integrity error"); - return StatusCode::SUCCESS; + // Only monitor good LAr Events. + xAOD::EventInfo::EventFlagErrorState error_state = GetEventInfo(ctx)->errorState(xAOD::EventInfo::LAr); + if (error_state==xAOD::EventInfo::Error) { + ATH_MSG_DEBUG("LAr event data integrity error"); + return StatusCode::SUCCESS; + } + + // Fill the specific Electron information. + // Get the Electron container. + SG::ReadHandle<xAOD::ElectronContainer> electrons(m_ParticleContainerKey, ctx); + ATH_CHECK(electrons.isValid()); + + // Set the values of the monitored variables for the event. + u_int16_t mynp = 0; + std::unordered_map<Regions, u_int16_t> region_counters = { + {BARREL, 0}, + {CRACK, 0}, + {ENDCAP, 0} + }; + + for (const auto *const e_iter : *electrons) { + // Check that the electron meets our requirements. + bool isGood; + if (!e_iter->passSelection(isGood,m_RecoName)) { + ATH_MSG_WARNING("Misconfiguration: " << m_RecoName << " is not a valid working point for electrons"); + break; } + if(isGood) { + ++mynp; - // - // now, fill the specific Electron information - // - // get the Electron container - - SG::ReadHandle<xAOD::ElectronContainer> electrons(m_ParticleContainerKey, ctx); - ATH_CHECK(electrons.isValid()); - - // Event variables to be monitored - auto lbNCandidates = Monitored::Scalar<u_int16_t>("LBEvoN",0); + Regions regionloc = GetRegion(e_iter->eta()); + ATH_MSG_DEBUG("Test electron in region : " << regionloc); - // Particle variables to be monitored - auto np = Monitored::Scalar<int>("N",0.0); - auto et = Monitored::Scalar<Float_t>("Et",0.0); - // Check if small differences between old and new monitoring are related to rounding effects - // auto eta = Monitored::Scalar<Float_t>("Eta",0.0); - auto eta = Monitored::Scalar<Double_t>("Eta",0.0); - auto phi = Monitored::Scalar<Float_t>("Phi",0.0); - auto is_pt_gt_2_5gev = Monitored::Scalar<bool>("is_pt_gt_2_5gev",false); - auto is_pt_gt_4gev = Monitored::Scalar<bool>("is_pt_gt_4gev",false); - auto is_pt_gt_20gev = Monitored::Scalar<bool>("is_pt_gt_20gev",false); - auto time = Monitored::Scalar<Float_t>("Time",0.0); - auto topoetcone40 = Monitored::Scalar<Float_t>("TopoEtCone40",0.0); - auto ptcone20 = Monitored::Scalar<Float_t>("PtCone20",0.0); - - // Particle variables per Region - - // BARREL - auto np_barrel = Monitored::Scalar<int>("NinBARREL",0.0); - auto et_barrel = Monitored::Scalar<Float_t>("EtinBARREL",0.0); - auto eta_barrel = Monitored::Scalar<Float_t>("EtainBARREL",0.0); - auto phi_barrel = Monitored::Scalar<Float_t>("PhiinBARREL",0.0); - auto time_barrel = Monitored::Scalar<Float_t>("TimeinBARREL",0.0); - auto ehad1_barrel = Monitored::Scalar<Float_t>("Ehad1inBARREL",0.0); - auto eoverp_barrel = Monitored::Scalar<Float_t>("EoverPinBARREL",0.0); - auto coreem_barrel = Monitored::Scalar<Float_t>("CoreEMinBARREL",0.0); - auto f0_barrel = Monitored::Scalar<Float_t>("F0inBARREL",0.0); - auto f1_barrel = Monitored::Scalar<Float_t>("F1inBARREL",0.0); - auto f2_barrel = Monitored::Scalar<Float_t>("F2inBARREL",0.0); - auto f3_barrel = Monitored::Scalar<Float_t>("F3inBARREL",0.0); - auto re233e237_barrel = Monitored::Scalar<Float_t>("Re233e237inBARREL",0.0); - auto re237e277_barrel = Monitored::Scalar<Float_t>("Re237e277inBARREL",0.0); - auto nofblayerhits_barrel = Monitored::Scalar<u_int8_t>("NOfBLayerHitsinBARREL",0); - auto nofpixelhits_barrel = Monitored::Scalar<u_int8_t>("NOfPixelHitsinBARREL",0); - auto nofscthits_barrel = Monitored::Scalar<u_int8_t>("NOfSCTHitsinBARREL",0); - auto noftrthits_barrel = Monitored::Scalar<u_int8_t>("NOfTRTHitsinBARREL",0); - auto noftrthighthresholdhits_barrel = Monitored::Scalar<u_int8_t>("NOfTRTHighThresholdHitsinBARREL",0); - auto deltaeta1_barrel = Monitored::Scalar<Float_t>("DeltaEta1inBARREL",0.0); - auto deltaphi2_barrel = Monitored::Scalar<Float_t>("DeltaPhi2inBARREL",0.0); - auto trackd0_barrel = Monitored::Scalar<Float_t>("Trackd0inBARREL",0.0); - - // ENDCAP - auto np_endcap = Monitored::Scalar<int>("NinENDCAP",0.0); - auto et_endcap = Monitored::Scalar<Float_t>("EtinENDCAP",0.0); - auto eta_endcap = Monitored::Scalar<Float_t>("EtainENDCAP",0.0); - auto phi_endcap = Monitored::Scalar<Float_t>("PhiinENDCAP",0.0); - auto time_endcap = Monitored::Scalar<Float_t>("TimeinENDCAP",0.0); - auto ehad1_endcap = Monitored::Scalar<Float_t>("Ehad1inENDCAP",0.0); - auto eoverp_endcap = Monitored::Scalar<Float_t>("EoverPinENDCAP",0.0); - auto coreem_endcap = Monitored::Scalar<Float_t>("CoreEMinENDCAP",0.0); - auto f0_endcap = Monitored::Scalar<Float_t>("F0inENDCAP",0.0); - auto f1_endcap = Monitored::Scalar<Float_t>("F1inENDCAP",0.0); - auto f2_endcap = Monitored::Scalar<Float_t>("F2inENDCAP",0.0); - auto f3_endcap = Monitored::Scalar<Float_t>("F3inENDCAP",0.0); - auto re233e237_endcap = Monitored::Scalar<Float_t>("Re233e237inENDCAP",0.0); - auto re237e277_endcap = Monitored::Scalar<Float_t>("Re237e277inENDCAP",0.0); - auto nofblayerhits_endcap = Monitored::Scalar<u_int8_t>("NOfBLayerHitsinENDCAP",0); - auto nofpixelhits_endcap = Monitored::Scalar<u_int8_t>("NOfPixelHitsinENDCAP",0); - auto nofscthits_endcap = Monitored::Scalar<u_int8_t>("NOfSCTHitsinENDCAP",0); - auto noftrthits_endcap = Monitored::Scalar<u_int8_t>("NOfTRTHitsinENDCAP",0); - auto noftrthighthresholdhits_endcap = Monitored::Scalar<u_int8_t>("NOfTRTHighThresholdHitsinENDCAP",0); - auto deltaeta1_endcap = Monitored::Scalar<Float_t>("DeltaEta1inENDCAP",0.0); - auto deltaphi2_endcap = Monitored::Scalar<Float_t>("DeltaPhi2inENDCAP",0.0); - auto trackd0_endcap = Monitored::Scalar<Float_t>("Trackd0inENDCAP",0.0); - - // CRACK - auto np_crack = Monitored::Scalar<int>("NinCRACK",0.0); - auto et_crack = Monitored::Scalar<Float_t>("EtinCRACK",0.0); - auto eta_crack = Monitored::Scalar<Float_t>("EtainCRACK",0.0); - auto phi_crack = Monitored::Scalar<Float_t>("PhiinCRACK",0.0); - auto time_crack = Monitored::Scalar<Float_t>("TimeinCRACK",0.0); - auto ehad1_crack = Monitored::Scalar<Float_t>("Ehad1inCRACK",0.0); - auto eoverp_crack = Monitored::Scalar<Float_t>("EoverPinCRACK",0.0); - auto coreem_crack = Monitored::Scalar<Float_t>("CoreEMinCRACK",0.0); - auto f0_crack = Monitored::Scalar<Float_t>("F0inCRACK",0.0); - auto f1_crack = Monitored::Scalar<Float_t>("F1inCRACK",0.0); - auto f2_crack = Monitored::Scalar<Float_t>("F2inCRACK",0.0); - auto f3_crack = Monitored::Scalar<Float_t>("F3inCRACK",0.0); - auto re233e237_crack = Monitored::Scalar<Float_t>("Re233e237inCRACK",0.0); - auto re237e277_crack = Monitored::Scalar<Float_t>("Re237e277inCRACK",0.0); - auto nofblayerhits_crack = Monitored::Scalar<u_int8_t>("NOfBLayerHitsinCRACK",0); - auto nofpixelhits_crack = Monitored::Scalar<u_int8_t>("NOfPixelHitsinCRACK",0); - auto nofscthits_crack = Monitored::Scalar<u_int8_t>("NOfSCTHitsinCRACK",0); - auto noftrthits_crack = Monitored::Scalar<u_int8_t>("NOfTRTHitsinCRACK",0); - auto noftrthighthresholdhits_crack = Monitored::Scalar<u_int8_t>("NOfTRTHighThresholdHitsinCRACK",0); - auto deltaeta1_crack = Monitored::Scalar<Float_t>("DeltaEta1inCRACK",0.0); - auto deltaphi2_crack = Monitored::Scalar<Float_t>("DeltaPhi2inCRACK",0.0); - auto trackd0_crack = Monitored::Scalar<Float_t>("Trackd0inCRACK",0.0); - - - auto is_pt_gt_4gev_barrel = Monitored::Scalar<bool>("is_pt_gt_4gevBARREL",false); - auto is_pt_gt_4gev_endcap = Monitored::Scalar<bool>("is_pt_gt_4gevENDCAP",false); - auto is_pt_gt_4gev_crack = Monitored::Scalar<bool>("is_pt_gt_4gevCRACK",false); - - auto is_pt_gt_2_5gev_barrel = Monitored::Scalar<bool>("is_pt_gt_2_5gevBARREL",false); - auto is_pt_gt_2_5gev_endcap = Monitored::Scalar<bool>("is_pt_gt_2_5gevENDCAP",false); - auto is_pt_gt_2_5gev_crack = Monitored::Scalar<bool>("is_pt_gt_2_5gevCRACK",false); - - auto is_pt_gt_20gev_barrel = Monitored::Scalar<bool>("is_pt_gt_20gevBARREL",false); - auto is_pt_gt_20gev_endcap = Monitored::Scalar<bool>("is_pt_gt_20gevENDCAP",false); - auto is_pt_gt_20gev_crack = Monitored::Scalar<bool>("is_pt_gt_20gevCRACK",false); - - // Set the values of the monitored variables for the event - - u_int16_t mylb = GetEventInfo(ctx)->lumiBlock(); - lbNCandidates = mylb; - - u_int16_t mynp = 0; - u_int16_t mynp_barrel = 0; - u_int16_t mynp_crack = 0; - u_int16_t mynp_endcap = 0; - - for (const auto *const e_iter : *electrons) { - - // Check that the electron meets our requirements - bool isGood; - if (! e_iter->passSelection(isGood,m_RecoName)) { - ATH_MSG_WARNING("Misconfiguration: " << m_RecoName << " is not a valid working point for electrons"); - break; // no point in continuing + if (region_counters.count(regionloc)) { + ++region_counters[regionloc]; } - if(isGood) { - mynp++; - //Float_t myetaloc = e_iter->eta(); - Double_t myetaloc = e_iter->eta(); - auto regionloc = GetRegion(myetaloc); - ATH_MSG_DEBUG("Test electron in region : " << regionloc); - switch(regionloc){ - case BARREL : - mynp_barrel++; - break; - case CRACK : - mynp_crack++; - break; - case ENDCAP : - mynp_endcap++; - break; - default : - ATH_MSG_DEBUG("Found an electron out the acceptance region : " << regionloc); - break; - } + else { + ATH_MSG_DEBUG("Found an electron out the acceptance region : " << regionloc); } - else continue; - - // do specific stuff with electrons - - Float_t myet = e_iter->pt(); // in MeV (/Gaudi::Units::GeV; // in GeV) - //Float_t myeta = e_iter->eta(); - Double_t myeta = e_iter->eta(); - Float_t myphi = e_iter->phi(); - - bool myis_pt_gt_2_5gev = myet > 2500. ; - bool myis_pt_gt_4gev = myet > 4000. ; - bool myis_pt_gt_20gev = myet > 20000. ; - - is_pt_gt_2_5gev = myis_pt_gt_2_5gev ; - is_pt_gt_4gev = myis_pt_gt_4gev ; - is_pt_gt_20gev = myis_pt_gt_20gev ; - - is_pt_gt_4gev_barrel = myis_pt_gt_4gev ; - is_pt_gt_4gev_endcap = myis_pt_gt_4gev ; - is_pt_gt_4gev_crack = myis_pt_gt_4gev ; - - is_pt_gt_2_5gev_barrel = myis_pt_gt_2_5gev ; - is_pt_gt_2_5gev_endcap = myis_pt_gt_2_5gev ; - is_pt_gt_2_5gev_crack = myis_pt_gt_2_5gev ; - - is_pt_gt_20gev_barrel = myis_pt_gt_20gev ; - is_pt_gt_20gev_endcap = myis_pt_gt_20gev ; - is_pt_gt_20gev_crack = myis_pt_gt_20gev ; - - // Isolation Energy - Float_t mytopoetcone40 = -999.; - e_iter->isolationValue(mytopoetcone40,xAOD::Iso::topoetcone40); - topoetcone40 = mytopoetcone40; - - Float_t myptcone20 = -999.; - e_iter->isolationValue(myptcone20,xAOD::Iso::ptcone20); - ptcone20 = myptcone20; - - Float_t mytime=0.0; - - // Shower shape variable details - Float_t myehad1 = 0.0; - Float_t myecore = 0.0; - Float_t myf0 = 0.0; - Float_t myf1 = 0.0; - Float_t myf2 = 0.0; - Float_t myf3 = 0.0; - Float_t e233 = 0.0; - Float_t e237 = 0.0; - Float_t e277 = 0.0; - Float_t myre233e237 = 0.0; - Float_t myre237e277 = 0.0; - - e_iter->showerShapeValue(myehad1, xAOD::EgammaParameters::ehad1); - e_iter->showerShapeValue(myecore, xAOD::EgammaParameters::ecore); - - e_iter->showerShapeValue(e237, xAOD::EgammaParameters::e237); - e_iter->showerShapeValue(e233, xAOD::EgammaParameters::e233); - e_iter->showerShapeValue(e277, xAOD::EgammaParameters::e277); - - if (e237!=0) myre233e237 = e233 / e237; - if (e277!=0) myre237e277 = e237 / e277; - - - // Cluster track match details - Float_t mydeltaeta1 = -999.0; - e_iter->trackCaloMatchValue(mydeltaeta1, xAOD::EgammaParameters::deltaEta1); - Float_t mydeltaphi2 = -999.0; - e_iter->trackCaloMatchValue(mydeltaphi2, xAOD::EgammaParameters::deltaPhi2); - - Float_t myeoverp = -999.0; - Float_t mytrackd0 = -999.0; + } + else { + continue; + } - // associated track details + // Do specific stuff with electrons. + Float_t myet = e_iter->pt(); // in MeV (/Gaudi::Units::GeV; // in GeV) + Double_t myeta = e_iter->eta(); + Float_t myphi = e_iter->phi(); + Float_t mytime=0.0; + + // Fill per region histograms. + std::unordered_map<Regions, const std::string> region_names { + {BARREL, "BARREL"}, + {CRACK, "CRACK"}, + {ENDCAP, "ENDCAP"} + }; + + Regions region = GetRegion(myeta); + if (region_names.count(region)) { + const std::string ®ion_name = region_names[region]; + + const Float_t e233 = showerShapeValueFloat(*e_iter, xAOD::EgammaParameters::e233, 0.); + const Float_t e237 = showerShapeValueFloat(*e_iter, xAOD::EgammaParameters::e237, 0.); + const Float_t e277 = showerShapeValueFloat(*e_iter, xAOD::EgammaParameters::e277, 0.); + + fillMonitorElectron( + *this, + Scalar<Float_t>("Etin" + region_name, myet), + Scalar<Float_t>("Etain" + region_name, myeta), + Scalar<Float_t>("Phiin" + region_name, myphi), + Scalar<Float_t>("Timein" + region_name, mytime), + Scalar<Float_t>("Ehad1in" + region_name, showerShapeValueFloat(*e_iter, xAOD::EgammaParameters::ehad1, 0.)), + Scalar<Float_t>("CoreEMin" + region_name, showerShapeValueFloat(*e_iter, xAOD::EgammaParameters::ecore, 0.)), + Scalar<Float_t>("Re233e237in" + region_name, divideOr(e233, e237, 0.)), + Scalar<Float_t>("Re237e277in" + region_name, divideOr(e237, e277, 0.)), + Scalar<Float_t>("DeltaEta1in" + region_name, trackCaloMatchValueFloat(*e_iter, xAOD::EgammaParameters::deltaEta1)), + Scalar<Float_t>("DeltaPhi2in" + region_name, trackCaloMatchValueFloat(*e_iter, xAOD::EgammaParameters::deltaPhi2)) + ); + + // Associated track details. const xAOD::TrackParticle *t = e_iter->trackParticle(); double trackp = 0; - u_int8_t mynofblayerhits=-1; - u_int8_t mynofpixelhits=-1; - u_int8_t mynofscthits=-1; - u_int8_t mynoftrthits=-1; - u_int8_t mynoftrthighthresholdhits=-1; - if(t) { trackp = t->pt()*cosh(t->eta()); - // retrieve track summary information - t->summaryValue(mynofblayerhits,xAOD::numberOfInnermostPixelLayerHits); - t->summaryValue(mynofpixelhits,xAOD::numberOfPixelHits); - t->summaryValue(mynofscthits,xAOD::numberOfSCTHits); - t->summaryValue(mynoftrthits,xAOD::numberOfTRTHits); - t->summaryValue(mynoftrthighthresholdhits,xAOD::numberOfTRTHighThresholdHits); - mytrackd0 = t->d0(); - } - else + fillMonitorElectron( + *this, + Scalar<u_int8_t>("NOfBLayerHitsin" + region_name, summaryValueInt(*t, xAOD::numberOfInnermostPixelLayerHits, -1)), + Scalar<u_int8_t>("NOfPixelHitsin" + region_name, summaryValueInt(*t, xAOD::numberOfPixelHits, -1)), + Scalar<u_int8_t>("NOfSCTHitsin" + region_name, summaryValueInt(*t, xAOD::numberOfSCTHits, -1)), + Scalar<u_int8_t>("NOfTRTHitsin" + region_name, summaryValueInt(*t, xAOD::numberOfTRTHits, -1)), + Scalar<u_int8_t>("NOfTRTHighThresholdHitsin" + region_name, summaryValueInt(*t, xAOD::numberOfTRTHighThresholdHits, -1)), + Scalar<Float_t>("Trackd0in" + region_name, t->d0()) + ); + } + else { ATH_MSG_DEBUG("Error attempting to retrieve associated track"); + } - - // Associated cluster details - + // Associated cluster details. const xAOD::CaloCluster *aCluster = e_iter->caloCluster(); if (aCluster) { mytime = aCluster->time(); - time = mytime ; - // Shower shape variable details - double ec = aCluster->et()*cosh(aCluster->eta()); - if (ec!=0) myf0 = aCluster->energyBE(0)/ec; - if (ec!=0) myf1 = aCluster->energyBE(1)/ec; - if (ec!=0) myf2 = aCluster->energyBE(2)/ec; - if (ec!=0) myf3 = aCluster->energyBE(3)/ec; - - if(trackp !=0) myeoverp = aCluster->e()/trackp; - - //ATH_MSG_WARNING("Test eoverp : " << myeoverp); + + // Shower shape variable details. + const double ec = aCluster->et()*cosh(aCluster->eta()); + fillMonitorElectron( + *this, + Scalar<Float_t>("F0in" + region_name, divideOr(aCluster->energyBE(0), ec, 0)), + Scalar<Float_t>("F1in" + region_name, divideOr(aCluster->energyBE(1), ec, 0)), + Scalar<Float_t>("F2in" + region_name, divideOr(aCluster->energyBE(2), ec, 0)), + Scalar<Float_t>("F3in" + region_name, divideOr(aCluster->energyBE(3), ec, 0)), + Scalar<Float_t>("EoverPin" + region_name, divideOr(aCluster->e(), trackp, 0)) + ); } - - // Fill per region histograms - auto region = GetRegion(myeta); - - //ATH_MSG_INFO("Test electron in region : " << region); - - switch(region){ - - case BARREL : - nofblayerhits_barrel = mynofblayerhits ; nofpixelhits_barrel = mynofpixelhits ; nofscthits_barrel = mynofscthits ; - noftrthits_barrel = mynoftrthits ; noftrthighthresholdhits_barrel = mynoftrthighthresholdhits; - deltaeta1_barrel = mydeltaeta1; deltaphi2_barrel = mydeltaphi2; trackd0_barrel = mytrackd0; - eoverp_barrel = myeoverp; - et_barrel = myet ; eta_barrel = myeta ; phi_barrel = myphi ; - time_barrel = mytime; ehad1_barrel = myehad1; coreem_barrel = myecore; - f0_barrel = myf0; f1_barrel = myf1; f2_barrel = myf2; f3_barrel = myf3; re233e237_barrel = myre233e237; re237e277_barrel = myre237e277; - fill("MonitorElectron",np_barrel, nofblayerhits_barrel, nofpixelhits_barrel, nofscthits_barrel, noftrthits_barrel, noftrthighthresholdhits_barrel, - deltaeta1_barrel, deltaphi2_barrel,trackd0_barrel,eoverp_barrel, - et_barrel,eta_barrel,phi_barrel, time_barrel, ehad1_barrel,coreem_barrel, f0_barrel,f1_barrel,f2_barrel, f3_barrel, - re233e237_barrel,re237e277_barrel,is_pt_gt_4gev_barrel,is_pt_gt_2_5gev_barrel,is_pt_gt_20gev_barrel); - break; - - case ENDCAP : - nofblayerhits_endcap = mynofblayerhits; nofpixelhits_endcap = mynofpixelhits ; nofscthits_endcap = mynofscthits ; - noftrthits_endcap = mynoftrthits ; noftrthighthresholdhits_endcap = mynoftrthighthresholdhits; - deltaeta1_endcap = mydeltaeta1; deltaphi2_endcap = mydeltaphi2; trackd0_endcap = mytrackd0; - eoverp_endcap = myeoverp; - et_endcap = myet ; eta_endcap = myeta ; phi_endcap = myphi ; - time_endcap = mytime; ehad1_endcap = myehad1; coreem_endcap = myecore; - f0_endcap = myf0; f1_endcap = myf1; f2_endcap = myf2; f3_endcap = myf3; re233e237_endcap = myre233e237; re237e277_endcap = myre237e277; - fill("MonitorElectron",np_endcap,nofblayerhits_endcap,nofpixelhits_endcap,nofscthits_endcap,noftrthits_endcap,noftrthighthresholdhits_endcap, - deltaeta1_endcap, deltaphi2_endcap,trackd0_endcap,eoverp_endcap,et_endcap,eta_endcap,phi_endcap, - time_endcap, ehad1_endcap,coreem_endcap, - f0_endcap,f1_endcap,f2_endcap,f3_endcap,re233e237_endcap,re237e277_endcap,is_pt_gt_4gev_endcap,is_pt_gt_2_5gev_endcap,is_pt_gt_20gev_endcap); - break; - - case CRACK : - nofblayerhits_crack = mynofblayerhits; nofpixelhits_crack = mynofpixelhits ; nofscthits_crack = mynofscthits ; - noftrthits_crack = mynoftrthits ; noftrthighthresholdhits_crack = mynoftrthighthresholdhits; - deltaeta1_crack = mydeltaeta1; deltaphi2_crack = mydeltaphi2; trackd0_crack = mytrackd0; - eoverp_crack = myeoverp; - et_crack = myet ; eta_crack = myeta ; phi_crack = myphi ; - time_crack = mytime; ehad1_crack = myehad1; coreem_crack = myecore; - f0_crack = myf0; f1_crack = myf1; f2_crack = myf2; f3_crack = myf3; re233e237_crack = myre233e237; re237e277_crack = myre237e277; - fill("MonitorElectron",np_crack,nofblayerhits_crack, nofpixelhits_crack,nofscthits_crack,noftrthits_crack,noftrthighthresholdhits_crack, - deltaeta1_crack, deltaphi2_crack,trackd0_crack,eoverp_crack,et_crack,eta_crack,phi_crack, - time_crack, ehad1_crack,coreem_crack,f0_crack,f1_crack,f2_crack,f3_crack,re233e237_crack,re237e277_crack,is_pt_gt_4gev_crack,is_pt_gt_2_5gev_crack,is_pt_gt_20gev_crack); - break; - - default : - ATH_MSG_DEBUG("found an electron outside the |eta| > 2.47 acceptance"); - break; + else { + ATH_MSG_DEBUG("Error attempting to retrieve associated cluster"); } - - et = myet ; eta = myeta ; phi = myphi ; - fill("MonitorElectron",et,eta,phi,time,ptcone20,topoetcone40,lbNCandidates, - is_pt_gt_2_5gev, is_pt_gt_4gev, is_pt_gt_20gev); - - // Fill. First argument is the tool name, all others are the variables to be histogramed + } + else { + ATH_MSG_DEBUG("found an electron outside the |eta| > 2.47 acceptance"); } - np = mynp; - np_barrel = mynp_barrel; - np_endcap = mynp_endcap; - np_crack = mynp_crack; - - fill("MonitorElectron",np,np_barrel,np_endcap,np_crack); - - return StatusCode::SUCCESS; + fillMonitorElectron( + *this, + Scalar<Float_t>("Et", myet), + // Check if small differences between old and new monitoring are related to rounding effects + //Scalar<Float_t>("Eta", myeta), + Scalar<Double_t>("Eta", myeta), + Scalar<Float_t>("Phi", myphi), + Scalar<Float_t>("Time", mytime), + Scalar<Float_t>("TopoEtCone40", isolationValueFloat(*e_iter, xAOD::Iso::topoetcone40)), + Scalar<Float_t>("PtCone20", isolationValueFloat(*e_iter, xAOD::Iso::ptcone20)), + Scalar<u_int16_t>("LBEvoN", GetEventInfo(ctx)->lumiBlock()), + Scalar<bool>("is_pt_gt_2_5gev", myet > 2500.), + Scalar<bool>("is_pt_gt_4gev", myet > 4000.), + Scalar<bool>("is_pt_gt_20gev", myet > 20000.) + ); + } + + fillMonitorElectron( + *this, + Scalar<int>("N", mynp), + Scalar<int>("NinBARREL", region_counters[BARREL]), + Scalar<int>("NinENDCAP", region_counters[ENDCAP]), + Scalar<int>("NinCRACK", region_counters[CRACK]) + ); + + return StatusCode::SUCCESS; } diff --git a/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.h b/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.h index ce6d345f45e8b6341853422fd13dbc2a0ca314ec..bf0728ef102d7c5c47bc6be8930b920ec5f22ca7 100755 --- a/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.h +++ b/Reconstruction/egamma/egammaPerformance/src/MonitorElectronAlgorithm.h @@ -16,36 +16,22 @@ #include "xAODEgamma/Electron.h" #include "xAODEgamma/ElectronContainer.h" #include "xAODEgamma/ElectronxAODHelpers.h" +#include "xAODEgamma/EgammaxAODHelpers.h" #include <string> class MonitorElectronAlgorithm : public AthMonitorAlgorithm { public: - MonitorElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); - virtual ~MonitorElectronAlgorithm(); - virtual StatusCode initialize() override; - StatusCode fillHistograms( const EventContext& ctx ) const override; - - enum Regions : int { BARREL=0, CRACK, ENDCAP, FORWARD, NREGIONS }; + MonitorElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ); + virtual ~MonitorElectronAlgorithm(); + virtual StatusCode initialize() override; + StatusCode fillHistograms( const EventContext& ctx ) const override; private: - SG::ReadHandleKey<xAOD::ElectronContainer> m_ParticleContainerKey {this, "ParticleContainerName", "Electrons", "Name of electron container" }; SG::ReadDecorHandleKeyArray<xAOD::ElectronContainer> m_ElectronIsolationKey {this, "ElectronIsolationKey", {"Electrons.ptcone20", "Electrons.topoetcone40"} }; Gaudi::Property<std::string> m_ParticlePrefix {this,"ParticlePrefix","electron","Name of the particle prefix to be used to define hists"}; Gaudi::Property<std::string> m_RecoName {this,"RecoName","LHTight","Name of particle flavor in egamma reco"}; Gaudi::Property<std::string> m_WithTrigger {this,"WithTrigger","","Name extension when electrons are chosen from triggered events"}; - - Regions GetRegion(Float_t eta) const { - Float_t aeta = fabs(eta); - // check if object is in barrel - if ( aeta < 1.37 ) return MonitorElectronAlgorithm::BARREL; - // check if object is in end-caps - if ( aeta > 1.52 && aeta < 2.47 ) return MonitorElectronAlgorithm::ENDCAP; - // check if object is in crack region - if ( aeta > 1.37 && aeta < 1.52 ) return MonitorElectronAlgorithm::CRACK; - return MonitorElectronAlgorithm::NREGIONS; // out of acceptance - } - }; #endif