ATLAS Offline Software
TrigTLAMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 TrigTLAMonitorAlgorithm::TrigTLAMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
9  : AthMonitorAlgorithm(name,pSvcLocator)
10 {}
11 
13 
14 
22 
23  ATH_CHECK( m_trigDecisionTool.retrieve() );
24 
26 }
27 
28 /*************************************************
29 * Main filling function *
30 **************************************************/
31 
32 StatusCode TrigTLAMonitorAlgorithm::fillHistograms( const EventContext& ctx ) const {
33  // This is the method exectued on every event (inherited from AthMonitorAlgorithm)
34  using namespace Monitored;
35 
36  //
37  // print the trigger chain names
38  std::string chainName;
39 
40  int size_AllChains = m_allChains.size();
41  ATH_MSG_DEBUG(" Size of the AllChains trigger container: " << size_AllChains );
42  for (int i =0; i<size_AllChains; i++){
44  ATH_MSG_DEBUG(" Chain number: " << i << " AllChains Chain Name: " << chainName );
45  }
46 
47  //
48  // Retrieve all the containers of monitored objects
54 
55  ANA_CHECK( readContainer<xAOD::TrigCompositeContainer>(tcEventInfo, m_tcEventInfoContainerKey, ctx) );
56  ANA_CHECK( readContainer<xAOD::JetContainer> (jets, m_jetContainerKey, ctx) );
57  ANA_CHECK( readContainer<xAOD::JetContainer> (pfjets, m_pfjetContainerKey, ctx) );
58  ANA_CHECK( readContainer<xAOD::PhotonContainer> (phs, m_photonContainerKey, ctx) );
59  ANA_CHECK( readContainer<xAOD::MuonContainer> (muons, m_muonContainerKey, ctx) );
60  ANA_CHECK( readContainer<xAOD::TrackParticleContainer>(tracks, m_trackParticleContainerKey, ctx) );
61 
62  //
63  // event-wide variables
64  ANA_CHECK(fillEventInfoHistogram<float>(tcEventInfo, "AvgMu", "eventInfo" ));
65  if (pfjets->size()>0){
66  ATH_MSG_DEBUG("nEMPFlowJets = "<<pfjets->size());
67  ANA_CHECK(fillEventInfoHistogram<int>(tcEventInfo, "NumPV", "eventInfo" ));
68  ANA_CHECK(fillEventInfoHistogram<double>(tcEventInfo, "JetDensityEMPFlow", "eventInfo" ));
69  }
70  if (jets->size()>0){
71  ATH_MSG_DEBUG("nEMTopoJets = "<<jets->size());
72  ANA_CHECK(fillEventInfoHistogram<double>(tcEventInfo, "JetDensityEMTopo", "eventInfo" ));
73  }
74 
75  const std::vector<std::string> jetCalibStates = {"JetConstitScaleMomentum_pt", "JetPileupScaleMomentum_pt", "JetEtaJESScaleMomentum_pt"};
76  const std::vector<std::string> pfjetCalibStates = {"JetConstitScaleMomentum_pt", "JetPileupScaleMomentum_pt", "JetEtaJESScaleMomentum_pt", "JetGSCScaleMomentum_pt"};
77 
78  for ( const std::string& trigName : m_allChains ) {
79  //Test if trigName has fired
80  if(m_trigDecisionTool->isPassed(trigName, TrigDefs::requireDecision)){
81  ATH_MSG_DEBUG("--->"<<trigName<<" fired!");
82  // proceed filling the histogram
83 
84  //
85  // jets
86  using J = xAOD::Jet;
87  ANA_CHECK(fillParticleHistograms<J>(jets, "jet", trigName));
88  if (jets->size()>0){
89  for (const auto& calibState: jetCalibStates){
90  ANA_CHECK(fillJetPtCalibStatesHistograms(jets,calibState, "jet", trigName));
91  }
92  ANA_CHECK( (fillObjectVariableHistogram<J,float>(jets,"N90Constituents", "jet", trigName )) );
93  ANA_CHECK( (fillObjectVariableHistogram<J,float>(jets,"Timing", "jet", trigName, -99)) );
94  ANA_CHECK( (fillObjectVariableHistogram<J,float>(jets,"EMFrac", "jet", trigName, -99)) );
95  ANA_CHECK( (fillObjectVariableHistogram<J,float>(jets,"HECFrac", "jet", trigName, -99)) );
96  }
97 
98  //
99  // particle flow jets
100  ANA_CHECK(fillParticleHistograms<J>(pfjets, "pfjet", trigName));
101  if (pfjets->size()>0){
102  for (const auto& calibState: pfjetCalibStates){
103  ANA_CHECK(fillJetPtCalibStatesHistograms(pfjets, calibState, "pfjet", trigName));
104  }
105  ANA_CHECK( fillJetTrackVariableHistogram<float>(pfjets,"TrackWidthPt1000", "pfjet", trigName) );
106  ANA_CHECK( fillJetTrackVariableHistogram<int> (pfjets,"NumTrkPt1000", "pfjet", trigName) );
107  ANA_CHECK( fillJetTrackVariableHistogram<float>(pfjets,"SumPtTrkPt500", "pfjet", trigName) );
108  ANA_CHECK( fillJetTrackVariableHistogram<float>(pfjets,"SumPtChargedPFOPt500", "pfjet", trigName) );
109  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"ActiveArea", "pfjet", trigName)) );
110  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"Jvt", "pfjet", trigName, -99)) );
111  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"JvtRpt", "pfjet", trigName, -99)) );
112  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"fastDIPS20211215_pu", "pfjet", trigName)) );
113  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"fastDIPS20211215_pb", "pfjet", trigName)) );
114  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"fastDIPS20211215_pc", "pfjet", trigName)) );
115  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"GN120230331_pu", "pfjet", trigName)) );
116  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"GN120230331_pb", "pfjet", trigName)) );
117  ANA_CHECK( (fillObjectVariableHistogram<J,float>(pfjets,"GN120230331_pc", "pfjet", trigName)) );
118  }
119 
120  //
121  // photons
122  ATH_CHECK(fillParticleHistograms<xAOD::Photon>(phs, "ph", trigName));
123 
124  //
125  // muons
126  ANA_CHECK(fillParticleHistograms<xAOD::Muon>(muons, "muon", trigName));
127 
128  //
129  // Tracks
130  using TP = xAOD::TrackParticle;
131  if (tracks->size()>0 && trigName.find("pf_ftf") != std::string::npos) {
132  ANA_CHECK( fillParticleHistograms<TP>(tracks, "trk", trigName) );
133  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "qOverP", "trk", trigName)) );
134  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "chiSquared", "trk", trigName)) );
135  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "numberDoF", "trk", trigName)) );
136  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "btagIp_d0", "trk", trigName)) );
137  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "btagIp_d0Uncertainty", "trk", trigName)) );
138  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "btagIp_z0SinTheta", "trk", trigName)) );
139  ANA_CHECK( (fillObjectVariableHistogram<TP,float>(tracks, "btagIp_z0SinThetaUncertainty", "trk", trigName)) );
140  }
141 
142  //
143  // Delta Angles
144  if(jets->size()>=2) {
145  ANA_CHECK(fillDeltaRHistograms(jets ->at(0), jets ->at(1), "jet0jet1" , trigName));
146  }
147 
148  if(pfjets->size()>=2) {
149  ANA_CHECK(fillDeltaRHistograms(pfjets->at(0), pfjets->at(1), "pfjet0pfjet1", trigName));
150  }
151 
152  if(jets->size()>=1 && phs->size()>=1) {
153  ANA_CHECK(fillDeltaRHistograms(jets ->at(0), phs ->at(0), "jet0ph0" , trigName));
154  }
155 
156  if(pfjets->size()>=1 && phs->size()>=1) {
157  ANA_CHECK(fillDeltaRHistograms(pfjets->at(0), phs ->at(0), "pfjet0ph0" , trigName));
158  }
159  }
160  } // for AllChains
161 
162  return StatusCode::SUCCESS;
163 }
164 
165 
166 /*************************************************
167 * Implementation of specialized fillers *
168 **************************************************/
169 
170 StatusCode TrigTLAMonitorAlgorithm::fillDeltaRHistograms(const xAOD::IParticle* p0, const xAOD::IParticle* p1, const std::string& prefix, const std::string& trigName) const
171 {
172  // histograms
173  Monitored::Scalar<double> dr(prefix+"dr_" +trigName,0.0);
174 
175  // fill
176  dr = p0->p4().DeltaR(p1->p4());
177  fill("TrigTLAMonitor", dr);
178 
179  return StatusCode::SUCCESS;
180 }
181 
182 
183 StatusCode TrigTLAMonitorAlgorithm::fillJetPtCalibStatesHistograms(SG::ReadHandle<xAOD::JetContainer> jets, const std::string& calibState, const std::string& prefix, const std::string& trigName) const {
184 
185  Monitored::Scalar<float> ptCalibScale (prefix+calibState+"_"+trigName,-1.0);
186 
187  unsigned cnt(0);
188  for(auto jet : *jets) {
189  auto status = jet->getAttribute<float>(calibState, ptCalibScale);
190  if (!status){
191  ATH_MSG_WARNING("Failed retrieving "<<calibState<<" for "<<prefix);
192  }
193  ptCalibScale = ptCalibScale*1e-3;
194  fill("TrigTLAMonitor",ptCalibScale);
195  if (cnt < 3) ATH_MSG_DEBUG(prefix<<" "<<calibState<<" = "<<ptCalibScale<<" GeV");
196  cnt++;
197  }
198 
199  return StatusCode::SUCCESS;
200 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
TrigTLAMonitorAlgorithm::~TrigTLAMonitorAlgorithm
virtual ~TrigTLAMonitorAlgorithm()
Definition: TrigTLAMonitorAlgorithm.cxx:12
TrigTLAMonitorAlgorithm::m_jetContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerKey
Definition: TrigTLAMonitorAlgorithm.h:29
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
TrigTLAMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TrigTLAMonitorAlgorithm.cxx:32
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
python.TurnDataReader.dr
dr
Definition: TurnDataReader.py:112
TrigTLAMonitorAlgorithm::m_trigDecisionTool
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecisionTool
Definition: TrigTLAMonitorAlgorithm.h:36
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
TrigTLAMonitorAlgorithm::fillJetPtCalibStatesHistograms
StatusCode fillJetPtCalibStatesHistograms(SG::ReadHandle< xAOD::JetContainer > jets, const std::string &calibState, const std::string &prefix, const std::string &trigName) const
Fill jet pT to 1D histograms at different calibration scales.
Definition: TrigTLAMonitorAlgorithm.cxx:183
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
xAOD::TrackParticle
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParticle.h:13
TrigTLAMonitorAlgorithm::m_photonContainerKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_photonContainerKey
Definition: TrigTLAMonitorAlgorithm.h:31
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigTLAMonitorAlgorithm::m_pfjetContainerKey
SG::ReadHandleKey< xAOD::JetContainer > m_pfjetContainerKey
Definition: TrigTLAMonitorAlgorithm.h:30
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TrigTLAMonitorAlgorithm::m_tcEventInfoContainerKey
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_tcEventInfoContainerKey
Definition: TrigTLAMonitorAlgorithm.h:34
TrigTLAMonitorAlgorithm::TrigTLAMonitorAlgorithm
TrigTLAMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigTLAMonitorAlgorithm.cxx:8
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigTLAMonitorAlgorithm::m_allChains
Gaudi::Property< std::vector< std::string > > m_allChains
Definition: TrigTLAMonitorAlgorithm.h:27
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
TrigTLAMonitorAlgorithm::m_trackParticleContainerKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey
Definition: TrigTLAMonitorAlgorithm.h:33
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
TrigTLAMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigTLAMonitorAlgorithm.cxx:15
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
merge.status
status
Definition: merge.py:17
TrigTLAMonitorAlgorithm.h
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
TrigTLAMonitorAlgorithm::m_muonContainerKey
SG::ReadHandleKey< xAOD::MuonContainer > m_muonContainerKey
Definition: TrigTLAMonitorAlgorithm.h:32
TRTCalib_cfilter.p0
p0
Definition: TRTCalib_cfilter.py:129
TrigTLAMonitorAlgorithm::fillDeltaRHistograms
StatusCode fillDeltaRHistograms(const xAOD::IParticle *p0, const xAOD::IParticle *p1, const std::string &prefix, const std::string &trigName) const
Fill kinematic histograms for a given particle of type T
Definition: TrigTLAMonitorAlgorithm.cxx:170