diff --git a/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigGeneralMonitorAlgorithm.py b/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigGeneralMonitorAlgorithm.py index e2652ccd77ce7c63c84c92171a6e6545d0bc420a..5d2d5d048437f5f0f05776eb280d7b2f50b7504e 100644 --- a/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigGeneralMonitorAlgorithm.py +++ b/Trigger/TrigMonitoring/TrigHLTMonitoring/python/TrigGeneralMonitorAlgorithm.py @@ -16,7 +16,6 @@ def TrigGeneralMonConfig(inputFlags): from AthenaCommon.Logging import logging log_trighlt = logging.getLogger( 'TrigGeneralMonitorAlgorithm' ) - log_trighlt.debug('In TrigGeneralMonitorAlgorithm.py') ###Read the menu from the database from TrigConfigSvc.TriggerConfigAccess import getHLTMenuAccess @@ -48,72 +47,19 @@ def TrigGeneralMonConfig(inputFlags): ('HLT_Electrons','HLT_[0-9]*e[0-9]+.*'), #1 ('HLT_Gamma','HLT_[0-9]*g[0-9]+.*'), #2 ('HLT_Muons','HLT_[0-9]*mu[0-9]+.*'), #3 - ('HLT_MissingET','HLT_(t|x)e[0-9]+.*'), #4 - ('HLT_Taus','HLT_(tau[0-9]*|trk.*Tau).*'), #5 + ('HLT_Taus','HLT_(tau[0-9]*|trk.*Tau).*'), #4 + ('HLT_MissingET','HLT_(t|x)e[0-9]+.*'), #5 ('HLT_Jets','HLT_[0-9]*j[0-9]+.*'), #6 ('HLT_MinBias','HLT_mb.*')] #7 - #top level + #top level group hltGroup = helper.addGroup( trigHLTMonAlg, 'TrigHLTMonitor', 'HLT/ResultMon/' ) - #The signatures, including All as first item - listOfSignatureGroups =[] - hltAllGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTAllMonitor', - 'HLT/ResultMon/HLT_AllChains' - ) - listOfSignatureGroups.append(hltAllGroup) - - hltEleGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTEleMonitor', - 'HLT/ResultMon/HLT_Electrons' - ) - listOfSignatureGroups.append(hltEleGroup) - - hltGamGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTGamMonitor', - 'HLT/ResultMon/HLT_Gamma' - ) - listOfSignatureGroups.append(hltGamGroup) - - hltMuoGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTMuoMonitor', - 'HLT/ResultMon/HLT_Muons' - ) - listOfSignatureGroups.append(hltMuoGroup) - - hltMETGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTMETMonitor', - 'HLT/ResultMon/HLT_MissingET' - ) - listOfSignatureGroups.append(hltMETGroup) - - hltTauGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTTauMonitor', - 'HLT/ResultMon/HLT_Taus' - ) - listOfSignatureGroups.append(hltTauGroup) - - hltJetGroup = helper.addGroup( - trigHLTMonAlg, - 'TrigHLTJetMonitor', - 'HLT/ResultMon/HLT_Jets' - ) - listOfSignatureGroups.append(hltJetGroup) - - #No RoI map for minbias - # Configure histograms #NB! The histograms defined here must match the ones in the cxx file exactly @@ -124,9 +70,12 @@ def TrigGeneralMonConfig(inputFlags): hltGroup.defineHistogram('HLTEvents', title='HLT events;HLT;Events', path='',xbins=2,xmin=0,xmax=2) - consistency_names=['SMK DB NULL','SMK BS NULL','SMK Inconsistent','HLT Prescale DB NULL','HLT Prescale BS NULL','HLT Prescale Inconsistent','No onlineKeys','No eventKeys'] + consistency_names=['SMK DB NULL','SMK BS NULL','SMK Inconsistent','HLT Prescale DB NULL', + 'HLT Prescale BS NULL','HLT Prescale Inconsistent', + 'No onlineKeys','No eventKeys'] hltGroup.defineHistogram('ConfigConsistency_HLT', title='ConfigConsistency_HLT;;Events', - path='',xbins=8,xmin=1,xmax=9,xlabels=consistency_names,opt='kAlwaysCreate') + path='',xbins=8,xmin=1,xmax=9,xlabels=consistency_names, + opt='kAlwaysCreate') ############################################################ @@ -137,10 +86,12 @@ def TrigGeneralMonConfig(inputFlags): ## The HLT chains ListOf_HLT_names = [] HLT_names_signature = [] + ListOf_signatures = [] import re for signame, m_this_regex in signature_names_regexes: log_trighlt.debug('Signature: %s', signame) + ListOf_signatures.append(signame) this_regex = re.compile(m_this_regex) HLT_names_signature.clear() #re-use the list for chain_name in getHLTMenuAccess(inputFlags): @@ -152,17 +103,12 @@ def TrigGeneralMonConfig(inputFlags): #Sort HLT names alphabetically, to make the HLT histograms have the same #x axes for different runs and reprocessings - log_trighlt.debug('Sortning the chain names alphabetically') ListOf_HLT_names_sorted = [] HLT_names_signature_sorted = [] for i in range(len(ListOf_HLT_names)): HLT_names_signature.clear() HLT_names_signature=ListOf_HLT_names[i] - log_trighlt.debug('Signature %i before sorting:',i) - for thisname in HLT_names_signature: - log_trighlt.debug('chain: %s',thisname) - log_trighlt.debug('Signature %i after sorting:',i) HLT_names_signature_sorted.clear() HLT_names_signature_sorted = sorted(HLT_names_signature) ListOf_HLT_names_sorted.append(list(HLT_names_signature_sorted)) @@ -175,7 +121,6 @@ def TrigGeneralMonConfig(inputFlags): L1_names =[] log_trighlt.debug('L1 items: ') for item_name in getL1MenuAccess(inputFlags): - log_trighlt.debug('L1 item_name = %s',item_name) L1_names.append(item_name) max_L1_items = len(L1_names) log_trighlt.debug('max_L1_items = %i', max_L1_items) @@ -207,7 +152,7 @@ def TrigGeneralMonConfig(inputFlags): titlename = sig+";;"+"Events" HLT_names_signature_sorted.clear() HLT_names_signature_sorted = ListOf_HLT_names_sorted[i] - log_trighlt.debug('Number of chains = %i', len(HLT_names_signature_sorted)) + Xmax=len(HLT_names_signature_sorted) if Xmax<1: Xmax = 1 #Avoid error messages if there are no chains in this signature @@ -215,21 +160,52 @@ def TrigGeneralMonConfig(inputFlags): for trigstatus in triggerstatus: #loop over RAW/PS histname = sig+trigstatus - log_trighlt.debug('Histname = %s', histname) + titlename = sig+trigstatus+";;"+"Events" hltGroup.defineHistogram(histname,title=titlename, path=sig,xbins=len(HLT_names_signature_sorted), xmin=0,xmax=Xmax, xlabels=HLT_names_signature_sorted,opt='kAlwaysCreate') + #eta and phi, 1D + histname = sig+"_eta" + titlename = histname+";#eta;"+"Events" + hltGroup.defineHistogram(histname,title=titlename, + path=sig,xbins=64,xmin=-3.2,xmax=3.2) + + histname = sig+"_phi" + titlename = histname+";#phi;"+"Events" + hltGroup.defineHistogram(histname,title=titlename, + path=sig,xbins=64,xmin=-3.2,xmax=3.2) + + #RoI count + histname = sig+"RoI_N" + titlename = histname+";Number of RoIs;"+"Events" + hltGroup.defineHistogram(histname,title=titlename, + path=sig,xbins=100,xmin=0,xmax=500) + + ### RoIs, one per signature + #Tools for the signatures, including AllChains as first item + listOfSignatureGroups =[] + for signame in ListOf_signatures: + thistoolname = 'Trig'+signame+'Monitor' + thisGroup = helper.addGroup( + trigHLTMonAlg, + thistoolname, + 'HLT/ResultMon/'+signame + ) + listOfSignatureGroups.append(thisGroup) + + + #Creating the RoI histograms log_trighlt.debug('Creating RoI histograms...') for i, thisGroup in enumerate(listOfSignatureGroups): thispair = signature_names_regexes[i] thissigname = thispair[0] #first item in the pair is the signature name - log_trighlt.debug('Signature name %s',thissigname) histname = "eta,phi;"+thissigname+"RoIs" - titlename = thissigname+";#eta;#phi" + + titlename = thissigname+"RoIs;#eta;#phi" thisGroup.defineHistogram(histname,type='TH2F',title=titlename, path='',xbins=64,xmin=-3.2,xmax=3.2, ybins=64,ymin=-3.2,ymax=3.2) diff --git a/Trigger/TrigMonitoring/TrigHLTMonitoring/src/TrigHLTMonitorAlgorithm.cxx b/Trigger/TrigMonitoring/TrigHLTMonitoring/src/TrigHLTMonitorAlgorithm.cxx index d0478b792ec440ac510e75c92bc6e4f99cb12f73..dccdec99652cfe1e0f71a4264f82cf75a35282ef 100644 --- a/Trigger/TrigMonitoring/TrigHLTMonitoring/src/TrigHLTMonitorAlgorithm.cxx +++ b/Trigger/TrigMonitoring/TrigHLTMonitoring/src/TrigHLTMonitorAlgorithm.cxx @@ -32,15 +32,8 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co using namespace Monitored; StatusCode sc = StatusCode::FAILURE; - //Fetch the tools + //Fetch the general tool auto tool = getGroup("TrigHLTMonitor"); - auto toolAll = getGroup("TrigHLTAllMonitor"); - auto toolEle = getGroup("TrigHLTEleMonitor"); - auto toolGam = getGroup("TrigHLTGamMonitor"); - auto toolMuo = getGroup("TrigHLTMuoMonitor"); - auto toolMET = getGroup("TrigHLTMETMonitor"); - auto toolTau = getGroup("TrigHLTTauMonitor"); - auto toolJet = getGroup("TrigHLTJetMonitor"); //////////////////////////////////////// @@ -79,29 +72,54 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co // HLT chain monitoring ATH_MSG_DEBUG( "HLT chain monitoring" ); - ATH_MSG_DEBUG( "Setting up the regex map..." ); + //Set up the regex map std::map streams; streams.insert(std::make_pair("HLT_AllChains", "HLT_.*")); streams.insert(std::make_pair("HLT_Electrons", "HLT_[0-9]*e[0-9]+.*")); streams.insert(std::make_pair("HLT_Gamma", "HLT_[0-9]*g[0-9]+.*")); streams.insert(std::make_pair("HLT_Muons", "HLT_[0-9]*mu[0-9]+.*")); - streams.insert(std::make_pair("HLT_MissingET", "HLT_(t|x)e[0-9]+.*")); streams.insert(std::make_pair("HLT_Taus", "HLT_(tau[0-9]*|trk.*Tau).*")); + streams.insert(std::make_pair("HLT_MissingET", "HLT_(t|x)e[0-9]+.*")); streams.insert(std::make_pair("HLT_Jets", "HLT_[0-9]*j[0-9]+.*")); streams.insert(std::make_pair("HLT_MinBias", "HLT_mb.*")); - //// Set the values of the monitored variables for the event + //// Set the values of the monitored variables for the event + + //Number of RoIs per signature + std::vector roiN; - ATH_MSG_DEBUG( "Iterating over the regex map..."); + //Iterate over the regex map... std::map::const_iterator strItr; + int N_sig = 0; for (strItr=streams.begin();strItr!=streams.end(); ++strItr){ std::string signaturename = strItr->first; std::string thisregex = strItr->second; + + //Open the right group + std::string toolname = "Trig"+signaturename+"Monitor"; + ATH_MSG_DEBUG("Initializing tool " << toolname ); + auto thisTool = getGroup(toolname); + + //RAW and PS std::string histname_raw = signaturename+"RAW"; std::string histname_ps = signaturename+"PS"; auto HLT_RAW = Monitored::Scalar(histname_raw); auto HLT_PS = Monitored::Scalar(histname_ps); + + //eta and phi + std::string histname_eta=signaturename+"_eta"; + std::string histname_phi=signaturename+"_phi"; + auto RoI_eta = Monitored::Scalar(histname_eta,0.0); + auto RoI_phi = Monitored::Scalar(histname_phi,0.0); + + + //Number of RoIs + roiN.push_back(0); //initialize roiN at 0 for each signature + std::string histname_roiN=signaturename+"RoI_N"; + auto RoI_N = Monitored::Scalar(histname_roiN,0); + + //Loop over HLT chains ATH_MSG_DEBUG( "Filling HLT" << signaturename << " and RoI information for " << thisregex ); std::vector< std::string > chainNames = m_trigDecTool->getChainGroup(thisregex)->getListOfTriggers(); @@ -116,7 +134,6 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co /// Fill plain chains histogram HLT_RAW = chainNames[ith]; - ATH_MSG_DEBUG( "Fill HLT_RAW for " << signaturename << " and " << chainNames[ith]); fill(tool,HLT_RAW); //If the chain is prescaled @@ -128,7 +145,6 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co else { ATH_MSG_WARNING("No chain found in m_trigDecTool->ExperimentalAndExpertMethods().getChainConfigurationDetails(" << chainNames[ith] << "). Using prescale 0"); } - ATH_MSG_DEBUG( "Prescale: " << prescale ); if(prescale>1. || prescale<1.) { //NB! Right now very few chains are prescaled, so this histogram is seldom filled HLT_PS = chainNames[ith]; @@ -136,77 +152,36 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co fill(tool,HLT_PS); } - /// Fill RoIs histogram - ATH_MSG_DEBUG("Fill RoI histograms for chain " << chainNames[ith] ); + /// Fill RoIs histogram and 1D histos for eta, phi, RoI count std::vector> fvec = m_trigDecTool->features(chainNames[ith], TrigDefs::Physics, "", TrigDefs::lastFeatureOfType, initialRoIString()); - //Loop over RoIs for (const LinkInfo& li : fvec) { if( li.isValid() ) { - auto phi = Monitored::Scalar("phi",0.0); - auto eta = Monitored::Scalar("eta",0.0); - if(signaturename=="HLT_AllChains") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolAll, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); - } - //Check signatures - if(signaturename=="HLT_Electrons") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolEle, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); + //Fill 1D histos of roi_N, eta, phi + const TrigRoiDescriptor* roi = *(li.link).cptr(); + if(!roi->isFullscan()) { + RoI_eta = roi->eta(); + RoI_phi = roi->phi(); + fill(tool,RoI_eta); + fill(tool,RoI_phi); + roiN[N_sig]++; } - else if(signaturename=="HLT_Gamma") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolGam, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); + else { + ATH_MSG_DEBUG( "RoI is FULLSCAN, chain " << chainNames[ith]); } - else if(signaturename=="HLT_Muons") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolMuo, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); - } - else if(signaturename=="HLT_MissingET") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolMET, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); - } - else if(signaturename=="HLT_Taus") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolTau, eta, phi); - const TrigRoiDescriptor* roi = *(li.link).cptr(); - eta = roi->eta(); - phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); - } - else if(signaturename=="HLT_Jets") { - ATH_MSG_DEBUG( "RoI: filling for " << signaturename ); - auto HLT_RoIs = Monitored::Group(toolJet, eta, phi); + + //Fill 2D RoI maps + auto phi = Monitored::Scalar("phi",0.0); + auto eta = Monitored::Scalar("eta",0.0); + + if(!roi->isFullscan()) { + auto HLT_RoIs = Monitored::Group(thisTool, eta, phi); const TrigRoiDescriptor* roi = *(li.link).cptr(); eta = roi->eta(); phi = roi->phi(); - ATH_MSG_DEBUG( "RoI: eta = " << eta << ", phi = " << phi ); } - - - }//end if(li.isValid()) else { @@ -217,9 +192,16 @@ StatusCode TrigHLTMonitorAlgorithm::fillHistograms( const EventContext& ctx ) co }// end if(m_trigDecTool->isPassed(chainNames[ith])) }// end if( chainNames[ith] != "" ) }//end for(unsigned int ith=0; ith0) {//only fill if we have at least one RoI for the signature + fill(tool,RoI_N); + } + + N_sig++; + }//end loop over streams + ////////////////////////////////////// // HLTResult and ConfigConsistency @@ -240,7 +222,7 @@ StatusCode TrigHLTMonitorAlgorithm::fillResultAndConsistencyHistograms( const Ev StatusCode sc_hltEvents = StatusCode::FAILURE; StatusCode sc_onlineKeys = StatusCode::FAILURE; StatusCode sc_eventKeys = StatusCode::FAILURE; - ATH_MSG_DEBUG("---> Filling Result and Consistency histograms"); + ATH_MSG_DEBUG("Filling Result and Consistency histograms"); // Declare the quantities which should be monitored //NB! The variables and histograms defined here must match the ones in the py file exactly!