diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt index 8e91801b935a251cd8ef36978c3d26e672fb4df1..6684b17a60b94e21f22df283558141c3773a4846 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/CMakeLists.txt @@ -29,6 +29,7 @@ atlas_depends_on_subdirs( PUBLIC Trigger/TrigConfiguration/TrigConfHLTData Trigger/TrigEvent/TrigSteeringEvent Trigger/TrigMonitoring/TrigHLTMonitoring + PhysicsAnalysis/AnalysisCommon/PATCore PRIVATE Control/AthenaBaseComps Control/AthenaMonitoring @@ -46,13 +47,13 @@ atlas_add_component( TrigEgammaAnalysisTools Root/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AsgTools xAODCaloEvent xAODEgamma xAODEventInfo xAODJet xAODPrimitives xAODTracking xAODTrigCalo xAODTrigEgamma xAODTrigRinger xAODTrigger xAODTruth LumiBlockCompsLib ElectronPhotonSelectorToolsLib RecoToolInterfaces egammaMVACalibLib TrigDecisionToolLib TrigEgammaMatchingToolLib TrigConfHLTData TrigSteeringEvent TrigHLTMonitoringLib AthenaBaseComps AthenaMonitoringLib StoreGateLib SGtests GaudiKernel ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} AsgTools xAODCaloEvent xAODEgamma xAODEventInfo xAODJet xAODPrimitives xAODTracking xAODTrigCalo xAODTrigEgamma xAODTrigRinger xAODTrigger xAODTruth LumiBlockCompsLib ElectronPhotonSelectorToolsLib RecoToolInterfaces egammaMVACalibLib TrigDecisionToolLib TrigEgammaMatchingToolLib TrigConfHLTData TrigSteeringEvent TrigHLTMonitoringLib AthenaBaseComps AthenaMonitoringLib StoreGateLib SGtests GaudiKernel PATCoreLib ) # Install files from the package: atlas_install_headers( TrigEgammaAnalysisTools ) atlas_install_python_modules( python/TrigEgamma*.py ) atlas_install_joboptions( share/test*.py ) -atlas_install_generic( macros/trigEgammaDQ.py macros/get_trigEgammaDQ.sh - DESTINATION share/bin +atlas_install_generic( share/trigEgammaDQ.py share/get_trigEgammaDQ.sh + DESTINATION share EXECUTABLE ) diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx index fe32ae8c4f1926a51e60e29c118fbbd447e2b2e8..fc0588b9579b5e687c67f16f2f6116b00de00a58 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/EfficiencyTool.cxx @@ -18,6 +18,7 @@ EfficiencyTool:: EfficiencyTool( const std::string& myname ) : TrigEgammaAnalysisBaseTool(myname) { + m_detailedHists=false; } //********************************************************************** @@ -233,8 +234,7 @@ void EfficiencyTool::fillInefficiency(const std::string dir,const xAOD::Electron else ATH_MSG_DEBUG("REGTEST::Inefficiency No track"); } -void EfficiencyTool::inefficiency(const std::string basePath, - const unsigned int runNumber, const unsigned int eventNumber, const float etthr, +void EfficiencyTool::inefficiency(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); @@ -252,177 +252,52 @@ void EfficiencyTool::inefficiency(const std::string basePath, float eta = eg->eta(); float phi = eg->phi(); ATH_MSG_DEBUG("INEFF::Offline et, eta, phi " << et << " " << eta << " " << phi); + const xAOD::Electron* selEF = NULL; const xAOD::Photon* selPh = NULL; const xAOD::CaloCluster* selClus = NULL; const xAOD::TrackParticle* selTrk = NULL; - - // Can we acquire L1 information - // - //auto initRois = fc.get<TrigRoiDescriptor>(); - //if ( initRois.size() < 1 ) ATH_MSG_DEBUG("No L1 RoI"); - //auto itEmTau = m_trigDecTool->ancestor<xAOD::EmTauRoI>(initRois[0]); - //ATH_MSG_DEBUG("INEFF::Retrieve L1"); - //const auto* EmTauRoI = getFeature<xAOD::EmTauRoI>(feat); - 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); - //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"); - - - //xAOD::TrackParticleContainer *EFTrk=0; - //if(EFTrkEFID!=NULL) EFTrk=EFTrkEFID; - //else if(EFTrkIDTrig!=NULL) EFTrk=EFTrkIDTrig; float dRmax=0.07; - - bool passedL1Calo=ancestorPassed<xAOD::EmTauRoI>(feat); - bool passedL2Calo = ancestorPassed<xAOD::TrigEMCluster>(feat); - bool passedL2 = ancestorPassed<xAOD::TrigElectronContainer>(feat); - bool passedEFCalo = ancestorPassed<xAOD::CaloClusterContainer>(feat,"TrigEFCaloCalibFex"); - //bool passedEFTrkEFID = ancestorPassed<xAOD::TrackParticleContainer>(feat,"InDetTrigTrackingxAODCnv_Electron_EFID"); - bool passedEFTrkIDTrig = ancestorPassed<xAOD::TrackParticleContainer>(feat,"InDetTrigTrackingxAODCnv_Electron_IDTrig"); - //bool passedEFTrk = passedEFTrkEFID || passedEFTrkIDTrig; - bool passedEF = ancestorPassed<xAOD::ElectronContainer>(feat); - - // Ensure L1 passes - // And offline passes et cut - std::vector<std::string> pidnames {"Loose","Medium","Tight"}; - if(passedEF){ + 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); } } - - if(passedL1Calo && et > etthr) { + // Ensure L1 passes + // And offline passes et cut + if(getAccept().getCutResult("L1Calo") && et > etthr) { ATH_MSG_DEBUG("INEFF::Passed L1 and offline et"); - ATH_MSG_DEBUG("INEFF:: " << passedL2Calo << passedL2 << passedEFCalo << passedEF); - if(passedL2Calo){ - ATH_MSG_DEBUG("INEFF::Passes L2 Calo"); - hist1("eff_triggerstep")->Fill("L2Calo",1); - } - else{ - ATH_MSG_DEBUG("INEFF::Fails L2 Calo"); - hist1("eff_triggerstep")->Fill("L2Calo",0); - } - if(passedL2){ - ATH_MSG_DEBUG("INEFF::Passes L2"); - hist1("eff_triggerstep")->Fill("L2",1); - } - else { - ATH_MSG_DEBUG("INEFF::Fails L2"); - hist1("eff_triggerstep")->Fill("L2",0); - } - /*if(L2Trk==NULL){ - hist1("eff_triggerstep")->Fill("L2TrackCont",0); - } - else{ - hist1("eff_triggerstep")->Fill("L2TrackCont",1); - }*/ - if(passedEFCalo){ - ATH_MSG_DEBUG("INEFF::Passes EFCalo"); - hist1("eff_triggerstep")->Fill("EFCalo",1); - } - else{ - ATH_MSG_DEBUG("INEFF::Fails EFCalo"); - hist1("eff_triggerstep")->Fill("EFCalo",0); - } - if(EFClus==NULL) hist1("eff_triggerstep")->Fill("EFCaloCont",0); - else hist1("eff_triggerstep")->Fill("EFCaloCont",1); - if(passedEFTrkIDTrig){ - ATH_MSG_DEBUG("INEFF:: Passes Track Hypo!"); - hist1("eff_triggerstep")->Fill("EFTrack",1); - } - else { - //ATH_MSG_INFO("INEFF:: Fails Track Hypo!"); - //ATH_MSG_INFO("INEFF:: EFCalo result " << passedEFCalo); - hist1("eff_triggerstep")->Fill("EFTrack",0); - } - if(EFTrkIDTrig==NULL){ - hist1("eff_triggerstep")->Fill("EFTrackCont",0); - ATH_MSG_DEBUG("TRKTEST: NULL Track Container! Run, Event " << runNumber << " " << eventNumber); - } - else{ - hist1("eff_triggerstep")->Fill("EFTrackCont",1); - ATH_MSG_DEBUG("TRKTEST: Container has " << EFTrkIDTrig->size() << " ntracks"); - } - if(passedEF){ - ATH_MSG_DEBUG("INEFF::Passes EF"); - hist1("eff_triggerstep")->Fill("HLT",1); - } - else{ - ATH_MSG_DEBUG("INEFF::Fails EF"); - hist1("eff_triggerstep")->Fill("HLT",0); - } - if(EFEl==NULL) hist1("eff_triggerstep")->Fill("HLTCont",0); - else hist1("eff_triggerstep")->Fill("HLTCont",1); + hist1("eff_triggerstep")->Fill("L2Calo",getAccept().getCutResult("L2Calo")); + hist1("eff_triggerstep")->Fill("L2",getAccept().getCutResult("L2")); + hist1("eff_triggerstep")->Fill("EFCalo",getAccept().getCutResult("EFCalo")); + hist1("eff_triggerstep")->Fill("EFTrack",getAccept().getCutResult("EFTrack")); + hist1("eff_triggerstep")->Fill("HLT",getAccept().getCutResult("HLT")); // Fill efficiency plot for HLT trigger steps - if(!passedEF && passedEFCalo){ - ATH_MSG_DEBUG("REGEST::Fails EF Electron, passes EFCalo Hypo Run " << runNumber << " Event " << eventNumber); - - dRmax=0.15; - if ( EFEl != NULL ){ - ATH_MSG_DEBUG("Retrieved ElectronContainer for inefficiency " << EFEl->size()); - for(const auto& el : *EFEl){ - float dr=dR(eta,phi,el->eta(),el->phi()); - if ( dr<dRmax){ - dRmax=dr; - selEF = el; - } // dR - } // loop over EFEl - ATH_MSG_DEBUG("Closest electron dR " << dRmax); - } //FC exists - else ATH_MSG_DEBUG("Electron Container NULL"); - dRmax=0.15; - if ( EFPh != NULL ){ - ATH_MSG_DEBUG("Retrieved PhotonnContainer for inefficiency " << EFPh->size()); - for(const auto& ph : *EFPh){ - float dr=dR(eta,phi,ph->eta(),ph->phi()); - if ( dr<dRmax){ - dRmax=dr; - selPh = ph; - } // dR - } // loop over EFEl - ATH_MSG_DEBUG("Closest electron dR " << dRmax); - } //FC exists - else ATH_MSG_DEBUG("Photon Container NULL"); + if(!getAccept().getCutResult("HLT") && getAccept().getCutResult("EFCalo")){ + 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); + //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; - if ( EFClus != NULL ){ - ATH_MSG_DEBUG("Retrieved ClusterContainer for inefficiency " << EFClus->size()); - for(const auto& clus : *EFClus){ - float dr=dR(eta,phi,clus->eta(),clus->phi()); - if(dr<dRmax){ - dRmax=dr; - selClus = clus; - } // dR - } // loop over EFPh - ATH_MSG_DEBUG("Closest cluster dR " << dRmax); - } - else ATH_MSG_DEBUG("CaloCluster Container NULL"); - dRmax=0.15; - if ( EFTrkIDTrig != NULL ){ - ATH_MSG_DEBUG("Retrieved TrackContainer for inefficiency " << EFTrkIDTrig->size()); - for(const auto& trk : *EFTrkIDTrig){ - float dr=dR(eta,phi,trk->eta(),trk->phi()); - if(dr<dRmax){ - dRmax=dr; - selTrk = trk; - } // dR - } // loop over EFPh - ATH_MSG_DEBUG("Closest track dR " << dRmax); - } //FC exists - else ATH_MSG_DEBUG("TrackParticle Container NULL"); + // 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==NULL){ hist1("eff_hltreco")->Fill("ClusterCont",0); hist1("eff_hltreco")->Fill("Cluster",0); @@ -495,7 +370,7 @@ void EfficiencyTool::inefficiency(const std::string basePath, } } - fillInefficiency(basePath,selEF,selPh,selClus,selTrk); + } } ATH_MSG_DEBUG("End Inefficiency Analysis ======================= " << basePath); @@ -583,22 +458,18 @@ void EfficiencyTool::fillEfficiency(const std::string dir,bool isPassed,const fl 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 + // + /*if(isPrescaled(info.trigName)){ + ATH_MSG_DEBUG(info.trigName << " prescaled, skipping"); + return StatusCode::SUCCESS; + }*/ + const std::string dir = basePath+"/"+info.trigName; const float etthr = info.trigThrHLT; const std::string pidword = info.trigPidDecorator; - unsigned int runNumber=0; - unsigned int eventNumber=0; - // This will retrieve eventInfo for each trigger - // Retrieve once and access via a private member - /*const xAOD::EventInfo *eventInfo; - if ( (m_storeGate->retrieve(eventInfo, "EventInfo")).isFailure() ){ - ATH_MSG_WARNING("Failed to retrieve eventInfo "); - } - else { - runNumber=eventInfo->runNumber(); - eventNumber=eventInfo->eventNumber(); - }*/ ATH_MSG_DEBUG("Efficiency for " << info.trigName << " " <<pidword); for(const auto pairObj : pairObjs){ // Final cuts done here @@ -612,63 +483,35 @@ StatusCode EfficiencyTool::toolExecute(const std::string basePath,const TrigInfo float et = getCluster_et(pairObj.first)/1e3; if(et < info.trigThrHLT-5.0) continue; // return StatusCode::SUCCESS; } // Offline photon - ATH_MSG_DEBUG("Fill probe histograms"); - bool passedL1Calo=false; - bool passedL2Calo=false; - bool passedL2=false; - bool passedEFCalo=false; - bool passedEF=false; - if ( pairObj.second ) { - ATH_MSG_DEBUG("Retrieve Ancestor passed"); - passedL1Calo=ancestorPassed<xAOD::EmTauRoI>(pairObj.second); - passedL2Calo = ancestorPassed<xAOD::TrigEMCluster>(pairObj.second); - if(xAOD::EgammaHelpers::isElectron(pairObj.first)) - passedL2 = ancestorPassed<xAOD::TrigElectronContainer>(pairObj.second); - - else - passedL2 = ancestorPassed<xAOD::TrigPhotonContainer>(pairObj.second); - - passedEFCalo = ancestorPassed<xAOD::CaloClusterContainer>(pairObj.second); - - if(xAOD::EgammaHelpers::isElectron(pairObj.first)) - passedEF = ancestorPassed<xAOD::ElectronContainer>(pairObj.second); - else - passedEF = ancestorPassed<xAOD::PhotonContainer>(pairObj.second); - + setAccept(pairObj.second,info); //Sets the trigger accepts + if (pairObj.second!=NULL) { + // Inefficiency analysis + if(!info.trigL1){ + if(pairObj.first->type()==xAOD::Type::Electron){ + if(!pairObj.first->auxdecor<bool>(info.trigPidDecorator)) continue; + inefficiency(dir+"/Efficiency/HLT",etthr,pairObj); + } + } } // Features if(info.trigL1) - this->fillEfficiency(dir+"/Efficiency/L1Calo",passedL1Calo,etthr,pidword,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/L1Calo",getAccept().getCutResult("L1Calo"),etthr,pidword,pairObj.first); else { - if(m_detailedHists) this->fillEfficiency(dir+"/Efficiency/L1Calo",passedL1Calo,etthr,pidword,pairObj.first); - this->fillEfficiency(dir+"/Efficiency/HLT",passedEF,etthr,pidword,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/HLT",getAccept().getCutResult("HLT"),etthr,pidword,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/L2Calo",getAccept().getCutResult("L2Calo"),etthr,pidword,pairObj.first,m_detailedHists); + this->fillEfficiency(dir+"/Efficiency/L2",getAccept().getCutResult("L2"),etthr,pidword,pairObj.first,m_detailedHists); + this->fillEfficiency(dir+"/Efficiency/EFCalo",getAccept().getCutResult("EFCalo"),etthr,pidword,pairObj.first,m_detailedHists); if(m_detailedHists){ - this->fillEfficiency(dir+"/Efficiency/L2Calo",passedL2Calo,etthr,pidword,pairObj.first); - this->fillEfficiency(dir+"/Efficiency/L2",passedL2,etthr,pidword,pairObj.first); - this->fillEfficiency(dir+"/Efficiency/EFCalo",passedEFCalo,etthr,pidword,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/L1Calo",getAccept().getCutResult("L1Calo"),etthr,pidword,pairObj.first); for(const auto pid : m_isemname) { - this->fillEfficiency(dir+"/Efficiency/HLT/"+pid,passedEF,etthr,"is"+pid,pairObj.first); - if( pairObj.first->auxdecor<bool>("Isolated") ) fillEfficiency(dir+"/Efficiency/HLT/"+pid+"Iso",passedEF,etthr,"is"+pid,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/HLT/"+pid,getAccept().getCutResult("HLT"),etthr,"is"+pid,pairObj.first); + if( pairObj.first->auxdecor<bool>("Isolated") ) fillEfficiency(dir+"/Efficiency/HLT/"+pid+"Iso",getAccept().getCutResult("HLT"),etthr,"is"+pid,pairObj.first); } for(const auto pid : m_lhname) { - this->fillEfficiency(dir+"/Efficiency/HLT/"+pid,passedEF,etthr,"is"+pid,pairObj.first); - if( pairObj.first->auxdecor<bool>("Isolated") ) fillEfficiency(dir+"/Efficiency/HLT/"+pid+"Iso",passedEF,etthr,"is"+pid,pairObj.first); + this->fillEfficiency(dir+"/Efficiency/HLT/"+pid,getAccept().getCutResult("HLT"),etthr,"is"+pid,pairObj.first); + if( pairObj.first->auxdecor<bool>("Isolated") ) fillEfficiency(dir+"/Efficiency/HLT/"+pid+"Iso",getAccept().getCutResult("HLT"),etthr,"is"+pid,pairObj.first); } } - else { - this->fillEfficiency(dir+"/Efficiency/L2Calo",passedL2Calo,etthr,pidword,pairObj.first,false); - this->fillEfficiency(dir+"/Efficiency/L2",passedL2,etthr,pidword,pairObj.first,false); - this->fillEfficiency(dir+"/Efficiency/EFCalo",passedEFCalo,etthr,pidword,pairObj.first,false); - } - - - // Inefficiency analysis - // - if(pairObj.first->type()==xAOD::Type::Electron){ - if(!pairObj.first->auxdecor<bool>(info.trigPidDecorator)) continue; - inefficiency(dir+"/Efficiency/HLT",runNumber,eventNumber,etthr,pairObj); - } - //else inefficiency(dir+"/Efficiency/HLT",runNumber,eventNumber,etthr,pairObj); ATH_MSG_DEBUG("Complete efficiency"); } } diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx index 91bcb7180cd6d29ce1dd6c04214a8c8fd25ae429..e26cff93835eb1f31a74dc4c84f0a556f7193964 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaAnalysisBaseTool.cxx @@ -49,8 +49,8 @@ TrigEgammaAnalysisBaseTool( const std::string& myname ) : AsgTool(myname), m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"), m_matchTool("Trig::TrigEgammaMatchingTool/TrigEgammaMatchingTool"), - m_lumiTool("LuminosityTool"), - m_lumiBlockMuTool("LumiBlockMuTool/LumiBlockMuTool") + m_lumiTool("LuminosityTool/OnlLuminosity"),//online mu + m_lumiBlockMuTool("LumiBlockMuTool/LumiBlockMuTool") //offline mu { declareProperty("MatchTool",m_matchTool); declareProperty("PlotTool",m_plot); @@ -162,6 +162,7 @@ StatusCode TrigEgammaAnalysisBaseTool::initialize() { }*/ + for(const auto cut:m_trigLevel) m_accept.addCut(cut,cut); return sc; } @@ -477,17 +478,54 @@ bool TrigEgammaAnalysisBaseTool::isPrescaled(const std::string trigger){ rerun=bit&TrigDefs::EF_resurrected; //Rerun, only check for HLT } + + ATH_MSG_DEBUG("Checking prescale for " << trigger << " " << l1item); const unsigned int l1bit=tdt()->isPassedBits(l1item); bool l1_afterpre=l1bit&TrigDefs::L1_isPassedAfterPrescale; bool l1_beforepre=l1bit&TrigDefs::L1_isPassedBeforePrescale; l1prescale=l1_beforepre && !l1_afterpre; - prescale=efprescale || l1prescale; + ATH_MSG_DEBUG("L1 prescale " << l1item << " " << l1prescale << " before " << l1_beforepre << " after " << l1_afterpre); + ATH_MSG_DEBUG("EF prescale " << trigger << " " << efprescale << " Prescale " << prescale); if(rerun) return false; // Rerun use the event if(prescale) return true; // Prescaled, reject event return false; // Not prescaled, use event } +void TrigEgammaAnalysisBaseTool::setAccept(const HLT::TriggerElement *te,const TrigInfo info){ + ATH_MSG_DEBUG("setAccept"); + m_accept.clear(); + bool passedL1Calo=false; + bool passedL2Calo=false; + bool passedEFCalo=false; + bool passedL2=false; + bool passedEFTrk=false; + bool passedEF=false; + + passedL1Calo = ancestorPassed<xAOD::EmTauRoI>(te); + if(!info.trigL1){ // HLT item get full decision + passedL2Calo = ancestorPassed<xAOD::TrigEMCluster>(te); + passedEFCalo = ancestorPassed<xAOD::CaloClusterContainer>(te,"TrigEFCaloCalibFex"); + if(info.trigType == "electron"){ + passedL2=ancestorPassed<xAOD::TrigElectronContainer>(te); + passedEF = ancestorPassed<xAOD::ElectronContainer>(te); + passedEFTrk = ancestorPassed<xAOD::TrackParticleContainer>(te,"InDetTrigTrackingxAODCnv_Electron_IDTrig"); + } + else if(info.trigType == "photon"){ + passedL2=ancestorPassed<xAOD::TrigPhotonContainer>(te); + passedEF = ancestorPassed<xAOD::PhotonContainer>(te); + passedEFTrk=true;// Assume true for photons + } + } + + m_accept.setCutResult("L1Calo",passedL1Calo); + m_accept.setCutResult("L2Calo",passedL2Calo); + m_accept.setCutResult("L2",passedL2); + m_accept.setCutResult("EFCalo",passedEFCalo); + m_accept.setCutResult("EFTrack",passedEFTrk); + m_accept.setCutResult("HLT",passedEF); +} + float TrigEgammaAnalysisBaseTool::dR(const float eta1, const float phi1, const float eta2, const float phi2){ float deta = fabs(eta1 - eta2); float dphi = fabs(phi1 - phi2) < TMath::Pi() ? fabs(phi1 - phi2) : 2*TMath:: \ @@ -914,3 +952,7 @@ void TrigEgammaAnalysisBaseTool::calculatePileupPrimaryVertex(){ } +// definitions +const std::vector<std::string> TrigEgammaAnalysisBaseTool::m_trigLevel = {"L1Calo","L2Calo","L2","EFCalo","EFTrack","HLT"}; +const std::map<std::string,std::string> TrigEgammaAnalysisBaseTool::m_trigLvlMap = {{"L1Calo","Trigger L1Calo step"},{"L2Calo","Trigger L2Calo step"}, + {"L2","Trigger L2 step"},{"EFCalo","Trigger EFCalo step"},{"EFTrack","Trigger EFTrack step"},{"HLT","Trigger HLT accept"}}; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx index b3483ef25ec3eda962180f51e6aa1c9d1bf0e304..c89958b09f1e836524e2522757e33d289796bf58 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaDistTool.cxx @@ -22,6 +22,7 @@ TrigEgammaDistTool:: TrigEgammaDistTool( const std::string& myname ) : TrigEgammaAnalysisBaseTool(myname) { + m_detailedHists=false; } //********************************************************************** diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx index 372088822a0161e3db11b2114bbc407aad99444e..f3876835a5f4e89d9ba1b4a044ac771f1e8c3fbc 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavAnalysisTool.cxx @@ -81,18 +81,20 @@ StatusCode TrigEgammaNavAnalysisTool::childExecute(){ TrigEgammaAnalysisBaseTool::calculatePileupPrimaryVertex(); + // Check HLTResult + if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ + ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); + return StatusCode::SUCCESS; + } int ilist=0; for(const auto trigger : m_trigList){ ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger << " " << getTrigInfo(trigger).trigName); - if(isPrescaled(trigger)) continue; //Account for L1 and HLT prescale discard event // Trigger counts cd(m_dir+"/Expert/Event"); if(tdt()->isPassed(trigger)) hist1(m_anatype+"_trigger_counts")->AddBinContent(ilist+1); - // Skip event if prescaled out - // Prescale cut has ill effects - // if(tdt()->isPassedBits("HLT_"+trigger) & TrigDefs::EF_prescaled) continue; + std::string basePath = m_dir+"/"+trigger+"/Distributions/"; const TrigInfo info = getTrigInfo(trigger); if ( TrigEgammaNavBaseTool::executeNavigation(info).isFailure() ){ diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx index 12ebf094755c7b3a9016f59cb53cf16fd14d3cd0..7e8e808990f0a701ca562a9722bbba8741b3c8b0 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavBaseTool.cxx @@ -101,12 +101,6 @@ bool TrigEgammaNavBaseTool::EventWiseSelection( ){ m_eventInfo=0; m_truthContainer = 0; - // Check HLTResult - if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ - ATH_MSG_WARNING("HLTResult truncated, skip event"); - return false; - } - if ( (m_storeGate->retrieve(m_eventInfo, "EventInfo")).isFailure() ){ ATH_MSG_WARNING("Failed to retrieve eventInfo "); return false; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx index 01506c6bf1605396557adc2766232513e220a7c8..5016b54543e214abae51c6325a6b08e6aaaa1265 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPAnalysisTool.cxx @@ -142,9 +142,14 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() ATH_MSG_DEBUG("Execute TP selection"); TrigEgammaNavTPBaseTool::executeTandP(); + // Check HLTResult + if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ + ATH_MSG_WARNING("HLTResult truncated, skip trigger analysis"); + return StatusCode::SUCCESS; + } + for(unsigned int ilist = 0; ilist != m_trigList.size(); ilist++) { std::string probeTrigger = m_trigList.at(ilist); - if(isPrescaled(probeTrigger)) continue; //Account for L1 and HLT prescale, discard event const char * cprobeTrigger = m_trigList.at(ilist).c_str(); ATH_MSG_DEBUG("Start Chain Analysis ============================= " << probeTrigger); cd(m_dir+"/Expert/Event"); @@ -164,58 +169,43 @@ StatusCode TrigEgammaNavTPAnalysisTool::childExecute() if(tool->toolExecute(m_dir+"/Expert",info,m_pairObj).isFailure()) ATH_MSG_DEBUG("TE Tool Fails");// Requires offline match } + if(isPrescaled(probeTrigger)){ + ATH_MSG_DEBUG(probeTrigger << " prescaled, skipping efficiency"); + continue; //Account for L1 and HLT prescale, discard event + } for(unsigned int i=0;i<m_pairObj.size();i++){ const xAOD::Electron* offEl = static_cast<const xAOD::Electron *> (m_pairObj[i].first); float et = getEt(offEl)/1e3; if(et < info.trigThrHLT-5.0) continue; if(!offEl->auxdecor<bool>(info.trigPidDecorator)) continue; - bool passedL1Calo=false; - bool passedL2Calo=false; - bool passedL2=false; - bool passedEFCalo=false; - bool passedEF=false; const HLT::TriggerElement* feat = m_pairObj[i].second; - + setAccept(feat,info); //Sets the trigger accepts cd(m_dir+"/Expert/Event"); if(et > info.trigThrHLT + 1.0) hist1(m_anatype+"_nProbes")->Fill(cprobeTrigger,1); if ( feat ) { - passedL1Calo=ancestorPassed<xAOD::EmTauRoI>(feat); - passedL2Calo = ancestorPassed<xAOD::TrigEMCluster>(feat); - passedL2 = ancestorPassed<xAOD::TrigElectronContainer>(feat); - passedEFCalo = ancestorPassed<xAOD::CaloClusterContainer>(feat); - passedEF = ancestorPassed<xAOD::ElectronContainer>(feat); if(et > info.trigThrHLT + 1.0){ - if( passedL1Calo){ + hist1(m_anatype+"_EffL1")->Fill(cprobeTrigger,getAccept().getCutResult("L1Calo")); + hist1(m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,getAccept().getCutResult("L2Calo")); + hist1(m_anatype+"_EffL2")->Fill(cprobeTrigger,getAccept().getCutResult("L2")); + hist1(m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,getAccept().getCutResult("EFCalo")); + hist1(m_anatype+"_EffHLT")->Fill(cprobeTrigger,getAccept().getCutResult("HLT")); + if( getAccept().getCutResult("L1Calo")){ hist1(m_anatype+"_nProbesL1")->Fill(cprobeTrigger,1); - hist1(m_anatype+"_EffL1")->Fill(cprobeTrigger,1); } - else hist1(m_anatype+"_EffL1")->Fill(cprobeTrigger,0); - - if( passedL2Calo ){ + if( getAccept().getCutResult("L2Calo") ){ hist1(m_anatype+"_nProbesL2Calo")->Fill(cprobeTrigger,1); - hist1(m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,1); } - else hist1(m_anatype+"_EffL2Calo")->Fill(cprobeTrigger,0); - - if( passedL2 ){ + if( getAccept().getCutResult("L2") ){ hist1(m_anatype+"_nProbesL2")->Fill(cprobeTrigger,1); - hist1(m_anatype+"_EffL2")->Fill(cprobeTrigger,1); } - else hist1(m_anatype+"_EffL2")->Fill(cprobeTrigger,0); - - if( passedEFCalo ){ + if( getAccept().getCutResult("EFCalo") ){ hist1(m_anatype+"_nProbesEFCalo")->Fill(cprobeTrigger,1); - hist1(m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,1); } - else hist1(m_anatype+"_EffEFCalo")->Fill(cprobeTrigger,0); - - if( passedEF ){ + if( getAccept().getCutResult("HLT") ){ hist1(m_anatype+"_nProbesHLT")->Fill(cprobeTrigger,1); - hist1(m_anatype+"_EffHLT")->Fill(cprobeTrigger,1); } - else hist1(m_anatype+"_EffHLT")->Fill(cprobeTrigger,0); } } // Features // Fill TProfile for no feature found (means no match) diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx index 337a192db7ec75641e22521f7e78e0a53d7cd370..8797e0894df17456742e0878315fb95bc16b9a72 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaNavTPBaseTool.cxx @@ -114,11 +114,6 @@ bool TrigEgammaNavTPBaseTool::EventWiseSelection(){ m_jets = 0; m_truthContainer=0; - // Check HLTResult - if(tdt()->ExperimentalAndExpertMethods()->isHLTTruncated()){ - ATH_MSG_WARNING("HLTResult truncated, skip event"); - return false; - } if ( (m_storeGate->retrieve(m_eventInfo, "EventInfo")).isFailure() ){ ATH_MSG_WARNING("Failed to retrieve eventInfo "); diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx index 2cb16e0d0f3a462d615298c587173e0e304e4480..486638fac51df346eb8a47b90e5bd8cc84caea12 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/Root/TrigEgammaResolutionTool.cxx @@ -15,6 +15,7 @@ TrigEgammaResolutionTool:: TrigEgammaResolutionTool( const std::string& myname ) : TrigEgammaAnalysisBaseTool(myname) { + m_detailedHists=false; } //********************************************************************** @@ -87,45 +88,19 @@ void TrigEgammaResolutionTool::resolutionPhoton(const std::string basePath,std:: std::string dir1 = basePath + "/Resolutions/HLT"; std::string dir2 = basePath + "/AbsResolutions/HLT"; - const xAOD::Photon* phOff =static_cast<const xAOD::Photon*> (pairObj.first); - const HLT::TriggerElement *feat = pairObj.second; - bool passedEFPh = ancestorPassed<xAOD::PhotonContainer>(feat); - double deltaR=0.; - double dRMax = 100; + float dRmax = 100; const xAOD::Photon *phEF = NULL; - - const auto* EFPh = getFeature<xAOD::PhotonContainer>(feat); - const TrigPassBits *EFbits = getFeature<TrigPassBits>(feat); - if(EFbits==NULL) ATH_MSG_DEBUG("PassBits NULL"); - if(EFPh != NULL && EFbits!=NULL){ - if(passedEFPh){ - for(const auto& ph : *EFPh){ - if( HLT::isPassing(EFbits,ph,EFPh)) ATH_MSG_DEBUG("Found passing Hypo object"); - else { - ATH_MSG_DEBUG("Failed Hypo Selection"); - continue; - } - if(ph == NULL) { - ATH_MSG_DEBUG("Photon from TE NULL"); - continue; - } - if(ph->caloCluster() && phOff->caloCluster()) - deltaR = dR(phOff->caloCluster()->eta(),phOff->caloCluster()->phi(), ph->caloCluster()->eta(),ph->caloCluster()->phi()); - else - deltaR = dR(phOff->eta(),phOff->phi(),ph->eta(),ph->phi()); - if (deltaR < dRMax) { - dRMax = deltaR; - phEF =ph; - } - } //Loop over EF photons - } // Passed Hypo - if(dRMax < 0.05){ - fillHLTResolution(dir1,phEF,phOff); - if(filliso) fillIsolationResolution(dir1,phEF,phOff); - if(m_detailedHists) fillHLTAbsResolution(dir2,phEF,phOff); - } - } // Feature Container - else ATH_MSG_DEBUG("Feature Container NULL"); + if(pairObj.second){ + if(ancestorPassed<xAOD::PhotonContainer>(pairObj.second)) + phEF=closestObject<xAOD::Photon,xAOD::PhotonContainer>(pairObj,dRmax); + if(phEF){ + if(dRmax < 0.05){ + fillHLTResolution(dir1,phEF,pairObj.first); + if(filliso) fillIsolationResolution(dir1,phEF,pairObj.first); + if(m_detailedHists) fillHLTAbsResolution(dir2,phEF,pairObj.first); + } + } + } } void TrigEgammaResolutionTool::resolutionElectron(const std::string basePath,std::pair<const xAOD::Egamma*,const HLT::TriggerElement*> pairObj,bool filliso){ @@ -137,133 +112,67 @@ void TrigEgammaResolutionTool::resolutionElectron(const std::string basePath,std std::string dir7 = basePath + "/Resolutions/L1Calo"; std::string dir8 = basePath + "/AbsResolutions/L1Calo"; - const xAOD::Electron* elOff =static_cast<const xAOD::Electron*> (pairObj.first); - const HLT::TriggerElement *feat = pairObj.second; - - bool passedEFEl = ancestorPassed<xAOD::ElectronContainer>(feat); - double deltaR=0.; - double dRMax = 100; - const xAOD::Electron *elEF(0); - - const auto* EFEl = getFeature<xAOD::ElectronContainer>(feat); - const TrigPassBits *EFbits = getFeature<TrigPassBits>(feat); - if(EFbits==NULL) ATH_MSG_DEBUG("PassBits NULL"); - // Require passing hypo and passing object - if(EFEl!=NULL && EFbits!=NULL) { - ATH_MSG_DEBUG("Retrieve Electron FC"); - if(passedEFEl){ - for(const auto& el : *EFEl){ - // Only consider passing objects - if(!el) continue; - if( HLT::isPassing(EFbits,el,EFEl)) ATH_MSG_DEBUG("Found passing Hypo object"); - else { - ATH_MSG_DEBUG("Failed Hypo Selection"); - continue; + float dRmax = 100; + const xAOD::Electron *elEF = NULL; + if(pairObj.second){ + if(ancestorPassed<xAOD::ElectronContainer>(pairObj.second)) + elEF=closestObject<xAOD::Electron,xAOD::ElectronContainer>(pairObj,dRmax); + if(elEF){ + if(dRmax < 0.05){ + fillHLTResolution(dir1,elEF,pairObj.first); + if(filliso) fillIsolationResolution(dir1,elEF,pairObj.first); + if(m_detailedHists) fillHLTAbsResolution(dir2,elEF,pairObj.first); + const xAOD::TrigEMCluster* clus = getFeature<xAOD::TrigEMCluster>(pairObj.second); + if ( clus != NULL ) { + if(m_detailedHists) fillL2CaloResolution(dir5,clus,pairObj.first); + fillL2CaloResolution(dir6,clus,elEF); } - if(el->trackParticle() && elOff->trackParticle()) - deltaR = dR(elOff->trackParticle()->eta(),elOff->trackParticle()->phi(), el->trackParticle()->eta(),el->trackParticle()->phi()); - else - deltaR = dR(elOff->eta(),elOff->phi(),el->eta(),el->phi()); - if (deltaR < dRMax) { - dRMax=deltaR; - elEF=el; - } - } // Loop over EF container - } // Passed Hypo - if(dRMax < 0.05){ - fillHLTResolution(dir1,elEF,elOff); - if(filliso) fillIsolationResolution(dir1,elEF,elOff); - if(m_detailedHists) fillHLTAbsResolution(dir2,elEF,elOff); - const xAOD::TrigEMCluster* clus = getFeature<xAOD::TrigEMCluster>(feat); - if ( clus != NULL ) { - if(m_detailedHists) fillL2CaloResolution(dir5,clus, elOff ); - fillL2CaloResolution(dir6,clus, elEF ); - } - } - } // EFEl Feature - else ATH_MSG_DEBUG("NULL EFEl Feature"); - // L1 resolutions - if(m_detailedHists){ - if (feat) { - auto itEmTau = tdt()->ancestor<xAOD::EmTauRoI>(feat); + } + } + // L1 resolutions + if(m_detailedHists){ + auto itEmTau = tdt()->ancestor<xAOD::EmTauRoI>(pairObj.second); const xAOD::EmTauRoI *l1 = itEmTau.cptr(); if (l1) { - fillL1CaloResolution(dir7, l1, elOff); - fillL1CaloAbsResolution(dir8, l1, elOff); + fillL1CaloResolution(dir7, l1, pairObj.first); + fillL1CaloAbsResolution(dir8, l1, pairObj.first); } } } - else ATH_MSG_DEBUG("NULL L1 Feature"); } -void TrigEgammaResolutionTool::resolutionL2Photon(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj){ - const xAOD::Photon* phOff =static_cast<const xAOD::Photon*> (pairObj.first); - const HLT::TriggerElement *feat = pairObj.second; - bool passedL2Ph = ancestorPassed<xAOD::TrigPhotonContainer>(feat); - double deltaR=0.; - double dRMax = 100; +void TrigEgammaResolutionTool::resolutionL2Photon(const std::string dir,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj){ + cd(dir); + float dRmax = 100; const xAOD::TrigPhoton *phL2 = NULL; - - const auto* L2Ph = getFeature<xAOD::TrigPhotonContainer>(feat); - dRMax=100.; - if(L2Ph != NULL){ - for(const auto& ph : *L2Ph){ - if(ph == NULL) { - ATH_MSG_DEBUG("TrigPhoton from TE NULL"); - continue; + if(pairObj.second){ + if(ancestorPassed<xAOD::TrigPhotonContainer>(pairObj.second)) + phL2=closestObject<xAOD::TrigPhoton,xAOD::TrigPhotonContainer>(pairObj,dRmax); + if(phL2){ + if(dRmax < 0.05){ + //Do something here } - deltaR = dR(phOff->caloCluster()->eta(),phOff->caloCluster()->phi(), ph->eta(),ph->phi()); - if (deltaR < dRMax) { - dRMax = deltaR; - phL2 =ph; - } - } //Loop over EF photons - if(dRMax < 0.05) { - if(passedL2Ph && phL2!=NULL){ - //fillRes(trigger,phEF,phOff); - //fillShowerShapes(trigger,phEF,phOff); - } // Is EF Photon - } // Found closest photon match - } // Feature Container - else ATH_MSG_DEBUG("Feature Container NULL"); + } + } } void TrigEgammaResolutionTool::resolutionL2Electron(const std::string dir,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj){ cd(dir); - const xAOD::Egamma *eg = pairObj.first; - const HLT::TriggerElement *feat = pairObj.second; - bool passedL2Electron = ancestorPassed<xAOD::TrigElectronContainer>(feat); - double deltaR=0.; - double dRMax = 100; - const xAOD::TrigElectron *trigEl = NULL; - - const auto* L2El = getFeature<xAOD::TrigElectronContainer>(feat); - - // Get the pass bits also - dRMax=100.; - if(L2El!=NULL){ - for(const auto& el : *L2El){ - if(el==NULL) { - ATH_MSG_DEBUG("TrigElectron from TE NULL"); - continue; + + float dRmax = 100; + const xAOD::TrigElectron *elL2 = NULL; + if(pairObj.second){ + if(ancestorPassed<xAOD::TrigElectronContainer>(pairObj.second)) + elL2=closestObject<xAOD::TrigElectron,xAOD::TrigElectronContainer>(pairObj,dRmax); + if(elL2){ + if(dRmax < 0.05){ + //Do something here } - deltaR = dR(eg->caloCluster()->eta(),eg->caloCluster()->phi(), el->eta(),el->phi()); - if (deltaR < dRMax) { - dRMax = deltaR; - trigEl=el; - } - } //Loop over EF photons - if(dRMax < 0.05) { - if(passedL2Electron && trigEl!=NULL){ - // Do something, fill resolutions and distributions - //fillRes(trigger,phEF,phOff); - //fillShowerShapes(trigger,phEF,phOff); - } // Is EF Photon - } // Found closest photon match - } // Feature Container - else ATH_MSG_DEBUG("Feature Container NULL"); + } + } } + void TrigEgammaResolutionTool::fillL1CaloResolution(const std::string dir,const xAOD::EmTauRoI *l1, const xAOD::Egamma *off){ cd(dir); ATH_MSG_DEBUG("Fill L1CaloResolution"); diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h index 3cc815448b791a603c84621bbc7328ee3959e80d..497301184539e53e43e4e669a3619f873ed204f7 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/EfficiencyTool.h @@ -27,12 +27,12 @@ public: protected: private: void fillEfficiency(const std::string,bool,const float,const std::string,const xAOD::Egamma *,bool fill2D=true); - void inefficiency(const std::string,const unsigned int, const unsigned int,const float,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); + 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>*/); - /*! Include more detailed histograms */ + /*! Include more detailed histograms */ bool m_detailedHists; }; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h index ea600877c84ef52406354b5c9c5430aa008d991f..19dbd3d6d8544d89d9c4dfe603e8d2ee3154f7a3 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaAnalysisBaseTool.h @@ -8,6 +8,7 @@ #include "TrigEgammaAnalysisTools/ITrigEgammaAnalysisBaseTool.h" #include "AsgTools/AsgTool.h" +#include "PATCore/TAccept.h" #include "TrigDecisionTool/TrigDecisionTool.h" #include "TrigEgammaMatchingTool/ITrigEgammaMatchingTool.h" #include "TrigEgammaAnalysisTools/ITrigEgammaPlotTool.h" @@ -48,7 +49,7 @@ public: StatusCode finalize(); 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 float eta, const float phi, const T2 cont); + template <class T1, class T2> const T1* closestObject(const std::pair<const xAOD::Egamma *, const HLT::TriggerElement *>, float &, bool usePassbits=true,const std::string key=""); void setParent(IHLTMonTool *parent){ m_parent = parent;}; void setPlotTool(ToolHandle<ITrigEgammaPlotTool> tool){m_plot=tool;} void setDetail(bool detail){m_detailedHists=detail;} @@ -83,7 +84,11 @@ private: std::map<std::string,TrigInfo> m_trigInfo; /*! Include more detailed histograms */ bool m_detailedHists; - + /*! TAccept to store TrigDecision */ + Root::TAccept m_accept; + /*! Helper strings for trigger level analysis */ + static const std::vector<std::string> m_trigLevel; + static const std::map<std::string,std::string> m_trigLvlMap; // Properties ToolHandle<Trig::TrigDecisionTool> m_trigdec; @@ -149,6 +154,11 @@ protected: // Retrieve Properties bool getDetail(){return m_detailedHists;} bool getTP(){return m_tp;} + + // TAccept + Root::TAccept getAccept(){return m_accept;} + void setAccept(Root::TAccept accept){m_accept=accept;} + void setAccept(const HLT::TriggerElement *,const TrigInfo); //Class Members // Athena services StoreGateSvc * m_storeGate; @@ -315,19 +325,32 @@ TrigEgammaAnalysisBaseTool::ancestorPassed(const HLT::TriggerElement* te,const s return ( (m_trigdec->ancestor<T>(te)).te()->getActiveState()); } -//Cannot deduce -/*template <class T1, class T2> +template <class T1, class T2> const T1* -TrigEgammaAnalysisBaseTool::closestObject(const float eta, const float phi, const T2 cont){ +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==NULL) return NULL; + const TrigPassBits *bits = NULL; + if(usePassbits){ + bits=getFeature<TrigPassBits>(pairObj.second); + if(bits==NULL) return NULL; + } const T1 *cl = NULL; - const float dRmax = 0.15; + float dr=0.; for(const auto& obj : *cont){ - float dr=dR(eta,phi,obj->eta(),obj->phi()); + if( usePassbits && !HLT::isPassing(bits,obj,cont) ) continue; + if(obj==NULL) continue; + dr=dR(eta,phi,obj->eta(),obj->phi()); if ( dr<dRmax){ dRmax=dr; cl = obj; } // dR } return cl; -}*/ +} + #endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaDistTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaDistTool.h index 041c39939fb0a4709f5e99872c45079980afbcc5..56a0eeb5119e60d389dc1f9262b6dc3b77b3a1f4 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaDistTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaDistTool.h @@ -34,10 +34,8 @@ private: void fillL2Calo(const std::string,const xAOD::TrigEMCluster *); void fillRinger(const std::string,const xAOD::TrigEMCluster *); void fillL1Calo(const std::string,const xAOD::EmTauRoI *); - - /*! Include more detailed histograms */ + /*! Include more detailed histograms */ bool m_detailedHists; - }; #endif diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaInfo.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaInfo.h index 032fa021506882c18de3537831aebe93bd527a7a..7ed0a4a28315e42a361ff67fe698d8c557082032 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaInfo.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaInfo.h @@ -20,3 +20,4 @@ typedef struct _triginfo // Enums enum class TrigEgammaMonLevel {SHIFTER, EXPERT, DETAIL}; + diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h index fe343dcffae4f687c119bc55130726163d208d19..112a81a74ca6373bac7d6c0447298c618506d328 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/TrigEgammaAnalysisTools/TrigEgammaResolutionTool.h @@ -40,8 +40,7 @@ private: void resolutionL2Photon(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); void resolutionL2Electron(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); void resolutionEFCalo(const std::string,std::pair< const xAOD::Egamma*,const HLT::TriggerElement*> pairObj); - - /*! Include more detailed histograms */ + /*! Include more detailed histograms */ bool m_detailedHists; }; diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements index 9d61d53dd43122880344bd1d35862ff1ef766701..f855ed2e8e14532e0b524ec82817b617638289bd 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/cmt/requirements @@ -28,10 +28,12 @@ use xAODTruth xAODTruth-* Event/xAOD use xAODTrigRinger xAODTrigRinger-* Event/xAOD #use xAODCaloRings xAODCaloRings-* Event/xAOD + # Added for Track Isolation Emulation use InDetTrackSelectionTool InDetTrackSelectionTool-* InnerDetector/InDetRecTools use RecoToolInterfaces RecoToolInterfaces-* Reconstruction/RecoTools use xAODPrimitives xAODPrimitives-* Event/xAOD +use PATCore PATCore-* PhysicsAnalysis/AnalysisCommon private use AthenaBaseComps AthenaBaseComps-* Control @@ -44,6 +46,8 @@ end_private apply_pattern declare_joboptions files="test*.py" apply_pattern declare_python_modules files="TrigEgamma*.py" -apply_pattern generic_declare_for_link kind=binaries files="-s=../macros trigEgammaDQ.py get_trigEgammaDQ.sh" prefix=share/bin +apply_pattern declare_scripts files="../share/*.sh \ + ../share/trigEgammaDQ.py" +#apply_pattern generic_declare_for_link kind=binaries files="-s=../macros trigEgammaDQ.py get_trigEgammaDQ.sh" prefix=share/bin library TrigEgammaAnalysisTools *.cxx ../Root/*.cxx -s=components *.cxx apply_pattern component_library diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/get_trigEgammaDQ.sh old mode 100644 new mode 100755 similarity index 80% rename from Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh rename to Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/get_trigEgammaDQ.sh index 3050435e4ef69a46f3506730a9d1ada2d15aa5e6..f76ed7e2c50e610f4cbda9d7dacecf39837ab6a0 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/get_trigEgammaDQ.sh +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/get_trigEgammaDQ.sh @@ -55,8 +55,8 @@ else eos cp ${BASE}/${DIR2}/${FILETOCOPY} . fi inputfile=`ls | grep HIST` -hcg.exe ${inputfile} -d HLT/Egamma -r Egamma TREG --tag "reference = stream=physics_Main:CentrallyManagedReferences_Main;CentrallyManagedReferences" -ds "https://twiki.cern.ch/twiki/bin/view/Atlas/TrigEgammaDataQualityAndMonitoring" --deleteref > ${data}.${stream}.$run.config -python trigEgammaDQ.py --file ${inputfile} --run ${run} --t0 True +hcg.exe ${inputfile} -d HLT/Egamma -r Egamma TREG -ds "https://twiki.cern.ch/twiki/bin/view/Atlas/TrigEgammaDataQualityAndMonitoring" -a "HLT_Histogram_Not_Empty_with_Ref&GatherData" --deleteref > ${data}.${stream}.$run.config +trigEgammaDQ.py --file ${inputfile} --run ${run} --t0 True rm *.bak #tar -czf TrigEgammaDQArchive_Run_${run}.tar.gz ${data}.* *.C *.eps --remove-files diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/trigEgammaDQ.py old mode 100644 new mode 100755 similarity index 78% rename from Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py rename to Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/trigEgammaDQ.py index 3309d9656a219b6e1e47953cce725eb894ea96ce..9ed7232c2431dea311e8cb9792ce3816ac77306a --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/macros/trigEgammaDQ.py +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/share/trigEgammaDQ.py @@ -1,7 +1,5 @@ #! /usr/bin/env python -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration - import sys, optparse, shutil, os, argparse from sys import argv, exit import subprocess @@ -22,10 +20,13 @@ import ROOT from ROOT import TFile, TH1F, TH2,TGaxis from ROOT import TCanvas, TLegend from ROOT import SetOwnership +from ROOT import gROOT, TStyle from TrigEgammaAnalysisTools.TrigEgammaDataQuality import TrigEgammaPlotHolder -from AtlasStyle import * +#Configuration of macro -- needs more argument options +# Provide plot category and names of histos +# Mapping of triggers to make comparison plots (complist) dqlist = {'Efficiency':['eff_et','eff_eta','eff_phi','eff_mu']} dqlevel = ['HLT','L1Calo'] complist={'L1_EM20VH':'L1_EM20VHI', @@ -33,11 +34,125 @@ complist={'L1_EM20VH':'L1_EM20VHI', 'L1_EM22VHI':'HLT_e26_lhtight_nod0_ivarloose', 'HLT_e24_lhmedium_L1EM20VH':'HLT_e24_lhmedium_L1EM20VHI', 'HLT_e24_lhmedium_L1EM20VHI':'HLT_e24_lhmedium_ivarloose', + 'HLT_e24_lhmedium_iloose':'HLT_e24_lhmedium_ivarloose', 'HLT_e24_lhmedium_ivarloose':'HLT_e24_lhmedium_nod0_ivarloose', 'HLT_e24_lhmedium_nod0_ivarloose':'HLT_e24_lhtight_nod0_ivarloose', } ######################################################### +# AtlasStyle and helper functions +def SetAtlasStyle (): + print "\nApplying ATLAS style settings..." + atlasStyle = AtlasStyle() + gROOT.SetStyle("ATLAS") + gROOT.ForceStyle() + +def AtlasStyle(): + atlasStyle = TStyle("ATLAS","Atlas style") + # use plain black on white colors + icol=0 # WHITE + atlasStyle.SetFrameBorderMode(icol) + atlasStyle.SetFrameFillColor(icol) + atlasStyle.SetCanvasBorderMode(icol) + atlasStyle.SetCanvasColor(icol) + atlasStyle.SetPadBorderMode(icol) + atlasStyle.SetPadColor(icol) + atlasStyle.SetStatColor(icol) + #atlasStyle.SetFillColor(icol) # don't use: white fill color for *all* objects + # set the paper & margin sizes + atlasStyle.SetPaperSize(20,26) + + # set margin sizes + atlasStyle.SetPadTopMargin(0.07) + atlasStyle.SetPadRightMargin(0.09) + atlasStyle.SetPadBottomMargin(0.16) + atlasStyle.SetPadLeftMargin(0.16) + + # set title offsets (for axis label) + atlasStyle.SetTitleXOffset(1.4) + atlasStyle.SetTitleYOffset(1.4) + + # use large fonts + #Int_t font=72 # Helvetica italics + font=42 # Helvetica + tsize=0.05 + atlasStyle.SetTextFont(font) + + atlasStyle.SetTextSize(tsize) + atlasStyle.SetLabelFont(font,"x") + atlasStyle.SetTitleFont(font,"x") + atlasStyle.SetLabelFont(font,"y") + atlasStyle.SetTitleFont(font,"y") + atlasStyle.SetLabelFont(font,"z") + atlasStyle.SetTitleFont(font,"z") + + atlasStyle.SetLabelSize(tsize,"x") + atlasStyle.SetTitleSize(tsize,"x") + atlasStyle.SetLabelSize(tsize,"y") + atlasStyle.SetTitleSize(tsize,"y") + atlasStyle.SetLabelSize(tsize,"z") + atlasStyle.SetTitleSize(tsize,"z") + + # use bold lines and markers + atlasStyle.SetMarkerStyle(20) + atlasStyle.SetMarkerSize(1.2) + atlasStyle.SetHistLineWidth(2) + atlasStyle.SetLineStyleString(2,"[12 12]") # postscript dashes + + # get rid of X error bars + #atlasStyle.SetErrorX(0.001) + # get rid of error bar caps + atlasStyle.SetEndErrorSize(0.) + + # do not display any of the standard histogram decorations + atlasStyle.SetOptTitle(0) + #atlasStyle.SetOptStat(1111) + atlasStyle.SetOptStat(0) + #atlasStyle.SetOptFit(1111) + atlasStyle.SetOptFit(0) + + # put tick marks on top and RHS of plots + atlasStyle.SetPadTickX(1) + atlasStyle.SetPadTickY(1) + atlasStyle.SetPalette(1) + return atlasStyle + +from ROOT import TLatex, gPad + +def ATLASLabel(x,y,text="Internal",color=1): + l = TLatex() + l.SetNDC(); + l.SetTextFont(72); + l.SetTextColor(color); + delx = 0.115*696*gPad.GetWh()/(472*gPad.GetWw()); + l.DrawLatex(x,y,"ATLAS"); + if True: + p = TLatex(); + p.SetNDC(); + p.SetTextFont(42); + p.SetTextColor(color); + p.DrawLatex(x+delx,y,text); + #p.DrawLatex(x,y,"#sqrt{s}=900GeV"); + +def ATLASRunNumberLabel(x,y,runnumber,color=1): + l = TLatex() + l.SetNDC(); + l.SetTextFont(42); + l.SetTextSize(0.045); + l.SetTextColor(color); + dely = 0.115*472*gPad.GetWh()/(506*gPad.GetWw()); + label="Run " + runnumber + l.DrawLatex(x,y-dely,label); + +def ATLASLumiLabel(x,y,lumi="78",color=1): + l = TLatex() + l.SetNDC(); + l.SetTextFont(42); + l.SetTextSize(0.045); + l.SetTextColor(color); + dely = 0.115*472*gPad.GetWh()/(506*gPad.GetWw()); + label="Data 2016, #sqrt{s}=13 TeV, "+lumi+" pb^{-1}" + l.DrawLatex(x,y-dely,label); def setCanvas(c): ROOT.gStyle.SetOptStat(0) @@ -140,6 +255,7 @@ def setLegend2(leg,histo1,histo2,trigName,trigName2): leg.AddEntry(histo2,trigName2,"p") leg.Draw() +# Main methods of program def montage(plotlist,name): print name plot_names_str = ' '.join(plotlist) @@ -173,8 +289,11 @@ def parseName(fpath): tname="" run="" flist=dlist[0].split(".") - if(len(flist)>1): + print flist + if(len(flist)>2): run=flist[1] + else: + run=flist[0] #print run if("Shifter" in fpath): tname=dlist.pop() diff --git a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx index 2e8a87803251b781c0487d39dda55a3b43507770..dd7bd078d5cafd27abcf966fe9f249a9caf90725 100644 --- a/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx +++ b/Trigger/TrigAnalysis/TrigEgammaAnalysisTools/src/TrigEgammaMonTool.cxx @@ -24,7 +24,6 @@ TrigEgammaMonTool( const std::string & type, const std::string & name, const IIn :IHLTMonTool(type, name, parent) { declareProperty( "Tools", m_asgToolNames); - //declareProperty( "Tools", m_asgtools); } TrigEgammaMonTool::~TrigEgammaMonTool(){} @@ -83,7 +82,7 @@ StatusCode TrigEgammaMonTool::fill(){ StatusCode TrigEgammaMonTool::proc(){ // Finalize the efficiency for end of run - if(!endOfRun){ return(StatusCode::SUCCESS); } + if(!endOfRunFlag()){ return(StatusCode::SUCCESS); } ATH_MSG_INFO ("Finalizing " << name() << "..."); for ( ToolHandleArray<ITrigEgammaAnalysisBaseTool>::const_iterator itoo=m_asgtools.begin(); itoo!=m_asgtools.end(); ++itoo ) {