diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx index a7cb3da37687504b89c78a1330bdeb88753756a8..e3f2596b7fc70f440c684ec0e140a6e83bdecc6a 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx @@ -15,147 +15,121 @@ #include <boost/foreach.hpp> //********************************************************************** -EfficiencyTool:: -EfficiencyTool( const std::string& myname ) -: TrigEgammaAnalysisBaseTool(myname) { +EfficiencyTool::EfficiencyTool(const std::string& myname): + TrigEgammaAnalysisBaseTool(myname) +{ m_detailedHists=false; } //********************************************************************** -StatusCode EfficiencyTool::childInitialize(){ - - +StatusCode EfficiencyTool::childInitialize() +{ return StatusCode::SUCCESS; } StatusCode EfficiencyTool::childBook() { - return StatusCode::SUCCESS; } + StatusCode EfficiencyTool::childExecute() { - return StatusCode::SUCCESS; } -StatusCode EfficiencyTool::childFinalize(){ +StatusCode EfficiencyTool::childFinalize() +{ return StatusCode::SUCCESS; } -void EfficiencyTool::analyseIsEMLH(const xAOD::Electron *eg, const std::string pid/*, const std::bitset<4> reco*/){ - - const std::string name1="IsEmLHFail"+pid; - const std::string pidword="isEMLH"+pid; - if(eg){ - unsigned int isem = eg->selectionisEM(pidword); - //float isolation=getIsolation_ptcone20(eg)/eg->pt(); - for(int ii=0;ii<11;ii++){ - if ( (isem>>ii) & 0x1 ) - hist1(name1)->Fill(ii+0.5); +bool EfficiencyTool::analyseIsEMLH(const xAOD::Electron *eg, const std::string pid) +{ + const std::string pidword = "isEM" + pid; + const std::string fail = "Fail" + pidword; + const std::string ineff = "Ineff" + pidword; + + unsigned int isem = eg->selectionisEM(pidword); + + bool failIsEMLH = false; + for (int ii = 0; ii < 11; ii++) { + if ((isem >> ii) & 0x1) { + failIsEMLH = true; + hist1(fail)->Fill(ii + 0.5); + hist1(ineff)->Fill(ii + 3.5, 1); } } + return failIsEMLH; } -/************************************************************************************************************************************************ - * 32-bit isEM cut-based electron ID as defined here - * https://svnweb.cern.ch/trac/atlasoff/browser/PhysicsAnalysis/ElectronPhotonID/ElectronPhotonSelectorTools/trunk/python/TrigEGammaPIDdefs.py - ClusterEtaRange_Electron = 0""" @brief cluster eta range """ - ConversionMatch_Electron = 1""" @brief matching to photon (not necessarily conversion--the name is historical) """ - ClusterHadronicLeakage_Electron = 2""" @brief cluster leakage into the hadronic calorimeter """ - ClusterMiddleEnergy_Electron = 3""" @brief energy in 2nd sampling (e.g E277>0) """ - ClusterMiddleEratio37_Electron = 4""" @brief energy ratio in 2nd sampling (e.g E237/E277) """ - ClusterMiddleEratio33_Electron = 5""" @brief energy ratio in 2nd sampling (e.g E233/E237) """ - ClusterMiddleWidth_Electron = 6""" @brief width in the second sampling (e.g Weta2) """ - ClusterBackEnergyFraction_Electron = 7""" @brief energy fraction in the third layer """ - ClusterStripsEratio_Electron = 8""" @brief fraction of energy found in 1st sampling (NB: not used in fact for electrons)""" - ClusterStripsDeltaEmax2_Electron = 9""" @brief energy of 2nd maximum in 1st sampling ~e2tsts1/(1000+const_lumi*et) """ - ClusterStripsDeltaE_Electron = 10""" @brief difference between 2nd maximum and 1st minimum in strips (e2tsts1-emins1) """ - ClusterStripsWtot_Electron = 11""" @brief shower width in 1st sampling """ - ClusterStripsFracm_Electron = 12""" @brief shower shape in shower core 1st sampling """ - ClusterStripsWeta1c_Electron = 13""" @brief shower width weighted by distance from the maximum one """ - Empty = 14 Empty bit - ClusterStripsDEmaxs1_Electron = 15""" @brief difference between max and 2nd max in strips """ - TrackBlayer_Electron = 16""" @brief B layer hit """ - TrackPixel_Electron = 17""" @brief number of Pixel hits """ - TrackSi_Electron = 18""" @brief number of Pixel and SCT hits """ - TrackA0_Electron = 19""" @brief distance of closet approach """ - TrackMatchEta_Electron = 20""" @brief eta difference between cluster and extrapolated track in the 1st sampling """ - TrackMatchPhi_Electron = 21""" @brief phi difference between cluster and extrapolated track in the 2nd sampling """ - TrackMatchEoverP_Electron = 22""" @brief energy-momentum match """ - TrackTRTeProbabilityHT_Electron = 23""" @brief Cut on the TRT eProbabilityHT_Electron """ - TrackTRThits_Electron = 24""" @brief number of TRT hits """ - TrackTRTratio_Electron = 25""" @brief ratio of high to all TRT hits for isolated electrons """ - TrackTRTratio90_Electron = 26""" @brief ratio of high to all TRT hits for non-isolated electrons """ - TrackA0Tight_Electron = 27""" @brief distance of closet approach for tight selection """ - TrackMatchEtaTight_Electron = 28""" @brief eta difference between cluster and extrapolated track in the 1st sampling for tight selection """ - Isolation_Electron = 29""" @brief isolation """ - ClusterIsolation_Electron = 30""" @brief calorimetric isolation """ - TrackIsolation_Electron = 31""" @brief tracker isolation """ - **************************************************************************************************************************************************/ -void EfficiencyTool::analyseIsEM(const xAOD::Electron *eg, const std::string pid,const std::bitset<4> reco){ - //{"ShowerShape","TrkClus","Track","TRT","Track+TRT","TrkClus+Trk+TRT","Isolation","IsEM + Iso","Track+Cluster","Track Only","Cluster","PhotonCluster","No Object","Some object","Unknown","Total"}; - const std::string name1="IsEmFail"+pid; - const std::string name2="IneffIsEm"+pid; - const std::string pidword="isEM"+pid; - // reco; //Electron, cluster, track, photon - if(eg){ - bool cluster=false; - bool trkclus=false; - bool trk=false; - bool trt=false; - bool failisem=false; - bool failiso=false; - - unsigned int isem = eg->selectionisEM(pidword); - float isolation=getIsolation_ptcone20(eg)/eg->pt(); - if(isolation>0.1) failiso=true; - for(int ii=0;ii<29;ii++){ - if ( (isem>>ii) & 0x1 ){ - failisem=true; - hist1(name1)->Fill(ii+0.5); - if(ii <= 15) - if ( (isem>>ii) & 0x1 ) cluster=true; - if((ii >=16 && ii <= 19) || ii == 27) - if ( (isem>>ii) & 0x1 ) trk=true; - if(ii == 20 || ii == 21 || ii == 22 || ii == 28) - if ( (isem>>ii) & 0x1 ) trkclus=true; - if(ii >= 23 && ii <= 26) - if ( (isem>>ii) & 0x1 ) trt=true; +bool EfficiencyTool::analyseIsEM(const xAOD::Electron *eg, const std::string pid) +{ + const std::string pidword = "isEM" + pid; + const std::string fail = "Fail" + pidword; + const std::string ineff = "Ineff" + pidword; + const std::string ineffTrk = ineff + "Trk"; + const std::string ineffTrkClus = ineff + "TrkClus"; + const std::string ineffTRT = ineff + "TRT"; + + bool failclus = false; + bool failtrkclus = false; + bool failtrk = false; + bool failtrt = false; + bool failisem = false; + + unsigned int isem = eg->selectionisEM(pidword); + + for (int ii = 0; ii < 29; ii++) { + if ((isem >> ii) & 0x1) { + failisem = true; + hist1(fail)->Fill(ii + 0.5); + if (ii >= 16 && ii <= 19) { + failtrk = true; + hist1(ineffTrk)->Fill(ii - 15.5, 1); + hist1(ineffTrk)->Fill(5.5, 1); + } + if (ii == 27) { + failtrk = true; + hist1(ineffTrk)->Fill(4.5, 1); + hist1(ineffTrk)->Fill(5.5, 1); + } + if (ii == 20 || ii == 21 || ii == 22) { + failtrkclus = true; + hist1(ineffTrkClus)->Fill(ii - 19.5, 1); + hist1(ineffTrkClus)->Fill(4.5, 1); + } + if (ii == 28) { + failtrkclus = true; + hist1(ineffTrkClus)->Fill(3.5, 1); + hist1(ineffTrkClus)->Fill(4.5, 1); + } + if (ii >= 23 && ii <= 26) { + failtrt = true; + hist1(ineffTRT)->Fill(ii - 22.5, 1); + hist1(ineffTRT)->Fill(4.5, 1); } } - if(failiso) hist1(name1)->Fill(31+0.5); - - bool onlyclus= !trkclus && !trk && !trt && cluster && !failiso; - bool onlytrkclus= trkclus && !trk && !trt && !cluster && !failiso; - bool onlytrk= !trkclus && trk && !trt && !cluster && !failiso; - bool trktrt= !trkclus && trk && trt && !cluster && !failiso; - bool onlytrt= !trkclus && !trk && trt && !cluster && !failiso; - bool trkclustrktrt= trkclus && trk && trt && !cluster && !failiso; - bool onlyiso= !trkclus && !trk && !trt && !cluster && failiso; - - if(onlyclus) hist1(name2)->Fill(0.5,1); // 0.5 - else if(onlytrkclus) hist1(name2)->Fill(1.5,1); - else if(onlytrk) hist1(name2)->Fill(2.5,1); - else if(onlytrt) hist1(name2)->Fill(3.5,1); - else if(trktrt) hist1(name2)->Fill(4.5,1); - else if(trkclustrktrt) hist1(name2)->Fill(5.5,1); - else if(onlyiso) hist1(name2)->Fill(6.5,1); - else if(failisem || failiso) hist1(name2)->Fill(7.5,1); //Something failed - else hist1(name2)->Fill(13.5,1); // Unknown -- some combination failed + } - else if(!reco.test(0) && reco.test(1) && reco.test(2)) hist1(name2)->Fill(8.5,1); //Track and Cluster - else if(!reco.test(0) && !reco.test(1) && reco.test(2)) hist1(name2)->Fill(9.5,1); // No Cluster w/ track - else if(!reco.test(0) && reco.test(1) && !reco.test(2)) hist1(name2)->Fill(10.5,1); //Cluster Only - else if(!reco.test(0) && !reco.test(1) && !reco.test(2) && !reco.test(3)) hist1(name2)->Fill(12.5,1); // No object in RoI - else if(reco.test(1)||reco.test(2)||reco.test(3)) hist1(name2)->Fill(13.5,1); - else hist1(name2)->Fill(14.5,1); - - if(reco.test(3) && reco.test(1)) hist1(name2)->Fill(11.5,1); //Has cluster and photon --> should be same as cluster only? - hist1(name2)->Fill(15.5,1); + bool onlyclus = !failtrkclus && !failtrk && !failtrt && failclus; + bool onlytrkclus = failtrkclus && !failtrk && !failtrt && !failclus; + bool onlytrk = !failtrkclus && failtrk && !failtrt && !failclus; + bool trktrt = !failtrkclus && failtrk && failtrt && !failclus; + bool onlytrt = !failtrkclus && !failtrk && failtrt && !failclus; + bool trkclustrktrt = failtrkclus && failtrk && failtrt && !failclus; + + if (onlyclus) hist1(ineff)->Fill(3.5, 1); + else if (onlytrkclus) hist1(ineff)->Fill(4.5, 1); + else if (onlytrk) hist1(ineff)->Fill(5.5, 1); + else if (onlytrt) hist1(ineff)->Fill(6.5, 1); + else if (trktrt) hist1(ineff)->Fill(7.5, 1); + else if (trkclustrktrt) hist1(ineff)->Fill(8.5, 1); + else hist1(ineff)->Fill(23.5, 1); // Unknown -- some combination failed + + return failisem; } -void EfficiencyTool::fillInefficiency(const std::string dir,const xAOD::Electron *selEF,const xAOD::Photon *selPh,const xAOD::CaloCluster *clus,const xAOD::TrackParticle *trk){ +void EfficiencyTool::fillInefficiency(const std::string& pid, const std::string dir,const xAOD::Electron *selEF,const xAOD::Photon *selPh,const xAOD::CaloCluster *clus,const xAOD::TrackParticle *trk) +{ cd(dir); ATH_MSG_DEBUG("REGTEST::Inefficiency"); // Currently check the PID on the xAOD @@ -165,89 +139,153 @@ void EfficiencyTool::fillInefficiency(const std::string dir,const xAOD::Electron // 11 bins for isEMLH // Fill Reco efficiency (find a nearby object) - /*if(clus) hist1("eff_hltreco")->Fill("Cluster",1); + /*if(clus) hist1("eff_hltreco")->Fill("Cluster", 1); else hist1("eff_hltreco")->Fill("Cluster",0); - if(trk) hist1("eff_hltreco")->Fill("Track",1); + if(trk) hist1("eff_hltreco")->Fill("Track", 1); else hist1("eff_hltreco")->Fill("Track",0); - if(selPh) hist1("eff_hltreco")->Fill("Photon",1); + if(selPh) hist1("eff_hltreco")->Fill("Photon", 1); else hist1("eff_hltreco")->Fill("Photon",0); - if(selEF) hist1("eff_hltreco")->Fill("Electron",1); + if(selEF) hist1("eff_hltreco")->Fill("Electron", 1); else hist1("eff_hltreco")->Fill("Electron",0);*/ - - std::vector<std::string> pidnames {"Loose","Medium","Tight"}; std::bitset<4> reco; //Electron, cluster, track, photon + + bool failiso = false; + bool failbits = false; - if(selEF!=nullptr) reco.set(0); - if(clus!=nullptr) reco.set(1); - if(trk!=nullptr) reco.set(2); - if(selPh!=nullptr) reco.set(3); - for(const auto name:pidnames){ - analyseIsEM(selEF,name,reco); - analyseIsEMLH(selEF,name/*,reco*/); + if(selEF != nullptr) reco.set(0); + if(clus != nullptr) reco.set(1); + if(trk != nullptr) reco.set(2); + if(selPh != nullptr) reco.set(3); + + const std::string fail = "FailisEM" + pid; + const std::string ineff = "IneffisEM" + pid; + + float lastbin = hist1(ineff)->GetNbinsX() - 0.5; + float sumbin = lastbin - 1; + + if (!getAccept().getCutResult("L2Calo")) { + hist1(ineff)->Fill(0.5, 1); + hist1(ineff)->Fill(sumbin, 1); } - - float lastbinIsEM=hist1("IsEmFailTight")->GetNbinsX()-1; - float lastbinIsEMLH=hist1("IsEmLHFailTight")->GetNbinsX()-1; - for(const auto name:pidnames){ - hist1("IsEmFail"+name)->Fill(lastbinIsEM+0.5); - hist1("IsEmLHFail"+name)->Fill(lastbinIsEMLH+0.5); + else if (!getAccept().getCutResult("L2")) { + hist1(ineff)->Fill(1.5, 1); + hist1(ineff)->Fill(sumbin, 1); } - - if(selPh==nullptr) ATH_MSG_DEBUG("fillIneffiency::No photon found!"); - if(selEF!=nullptr){ - ATH_MSG_DEBUG("REGTEST::Inefficiency Electron pt, eta, phi "<< selEF->pt() << " " << selEF->eta() << " " << selEF->phi()); + else if (!getAccept().getCutResult("EFCalo")) { + hist1(ineff)->Fill(2.5, 1); + hist1(ineff)->Fill(sumbin, 1); } - else { - if(trk==nullptr && clus!=nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, nearby cluster"); - // No electron candidate but we have photon - // Do something for hasCluster - for(const auto name:pidnames){ - hist1("IsEmFail"+name)->Fill( (lastbinIsEM-3) + 0.5); - hist1("IsEmLHFail"+name)->Fill( (lastbinIsEMLH-3) + 0.5); + // else if (!getAccept().getCutResult("EFTrack")) { + // hist1(ineff)->Fill(3.5, 1); + // hist1(ineff)->Fill(13.5, 1); + // } + else if (!getAccept().getCutResult("HLT")) { + if (reco.test(0)) { + if (boost::contains(pid, "LH")) failbits = analyseIsEMLH(selEF, pid); + else failbits = analyseIsEM(selEF, pid); + + float isolation = getIsolation_ptcone20(selEF) / selEF->pt(); + if(isolation > 0.1) failiso = true; + if (failiso) hist1(fail)->Fill(31 + 0.5); + + if (failbits && !failiso) { + hist1(ineff)->Fill(lastbin - 11, 1); + hist1(ineff)->Fill(sumbin, 1); } - } - if(clus==nullptr && trk!=nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); - // No electron candidate but we have photon - // Do something for hasCluster - for(const auto name:pidnames){ - hist1("IsEmFail"+name)->Fill( (lastbinIsEM-2) + 0.5); - hist1("IsEmLHFail"+name)->Fill( (lastbinIsEMLH-2) + 0.5); + else if (!failbits && failiso) { + hist1(ineff)->Fill(lastbin - 10, 1); + hist1(ineff)->Fill(sumbin, 1); } + else if (failbits || failiso) { + hist1(ineff)->Fill(lastbin - 9, 1); + hist1(ineff)->Fill(sumbin, 1); + } + else { + hist1(ineff)->Fill(lastbin - 2, 1); + hist1(ineff)->Fill(sumbin, 1); + } + } + else if (!reco.test(0) && reco.test(1) && reco.test(2)) { + hist1(ineff)->Fill(lastbin - 8, 1); //Track and Cluster + hist1(ineff)->Fill(sumbin, 1); + } + else if (!reco.test(0) && !reco.test(1) && reco.test(2)) { + hist1(ineff)->Fill(lastbin - 7, 1); // No Cluster w/ track + hist1(ineff)->Fill(sumbin, 1); } - if(clus==nullptr && trk==nullptr){ - ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); - // Unknown failure - for(const auto name:pidnames){ - hist1("IsEmFail"+name)->Fill( (lastbinIsEM-1) + 0.5); - hist1("IsEmLHFail"+name)->Fill( (lastbinIsEMLH-1) + 0.5); + else if (!reco.test(0) && reco.test(1) && !reco.test(2)) { + hist1(ineff)->Fill(lastbin - 6, 1); //Cluster Only + hist1(ineff)->Fill(sumbin, 1); + } + else if (!reco.test(0) && !reco.test(1) && !reco.test(2) && !reco.test(3)) { + hist1(ineff)->Fill(lastbin - 5, 1); // No object in RoI + hist1(ineff)->Fill(sumbin, 1); + } + else if (reco.test(1) || reco.test(2) || reco.test(3)) { + hist1(ineff)->Fill(lastbin - 4, 1); + hist1(ineff)->Fill(sumbin, 1); + } + else { + hist1(ineff)->Fill(lastbin - 3, 1); + hist1(ineff)->Fill(sumbin, 1); + } + + // hist1(ineff)->Fill(n + 12.5, 1); // total (HLT) + + // if(reco.test(3) && reco.test(1)) hist1(ineff)->Fill(n + 7.5, 1); //Has cluster and photon --> should be same as cluster only? + + float lastbinfail = hist1(fail)->GetNbinsX() - 1; + hist1(fail)->Fill(lastbinfail + 0.5); + + if (selPh == nullptr) ATH_MSG_DEBUG("fillIneffiency::No photon found!"); + if (selEF != nullptr){ + ATH_MSG_DEBUG("REGTEST::Inefficiency Electron pt, eta, phi "<< selEF->pt() << " " << selEF->eta() << " " << selEF->phi()); + } + else { + if (trk == nullptr && clus != nullptr){ + ATH_MSG_DEBUG("fillInefficiency::No Electron, nearby cluster"); + // No electron candidate but we have photon + // Do something for hasCluster + hist1(fail)->Fill((lastbinfail - 3) + 0.5); + } + if (clus == nullptr && trk != nullptr){ + ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); + // No electron candidate but we have photon + // Do something for hasCluster + hist1(fail)->Fill((lastbinfail - 2) + 0.5); + } + if (clus == nullptr && trk == nullptr){ + ATH_MSG_DEBUG("fillInefficiency::No Electron, no cluster"); + // Unknown failure + hist1(fail)->Fill((lastbinfail - 1) + 0.5); } } + if (clus != nullptr) ATH_MSG_DEBUG("REGTEST::Inefficiency Cluster " << clus->et() << " " << clus->eta() << " " << clus->phi()); + if (trk != nullptr) ATH_MSG_DEBUG("REGTEST::Inefficiency Track " << trk->pt() << " " << trk->eta() << " " << trk->phi()); + else ATH_MSG_DEBUG("REGTEST::Inefficiency No track"); } - if(clus!=nullptr) ATH_MSG_DEBUG("REGTEST::Inefficiency Cluster " << clus->et() << " " << clus->eta() << " " << clus->phi()); - if(trk!=nullptr) ATH_MSG_DEBUG("REGTEST::Inefficiency Track " << trk->pt() << " " << trk->eta() << " " << trk->phi()); - else ATH_MSG_DEBUG("REGTEST::Inefficiency No track"); + hist1(ineff)->Fill(lastbin, 1); } -void EfficiencyTool::inefficiency(const std::string basePath,const float etthr, - std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj){ +void EfficiencyTool::inefficiency(const std::string& pid, const std::string basePath,const float etthr, + std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj) +{ ATH_MSG_DEBUG("INEFF::Start Inefficiency Analysis ======================= " << basePath); cd(basePath); // Inefficiency analysis - float et=0.; - const xAOD::Egamma* eg =pairObj.first; + float et = 0.0; + const xAOD::Egamma* eg = pairObj.first; const HLT::TriggerElement *feat = pairObj.second; if(xAOD::EgammaHelpers::isElectron(pairObj.first)){ ATH_MSG_DEBUG("Offline Electron"); - const xAOD::Electron* el =static_cast<const xAOD::Electron*> (eg); - et = getEt(el)/1e3; + const xAOD::Electron* el = static_cast<const xAOD::Electron*>(eg); + et = getEt(el) / 1e3; } - else et=eg->caloCluster()->et()/1e3; + else et = eg->caloCluster()->et() / 1e3; float eta = eg->eta(); float phi = eg->phi(); @@ -258,17 +296,12 @@ void EfficiencyTool::inefficiency(const std::string basePath,const float etthr, const xAOD::CaloCluster* selClus = nullptr; const xAOD::TrackParticle* selTrk = nullptr; - float dRmax=0.07; + float dRmax = 0.07; - std::vector<std::string> pidnames {"Loose","Medium","Tight"}; - if(getAccept().getCutResult("HLT")){ - for(const auto name:pidnames){ - for(int ibin=0; ibin<hist1("IneffIsEm"+name)->GetNbinsX();ibin++) - hist1("IneffIsEm"+name)->Fill(ibin+0.5,0); - } - } - // Ensure L1 passes - // And offline passes et cut + const std::string pidword = "isEM" + pid; + const std::string ineff = "Ineff" + pidword; + + // Ensure L1 passes and offline passes et cut if(getAccept().getCutResult("L1Calo") && et > etthr) { ATH_MSG_DEBUG("INEFF::Passed L1 and offline et"); hist1("eff_triggerstep")->Fill("L2Calo",getAccept().getCutResult("L2Calo")); @@ -278,105 +311,118 @@ void EfficiencyTool::inefficiency(const std::string basePath,const float etthr, hist1("eff_triggerstep")->Fill("HLT",getAccept().getCutResult("HLT")); // Fill efficiency plot for HLT trigger steps - if(!getAccept().getCutResult("HLT") && getAccept().getCutResult("EFCalo")){ + if(!getAccept().getCutResult("HLT")/* || !getAccept().getCutResult("EFTrack")*/ || !getAccept().getCutResult("EFCalo") || + !getAccept().getCutResult("L2") || !getAccept().getCutResult("L2Calo")) { ATH_MSG_DEBUG("INEFF::Retrieve features for EF containers only "); ATH_MSG_DEBUG("INEFF::Retrieve EF Electron"); const auto* EFEl = getFeature<xAOD::ElectronContainer>(feat); ATH_MSG_DEBUG("INEFF::Retrieve EF Photons"); const auto* EFPh = getFeature<xAOD::PhotonContainer>(feat); ATH_MSG_DEBUG("INEFF::Retrieve EF Cluster"); - const auto* EFClus = getFeature<xAOD::CaloClusterContainer>(feat); + const auto* EFClus = getFeature<xAOD::CaloClusterContainer>(feat,"TrigEFCaloCalibFex"); //ATH_MSG_DEBUG("INEFF::Retrieve EF Trk"); //const auto* L2Trk = getFeature<xAOD::TrackParticleContainer>(feat); //const auto* L2Trk = getFeature<xAOD::TrackParticleContainer>(feat,"InDetTrigTrackingxAODCnv_Electron_FTF"); //const auto* EFIDTrk = getFeature<xAOD::TrackParticleContainer>(feat,"InDetTrigTrackingxAODCnv_Electron_EFID"); const auto* EFTrkIDTrig = getFeature<xAOD::TrackParticleContainer>(feat,"InDetTrigTrackingxAODCnv_Electron_IDTrig"); - dRmax=0.15; + dRmax = 0.15; // Find closest object for all objects - selEF=closestObject<xAOD::Electron,xAOD::ElectronContainer>(pairObj,dRmax,false); - selPh=closestObject<xAOD::Photon,xAOD::PhotonContainer>(pairObj,dRmax,false); - selClus=closestObject<xAOD::CaloCluster,xAOD::CaloClusterContainer>(pairObj,dRmax,false); - selTrk=closestObject<xAOD::TrackParticle,xAOD::TrackParticleContainer>(pairObj,dRmax,false,"InDetTrigTrackingxAODCnv_Electron_IDTrig"); - fillInefficiency(basePath,selEF,selPh,selClus,selTrk); - if(EFClus==nullptr){ - hist1("eff_hltreco")->Fill("ClusterCont",0); - hist1("eff_hltreco")->Fill("Cluster",0); - hist1("eff_hltreco")->Fill("ClusterMatch",0); + selEF = closestObject<xAOD::Electron,xAOD::ElectronContainer>(pairObj, dRmax, false); + selPh = closestObject<xAOD::Photon,xAOD::PhotonContainer>(pairObj, dRmax, false); + selClus = closestObject<xAOD::CaloCluster,xAOD::CaloClusterContainer>(pairObj, dRmax, false,"TrigEFCaloCalibFex"); + selTrk = closestObject<xAOD::TrackParticle,xAOD::TrackParticleContainer>(pairObj, dRmax, false, "InDetTrigTrackingxAODCnv_Electron_IDTrig"); + fillInefficiency(pid, basePath, selEF, selPh, selClus, selTrk); + if (EFClus == nullptr){ + hist1("eff_hltreco")->Fill("ClusterCont", 0); + hist1("eff_hltreco")->Fill("Cluster", 0); + hist1("eff_hltreco")->Fill("ClusterMatch", 0); } else{ hist1("eff_hltreco")->Fill("ClusterCont",1); - if(EFClus->size() > 0){ + if (EFClus->size() > 0){ hist1("eff_hltreco")->Fill("Cluster",1); - if(selClus) hist1("eff_hltreco")->Fill("ClusterMatch",1); - else hist1("eff_hltreco")->Fill("ClusterMatch",0); + if (selClus) hist1("eff_hltreco")->Fill("ClusterMatch",1); + else hist1("eff_hltreco")->Fill("ClusterMatch", 0); } else{ - hist1("eff_hltreco")->Fill("Cluster",0); - hist1("eff_hltreco")->Fill("ClusterMatch",0); + hist1("eff_hltreco")->Fill("Cluster", 0); + hist1("eff_hltreco")->Fill("ClusterMatch", 0); } } - if(EFTrkIDTrig==nullptr){ - hist1("eff_hltreco")->Fill("TrackCont",0); - hist1("eff_hltreco")->Fill("Track",0); - hist1("eff_hltreco")->Fill("TrackMatch",0); + if (EFTrkIDTrig == nullptr){ + hist1("eff_hltreco")->Fill("TrackCont", 0); + hist1("eff_hltreco")->Fill("Track", 0); + hist1("eff_hltreco")->Fill("TrackMatch", 0); } else{ hist1("eff_hltreco")->Fill("TrackCont",1); - if(EFTrkIDTrig->size() > 0){ + if (EFTrkIDTrig->size() > 0){ hist1("eff_hltreco")->Fill("Track",1); - if(selTrk) hist1("eff_hltreco")->Fill("TrackMatch",1); - else hist1("eff_hltreco")->Fill("TrackMatch",0); + if (selTrk) hist1("eff_hltreco")->Fill("TrackMatch",1); + else hist1("eff_hltreco")->Fill("TrackMatch", 0); } else{ - hist1("eff_hltreco")->Fill("Track",0); - hist1("eff_hltreco")->Fill("TrackMatch",0); + hist1("eff_hltreco")->Fill("Track", 0); + hist1("eff_hltreco")->Fill("TrackMatch", 0); } } - if(EFPh==nullptr){ - hist1("eff_hltreco")->Fill("PhotonCont",0); - hist1("eff_hltreco")->Fill("Photon",0); - hist1("eff_hltreco")->Fill("PhotonMatch",0); + if (EFPh == nullptr){ + hist1("eff_hltreco")->Fill("PhotonCont", 0); + hist1("eff_hltreco")->Fill("Photon", 0); + hist1("eff_hltreco")->Fill("PhotonMatch", 0); } else { hist1("eff_hltreco")->Fill("PhotonCont",1); - if(EFPh->size() > 0){ + if (EFPh->size() > 0){ hist1("eff_hltreco")->Fill("Photon",1); - if(selPh) hist1("eff_hltreco")->Fill("PhotonMatch",1); - else hist1("eff_hltreco")->Fill("PhotonMatch",0); + if (selPh) hist1("eff_hltreco")->Fill("PhotonMatch",1); + else hist1("eff_hltreco")->Fill("PhotonMatch", 0); } else{ - hist1("eff_hltreco")->Fill("Photon",0); - hist1("eff_hltreco")->Fill("PhotonMatch",0); + hist1("eff_hltreco")->Fill("Photon", 0); + hist1("eff_hltreco")->Fill("PhotonMatch", 0); } } - if(EFEl==nullptr){ - hist1("eff_hltreco")->Fill("ElectronCont",0); - hist1("eff_hltreco")->Fill("Electron",0); - hist1("eff_hltreco")->Fill("ElectronMatch",0); + if (EFEl == nullptr){ + hist1("eff_hltreco")->Fill("ElectronCont", 0); + hist1("eff_hltreco")->Fill("Electron", 0); + hist1("eff_hltreco")->Fill("ElectronMatch", 0); } else { hist1("eff_hltreco")->Fill("ElectronCont",1); - if(EFEl->size() > 0){ + if (EFEl->size() > 0){ hist1("eff_hltreco")->Fill("Electron",1); if(selEF) hist1("eff_hltreco")->Fill("ElectronMatch",1); - else hist1("eff_hltreco")->Fill("ElectronMatch",0); + else hist1("eff_hltreco")->Fill("ElectronMatch", 0); } else{ - hist1("eff_hltreco")->Fill("Electron",0); - hist1("eff_hltreco")->Fill("ElectronMatch",0); + hist1("eff_hltreco")->Fill("Electron", 0); + hist1("eff_hltreco")->Fill("ElectronMatch", 0); } } - - + } + else { + if (boost::contains(pid, "LH")) + for (int ibin = 0; ibin < hist1("IneffisEM" + pid)->GetNbinsX(); ibin++) + hist1("IneffisEM" + pid)->Fill(ibin + 0.5, 0); + else { + std::vector<std::string> groupnames {"Trk", "TrkClus", "TRT"}; + for (int ibin = 0; ibin < hist1("IneffisEM" + pid)->GetNbinsX(); ibin++) + hist1("IneffisEM" + pid)->Fill(ibin + 0.5, 0); + for (const auto groupname : groupnames) + for (int ibin = 0; ibin < hist1("IneffisEM" + pid + groupname)->GetNbinsX(); ibin++) + hist1("IneffisEM" + pid + groupname)->Fill(ibin + 0.5, 0); + } } } ATH_MSG_DEBUG("End Inefficiency Analysis ======================= " << basePath); } -void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const float etthr, const std::string pidword, const xAOD::Egamma *eg, bool fill2D){ +void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const float etthr, const std::string pidword, const xAOD::Egamma *eg, bool fill2D) +{ cd(dir); float et=0.; bool pid=true; @@ -458,9 +504,9 @@ void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const fl } // Passes offline pid, fill histograms } -StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo info, - std::vector<std::pair< const xAOD::Egamma*,const HLT::TriggerElement*>> pairObjs){ - +StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo info, std::vector<std::pair< const xAOD::Egamma*, + const HLT::TriggerElement*>> pairObjs) +{ if(m_tp) return StatusCode::SUCCESS; // Removing Prescale check, in reprocessing L1AfterPrescale always false @@ -473,6 +519,7 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo const std::string dir = basePath+"/"+info.trigName; const float etthr = info.trigThrHLT; const std::string pidword = info.trigPidDecorator; + const std::string pid = info.trigPidDecorator.substr(2); ATH_MSG_DEBUG("Efficiency for " << info.trigName << " " <<pidword); for(const auto pairObj : pairObjs){ @@ -511,8 +558,9 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo // Inefficiency analysis if(!info.trigL1){ if(pairObj.first->type()==xAOD::Type::Electron){ - if(!pairObj.first->auxdecor<bool>(info.trigPidDecorator)) continue; - inefficiency(dir+"/"+algname+"/HLT",etthr,pairObj); + if(pairObj.first->auxdecor<bool>(pidword)){ + inefficiency(pid,dir+"/"+algname+"/HLT",etthr,pairObj); + } } } } // Features @@ -543,9 +591,7 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo ialg++; }// Loop over efficiency (and or) Emulation - }// Loop over trigger electrons pairs - return StatusCode::SUCCESS; } diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx index dcd1c0e0291d1485158ed2ed0cc00ed75cd90032..725ccfca5b95630d3ece64ef740501429be0982d 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx @@ -120,7 +120,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i for (const auto feat : vec_el){ if(feat.te()==nullptr) continue; const auto* cont = getFeature<xAOD::ElectronContainer>(feat.te()); - const auto *bits = getFeature<TrigPassBits>(feat.te()); + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<xAOD::ElectronContainer>(feat.te(),cont); if(cont==nullptr) continue; cd(dir+"HLT"); if(ancestorPassed<xAOD::ElectronContainer>(feat.te())) @@ -132,8 +132,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i fillTracking(dir+"HLT",obj); // Fill HLT shower shapes } // Only consider passing objects if bits available - //else if(!bits->isPassing(obj,cont)) continue; - else if(!HLT::isPassing(bits,obj,cont) ) continue; + else if(!bits->isPassing(obj,cont)) continue; fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes fillTracking(dir+"HLT",obj); // Fill HLT shower shapes } @@ -155,23 +154,22 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i if(boost::contains(info.trigName,"ringer") || info.trigEtcut || info.trigPerf) fillRinger(dir+"L2Calo",obj); // Fill HLT shower shapes } - // Should monitor the selected objects - // Currently not implemented for EFCalo const auto vec_clus = fc.get<xAOD::CaloClusterContainer>("TrigEFCaloCalibFex",TrigDefs::alsoDeactivateTEs); for(const auto feat : vec_clus){ if(feat.te()==nullptr) continue; - const auto *cont = getFeature<xAOD::CaloClusterContainer>(feat.te()); - const auto *bits = getFeature<TrigPassBits>(feat.te()); + const auto *cont = getFeature<xAOD::CaloClusterContainer>(feat.te(),"TrigEFCaloCalibFex"); + ATH_MSG_DEBUG("Retreive clusters, bits"); + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<xAOD::CaloClusterContainer>(feat.te(),cont); if(cont==nullptr) continue; + ATH_MSG_DEBUG("check bits"); if(bits==nullptr) continue; cd(dir+"HLT"); - if(ancestorPassed<xAOD::CaloClusterContainer>(feat.te())) + if(ancestorPassed<xAOD::CaloClusterContainer>(feat.te(),"TrigEFCaloCalibFex")) hist1("rejection")->Fill("EFCalo",1); + ATH_MSG_DEBUG("analyze clusters"); for(const auto& clus : *cont){ if(clus==nullptr) continue; - if(bits!=nullptr) - if(!HLT::isPassing(bits,clus,cont) ) continue; - //if(!bits->isPassing(clus,cont)) continue; + if(!bits->isPassing(clus,cont)) continue; fillEFCalo(dir+"EFCalo",clus); } } @@ -183,7 +181,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i for (const auto feat : vec_l2el){ if(feat.te()==nullptr) continue; const auto* cont = getFeature<xAOD::TrigElectronContainer>(feat.te()); - const auto *bits = getFeature<TrigPassBits>(feat.te()); + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<xAOD::TrigElectronContainer>(feat.te(),cont); if(bits==nullptr) continue; if(cont==nullptr) continue; cd(dir+"HLT"); @@ -192,8 +190,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i for(const auto& obj : *cont){ // Only consider passing objects if(!obj) continue; - if(!HLT::isPassing(bits,obj,cont) ) continue; - //if(!bits->isPassing(obj,cont)) continue; + if(!bits->isPassing(obj,cont)) continue; fillL2Electron(dir+"L2Electron",obj); // Fill HLT shower shapes } } @@ -201,7 +198,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i for (const auto feat : vec_el){ if(feat.te()==nullptr) continue; const auto* cont = getFeature<xAOD::ElectronContainer>(feat.te()); - const auto *bits = getFeature<TrigPassBits>(feat.te()); + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<xAOD::ElectronContainer>(feat.te(),cont); if(cont==nullptr) continue; cd(dir+"HLT"); if(ancestorPassed<xAOD::ElectronContainer>(feat.te())) @@ -213,8 +210,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i fillTracking(dir+"HLT",obj); // Fill HLT shower shapes } // Only consider passing objects if bits available - else if(!HLT::isPassing(bits,obj,cont) ) continue; - //else if(!bits->isPassing(obj,cont)) continue; + else if(!bits->isPassing(obj,cont)) continue; fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes fillTracking(dir+"HLT",obj); // Fill HLT shower shapes } @@ -225,7 +221,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i for (const auto feat : vec_ph){ if(feat.te()==nullptr) continue; const auto* cont = getFeature<xAOD::PhotonContainer>(feat.te()); - const auto *bits = getFeature<TrigPassBits>(feat.te()); + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<xAOD::PhotonContainer>(feat.te(),cont); if(cont==nullptr) continue; cd(dir+"HLT"); if(ancestorPassed<xAOD::PhotonContainer>(feat.te())) @@ -237,8 +233,7 @@ StatusCode TrigEgammaDistTool::toolExecute(const std::string basePath,TrigInfo i fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes } // Only consider passing objects if bits available - //else if(!bits->isPassing(obj,cont)) continue; - else if(!HLT::isPassing(bits,obj,cont) ) continue; + else if(!bits->isPassing(obj,cont)) continue; fillShowerShapes(dir+"HLT",obj); // Fill HLT shower shapes } } diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx index 8798acf8035499b7197d99c70a0191dbccf63dd7..a51655d48417e9fcc539b0ee951d5ba1123a67a6 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaPlotTool.cxx @@ -681,6 +681,13 @@ void TrigEgammaPlotTool::bookAbsResolutionHistos(const std::string directory){ addHistogram(new TH1F("res_d0", "resolution d0; (d0(on)-d0(off)) ; Count", 100, -0.5, 0.5)); addHistogram(new TH1F("res_d0sig", "resolution d0sig; (d0sig(on)-d0sig(off)) ; Count", 50, -10, 10)); addHistogram(new TH1F("res_eprobht","resolution eProbHT; (eProbHT(on)-eProbHT(off)); Count",50, -1, 1)); + // TRT + addHistogram(new TH2F("res_eprobhtVsPt", "eProbHT resolution as function of p_{T}; p_{T} [GeV]; (eprobHT(on)-eprobHT(off)); Count", + 50, 0., 100., + 50, -1., 1.)); + addHistogram(new TH2F("res_eprobht_onVsOff", "online eprobHT vs offline eprobHT; offline ; online ; Count", + 50, 0., 1., + 50, 0., 1.)); addHistogram(new TH1F("res_nscthits","resolution nSCTHit; (nSCTHits(on)-nSCTHits(off); Count",20, -10, 10)); addHistogram(new TH1F("res_npixhits","resolution nPixHit; (nPixHits(on)-nPixHits(off)); Count",10, -5, 5)); addHistogram(new TH1F("res_ptcone20", "resolution ptcone20; ptcone20 (on-off); Count", 200, -20, 20)); @@ -727,6 +734,13 @@ void TrigEgammaPlotTool::bookElectronResolutionHistos(const std::string director addHistogram(new TH1F("res_eprobht","resolution eProbHT; (eProbHT(on)-eProbHT(off)); Count",50, -1, 1)); addHistogram(new TH1F("res_nscthits","resolution nSCTHit; (nSCTHits(on)-nSCTHits(off); Count",20, -10, 10)); addHistogram(new TH1F("res_npixhits","resolution nPixHit; (nPixHits(on)-nPixHits(off)); Count",10, -5, 5)); + // TRT + addHistogram(new TH2F("res_eprobhtVsPt", "eProbHT resolution as function of p_{T}; p_{T} [GeV]; (eprobHT(on)-eprobHT(off)); Count", + 50, 0., 100., + 50, -1., 1.)); + addHistogram(new TH2F("res_eprobht_onVsOff", "online eprobHT vs offline eprobHT; offline ; online ; Count", + 50, 0., 1., + 50, 0., 1.)); } void TrigEgammaPlotTool::bookElectronIsoResolutionHistos(const std::string directory){ @@ -1173,22 +1187,6 @@ void TrigEgammaPlotTool::bookL1Histos(TrigInfo trigInfo){ void TrigEgammaPlotTool::bookExpertHistos(TrigInfo trigInfo){ - // Labels - std::vector<std::string> label_isem {"ClusterEtaRange","ConversionMatch", - "ClusterHadronicLeakage","ClusterMiddleEnergy","ClusterMiddleEratio37","ClusterMiddleEratio33","ClusterMiddleWidth", - "f3","ClusterStripsEratio","ClusterStripsDeltaEmax2","ClusterStripsDeltaE","ClusterStripsWtot","ClusterStripsFracm","ClusterStripsWeta1c", - "empty14","ClusterStripsDEmaxs1", - "TrackBlayer","TrackPixel","TrackSi","TrackA0","TrackMatchEta","TrackMatchPhi","TrackMatchEoverP","TrackTRTeProbabilityHT_Electron", - "TrackTRThits","TrackTRTratio","TrackTRTratio90","TrackA0Tight","TrackMatchEtaTight","Isolation","ClusterIsolation","TrackIsolation", - "No Track","No Cluster","No Object","Total"}; - - std::vector<std::string> label_islh {"Kinematic","NSi","NPix","NBlayer","Conversion","LH","A0","dEta","dPhiRes","WstotHighET","EoverPHighEt", - "No Track","No Cluster","No Object","Total"}; - - std::vector<std::string> label_isem2 {"ShowerShape","TrkClus","Track","TRT","Track + TRT","TrkClus+Trk+TRT","Isolation","IsEM||Iso", - "Track+Cluster","Track Only","Cluster","Photon+Cluster","No Object","Some Object","Unknown","Total"}; - - const std::string basePath=m_baseDir+"/Expert/"+trigInfo.trigName; std::string dirname; std::vector <std::string> dirnames; @@ -1223,26 +1221,55 @@ void TrigEgammaPlotTool::bookExpertHistos(TrigInfo trigInfo){ if(trigInfo.trigType=="electron"){ addHistogram(new TProfile("eff_triggerstep","eff_triggerstep",11,0,11)); addHistogram(new TProfile("eff_hltreco","eff_hltreco",12,0,12)); - addHistogram(new TH1F("IsEmFailLoose","IsEmFailLoose",36,0,36)); - addHistogram(new TH1F("IsEmFailMedium","IsEmFailMedium",36,0,36)); - addHistogram(new TH1F("IsEmFailTight","IsEmFailTight",36,0,36)); - addHistogram(new TProfile("IneffIsEmLoose","IsEmLoose",16,0,16)); - addHistogram(new TProfile("IneffIsEmMedium","IsEmMedium",16,0,16)); - addHistogram(new TProfile("IneffIsEmTight","IsEmTight",16,0,16)); setLabels(hist1("eff_triggerstep"),m_label_trigstep); setLabels(hist1("eff_hltreco"),m_label_hltobj); - setLabels(hist1("IsEmFailLoose"),label_isem); - setLabels(hist1("IsEmFailMedium"),label_isem); - setLabels(hist1("IsEmFailTight"),label_isem); - setLabels(hist1("IneffIsEmLoose"),label_isem2); - setLabels(hist1("IneffIsEmMedium"),label_isem2); - setLabels(hist1("IneffIsEmTight"),label_isem2); - addHistogram(new TH1F("IsEmLHFailLoose","IsEmLHFailLoose",15,0,15)); - addHistogram(new TH1F("IsEmLHFailMedium","IsEmLHFailMedium",15,0,15)); - addHistogram(new TH1F("IsEmLHFailTight","IsEmLHFailTight",15,0,15)); - setLabels(hist1("IsEmLHFailLoose"),label_islh); - setLabels(hist1("IsEmLHFailMedium"),label_islh); - setLabels(hist1("IsEmLHFailTight"),label_islh); + + // Labels + std::vector<std::string> label_failisem {"ClusterEtaRange","ConversionMatch", + "ClusterHadronicLeakage","ClusterMiddleEnergy","ClusterMiddleEratio37","ClusterMiddleEratio33","ClusterMiddleWidth", + "f3","ClusterStripsEratio","ClusterStripsDeltaEmax2","ClusterStripsDeltaE","ClusterStripsWtot","ClusterStripsFracm","ClusterStripsWeta1c", + "empty14","ClusterStripsDEmaxs1", + "TrackBlayer","TrackPixel","TrackSi","TrackA0","TrackMatchEta","TrackMatchPhi","TrackMatchEoverP","TrackTRTeProbabilityHT_Electron", + "TrackTRThits","TrackTRTratio","TrackTRTratio90","TrackA0Tight","TrackMatchEtaTight","Isolation","ClusterIsolation","TrackIsolation", + "No Track","No Cluster","No Object","Total"}; + + std::vector<std::string> label_failisemlh {"Kinematic","NSi","NPix","NBlayer","Conversion","LH","A0","dEta","dPhiRes","WstotHighET","EoverPHighEt", + "No Track","No Cluster","No Object","Total"}; + + std::vector<std::string> label_ineffisem {"L2Calo", "L2", "EFCalo",/* "EFTrack",*/ "Shower shape", "TrkClus", "Track", "TRT", "Track & TRT", "TrkClus & Trk & TRT", "IsEM", "Isolation", "isEMLH and Iso", "Track & Cluster", "No cluster", "No track", "No object", "Some object", "Unknown w/o electron", "Unknown w/ electron", "Sum", "Total"}; + + std::vector<std::string> label_ineffisemlh {"L2Calo", "L2", "EFCalo",/* "EFTrack",*/ "Kinematic", "NSi", "NPix", "NBlayer", "Conversion", "LH", "A0", "dEta", "dPhiRes", "WstotHighET", "EoverPHighEt", "isEMLH", "Isolation", "isEMLH & Iso", "Track & Cluster", "No cluster", "No track", "No object", "Some object", "Unknown w/o electron", "Unknown w/ electron", "Sum", "Total"}; + + std::vector<std::string> label_isem_trk {"TrackBlayer_Electron","TrackPixel_Electron","TrackSi_Electron","TrackA0Tight_Electron","Total"}; + std::vector<std::string> label_isem_trkclus {"#eta match","#phi match","E/p match","TrackMatchEtaTight_Electron","Total"}; + std::vector<std::string> label_isem_trt {"TrackTRTeProbabilityHT_Electron","TrackTRThits_Electron","TrackTRTratio_Electron","TrackTRTratio90_Electron","TrackA0Tight_Electron","Total"}; + + std::string pid = trigInfo.trigPidDecorator.substr(2); + const std::string fail = "FailisEM" + pid; + const std::string ineffisEM = "IneffisEM" + pid; + + if (boost::contains(pid, "LH")) { + addHistogram(new TH1F(fail.c_str(), fail.c_str(), 15, 0, 15)); + addHistogram(new TProfile(ineffisEM.c_str(), ineffisEM.c_str(), 26, 0, 26)); + setLabels(hist1(fail), label_failisemlh); + setLabels(hist1(ineffisEM), label_ineffisemlh); + } + else { + addHistogram(new TH1F(fail.c_str(), fail.c_str(), 36, 0, 36)); + addHistogram(new TProfile(ineffisEM.c_str(), ineffisEM.c_str(), 22, 0, 22)); + setLabels(hist1(fail), label_ineffisem); + setLabels(hist1(ineffisEM), label_failisem); + + const std::string ineffTrk = ineffisEM + "Trk"; + const std::string ineffTrkClus = ineffisEM + "TrkClus"; + const std::string ineffTRT = ineffisEM + "TRT"; + addHistogram(new TProfile(ineffTrk.c_str(), ineffTrk.c_str(), 6, 0, 6)); + addHistogram(new TProfile(ineffTrkClus.c_str(), ineffTrkClus.c_str(), 5, 0, 5)); + addHistogram(new TProfile(ineffTRT.c_str(), ineffTRT.c_str(), 5, 0, 5)); + setLabels(hist1(ineffTrk), label_isem_trk); + setLabels(hist1(ineffTrkClus), label_isem_trkclus); + setLabels(hist1(ineffTRT), label_isem_trt); + } } if ( m_detailedHists ) { diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx index dba938fd868b2cad1de2b60d041d14f5ba8aa1fb..5c88a8fb88f1ab918df3b11bf4d16c98516334b1 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx @@ -247,7 +247,11 @@ void TrigEgammaResolutionTool::fillHLTResolution(const std::string dir,const xAO // Absolute resolution on track summary ints/floats val_off=getTrackSummaryFloat_eProbabilityHT(eloff); - if(val_off!=0.) hist1("res_eprobht")->Fill( (getTrackSummaryFloat_eProbabilityHT(elonl)-val_off)); + hist1("res_eprobht")->Fill( (getTrackSummaryFloat_eProbabilityHT(elonl)-val_off)); + hist2("res_eprobht_onVsOff")->Fill(val_off, + getTrackSummaryFloat_eProbabilityHT(elonl)); + hist2("res_eprobhtVsPt")->Fill(getTrack_pt(elonl)/1e3, + (getTrackSummaryFloat_eProbabilityHT(elonl) - val_off)); hist1("res_npixhits")->Fill(getTrackSummary_numberOfPixelHits(elonl)-getTrackSummary_numberOfPixelHits(elonl)); hist1("res_nscthits")->Fill(getTrackSummary_numberOfSCTHits(elonl)-getTrackSummary_numberOfSCTHits(elonl)); diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h index 0e6d1d2fff55e7ac6ec346b2a84051ae6927daad..43d14419293930651cf5ddf2a9d49c2b671fd475 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h @@ -30,10 +30,10 @@ private: protected: void fillEfficiency(const std::string,bool,const float,const std::string,const xAOD::Egamma *,bool fill2D=true); - void inefficiency(const std::string,const float,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); - void fillInefficiency(const std::string,const xAOD::Electron *,const xAOD::Photon *,const xAOD::CaloCluster *,const xAOD::TrackParticle *); - void analyseIsEM(const xAOD::Electron *,const std::string,const std::bitset<4>); - void analyseIsEMLH(const xAOD::Electron *,const std::string/*,const std::bitset<4>*/); + void inefficiency(const std::string&,const std::string,const float,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); + void fillInefficiency(const std::string&,const std::string,const xAOD::Electron *,const xAOD::Photon *,const xAOD::CaloCluster *,const xAOD::TrackParticle *); + bool analyseIsEM(const xAOD::Electron *,const std::string); + bool analyseIsEMLH(const xAOD::Electron *,const std::string/*,const std::bitset<4>*/); /*! Include more detailed histograms */ bool m_detailedHists; bool m_doEmulation; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h index 95f0fda936ea1b92d21b97a3c17e58545033a6ac..db4527953bf344a329bd77d2fe3b3903e0b9da01 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h @@ -55,6 +55,8 @@ public: StatusCode book(); StatusCode execute(); StatusCode finalize(); + template<class T, class B> std::unique_ptr<xAOD::TrigPassBits> createBits(const T* CONT, const B* BITS); + template<class T> std::unique_ptr<xAOD::TrigPassBits> getBits(const HLT::TriggerElement* te,const T* CONT); template<class T> const T* getFeature(const HLT::TriggerElement* te,const std::string key=""); template<class T> bool ancestorPassed(const HLT::TriggerElement* te,const std::string key=""); template <class T1, class T2> const T1* closestObject(const std::pair<const xAOD::Egamma *, const HLT::TriggerElement *>, @@ -334,9 +336,54 @@ protected: * templates the TE to get a feature * or find the passing TE * **********************/ + +// Attempt to create a unique_ptr from existing xAOD::TrigPassBits +// crashes at container_clid and AuxVectorData line 424(359) +// when retrieving the cached auxid variable from store +// Assuming my attempt to utilise smart pointers breaks the caching of aux data in ESDtoAOD. +// +// Instead template the conversion and always create transient passBit +template<class CONT, class BITS> +std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::createBits(const CONT* container, const BITS* passbits){ + ATH_MSG_DEBUG("Converting "<< ClassID_traits< BITS >::ID() ); + std::unique_ptr<xAOD::TrigPassBits> xbits(new xAOD::TrigPassBits()); + xbits->makePrivateStore(); + xbits->reset(container); + xbits->setSize(passbits->size()); + if(passbits->size()==0){ + xbits->setPassBits( std::vector< uint32_t >() ); + } + else { + xbits->setPassBits( std::vector< uint32_t >( ( ( passbits->size() - 1 ) / 32 ) + 1 ) ); + } + for ( size_t b = 0, bmax = passbits->size(); b < bmax; ++b ) { + xbits->markPassing(b, passbits->isPassing(b)); + } + return xbits; + +} + +template<class CONT> +std::unique_ptr< xAOD::TrigPassBits> TrigEgammaAnalysisBaseTool::getBits(const HLT::TriggerElement* te,const CONT* container){ + // For conversion of 2015/2016 data + const TrigPassBits *bits = getFeature<TrigPassBits>(te); + if(bits){ + ATH_MSG_DEBUG("Run1 conversion"); + ATH_MSG_DEBUG("create bits AOD to xAOD"); + return createBits<CONT,TrigPassBits>(container,bits); + } + // Workaround, see above + const xAOD::TrigPassBits *xbits=getFeature<xAOD::TrigPassBits>(te); + if(xbits){ + ATH_MSG_DEBUG("create bits xAOD to xAOD"); + return createBits<CONT,xAOD::TrigPassBits>(container,xbits); + } + else + return nullptr; +} + template<class T> -const T* -TrigEgammaAnalysisBaseTool::getFeature(const HLT::TriggerElement* te,const std::string key){ +const T* TrigEgammaAnalysisBaseTool::getFeature(const HLT::TriggerElement* te,const std::string key){ if ( te == nullptr ) return nullptr; if ( (m_trigdec->ancestor<T>(te,key)).te() == nullptr ) return nullptr; @@ -344,8 +391,7 @@ TrigEgammaAnalysisBaseTool::getFeature(const HLT::TriggerElement* te,const std:: } template<class T> -bool -TrigEgammaAnalysisBaseTool::ancestorPassed(const HLT::TriggerElement* te,const std::string key){ +bool TrigEgammaAnalysisBaseTool::ancestorPassed(const HLT::TriggerElement* te,const std::string key){ if ( te == nullptr ) return false; if ( (m_trigdec->ancestor<T>(te,key)).te() == nullptr ) return false; @@ -353,24 +399,22 @@ TrigEgammaAnalysisBaseTool::ancestorPassed(const HLT::TriggerElement* te,const s } template <class T1, class T2> -const T1* -TrigEgammaAnalysisBaseTool::closestObject(const std::pair<const xAOD::Egamma *,const HLT::TriggerElement *> pairObj, float &dRmax,bool usePassbits,const std::string key){ +const T1* TrigEgammaAnalysisBaseTool::closestObject(const std::pair<const xAOD::Egamma *,const HLT::TriggerElement *> pairObj, float &dRmax,bool usePassbits,const std::string key){ float eta = pairObj.first->eta(); float phi = pairObj.first->phi(); // Reset to resonable start value if(dRmax < 0.15) dRmax = 0.15; const auto *cont=getFeature<T2>(pairObj.second,key); if(cont==nullptr) return nullptr; - const TrigPassBits *bits = nullptr; + std::unique_ptr<xAOD::TrigPassBits> bits = getBits<T2>(pairObj.second,cont); + if(usePassbits){ - bits=getFeature<TrigPassBits>(pairObj.second); if(bits==nullptr) return nullptr; } const T1 *cl = nullptr; float dr=0.; for(const auto& obj : *cont){ - if( usePassbits && !HLT::isPassing(bits,obj,cont) ) continue; - //if( usePassbits && bits->isPassing(obj,cont) ) continue; + if( usePassbits && !bits->isPassing(obj,cont) ) continue; if(obj==nullptr) continue; dr=dR(eta,phi,obj->eta(),obj->phi()); if ( dr<dRmax){