Skip to content
Snippets Groups Projects
Commit 0cecee1f authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'tauMonitoring-run3' into 'master'

Tau monitoring run3

See merge request atlas/athena!27127
parents 1dfcff27 7d172554
No related branches found
No related tags found
No related merge requests found
#
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
#
def TauMonitoringConfig(flags):
from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
result = ComponentAccumulator()
from .tauMonitorAlgorithm import tauMonitoringConfig
result.merge(tauMonitoringConfig(flags))
return result
#
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
#
'''@file tauMonitorAlgorithm.py
@author C. D. Burton
@author P. Onyisi
@date 2018-01-11
@brief tau python configuration for the Run III AthenaMonitoring package
'''
def tauMonitoringConfig(inputFlags):
'''Function to configures some algorithms in the monitoring system.'''
### STEP 1 ###
# The following class will make a sequence, configure algorithms, and link
# them to GenericMonitoringTools
from AthenaMonitoring import AthMonitorCfgHelper
cfgHelper = AthMonitorCfgHelper(inputFlags, monName='tauMonitorAlgFamily')
### STEP 2 ###
# Adding an algorithm to the helper. Here, we will use the example
# algorithm in the AthenaMonitoring package. Just pass the type to the
# helper. Then, the helper will instantiate an instance and set up the
# base class configuration following the inputFlags. The returned object
# is the algorithm.
from tauMonitoring.tauMonitoringConf import tauMonitorAlgorithm
tauMonAlgBA = cfgHelper.addAlgorithm( tauMonitorAlgorithm, name='tauMonAlgBA')
tauMonAlgCR = cfgHelper.addAlgorithm( tauMonitorAlgorithm, name='tauMonAlgCR')
tauMonAlgEC = cfgHelper.addAlgorithm( tauMonitorAlgorithm, name='tauMonAlgEC')
### STEP 3 ###
# Edit properties of a algorithm
# some generic property
# exampleMonAlg.RandomHist = True
# to enable a trigger filter, for example:
#exampleMonAlg.TriggerChain = 'HLT_mu26_ivarmedium'
tauMonAlgBA.etaMin = -1.
tauMonAlgBA.etaMax = 1.3
tauMonAlgCR.etaMin = 1.3
tauMonAlgCR.etaMax = 1.7
tauMonAlgEC.etaMin = 1.7
tauMonAlgEC.etaMax = 3.5
tauMonAlgBA.kinGroupName = 'tauMonKinGroupBA'
tauMonAlgCR.kinGroupName = 'tauMonKinGroupCR'
tauMonAlgEC.kinGroupName = 'tauMonKinGroupEC'
### STEP 4 ###
# Add some tools. N.B. Do not use your own trigger decion tool. Use the
# standard one that is included with AthMonitorAlgorithm.
# Add a generic monitoring tool (a "group" in old language). The returned
# object here is the standard GenericMonitoringTool.
myKinGroupBA = cfgHelper.addGroup(alg=tauMonAlgBA, name='tauMonKinGroupBA', topPath='run/BA/' )
myKinGroupCR = cfgHelper.addGroup(alg=tauMonAlgCR, name='tauMonKinGroupCR', topPath='run/CR/' )
myKinGroupEC = cfgHelper.addGroup(alg=tauMonAlgEC, name='tauMonKinGroupEC', topPath='run/EC/' )
# Add a GMT for the other example monitor algorithm
# anotherGroup = cfgHelper.addGroup(anotherTauMonAlg,'tauMonitor')
### STEP 5 ###
# Configure histograms
for itup in [(myKinGroupBA,'BA'),(myKinGroupCR,'CR'),(myKinGroupEC,'EC')]:
(igroup, postfix) = itup
igroup.defineHistogram('Eflow', title='Eflow;Eflow;Events', path='Kinematics',
xbins=100, xmin=0., xmax=1000.)
igroup.defineHistogram('eta,phi', type='TH2F', title='PhiVsEtaTitle;#eta;#phi', path='Kinematics',
#xbins=[0,.1,.2,.4,.8,1.6],ybins=[0,10,30,40,60,70,90])
#xbins=[0,4.,8.,10.,15.],ybins=[0.,1.,2.,3.,4.])
xbins=30,xmin=-3.0,xmax=3.0,ybins=32,ymin=-3.15,ymax=3.15)
### STEP 6 ###
# Finalize. The return value should be a tuple of the ComponentAccumulator
# and the sequence containing the created algorithms. If we haven't called
# any configuration other than the AthMonitorCfgHelper here, then we can
# just return directly (and not create "result" above)
return cfgHelper.result()
# # Otherwise, merge with result object and return
# acc = cfgHelper.result()
# result.merge(acc)
# return result
if __name__=='__main__':
# Setup the Run III behavior
from AthenaCommon.Configurable import Configurable
Configurable.configurableRun3Behavior = 1
# Setup logs
from AthenaCommon.Logging import log
from AthenaCommon.Constants import INFO
log.setLevel(INFO)
# Set the Athena configuration flags
from AthenaConfiguration.AllConfigFlags import ConfigFlags
nightly = '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/CommonInputs/'
file = 'data16_13TeV.00311321.physics_Main.recon.AOD.r9264/AOD.11038520._000001.pool.root.1'
ConfigFlags.Input.Files = [nightly+file]
ConfigFlags.Input.isMC = False
ConfigFlags.Output.HISTFileName = 'tauRegions.root'
ConfigFlags.lock()
# Initialize configuration object, add accumulator, merge, and run.
from AthenaConfiguration.MainServicesConfig import MainServicesSerialCfg
from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
cfg = MainServicesSerialCfg()
cfg.merge(PoolReadCfg(ConfigFlags))
exampleMonitorAcc = tauMonitoringConfig(ConfigFlags) # calls the main function above
cfg.merge(exampleMonitorAcc)
# If you want to turn on more detailed messages ...
exampleMonitorAcc.getEventAlgo('tauMonAlgBA').OutputLevel = 2 # DEBUG
exampleMonitorAcc.getEventAlgo('tauMonAlgCR').OutputLevel = 2 # DEBUG
exampleMonitorAcc.getEventAlgo('tauMonAlgEC').OutputLevel = 2 # DEBUG
cfg.printConfig(withDetails=True) # set True for exhaustive info
cfg.run() #use cfg.run(20) to only run on first 20 events
#include "tauMonitoring/tauMonTool.h"
#include "tauMonitoring/tauMonitorAlgorithm.h"
DECLARE_COMPONENT( tauMonTool )
DECLARE_COMPONENT( tauMonitorAlgorithm )
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include "tauMonitoring/tauMonitorAlgorithm.h"
tauMonitorAlgorithm::tauMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
:AthMonitorAlgorithm(name,pSvcLocator)
,m_doRandom(true)
{
declareProperty("TauRecContainer", m_TauContainerKey="TauJets");
declareProperty("etaMin", m_etaMin=-1.);
declareProperty("etaMax", m_etaMax=2.6);
declareProperty("kinGroupName", m_kinGroupName="tauMonKinGroupBA");
}
tauMonitorAlgorithm::~tauMonitorAlgorithm() {}
StatusCode tauMonitorAlgorithm::initialize() {
using namespace Monitored;
ATH_CHECK( m_TauContainerKey.initialize() );
return AthMonitorAlgorithm::initialize();
}
StatusCode tauMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
using namespace Monitored;
auto Eflow = Monitored::Scalar<float>("Eflow",-1.);
auto eta = Monitored::Scalar<float>("eta",-4.0);
auto phi = Monitored::Scalar<float>("phi",-1.0);
SG::ReadHandle<xAOD::TauJetContainer> taus(m_TauContainerKey, ctx);
if (! taus.isValid() ) {
ATH_MSG_ERROR("evtStore() does not contain tau Collection with name "<< m_TauContainerKey);
return StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Number of taus: " << taus->size());
bool test = false;
for (const auto& tau : *taus) {
// do stuff with taus
eta = tau->eta();
phi = tau->phi();
ATH_MSG_DEBUG(m_etaMin << m_etaMax << eta);
if ( (fabs(eta) < m_etaMin) || (fabs(eta) > m_etaMax)) continue;
test=tau->detail(xAOD::TauJetParameters::mEflowApprox, Eflow);
if (test) fill(m_kinGroupName, Eflow, eta, phi );
}
return StatusCode::SUCCESS;
}
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TAUMONITORALGORITHM_H
#define TAUMONITORALGORITHM_H
#include "AthenaMonitoring/AthMonitorAlgorithm.h"
#include "AthenaMonitoring/Monitored.h"
#include "TRandom3.h"
#include "StoreGate/ReadCondHandleKey.h"
#include "StoreGate/ReadHandleKey.h"
#include "xAODTau/TauJetContainer.h"
class tauMonitorAlgorithm : public AthMonitorAlgorithm {
public:
tauMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator );
virtual ~tauMonitorAlgorithm();
virtual StatusCode initialize() override;
virtual StatusCode fillHistograms( const EventContext& ctx ) const override;
private:
Gaudi::Property<bool> m_doRandom {this,"RandomHist",false};
std::vector<int> m_abGroups1;
std::vector<std::vector<int>> m_abGroups2;
std::map<std::string,int> m_cGroups1;
std::map<std::string,std::map<std::string,int>> m_cGroups2;
SG::ReadHandleKey<xAOD::TauJetContainer> m_TauContainerKey;
Gaudi::Property<float> m_etaMin {this, "etaMin", -1.};
Gaudi::Property<float> m_etaMax {this, "etaMax", 3.0};
Gaudi::Property<std::string> m_kinGroupName {this, "kinGroupName", "tauMonKinGroupBA"};
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment