ATLAS Offline Software
Loading...
Searching...
No Matches
forwardElectronMonTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6//
7// 2014-10-22 Author: Remi Lafaye (Annecy)
8// 2015-03-24 Author: Bertrand LAFORGE (LPNHE Paris)
9//
10// NAME: forwardElectronMonTool.cxx
11// PACKAGE: offline/Reconstruction/egamma/egammaPerformance
12// PURPOSE: Shifter should look for the following defects:
13// taken from https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/EgammaShifts
14//
15// in energies (Et plots for electrons and photons)
16// ===========
17// LOWSTAT : For short runs and not enough statistics when not being able
18// to judge the result using the egamma stream. Needs to be commented.
19//
20// ENERGY_(BARREL,ENDCAP,CRACK,FORWARD) : This defect is a significant energy
21// mis-calibration is observed for a certain part of the detector. This flag
22// is then intolerable for that detector region.
23//
24// LARNOISE_(BARREL,ENDCAP,FORWARD) : If some part of the detector is miscalibrated
25// causing an energy shift of at least 5% this intolerable defect should be set.
26//
27// in eta,phi (eta,phi 2D plots for electrons and photons)
28// ==========
29// ETAPHI_SPIKES/LOWOCCUPANCY : Non standard distribution (eta phi plane) of egamma
30// objects. Region with unusual density of electrons / photons. This could be produced
31// by a problem in the LAR calorimeter. If there is a spike in the distribution set
32// EGAMMA_ETAPHI_SPIKES as defect. Examples of runs with this problem can be found in
33// Click for image. (hot spot) and Click for image. (FEB with 100% rejection during part
34// of the run). If a HV trip could not be recovered during the run, there will be a region
35// in the eta phi plane with low occupancy. Then set the defect EGAMMA_LOWOCCUPANCY.
36//
37// in eta and phi (eta,phi 1D plots for electrons)
38// ==============
39// BEAMSPOT : When the beamspot is shifted with respect to the nominal position the
40// azimuthal distribution (phi) of tracks is different than normal. When the new
41// constants for the beam spot get uploaded and reprocessed this defect vanishes.
42// This is an intolerable defect so only use it after checking the bulk reconstruction,
43// in some cases express reconstruction can have this problem but usually is solved at
44// the bulk. Example of the run with a failure in the determination of the beam spot can
45// be found in Click for image..
46//
47// BAD_BLAYER : To be used when the distributions (eta, phi) for medium and tight electrons
48// have marked excess or defect of entries due to a problem with the b-layer. If this happens
49// the loose distributions will look fine. To distinguish between this and TRT problem more
50// details on the run and investigation will be needed. If you have to use this defect you
51// should document it in the EgammaShiftsBadRuns page. Example of the result of a b-layer
52// module with low efficiency can be found in Click for image..
53//
54// BAD_TRT : To be used when the distributions (eta, phi) for tight electrons / photons have
55// marked excess or defect of entries due to a problem with the TRT (due to the high threshold
56// requirement). If this happens the loose and medium distributions will look fine. To distinguish
57// between this and pixel (b-layer) problem more details on the run and investigation will be needed.
58// If you have to use this defect you should document it in the Runs List page. Example of the result
59// of a few RODs disabled in TRT can be found in Click for image..
60//
61// in electron ID
62// ==============
63// SHAPES : Bad shape for defining variables of electrons or photons. Distributions do not match
64// the references. As the other defects they can be recoverable or not recoverable. In case, of
65// a hardware related issue, it will be likely not recoverable, problems related with alignment
66// or calibration will be likely recoverable. Example of this defect can be found in Click for image.
67// (decrease in the number of Si Hits due to BCID problem in SCT).
68//
70
71
73#include "GaudiKernel/MsgStream.h"
74#include "GaudiKernel/StatusCode.h"
78#include "xAODEgamma/Electron.h"
80#include "TH1F.h"
81#include "TH2F.h"
82
83forwardElectronMonTool::forwardElectronMonTool(const std::string & type, const std::string & name, const IInterface* parent)
84 : egammaMonToolBase(type,name,parent),
85 m_hN(nullptr),
86 m_hEt(nullptr),
87 m_hEta(nullptr),
88 m_hPhi(nullptr),
89 m_hEtaPhi(nullptr),
90 m_hTime(nullptr),
91 m_hTightN(nullptr),
92 m_hTightEt(nullptr),
93 m_hTightEta(nullptr),
94 m_hTightPhi(nullptr),
95 m_hTightEtaPhi(nullptr),
96 m_hTightTime(nullptr),
97 m_hLB_N(nullptr),
99{
103
104}
105
107{
110 return StatusCode::SUCCESS;
111}
112
114{
115 ATH_MSG_DEBUG("forwardElectronMonTool::bookHistograms()");
116 int start;
117 int end;
118 start = ENDCAP;
119 end = FORWARD;
120
121 // Create groups
122 MonGroup electronGroup(this,"egamma/forwardElectrons",run); // to be re-booked every new run
123
124 // Create sub groups
125 MonGroup electronIdGroup (this,"egamma/forwardElectrons/ID", run); // to be re-booked every new run
126 MonGroup electronLBGroup (this,"egamma/forwardElectrons/LBMON",run, ATTRIB_X_VS_LB, "", "merge"); // to be re-booked every new run
127
128 // MAIN PANEL
129 bookTH1F(m_hN, electronGroup, "forwardElectronN", "Number of LOOSE electrons",40, 0.0, 40.0);
130 bookTH1F(m_hEt, electronGroup, "forwardElectronEt", "LOOSE electron transverse energy [MeV]",100, -1000.0, 250000.0);
131 bookTH2F(m_hEtaPhi, electronGroup, "forwardElectronEtaPhi", "LOOSE electron #eta,#phi map (candidates with E>10GeV)", 64, -3.2, 3.2, 64, -3.2, 3.2);
132 bookTH1F(m_hEta, electronGroup, "forwardElectronEta", "LOOSE electron #eta", 64, -5., 5.);
133 bookTH1F(m_hPhi, electronGroup, "forwardElectronPhi", "LOOSE electron #phi", 64, -3.2, 3.2);
134 //bookTH1F(m_hTopoEtCone40, electronGroup, "forwardElectronTopoEtCone40","LOOSE forward electron Isolation Energy TopoEtCone40", 64, -10000., 40000.);
135 bookTH1F(m_hTime, electronGroup, "forwardElectronTime", "Time associated with the LOOSE electron cluster [ns]", 90, -30., 60.);
136
137 bookTH1F(m_hTightN, electronGroup, "forwardElectronTightN", "Number of TIGHT electrons",40, 0.0, 40.0);
138 bookTH1F(m_hTightEt, electronGroup, "forwardElectronTightEt", "TIGHT electron transverse energy [MeV]",100, -1000.0, 250000.0);
139 bookTH2F(m_hTightEtaPhi, electronGroup, "forwardElectronTightEtaPhi", "TIGHT electron #eta,#phi map (candidates with E>10GeV)", 64, -5., 5., 64, -3.2, 3.2);
140 bookTH1F(m_hTightEta, electronGroup, "forwardElectronTightEta", "TIGHT electron #eta", 100, -5., 5.);
141 bookTH1F(m_hTightPhi, electronGroup, "forwardElectronTightPhi", "TIGHT electron #phi", 64, -3.2, 3.2);
142 //bookTH1F(m_hTightTopoEtCone40, electronGroup, "forwardElectronTightTopoEtCone40","TIGHT forward electron Isolation Energy TopoEtCone40", 64, -10000., 40000.);
143 bookTH1F(m_hTightTime, electronGroup, "forwardElectronTightTime", "Time associated with the TIGHT electron cluster [ns]", 90, -30., 60.);
144
145 // ID PANEL
146 bookTH1FperRegion(m_hvDensity, electronIdGroup, "forwardElectronENG_DENS", "First Moment of Energy Density ;FistEngDens; Nevents", 200,0.,2., start,end);
147 bookTH1FperRegion(m_hvFrac, electronIdGroup, "forwardElectronFRAC_MAX", "Fraction of most energetic cell ;FacMax;Nevents", 50,0.,1., start,end);
148 bookTH1FperRegion(m_hvLongitu, electronIdGroup, "forwardElectronLONGITUDINAL", "Normalized Longitudinal Moment ;Longitudinal;Nevents", 100,0.,1., start,end);
149 bookTH1FperRegion(m_hvLambda, electronIdGroup, "forwardElectron2ND_LAMBDA", "Second Moment of Lambda ;SecondLambda;Nevents", 500,0.,10000.,start,end);
150 bookTH1FperRegion(m_hvLateral, electronIdGroup, "forwardElectronLATERAL", "Normalized Lateral Moment ;Lateral;Nevents", 100,0.,1., start,end);
151 bookTH1FperRegion(m_hvSecondR, electronIdGroup, "forwardElectron2ND_R", "Second Moment of R ;SecondR;Nevents", 500,0.,20000.,start,end);
152 bookTH1FperRegion(m_hvCenterL, electronIdGroup, "forwardElectronCENTER_LAMBDA", "distance of shower center from calo front face;CenterLambda;Nevents",500,0,2000,start,end);
153
154 bookTH1FperRegion(m_hvTightDensity, electronIdGroup, "forwardElectronTightENG_DENS", "First Moment of Energy Density ;FistEngDens; Nevents", 200,0.,2., start,end);
155 bookTH1FperRegion(m_hvTightFrac, electronIdGroup, "forwardElectronTightFRAC_MAX", "Fraction of most energetic cell ;FacMax;Nevents", 50,0.,1., start,end);
156 bookTH1FperRegion(m_hvTightLongitu, electronIdGroup, "forwardElectronTightLONGITUDINAL", "Normalized Longitudinal Moment ;Longitudinal;Nevents", 100,0.,1., start,end);
157 bookTH1FperRegion(m_hvTightLambda, electronIdGroup, "forwardElectronTight2ND_LAMBDA", "Second Moment of Lambda ;SecondLambda;Nevents", 500,0.,10000.,start,end);
158 bookTH1FperRegion(m_hvTightLateral, electronIdGroup, "forwardElectronTightLATERAL", "Normalized Lateral Moment ;Lateral;Nevents", 100,0.,1., start,end);
159 bookTH1FperRegion(m_hvTightSecondR, electronIdGroup, "forwardElectronTight2ND_R", "Second Moment of R ;SecondR;Nevents", 500,0.,20000.,start,end);
160 bookTH1FperRegion(m_hvTightCenterL, electronIdGroup, "forwardElectronTightCENTER_LAMBDA", "distance of shower center from calo front face;CenterLambda;Nevents",500,0,2000,start,end);
161
162
163 // EXPERT PER REGION PANEL
164 bookTH1FperRegion(m_hvN, electronGroup, "forwardElectronN", "Number of LOOSE electrons",40, 0.0, 40.0,start,end);
165 bookTH1FperRegion(m_hvEt, electronGroup, "forwardElectronEt", "LOOSE electron transverse energy [MeV]",100, -1000.0, 250000.0,start,end);
166 bookTH1FperRegion(m_hvEta, electronGroup, "forwardElectronEta","LOOSE electron #eta",64, -5., 5.,start,end);
167 bookTH1FperRegion(m_hvPhi, electronGroup, "forwardElectronPhi","LOOSE electron #phi",64, -3.2, 3.2,start,end);
168 //bookTH1FperRegion(m_hvTopoEtCone40, electronGroup,"forwardElectronTopoEtCone40", "LOOSE Forward electron Isolation Energy TopoEtCone40 [MeV]", 64, -10000., 40000.,start,end);
169 bookTH1FperRegion(m_hvTime,electronGroup,"forwardElectronTime", "LOOSE electron time [ns]",90, -30.0, 60.0,start,end);
170
171 bookTH1FperRegion(m_hvTightN, electronGroup,"forwardElectronTightN", "Number of TIGHT electrons",40, 0.0, 40.0,start,end);
172 bookTH1FperRegion(m_hvTightEt, electronGroup,"forwardElectronTightEt", "TIGHT electron transverse energy [MeV]",100, -1000.0, 250000.0,start,end);
173 bookTH1FperRegion(m_hvTightEta, electronGroup,"forwardElectronTightEta","TIGHT electron #eta",100, -5., 5.,start,end);
174 bookTH1FperRegion(m_hvTightPhi, electronGroup,"forwardElectronTightPhi","TIGHT electron #phi",64, -3.2, 3.2,start,end);
175 //bookTH1FperRegion(m_hvTightTopoEtCone40, electronGroup,"forwardElectronTightTopoEtCone40", "TIGHT Forward electron Isolation Energy TopoEtCone40 [MeV]", 64, -10000., 40000.,start,end);
176 bookTH1FperRegion(m_hvTightTime, electronGroup,"forwardElectronTightTime", "TIGHT electron time [ns]",90, -30.0, 60.0,start,end);
177
178 // LB MONITORING PANEL
179 bookTH1F(m_hLB_N, electronLBGroup, "forwardElectronNumbervsLB", "Number of Forward Electrons vs LB", 2000, -0.5, 1999.5);
180
181 return StatusCode::SUCCESS;
182}
183
185{
186 ATH_MSG_DEBUG("forwardElectronMonTool::fillHistograms()");
187
188 if (!hasGoodTrigger("forward electron")) return StatusCode::SUCCESS;
189
190 const EventContext& ctx = Gaudi::Hive::currentContext();
191
192 //check whether Lar signalled event bad
193 if(hasBadLar(ctx)) {
194 ATH_MSG_DEBUG("forwardElectronMonTool::hasBadLar()");
195 return StatusCode::RECOVERABLE;
196 }
197
198 //--------------------
199 //figure out current LB
200 //--------------------
201 unsigned int previousLB = m_currentLB;
203
204 //deal with the change of LB
205 if (m_currentLB>previousLB) {
206 // update the by LB variables
208 // Reset counters
210 }
211
212 // Get electron container
214 ATH_CHECK(electron_container.isValid());
215
216 xAOD::ElectronContainer::const_iterator e_iter = electron_container->begin();
217 xAOD::ElectronContainer::const_iterator e_end = electron_container->end();
218
219 ATH_MSG_DEBUG("Number of electrons: " << electron_container->size());
220
221 // Check that the auxiliary store association was made successfully:
222 if( ! electron_container->hasStore() ) {
223 ATH_MSG_DEBUG("No auxiliary store got associated to the electron container with key: " << m_ForwardElectronContainer);
224 return StatusCode::FAILURE;
225 }
226
227 //
228
229 int n_tot = 0;
230 int n_tot_tight = 0;
231 std::vector<int> n_el;
232 std::vector<int> n_el_tight;
233 n_el.resize(NREGION,0);
234 n_el_tight.resize(NREGION,0);
235
236 for (; e_iter!=e_end; ++e_iter) {
237 if(!(*e_iter)) continue;
238 if((*e_iter)->author(xAOD::EgammaParameters::AuthorFwdElectron)==0) continue;
239
240 // Basic kinematics
241 float et = (*e_iter)->pt();
242 float eta = (*e_iter)->eta();
243 float phi = (*e_iter)->phi();
244 int ir = GetForwardRegion(eta);
245 //ATH_MSG_DEBUG("electrons et, eta and phi" << et << " " << eta << " " << phi);
246
247 if (et<5000) return StatusCode::SUCCESS;
248
249 // Isolation Energy
250 //float topoetcone40 = -999.;
251 // Shower shape variable details
252 double firstENGdens=-999.;
253 double lateral=-999.;
254 double secondR=-999.;
255 double centerLambda=-999.;
256 double fracMax=-999.;
257 double longitudinal=-999.;
258 double secondLambda=-999.;
259 double time= -999.;
260
261 ATH_MSG_DEBUG( "Found one Forward Electron..." );
262
263 // bool isLoose;
264 // if ((*e_iter)->passSelection(isLoose,"FWDLoose")) { // cut based Loose Forward electrons
265 // if (isLoose) {
266
267 ATH_MSG_DEBUG( "this electron is also a Loose Forward Electron..." );
268
269 ++n_tot;
270 ++(n_el[ir]);
271 if(m_hEt) m_hEt->Fill(et);
272 if(m_hEtaPhi&&et>10000.) m_hEtaPhi->Fill(eta,phi);
273 if(m_hEta) m_hEta->Fill(eta);
274 if(m_hPhi) m_hPhi->Fill(phi);
275
276 m_hLB_N->Fill(m_currentLB);
277
281
282 // Isolation Energy
283 //if( (*e_iter)->isolationValue(topoetcone40,xAOD::Iso::topoetcone40)) {
284 // if (m_hTopoEtCone40) m_hTopoEtCone40->Fill(topoetcone40);
285 //}
286 //fillTH1FperRegion(m_hvTopoEtCone40,ir,topoetcone40);
287
288 // Associated cluster details
289 const xAOD::CaloCluster *aCluster = (*e_iter)->caloCluster();
290
291 if (aCluster) {
292 // loop on moments
293 if( aCluster->retrieveMoment( xAOD::CaloCluster::FIRST_ENG_DENS,firstENGdens) )
294 fillTH1FperRegion(m_hvDensity,ir,firstENGdens);
295 if( aCluster->retrieveMoment( xAOD::CaloCluster::ENG_FRAC_MAX, fracMax) )
297 if( aCluster->retrieveMoment( xAOD::CaloCluster::LONGITUDINAL, longitudinal) )
298 fillTH1FperRegion(m_hvLongitu,ir,longitudinal);
299 if( aCluster->retrieveMoment( xAOD::CaloCluster::SECOND_LAMBDA,secondLambda) )
300 fillTH1FperRegion(m_hvLambda,ir,secondLambda);
301 if( aCluster->retrieveMoment( xAOD::CaloCluster::LATERAL, lateral) )
303 if( aCluster->retrieveMoment( xAOD::CaloCluster::SECOND_R, secondR) )
305 if( aCluster->retrieveMoment( xAOD::CaloCluster::CENTER_LAMBDA, centerLambda) )
306 fillTH1FperRegion(m_hvCenterL,ir,centerLambda);
307 time = aCluster->time();
308 if (m_hTime) m_hTime->Fill(time);
310 }
311
312 // TIGHT electrons
313 bool isTight;
314 if((*e_iter)->passSelection(isTight,"Tight")) { // Tight Forward electrons
315 if(isTight) {
316 ATH_MSG_DEBUG( "this electron is also a Tight Forward Electron" );
317 n_tot_tight++;
318 ++(n_el_tight[ir]);
319 if(m_hTightEt) m_hTightEt->Fill(et);
320 if(m_hTightEtaPhi&&et>10000) m_hTightEtaPhi->Fill(eta,phi);
321 if(m_hTightEta) m_hTightEta->Fill(eta);
322 if(m_hTightPhi) m_hTightPhi->Fill(phi);
323 if (m_hTightTime) m_hTightTime->Fill(time);
324 //if (m_hTightTopoEtCone40) m_hTightTopoEtCone40->Fill(topoetcone40);
325
329
338 //fillTH1FperRegion(m_hvTightTopoEtCone40,ir,topoetcone40);
339 }
340 } else {
341 ATH_MSG_DEBUG( "Electron selection menu Tight is not defined" );
342 }
343
344 // Fill number of electrons histograms
345 if (m_hN) m_hN->Fill(n_tot);
346 if (m_hTightN) m_hTightN->Fill(n_tot_tight);
347 for(int i=0;i<NREGION;i++) {
348 fillTH1FperRegion(m_hvN,i,n_el[i]);
349 fillTH1FperRegion(m_hvTightN,i,n_el_tight[i]);
350 }
351 //} else {
352 //ATH_MSG_DEBUG( "Electron selection menu Loose is not defined" );
353 //}
354 }
355
356 return StatusCode::SUCCESS;
357}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
A container of information describing a monitoring object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual StatusCode initialize() override
void bookTH1FperRegion(std::vector< TH1 * > &vhist, MonGroup &mygroup, const std::string &hname, const std::string &htitle, int nbins, float low, float high, unsigned int min_region, unsigned int max_region)
unsigned int getCurrentLB(const EventContext &ctx)
bool hasBadLar(const EventContext &ctx)
bool hasGoodTrigger(const std::string &comment)
void bookTH2F(TH2 *&h, MonGroup &mygroup, const std::string &hname, const std::string &htitle, int nbinsx, float xlow, float xhigh, int nbinsy, float ylow, float yhigh)
egammaMonToolBase(const std::string &type, const std::string &name, const IInterface *parent)
static int GetForwardRegion(float eta)
static void fillTH1FperRegion(std::vector< TH1 * > &vhist, unsigned int ir, float x)
void bookTH1F(TH1 *&h, MonGroup &mygroup, const std::string &hname, const std::string &htitle, int nbins, float low, float high)
virtual StatusCode bookHistograms() override
An inheriting class should either override this function or bookHists().
std::vector< TH1 * > m_hvTightFrac
std::vector< TH1 * > m_hvTightTime
virtual StatusCode initialize() override
virtual StatusCode fillHistograms() override
An inheriting class should either override this function or fillHists().
unsigned int m_nForwardElectronsInCurrentLB
std::vector< TH1 * > m_hvSecondR
std::vector< int > m_nForwardElectronsPerLumiBlock
std::vector< TH1 * > m_hvFrac
std::vector< TH1 * > m_hvLambda
std::vector< TH1 * > m_hvCenterL
std::vector< TH1 * > m_hvTightEta
SG::ReadHandleKey< xAOD::ElectronContainer > m_ForwardElectronContainer
std::vector< TH1 * > m_hvTightCenterL
std::vector< TH1 * > m_hvLateral
std::vector< TH1 * > m_hvTightN
std::vector< TH1 * > m_hvTightLambda
std::vector< TH1 * > m_hvTightSecondR
std::vector< TH1 * > m_hvDensity
std::vector< TH1 * > m_hvTightLongitu
std::vector< TH1 * > m_hvTightDensity
std::vector< TH1 * > m_hvEt
std::vector< TH1 * > m_hvTightPhi
std::vector< TH1 * > m_hvTime
std::vector< TH1 * > m_hvTightEt
std::vector< TH1 * > m_hvEta
std::vector< TH1 * > m_hvLongitu
std::vector< TH1 * > m_hvPhi
forwardElectronMonTool(const std::string &type, const std::string &name, const IInterface *parent)
std::vector< TH1 * > m_hvTightLateral
bool retrieveMoment(MomentType type, double &value) const
Retrieve individual moment.
flt_t time() const
Access cluster time.
@ SECOND_LAMBDA
Second Moment in .
@ LATERAL
Normalized lateral moment.
@ LONGITUDINAL
Normalized longitudinal moment.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
@ SECOND_R
Second Moment in .
@ FIRST_ENG_DENS
First Moment in E/V.
@ CENTER_LAMBDA
Shower depth at Cluster Centroid.
int ir
counter of the current depth
Definition fastadd.cxx:49
Definition run.py:1
const uint16_t AuthorFwdElectron
Electron reconstructed by the Forward cluster-based algorithm.
Definition EgammaDefs.h:30
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Extra patterns decribing particle interation process.