ATLAS Offline Software
DQTLumiMonAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 DQTLumiMonAlg::DQTLumiMonAlg(const std::string& name, ISvcLocator* pSvcLocator)
8 : AthMonitorAlgorithm(name,pSvcLocator)
9 {}
10 
12 
14  // need to do this first, else we don't get environment() set up properly!
16  ATH_CHECK( m_VertexContainerKey.initialize() );
18  ATH_CHECK( m_PixelIDKey.initialize() );
19  return StatusCode::SUCCESS;
20 }
21 
22 StatusCode DQTLumiMonAlg::fillHistograms(const EventContext& ctx) const {
23  using namespace Monitored;
24  auto group = getGroup("default");
25 
26  RH<xAOD::EventInfo> eventInfo{GetEventInfo(ctx)};
27  if ( !eventInfo.isValid() ) {
28  ATH_MSG_WARNING("Could not retrieve EventInfo.");
29  return StatusCode::FAILURE;
30  }
31 
32  auto lumiBlock = Scalar<int>("LB", eventInfo->lumiBlock());
33 
34  auto avgLumi = Scalar("avgLumi", lbAverageLuminosity(ctx));
35  auto avgIntPerXing = Scalar("avgIntPerXing", lbAverageInteractionsPerCrossing(ctx));
36  float avgMuInverse = avgIntPerXing>0 ? 1./avgIntPerXing : 0.;
37  auto lumiPerBCID = Scalar("lumiPerBCID", lbLuminosityPerBCID(ctx));
38  auto intPerXing = Scalar("intPerXing", lbInteractionsPerCrossing(ctx));
39  auto duration = Scalar("duration", lbDuration(ctx));
40  auto avgLiveFrac = Scalar("avgLiveFrac", lbAverageLivefraction(ctx));
41  auto liveFracPerBCID = Scalar("liveFracPerBCID", livefractionPerBCID(ctx));
42  auto lumiWeight = Scalar("lumiWeight", lbLumiWeight(ctx));
43 
45  auto nLooseVtx = Scalar<int>("nLooseVtx",0);
46  auto nTightVtx = Scalar<int>("nTightVtx",0);
47  if ( vertices.isValid() ) {
48  for ( const auto vertex : *vertices ) {
49  if (!vertex || !vertex->nTrackParticles()) continue;
50  nLooseVtx++;
51 
52  int nGoodTracks = 0;
53  for (size_t i = 0; i < vertex->nTrackParticles(); ++i) {
54  if (vertex->trackWeight(i) >= m_tightTrackWeight) { ++nGoodTracks; }
55  }
56  if ( nGoodTracks>=m_tightNTracks ) {
57  nTightVtx++;
58  }
59  }
60  } else {
61  ATH_MSG_WARNING("Could not retrieve Vertex Container.");
62  }
63  auto nLooseVtxPerAvgMu = Scalar<float>("nLooseVtxPerAvgMu",nLooseVtx*avgMuInverse);
64  auto nTightVtxPerAvgMu = Scalar<float>("nTightVtxPerAvgMu",nTightVtx*avgMuInverse);
65 
66  fill(group,lumiBlock,avgLumi,avgIntPerXing,lumiPerBCID,intPerXing,duration,
67  avgLiveFrac,liveFracPerBCID,lumiWeight,nLooseVtx,nTightVtx,nLooseVtxPerAvgMu,
68  nTightVtxPerAvgMu);
69 
72  RH<PixelID> pixelID(m_PixelIDKey,ctx);
73  if ( !pixelClusters.isValid() ) {
74  ATH_MSG_WARNING("Could not retrieve Pixel Clusters.");
75  } else if ( !pixelID.isValid() ) {
76  ATH_MSG_WARNING("Could not retrieve Pixel ID.");
77  } else {
78  auto nClustersAll = Scalar<int>("nClustersAll",0);
79  auto nClustersECA = Scalar<int>("nClustersECA",0);
80  auto nClustersECC = Scalar<int>("nClustersECC",0);
81  auto nClustersB0 = Scalar<int>("nClustersB0",0);
82  auto nClustersB1 = Scalar<int>("nClustersB1",0);
83  auto nClustersB2 = Scalar<int>("nClustersB2",0);
84  for ( auto cluster : *pixelClusters ) {
85  if (!cluster)
86  continue;
87  for ( auto pixel : *cluster ) {
88  Identifier clusterID = pixel->identify();
89  nClustersAll++;
90  int ec = pixelID->barrel_ec(clusterID);
91  if (ec==2) nClustersECA++;
92  else if (ec==-2) nClustersECC++;
93  else if (ec==0) {
94  int ld = pixelID->layer_disk(clusterID);
95  if (ld==0) nClustersB0++;
96  else if(ld==1) nClustersB1++;
97  else if(ld==2) nClustersB2++;
98  }
99  }
100  ATH_MSG_DEBUG("nClustersAll is " << nClustersAll);
101  }
102  auto nClustersAllPerAvgMu = Scalar<int>("nClustersAllPerAvgMu",nClustersAll*avgMuInverse);
103  auto nClustersECAPerAvgMu = Scalar<int>("nClustersECAPerAvgMu",nClustersECA*avgMuInverse);
104  auto nClustersECCPerAvgMu = Scalar<int>("nClustersECCPerAvgMu",nClustersECC*avgMuInverse);
105  auto nClustersB0PerAvgMu = Scalar<int>("nClustersB0PerAvgMu",nClustersB0*avgMuInverse);
106  auto nClustersB1PerAvgMu = Scalar<int>("nClustersB1PerAvgMu",nClustersB1*avgMuInverse);
107  auto nClustersB2PerAvgMu = Scalar<int>("nClustersB2PerAvgMu",nClustersB2*avgMuInverse);
108 
109  fill("pixel",lumiBlock,avgIntPerXing,
110  nClustersAll,nClustersECA,nClustersECC,
111  nClustersB0,nClustersB1,nClustersB2,
112  nClustersAllPerAvgMu,nClustersECAPerAvgMu,nClustersECCPerAvgMu,
113  nClustersB0PerAvgMu,nClustersB1PerAvgMu,nClustersB2PerAvgMu);
114  }
115  }
116 
117  return StatusCode::SUCCESS;
118 }
AthMonitorAlgorithm::environment
Environment_t environment() const
Accessor functions for the environment.
Definition: AthMonitorAlgorithm.h:205
AthMonitorAlgorithm::livefractionPerBCID
virtual float livefractionPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the live fraction per bunch crossing ID.
Definition: AthMonitorAlgorithm.cxx:291
AthMonitorAlgorithm::lbInteractionsPerCrossing
virtual float lbInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate instantaneous number of interactions, i.e.
Definition: AthMonitorAlgorithm.cxx:234
AthMonitorAlgorithm::lbLumiWeight
virtual double lbLumiWeight(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average integrated luminosity multiplied by the live fraction.
Definition: AthMonitorAlgorithm.cxx:308
AthMonitorAlgorithm::lbAverageLuminosity
virtual float lbAverageLuminosity(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1).
Definition: AthMonitorAlgorithm.cxx:250
AthMonitorAlgorithm::Environment_t::AOD
@ AOD
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DQTLumiMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: DQTLumiMonAlg.cxx:22
AthMonitorAlgorithm::m_environment
AthMonitorAlgorithm::Environment_t m_environment
Instance of the Environment_t enum.
Definition: AthMonitorAlgorithm.h:350
DQTLumiMonAlg::initialize
virtual StatusCode initialize() override
initialize
Definition: DQTLumiMonAlg.cxx:13
DQTLumiMonAlg::m_VertexContainerKey
RHK< xAOD::VertexContainer > m_VertexContainerKey
Definition: DQTLumiMonAlg.h:31
DQTLumiMonAlg::~DQTLumiMonAlg
virtual ~DQTLumiMonAlg()
Definition: DQTLumiMonAlg.cxx:11
AthMonitorAlgorithm::lbLuminosityPerBCID
virtual float lbLuminosityPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the instantaneous luminosity per bunch crossing.
Definition: AthMonitorAlgorithm.cxx:262
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
DQTLumiMonAlg::m_tightNTracks
GP< int > m_tightNTracks
Definition: DQTLumiMonAlg.h:36
DQTLumiMonAlg::m_PixelIDKey
RHK< PixelID > m_PixelIDKey
Definition: DQTLumiMonAlg.h:33
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
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.
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
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
PixelAthHitMonAlgCfg.duration
duration
Definition: PixelAthHitMonAlgCfg.py:152
DQTLumiMonAlg::m_PixelClustersKey
RHK< InDet::PixelClusterContainer > m_PixelClustersKey
Definition: DQTLumiMonAlg.h:32
DQTLumiMonAlg.h
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AthMonitorAlgorithm::lbAverageLivefraction
virtual float lbAverageLivefraction(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the average luminosity livefraction.
Definition: AthMonitorAlgorithm.cxx:274
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
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
CaloLCW_tf.group
group
Definition: CaloLCW_tf.py:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
DQTLumiMonAlg::DQTLumiMonAlg
DQTLumiMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: DQTLumiMonAlg.cxx:7
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
AthMonitorAlgorithm::lbDuration
virtual double lbDuration(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Calculate the duration of the luminosity block (in seconds)
Definition: AthMonitorAlgorithm.cxx:319
xAOD::lumiBlock
setTeId lumiBlock
Definition: L2StandAloneMuon_v1.cxx:327
DQTLumiMonAlg::m_tightTrackWeight
GP< float > m_tightTrackWeight
Definition: DQTLumiMonAlg.h:35
geometry_dat_to_json.ld
ld
Definition: geometry_dat_to_json.py:32
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
SiliconTech::pixel
@ pixel
Identifier
Definition: IdentifierFieldParser.cxx:14