ATLAS Offline Software
L1CaloPprFineTimePlotManager.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 #include "GaudiKernel/ITHistSvc.h"
9 
10 #include "GaudiKernel/StatusCode.h"
11 #include "StoreGate/StoreGateSvc.h"
12 
16 
17 
19  ToolHandle<LVL1::IL1CaloOfflineTriggerTowerTools>&offlineTT_tool,
20  const int ADC_cut,
21  const unsigned int lumimax,
22  const std::string& pathInRootFile)
23  : L1CaloPprPlotManager(histoSvc,
24  offlineTT_tool,
25  ADC_cut,
26  lumimax,
27  pathInRootFile,
28  "FineTime",
29  "fineTime",
30  "Fine Time",
31  "[ns]",
32  true),
33  m_storeGate("StoreGateSvc", histoSvc->name()),
34  m_caloTool("LVL1::L1CaloMonitoringCaloTool/L1CaloMonitoringCaloTool"),
35  m_fineTimeCut(0),
36  m_ppmAdcMaxValue(1023),
37  m_RefValue(0),
38  m_emRefValue(0.),
39  m_hadRefValue(0.),
40  m_CalFactor(0),
41  m_emCalFactor(0.),
42  m_hadCalFactor(0.),
43  m_doCaloQualCut(true)
44 {
45  this->loadTools();
46 
47 }
48 
49 // --------------------------------------------------------------------------
50 
52  ToolHandle<LVL1::IL1TriggerTowerTool>&onlineTT_tool,
53  const int ADC_cut, const unsigned int lumimax,
54  const std::string& pathInRootFile)
55  : L1CaloPprPlotManager(aMonObj,
56  onlineTT_tool,
57  ADC_cut,
58  lumimax,
59  pathInRootFile,
60  "FineTime",
61  "fineTime",
62  "Fine Time",
63  "[ns]"),
64  m_storeGate("StoreGateSvc", aMonObj->name()),
65  m_caloTool("LVL1::L1CaloMonitoringCaloTool/L1CaloMonitoringCaloTool"),
66  m_fineTimeCut(0),
67  m_ppmAdcMaxValue(1023),
68  m_RefValue(0),
69  m_emRefValue(0.),
70  m_hadRefValue(0.),
71  m_CalFactor(0),
72  m_emCalFactor(0.),
73  m_hadCalFactor(0.),
74  m_doCaloQualCut(true)
75 {
76  this->loadTools();
77 
78 }
79 
80 // --------------------------------------------------------------------------
81 
83 {
84  StatusCode sc;
85 
86  sc = m_caloTool->loadCaloCells();
87  if ( sc.isFailure() ) {
88  ATH_MSG_WARNING("Could not load CaloCells");
89  }
90 
91  return sc;
92 
93 }
94 
95 // --------------------------------------------------------------------------
96 
97 
98 float L1CaloPprFineTimePlotManager::LArQuality(const xAOD::TriggerTower* trigTower, int layer){//layer: 0 is for the EMLayer, 1 is for HAD
99 
100  Identifier id(0);
101 
102  if(m_isOnline){
103  id = m_ttToolOnline->identifier(trigTower->eta(), trigTower->phi(), layer);
104  }else{
105  if(layer == 0) id = m_ttToolOffline->emID(trigTower->eta(),trigTower->phi());
106  else if(layer == 1) id = m_ttToolOffline->hadID(trigTower->eta(),trigTower->phi());
107  }
108 
109  float quality = m_caloTool->caloQuality(id);
110 
111  return quality;
112 
113 }
114 // --------------------------------------------------------------------------
116 
117  if((qual >= 0) && (qual < 20000)){
118  return false;
119  }
120 
121  return true;
122 
123 }
124 // --------------------------------------------------------------------------
126 
127  if((qual >= 0) && (qual < 5000)){
128  return false;
129  }
130 
131  return true;
132 
133 }
134 // --------------------------------------------------------------------------
135 
137 {
138  double fineTime = -1000.; // default value not supposed to be filled in histograms
139 
140  // Use reference rather than copying ADC vector
141  const std::vector<short unsigned int>& ADCslices = trigTower->adc();
142  unsigned int ADCPeakIndex = trigTower->adcPeak();
143  if (ADCslices[ADCPeakIndex] <= m_ppmAdcMinValue) return fineTime;
144 
145  bool isSaturatedTT = true;
146  bool badCaloQuality = false;
147  double refValue = 0;
148  double calFactor = 0;
149 
150  if ( theLayer == Emlayer )
151  {
152  refValue = m_RefValue;
153  calFactor = m_CalFactor;
154  isSaturatedTT = trigTower->isCpSaturated();
155  if(m_doCaloQualCut) badCaloQuality = this->badLArQuality(this->LArQuality(trigTower,0));
156  }
157  else //had Layer
158  {
159  refValue = m_RefValue;
160  calFactor = m_CalFactor;
161  isSaturatedTT = trigTower->isCpSaturated();
162  if(m_doCaloQualCut){
163  if(fabs(trigTower->eta()) >= 3.2){
164  badCaloQuality = this->badLArQuality(this->LArQuality(trigTower,1));
165  }else if(fabs(trigTower->eta()) >= 1.5){
166  badCaloQuality = this->badHecQuality(this->LArQuality(trigTower,1));
167  }else{
168  badCaloQuality = false;
169  }
170  }
171  }
172  //Cut on saturated Towers
173  if(isSaturatedTT) return fineTime;
174 
175  //Cut on out LArg noise bursts
176  if(badCaloQuality) return fineTime;
177 
178  unsigned int size = ADCslices.size();
179 
180  // the ansatz of computing fine time only makes sense
181  // if there are enough adc slices
182  if ( size<3 ) return fineTime;
183 
184  // Find fineTime only if the peak index is not on the boundaries
185  if( ADCPeakIndex > (size - 2) || ADCPeakIndex < 1 ) return fineTime;
186 
187  int peakSlice = ADCslices[ADCPeakIndex];
188  int inferiorSlice = ADCslices[ADCPeakIndex - 1];
189  int superiorSlice = ADCslices[ADCPeakIndex + 1];
190 
191  if( peakSlice > m_ppmAdcMinValue && peakSlice < m_ppmAdcMaxValue
192  && inferiorSlice < m_ppmAdcMaxValue
193  && superiorSlice < m_ppmAdcMaxValue )
194  {
195  double denom = (2*(2*peakSlice - superiorSlice - inferiorSlice));
196  double numer = superiorSlice - inferiorSlice;
197  if(denom > 0)
198  {
199  fineTime = numer/denom;
200  // scale back to sampling interval
201  fineTime = fineTime*m_sampleInterval;
202  // subtract the reference value
203  fineTime = fineTime - refValue;
204  if(calFactor <= 0.000001){//setting unreasonable calibration factors to minus 1
205  calFactor = -1;
206  }
207  // and calibrate the value
208  fineTime = (-1)*fineTime/calFactor;
209  }
210 
211  }
212  return fineTime;
213 }
214 
215 // --------------------------------------------------------------------------
216 
218 {
219  // fine time set to -1000. by default in getFineTime()
220  return ( (value != -1000.) && (fabs(value) < m_fineTimeCut) );
221 }
222 
223 // --------------------------------------------------------------------------
224 
226 {
227  StatusCode sc;
228 
229  if (m_isOnline) {
230  sc = m_caloTool.retrieve();
231  if ( sc.isFailure()) {
232  ATH_MSG_WARNING("Unable to locate tool L1CaloMonitoringCaloTool");
233  }
234  }
235  else {
236  sc = m_storeGate.retrieve();
237  if ( sc.isFailure()) {
238  ATH_MSG_WARNING("Unable to retrieve store gate");
239  }
240  }
241 
242 
243 }
L1CaloPprFineTimePlotManager::m_CalFactor
double m_CalFactor
Definition: L1CaloPprFineTimePlotManager.h:102
L1CaloPprPlotManager::m_sampleInterval
unsigned int m_sampleInterval
Definition: L1CaloPprPlotManager.h:224
xAOD::TriggerTower_v2::phi
virtual double phi() const final
The azimuthal angle ( ) of the particle.
Definition: TriggerTower_v2.cxx:222
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
xAOD::TriggerTower_v2::isCpSaturated
bool isCpSaturated() const
Is tower saturated?
Definition: TriggerTower_v2.cxx:196
Emlayer
@ Emlayer
Definition: L1CaloPprPlotManager.h:79
L1CaloPprFineTimePlotManager::L1CaloPprFineTimePlotManager
L1CaloPprFineTimePlotManager(ITHistSvc *histoSvc, ToolHandle< LVL1::IL1CaloOfflineTriggerTowerTools > &offlineTT_tool, const int ADC_cut, const unsigned int lumimax, const std::string &pathInRootFile)
Definition: L1CaloPprFineTimePlotManager.cxx:18
L1CaloPprFineTimePlotManager::LArQuality
float LArQuality(const xAOD::TriggerTower *trigTower, int layer)
Definition: L1CaloPprFineTimePlotManager.cxx:98
L1CaloPprFineTimePlotManager::m_fineTimeCut
double m_fineTimeCut
Definition: L1CaloPprFineTimePlotManager.h:95
IL1CaloOfflineTriggerTowerTools.h
athena.value
value
Definition: athena.py:122
L1CaloPprFineTimePlotManager::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Definition: L1CaloPprFineTimePlotManager.h:80
L1CaloPprFineTimePlotManager::m_RefValue
double m_RefValue
Definition: L1CaloPprFineTimePlotManager.h:98
L1CaloPprFineTimePlotManager::badLArQuality
bool badLArQuality(float qual)
Definition: L1CaloPprFineTimePlotManager.cxx:115
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
L1CaloPprFineTimePlotManager::m_ppmAdcMaxValue
int m_ppmAdcMaxValue
Definition: L1CaloPprFineTimePlotManager.h:96
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
ManagedMonitorToolBase.h
L1CaloPprFineTimePlotManager.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
xAOD::TriggerTower_v2::eta
virtual double eta() const final
The pseudorapidity ( ) of the particle.
Definition: TriggerTower_v2.cxx:210
L1CaloPprFineTimePlotManager::doMonitoring
bool doMonitoring(double &value)
Definition: L1CaloPprFineTimePlotManager.cxx:217
L1CaloPprFineTimePlotManager::loadTools
void loadTools()
Definition: L1CaloPprFineTimePlotManager.cxx:225
compute_lumi.denom
denom
Definition: compute_lumi.py:76
L1CaloPprFineTimePlotManager::badHecQuality
bool badHecQuality(float qual)
Definition: L1CaloPprFineTimePlotManager.cxx:125
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
L1CaloPprFineTimePlotManager::getMonitoringValue
double getMonitoringValue(const xAOD::TriggerTower *trigTower, CalLayerEnum theLayer)
Definition: L1CaloPprFineTimePlotManager.cxx:136
L1CaloPprFineTimePlotManager::m_doCaloQualCut
bool m_doCaloQualCut
Definition: L1CaloPprFineTimePlotManager.h:108
L1CaloPprPlotManager::m_ttToolOnline
ToolHandle< LVL1::IL1TriggerTowerTool > m_ttToolOnline
Definition: L1CaloPprPlotManager.h:163
L1CaloPprPlotManager::m_ttToolOffline
ToolHandle< LVL1::IL1CaloOfflineTriggerTowerTools > m_ttToolOffline
Definition: L1CaloPprPlotManager.h:162
IL1TriggerTowerTool.h
L1CaloPprPlotManager
Definition: L1CaloPprPlotManager.h:85
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
L1CaloPprFineTimePlotManager::m_caloTool
ToolHandle< LVL1::IL1CaloMonitoringCaloTool > m_caloTool
Definition: L1CaloPprFineTimePlotManager.h:86
L1CaloPprPlotManager::m_isOnline
bool m_isOnline
Definition: L1CaloPprPlotManager.h:217
beamspotman.qual
qual
Definition: beamspotman.py:481
xAOD::TriggerTower_v2::adcPeak
uint8_t adcPeak() const
get adcPeak
CalLayerEnum
CalLayerEnum
Definition: L1CaloPprPlotManager.h:78
L1CaloPprPlotManager::m_ppmAdcMinValue
int m_ppmAdcMinValue
Definition: L1CaloPprPlotManager.h:220
TriggerTower.h
StoreGateSvc.h
xAOD::TriggerTower_v2::adc
const std::vector< uint16_t > & adc() const
get adc
L1CaloPprFineTimePlotManager::getCaloCells
StatusCode getCaloCells()
Definition: L1CaloPprFineTimePlotManager.cxx:82