ATLAS Offline Software
MonitorFwdElectronAlgorithm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 
4  Author : B. Laforge (laforge@lpnhe.in2p3.fr)
5  4 May 2020
6 */
7 
9 
10 MonitorFwdElectronAlgorithm::MonitorFwdElectronAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
11 :AthMonitorAlgorithm(name,pSvcLocator)
12 {
13 }
14 
16  using namespace Monitored;
19  return StatusCode::SUCCESS;
20 }
21 
22 StatusCode MonitorFwdElectronAlgorithm::fillHistograms( const EventContext& ctx ) const {
23  using namespace Monitored;
24 
25  // Only monitor good LAr Events :
26 
28  if (error_state==xAOD::EventInfo::Error) {
29  ATH_MSG_DEBUG("LAr event data integrity error");
30  return StatusCode::SUCCESS;
31  }
32 
33  //
34  // now, fill the specific Electron information
35  //
36  // get the Electron container
37 
39  ATH_CHECK(electrons.isValid());
40 
41  // Event variables to be monitored
42  auto lbNCandidates = Monitored::Scalar<u_int16_t>("LBEvoN",0);
43 
44  // Particle variables to be monitored
45  auto np = Monitored::Scalar<int>("N",0.0);
46  auto np_endcap = Monitored::Scalar<int>("NinENDCAP",0.0);
47  auto np_forward = Monitored::Scalar<int>("NinFORWARD",0.0);
48  auto et = Monitored::Scalar<Float_t>("Et",0.0);
49  auto eta = Monitored::Scalar<Float_t>("Eta",0.0);
50  auto phi = Monitored::Scalar<Float_t>("Phi",0.0);
51  auto is_pt_gt_2_5gev = Monitored::Scalar<bool>("is_pt_gt_2_5gev",false);
52  auto is_pt_gt_10gev = Monitored::Scalar<bool>("is_pt_gt_10gev",false);
53 
54  auto time = Monitored::Scalar<Float_t>("Time",0.0);
55 
56  auto firstENGdens = Monitored::Scalar<Float_t>("EnergyDensity",0.0);
57  auto fracMax = Monitored::Scalar<Float_t>("FracMax",0.0);
58  auto lateral = Monitored::Scalar<Float_t>("Lateral",0.0);
59  auto longitudinal = Monitored::Scalar<Float_t>("Longitudinal",0.0);
60  auto secondLambda = Monitored::Scalar<Float_t>("SecondLambda",0.0);
61  auto secondR = Monitored::Scalar<Float_t>("SecondR",0.0);
62  auto centerLambda = Monitored::Scalar<Float_t>("CenterLambda",0.0);
63 
64 
65  // Particle variables per Region
66 
67  // variables per Region
68 
69  // ENDCAP
70  auto et_endcap = Monitored::Scalar<Float_t>("EtinENDCAP",0.0);
71  auto eta_endcap = Monitored::Scalar<Float_t>("EtainENDCAP",0.0);
72  auto phi_endcap = Monitored::Scalar<Float_t>("PhiinENDCAP",0.0);
73  auto time_endcap = Monitored::Scalar<Float_t>("TimeinENDCAP",0.0);
74  auto is_pt_gt_2_5gev_endcap = Monitored::Scalar<bool>("is_pt_gt_2_5gevENDCAP",false);
75  auto is_pt_gt_10gev_endcap = Monitored::Scalar<bool>("is_pt_gt_10gevENDCAP",false);
76 
77  // FORWARD
78  auto et_forward = Monitored::Scalar<Float_t>("EtinFORWARD",0.0);
79  auto eta_forward = Monitored::Scalar<Float_t>("EtainFORWARD",0.0);
80  auto phi_forward = Monitored::Scalar<Float_t>("PhiinFORWARD",0.0);
81  auto time_forward = Monitored::Scalar<Float_t>("TimeinFORWARD",0.0);
82  auto is_pt_gt_2_5gev_forward = Monitored::Scalar<bool>("is_pt_gt_2_5gevFORWARD",false);
83  auto is_pt_gt_10gev_forward = Monitored::Scalar<bool>("is_pt_gt_10gevFORWARD",false);
84 
85  // Set the values of the monitored variables for the event
86 
87  u_int16_t mylb = GetEventInfo(ctx)->lumiBlock();
88  lbNCandidates = mylb;
89 
90  u_int16_t mynp = 0;
91  u_int16_t mynp_endcap = 0;
92  u_int16_t mynp_forward = 0;
93 
94 
95  for (const auto *const e_iter : *electrons) {
96  // Check that the electron meets our requirements
97  bool isGood;
98  if (! e_iter->passSelection(isGood,m_RecoName)) {
99  ATH_MSG_WARNING("Misconfiguration: " << m_RecoName << " is not a valid working point for electrons");
100  break; // no point in continuing
101  }
102  if(isGood) {mynp++;}
103  else continue;
104 
105  // do specific stuff with electrons
106 
107  Float_t myet = e_iter->pt(); // in MeV (/Gaudi::Units::GeV; // in GeV)
108  Float_t myeta = e_iter->eta();
109  Float_t myphi = e_iter->phi();
110 
111  bool myis_pt_gt_2_5gev = myet > 2500. ;
112  bool myis_pt_gt_10gev = myet > 10000. ;
113 
114  is_pt_gt_2_5gev = myis_pt_gt_2_5gev ;
115  is_pt_gt_10gev = myis_pt_gt_10gev ;
116 
117 
118  // Associated cluster details
119  // Shower shape variable details
120 
121  double myfirstENGdens=-999.;
122  double myfracMax=-999.;
123  double mylateral=-999.;
124  double mylongitudinal=-999.;
125  double mysecondLambda=-999.;
126  double mysecondR=-999.;
127  double mycenterLambda=-999.;
128  double mytime= -999.;
129 
130  const xAOD::CaloCluster *aCluster = e_iter->caloCluster();
131  if (aCluster) {
132  aCluster->retrieveMoment(xAOD::CaloCluster::FIRST_ENG_DENS,myfirstENGdens);
133  aCluster->retrieveMoment(xAOD::CaloCluster::ENG_FRAC_MAX, myfracMax);
134  aCluster->retrieveMoment(xAOD::CaloCluster::LONGITUDINAL, mylongitudinal);
135  aCluster->retrieveMoment(xAOD::CaloCluster::SECOND_LAMBDA,mysecondLambda);
136  aCluster->retrieveMoment(xAOD::CaloCluster::LATERAL, mylateral);
137  aCluster->retrieveMoment(xAOD::CaloCluster::SECOND_R, mysecondR);
138  aCluster->retrieveMoment(xAOD::CaloCluster::CENTER_LAMBDA, mycenterLambda);
139  mytime = aCluster->time();
140  }
141 
142  firstENGdens = (Float_t) myfirstENGdens;
143  fracMax = (Float_t) myfracMax;
144  lateral = (Float_t) mylateral;
145  longitudinal = (Float_t) mylongitudinal;
146  secondLambda = (Float_t) mysecondLambda;
147  secondR = (Float_t) mysecondR;
148  centerLambda = (Float_t) mycenterLambda;
149  time = mytime;
150 
151  // Fill per region histograms
152 
153  auto region = GetRegion(myeta);
154  switch(region){
155  case ENDCAP :
156  mynp_endcap++;
157  et_endcap = myet ; eta_endcap = myeta ;
158  phi_endcap = myphi ; time_endcap = mytime;
159  fill("MonitorFwdElectron",et_endcap,eta_endcap,phi_endcap,time_endcap,is_pt_gt_2_5gev_endcap,is_pt_gt_10gev_endcap);
160  break;
161  case FORWARD :
162  mynp_forward++;
163  et_forward = myet ; eta_forward = myeta ;
164  phi_forward = myphi ; time_forward = mytime;
165  fill("MonitorFwdElectron",et_forward,eta_forward,phi_forward,time_forward,is_pt_gt_2_5gev_forward,is_pt_gt_10gev_forward);
166  break;
167  default :
168  //ATH_MSG_WARNING("found an electron outside the |eta| > 2.47 acceptance");
169  break;
170  }
171 
172  // Fill global histograms
173 
174  et = myet ; eta = myeta ; phi = myphi ;
175  fill("MonitorFwdElectron",et,eta,phi,time,lbNCandidates,
176  firstENGdens, fracMax, lateral, longitudinal, secondLambda,
177  secondR, centerLambda, time,
178  is_pt_gt_2_5gev, is_pt_gt_10gev);
179 
180  // Fill. First argument is the tool name, all others are the variables to be histogramed
181  }
182 
183  np = mynp; np_endcap = mynp_endcap ; np_forward = mynp_forward ;
184  fill("MonitorFwdElectron",np,np_endcap);
185 
186  return StatusCode::SUCCESS;
187 }
xAOD::CaloCluster_v1::SECOND_R
@ SECOND_R
Second Moment in .
Definition: CaloCluster_v1.h:123
xAOD::CaloCluster_v1::time
flt_t time() const
Access cluster time.
et
Extra patterns decribing particle interation process.
MonitorFwdElectronAlgorithm::GetRegion
Regions GetRegion(Float_t eta) const
Definition: MonitorFwdElectronAlgorithm.h:37
MonitorFwdElectronAlgorithm::FORWARD
@ FORWARD
Definition: MonitorFwdElectronAlgorithm.h:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MonitorFwdElectronAlgorithm::m_RecoName
Gaudi::Property< std::string > m_RecoName
Definition: MonitorFwdElectronAlgorithm.h:34
xAOD::CaloCluster_v1::CENTER_LAMBDA
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
Definition: CaloCluster_v1.h:136
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
xAOD::CaloCluster_v1::ENG_FRAC_MAX
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
Definition: CaloCluster_v1.h:140
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
MonitorFwdElectronAlgorithm::m_ParticleContainerKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_ParticleContainerKey
Definition: MonitorFwdElectronAlgorithm.h:32
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
xAOD::CaloCluster_v1::SECOND_LAMBDA
@ SECOND_LAMBDA
Second Moment in .
Definition: CaloCluster_v1.h:124
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
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
xAOD::CaloCluster_v1::retrieveMoment
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
Definition: CaloCluster_v1.cxx:738
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::CaloCluster_v1::FIRST_ENG_DENS
@ FIRST_ENG_DENS
First Moment in E/V.
Definition: CaloCluster_v1.h:143
MonitorFwdElectronAlgorithm::MonitorFwdElectronAlgorithm
MonitorFwdElectronAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MonitorFwdElectronAlgorithm.cxx:10
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::EventInfo_v1::EventFlagErrorState
EventFlagErrorState
States that a given sub-detector could be in.
Definition: EventInfo_v1.h:346
MonitorFwdElectronAlgorithm.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
MonitorFwdElectronAlgorithm::ENDCAP
@ ENDCAP
Definition: MonitorFwdElectronAlgorithm.h:28
MonitorFwdElectronAlgorithm::fillHistograms
StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: MonitorFwdElectronAlgorithm.cxx:22
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAOD::CaloCluster_v1::LATERAL
@ LATERAL
Normalized lateral moment.
Definition: CaloCluster_v1.h:137
python.CaloScaleNoiseConfig.default
default
Definition: CaloScaleNoiseConfig.py:79
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
xAOD::CaloCluster_v1::LONGITUDINAL
@ LONGITUDINAL
Normalized longitudinal moment.
Definition: CaloCluster_v1.h:138
MonitorFwdElectronAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: MonitorFwdElectronAlgorithm.cxx:15
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17