ATLAS Offline Software
InDetGlobalLRTMonAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
16 //main header
17 #include "InDetGlobalLRTMonAlg.h"
18 
19 //Standard c++
20 #include <vector>
21 #include <memory>
22 
23 
24 InDetGlobalLRTMonAlg::InDetGlobalLRTMonAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
25  AthMonitorAlgorithm(name, pSvcLocator),
26  m_trackSelTool ( "InDet::InDetTrackSelectionTool/TrackSelectionTool", this),
27  m_IBLParameterSvc("IBLParameterSvc",name),
28  m_doIBL(true)
29 {
30  //jo flags go here, keys and some tools -> in class
31  declareProperty("DoIBL", m_doIBL,"IBL present?");
32  declareProperty( "TrackSelectionTool", m_trackSelTool);
33 }
34 
35 
37 
38 
40  ATH_CHECK( m_IBLParameterSvc.retrieve() );
41 
42  m_doIBL = m_IBLParameterSvc->containsIBL();
43 
44  if (!m_trackSelTool.empty() ) ATH_CHECK( m_trackSelTool.retrieve() );
45 
47 
49 }
50 
51 
52 StatusCode InDetGlobalLRTMonAlg::fillHistograms( const EventContext& ctx ) const {
53  using namespace Monitored;
54 
55  //*******************************************************************************
56  //************************** Begin of filling Track Histograms ******************
57  //*******************************************************************************
58 
59  ATH_MSG_DEBUG("Filling InDetGlobalLRTMonAlg");
60 
61  // For histogram naming
62  auto lrtGroup = getGroup("LRT");
63 
64  int lb = GetEventInfo(ctx)->lumiBlock();
65  auto lb_m = Monitored::Scalar<int>( "m_lb", lb );
66 
67 
68  float lumiPerBCID = lbAverageInteractionsPerCrossing(ctx);
69  auto lumiPerBCID_m = Monitored::Scalar<float>( "m_lumiPerBCID", lumiPerBCID );
70 
71 
72  // retrieving tracks
73  auto LRT_trackParticles = SG::makeHandle(m_trackParticleName, ctx);
74 
75  // check for tracks
76  if ( !(LRT_trackParticles.isValid()) ) {
77  ATH_MSG_ERROR("InDetGlobalMonitoringRun3Test: Track container "<< m_trackParticleName.key() << " could not be found.");
78  return StatusCode::RECOVERABLE;
79  } else {
80  ATH_MSG_DEBUG("InDetGlobalMonitoringRun3Test: Track container "<< LRT_trackParticles.name() <<" is found.");
81  }
82 
83  // counters
84  int nBase = 0;
85  int nNoIBL = 0;
86  int nNoBL = 0;
87  int nNoTRText = 0;
88 
89  uint8_t iSummaryValue(0); // Dummy counter to retrieve summary values
90 
91  for (const auto& trackPart: *LRT_trackParticles) {
92  const Trk::Track * track = trackPart->track();
93  if ( !track )
94  {
95  ATH_MSG_DEBUG( "InDetGlobalMonitoringRun3Test: NULL track pointer in collection" );
96  continue;
97  }
98 
99  const Trk::Perigee *perigee = track->perigeeParameters();
100  if ( !perigee )
101  {
102  ATH_MSG_DEBUG( "InDetGlobalMonitoringRun3Test: NULL track->perigeeParameters pointer " );
103  continue;
104  }
105 
106  // Loose primary tracks
107  if ( !m_trackSelTool->accept(*track) )
108  continue;
109 
110  nBase++;
111 
112 
113  // =================================== //
114  // Fill hits BEGINS
115 
116  float eta_perigee = perigee->eta();
117  float phi_perigee = perigee->parameters()[Trk::phi0];
118 
119  auto eta_perigee_m = Monitored::Scalar<float>( "m_eta_perigee", eta_perigee);
120  auto phi_perigee_m = Monitored::Scalar<float>( "m_phi_perigee", phi_perigee);
121  fill(lrtGroup, eta_perigee_m, phi_perigee_m); // Trk_Base_eta_phi
122  fill(lrtGroup, eta_perigee_m);
123  fill(lrtGroup, phi_perigee_m);
124 
125  float d0_perigee = perigee->parameters()[Trk::d0];
126  auto d0_perigee_m = Monitored::Scalar<float>( "m_d0_perigee", d0_perigee);
127  fill(lrtGroup, d0_perigee_m);
128 
129  float z0_perigee = perigee->parameters()[Trk::z0];
130  auto z0_perigee_m = Monitored::Scalar<float>( "m_z0_perigee", z0_perigee);
131  fill(lrtGroup, z0_perigee_m);
132 
133  float theta = perigee->parameters()[Trk::theta];
134  float qOverPt = perigee->parameters()[Trk::qOverP]/sin(theta);
135  float charge = perigee->charge();
136  float pT = 0;
137  if ( qOverPt != 0 ) {
138  pT = (1/qOverPt)*(charge);
139  auto pT_m = Monitored::Scalar<float>("m_trkPt", pT/1000);
140  fill(lrtGroup, pT_m);
141  }
142 
143  if ( m_doIBL )
144  {
145  int numberOfInnermostPixelLayerHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfInnermostPixelLayerHits) ? iSummaryValue : 0;
146  auto numberOfInnermostPixelLayerHits_m = Monitored::Scalar<int>( "m_numberOfInnermostPixelLayerHits", numberOfInnermostPixelLayerHits);
147  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfInnermostPixelLayerHits_m);
148 
149  fill(lrtGroup, lb_m, numberOfInnermostPixelLayerHits_m);
150  }
151 
152  int numberOfPixelHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelHits) ? iSummaryValue : 0;
153  int numberOfPixelDeadSensors = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelDeadSensors) ? iSummaryValue : 0;
155  auto pixHits_m = Monitored::Scalar<int>( "m_pixHits", pixHits );
156  fill(lrtGroup, eta_perigee_m, phi_perigee_m, pixHits_m);
157  fill(lrtGroup, lb_m, pixHits_m);
158 
159  auto numberOfPixelDeadSensors_m = Monitored::Scalar<int>( "m_numberOfPixelDeadSensors", numberOfPixelDeadSensors );
160  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfPixelDeadSensors_m);
161 
162  int numberOfPixelSharedHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelSharedHits) ? iSummaryValue : 0;
163  auto numberOfPixelSharedHits_m = Monitored::Scalar<int>( "m_numberOfPixelSharedHits", numberOfPixelSharedHits);
164  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfPixelSharedHits_m);
165 
166  int numberOfPixelHoles = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelHoles) ? iSummaryValue : 0;
167  auto numberOfPixelHoles_m = Monitored::Scalar<int>( "m_numberOfPixelHoles", numberOfPixelHoles);
168  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfPixelHoles_m);
169 
170  int numberOfPixelSplitHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelSplitHits) ? iSummaryValue : 0;
171  auto numberOfPixelSplitHits_m = Monitored::Scalar<int>( "m_numberOfPixelSplitHits", numberOfPixelSplitHits);
172  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfPixelSplitHits_m);
173 
174  int numberOfSCTHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTHits) ? iSummaryValue : 0;
175  int numberOfSCTDeadSensors = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTDeadSensors) ? iSummaryValue : 0;
176  int sctHits = numberOfSCTHits + numberOfSCTDeadSensors;
177  auto sctHits_m = Monitored::Scalar<int>( "m_sctHits", sctHits );
178  fill(lrtGroup, eta_perigee_m, phi_perigee_m, sctHits_m);
179  fill(lrtGroup, lb_m, sctHits_m);
180 
181  auto numberOfSCTDeadSensors_m = Monitored::Scalar<int>( "m_numberOfSCTDeadSensors", numberOfSCTDeadSensors );
182  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfSCTDeadSensors_m);
183 
184  int numberOfSCTSharedHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTSharedHits) ? iSummaryValue : 0;
185  auto numberOfSCTSharedHits_m = Monitored::Scalar<int>( "m_numberOfSCTSharedHits", numberOfSCTSharedHits);
186  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfSCTSharedHits_m);
187 
188  int numberOfSCTHoles = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTHoles) ? iSummaryValue : 0;
189  auto numberOfSCTHoles_m = Monitored::Scalar<int>( "m_numberOfSCTHoles", numberOfSCTHoles);
190  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfSCTHoles_m);
191 
192  int numberOfTRTHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfTRTHits) ? iSummaryValue : 0;
193  int numberOfTRTDeadStraws = trackPart->summaryValue(iSummaryValue, xAOD::numberOfTRTDeadStraws) ? iSummaryValue : 0;
194  int trtHits = numberOfTRTHits + numberOfTRTDeadStraws;
195  auto trtHits_m = Monitored::Scalar<int>( "m_trtHits", trtHits );
196  fill(lrtGroup, eta_perigee_m, phi_perigee_m, trtHits_m);
197  fill(lrtGroup, lb_m, trtHits_m);
198 
199  auto numberOfTRTDeadStraws_m = Monitored::Scalar<int>( "m_numberOfTRTDeadStraws", numberOfTRTDeadStraws);
200  fill(lrtGroup, eta_perigee_m, phi_perigee_m, numberOfTRTDeadStraws_m);
201 
202  // Fill hits ENDS
203  // =================================== //
204 
205  // =================================== //
206  // FillEtaPhi BEGINS
207 
208  int InnermostPixelLayerHit = 0;
209  int NextToInnermostPixelLayerHit = 0;
210 
211  int expInHit = trackPart->summaryValue(iSummaryValue, xAOD::expectInnermostPixelLayerHit) ? iSummaryValue : 0;
212  int nInHits = trackPart->summaryValue(iSummaryValue, xAOD::numberOfInnermostPixelLayerHits) ? iSummaryValue : 0;
213 
216  int expNInHit = trackPart->summaryValue(iSummaryValue, expNInHitField) ? iSummaryValue : 0;
217  int nNInHits = trackPart->summaryValue(iSummaryValue, nNInHitField) ? iSummaryValue : 0;
218 
219  if ( m_doIBL )
220  {
221  // no IBL hit but a hit is expected
222  if ( expInHit==1 && nInHits==0 ) InnermostPixelLayerHit = 1;
223  auto InnermostPixelLayerHit_m = Monitored::Scalar<int>( "m_InnermostPixelLayerHit", InnermostPixelLayerHit);
224  fill(lrtGroup, eta_perigee_m, phi_perigee_m, InnermostPixelLayerHit_m);
225  }
226 
227  // no b-layer hit but a hit is expected
228  if ( expNInHit==1 && nNInHits==0 ) NextToInnermostPixelLayerHit = 1 ;
229  auto NextToInnermostPixelLayerHit_m = Monitored::Scalar<int>( "m_NextToInnermostPixelLayerHit", NextToInnermostPixelLayerHit);
230  fill(lrtGroup, eta_perigee_m, phi_perigee_m, NextToInnermostPixelLayerHit_m);
231 
232  // No TRT extension
233  int noTRTHits = 0;
234  if ( numberOfTRTHits == 0 ) noTRTHits = 1;
235  auto noTRTHits_m = Monitored::Scalar<int>( "m_noTRTHits", noTRTHits);
236  fill(lrtGroup, eta_perigee_m, phi_perigee_m, noTRTHits_m);
237 
238  // =================================== //
239  // FillEtaPhi ENDS
240 
241  int NoIBL = 0;
242  if ( m_doIBL )
243  {
244  // no IBL hit but a hit is expected
245  if ( expInHit==1 && nInHits==0 ) NoIBL = 1;
246  if (NoIBL == 1) nNoIBL++;
247  auto NoIBL_m = Monitored::Scalar<int>( "m_NoIBL_LB", NoIBL);
248  fill(lrtGroup, lb_m, NoIBL_m);
249  }
250 
251  int NoBL = 0;
252  if ( expNInHit==1 && nNInHits==0 ) NoBL = 1;
253  if (NoBL == 1) nNoBL++;
254  auto NoBL_m = Monitored::Scalar<int>( "m_NoBL_LB", NoBL);
255  fill(lrtGroup, lb_m, NoBL_m);
256 
257  int NoTRText = 0;
258  int numberOfTRTOutliers = trackPart->summaryValue(iSummaryValue, xAOD::numberOfTRTOutliers) ? iSummaryValue : 0;
259  if ( numberOfTRTHits + numberOfTRTOutliers == 0 ) NoTRText = 1;
260  if (NoTRText == 1) nNoTRText++;
261  auto NoTRText_m = Monitored::Scalar<int>( "m_NoTRText_LB", NoTRText);
262  fill(lrtGroup, lb_m, NoTRText_m);
263 
264  // FillHitMaps is false for now
265  // FillHoles is false for now
266 
267 
268  } // end of track loop
269 
270  // Filling per-event histograms
271  auto nBase_m = Monitored::Scalar<int>( "m_nBase", nBase);
272  fill(lrtGroup, nBase_m);
273 
274  auto nBaseLB_m = Monitored::Scalar<int>( "m_nBase_LB", nBase);
275  fill(lrtGroup, lb_m, nBaseLB_m);
276 
277  fill(lrtGroup, lumiPerBCID_m, nBaseLB_m);
278 
279  if ( m_doIBL ) {
280  auto nNoIBL_m = Monitored::Scalar<int>( "m_nNoIBL_LB", nNoIBL);
281  fill(lrtGroup, lb_m, nNoIBL_m);
282  }
283 
284  auto nNoBL_m = Monitored::Scalar<int>( "m_nNoBL_LB", nNoBL);
285  fill(lrtGroup, lb_m, nNoBL_m);
286 
287  auto nNoTRText_m = Monitored::Scalar<int>( "m_nNoTRText_LB", nNoTRText);
288  fill(lrtGroup, lb_m, nNoTRText_m);
289 
290  //*******************************************************************************
291  //**************************** End of filling Track Histograms ******************
292  //*******************************************************************************
293 
294  return StatusCode::SUCCESS;
295 }
xAOD::numberOfPixelHoles
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
Definition: TrackingPrimitives.h:261
CalculateHighPtTerm.pT
pT
Definition: ICHEP2016/CalculateHighPtTerm.py:57
InDetGlobalLRTMonAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: InDetGlobalLRTMonAlg.cxx:39
xAOD::numberOfSCTSharedHits
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:272
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
InDetGlobalLRTMonAlg.h
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
InDetGlobalLRTMonAlg::~InDetGlobalLRTMonAlg
virtual ~InDetGlobalLRTMonAlg()
Definition: InDetGlobalLRTMonAlg.cxx:36
Trk::z0
@ z0
Definition: ParamDefs.h:64
xAOD::numberOfPixelHits
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].
Definition: TrackingPrimitives.h:259
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
xAOD::numberOfTRTHits
@ numberOfTRTHits
number of TRT hits [unit8_t].
Definition: TrackingPrimitives.h:275
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
InDetGlobalLRTMonAlg::InDetGlobalLRTMonAlg
InDetGlobalLRTMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: InDetGlobalLRTMonAlg.cxx:24
InDetGlobalLRTMonAlg::m_IBLParameterSvc
ServiceHandle< IIBLParameterSvc > m_IBLParameterSvc
Definition: InDetGlobalLRTMonAlg.h:62
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
xAOD::numberOfPixelSharedHits
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:262
xAOD::SummaryType
SummaryType
Enumerates the different types of information stored in Summary.
Definition: TrackingPrimitives.h:228
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::expectNextToInnermostPixelLayerHit
@ expectNextToInnermostPixelLayerHit
Do we expect a 1st-layer barrel hit for this track?
Definition: TrackingPrimitives.h:247
python.BunchSpacingUtils.lb
lb
Definition: BunchSpacingUtils.py:88
InDetGlobalLRTMonAlg::m_trackParticleName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleName
Definition: InDetGlobalLRTMonAlg.h:60
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
Trk::theta
@ theta
Definition: ParamDefs.h:66
InDetGlobalLRTMonAlg::m_doIBL
bool m_doIBL
Definition: InDetGlobalLRTMonAlg.h:64
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
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
xAOD::numberOfPixelSplitHits
@ numberOfPixelSplitHits
number of Pixel all-layer hits split by cluster splitting [unit8_t].
Definition: TrackingPrimitives.h:263
xAOD::numberOfSCTHoles
@ numberOfSCTHoles
number of SCT holes [unit8_t].
Definition: TrackingPrimitives.h:270
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
xAOD::numberOfNextToInnermostPixelLayerHits
@ numberOfNextToInnermostPixelLayerHits
these are the hits in the 1st pixel barrel layer
Definition: TrackingPrimitives.h:248
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Trk::d0
@ d0
Definition: ParamDefs.h:63
charge
double charge(const T &p)
Definition: AtlasPID.h:538
AthMonitorAlgorithm::lbAverageInteractionsPerCrossing
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average mu, i.e.
Definition: AthMonitorAlgorithm.cxx:222
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
xAOD::numberOfTRTOutliers
@ numberOfTRTOutliers
number of TRT outliers [unit8_t].
Definition: TrackingPrimitives.h:276
xAOD::numberOfSCTDeadSensors
@ numberOfSCTDeadSensors
number of dead SCT sensors crossed [unit8_t].
Definition: TrackingPrimitives.h:273
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
InDetGlobalLRTMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: InDetGlobalLRTMonAlg.cxx:52
xAOD::numberOfSCTHits
@ numberOfSCTHits
number of hits in SCT [unit8_t].
Definition: TrackingPrimitives.h:268
xAOD::numberOfPixelDeadSensors
@ numberOfPixelDeadSensors
number of dead pixel sensors crossed [unit8_t].
Definition: TrackingPrimitives.h:266
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
InDetGlobalLRTMonAlg::m_trackSelTool
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelTool
Definition: InDetGlobalLRTMonAlg.h:58
xAOD::numberOfTRTDeadStraws
@ numberOfTRTDeadStraws
number of dead TRT straws crossed [unit8_t].
Definition: TrackingPrimitives.h:282
Trk::phi0
@ phi0
Definition: ParamDefs.h:65
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237