ATLAS Offline Software
Loading...
Searching...
No Matches
LArTTL1Calib.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// +======================================================================+
6// + +
7// + Author ........: F. Ledroit +
8// + Institut ......: ISN Grenoble +
9// + Creation date .: 09/01/2003 +
10// + +
11// +======================================================================+
12//
13// ........ includes
14//
16// .......... utilities
17//
18
20#include "LArRawEvent/LArTTL1.h"
22//
23// ........ Gaudi needed includes
24//
25#include "Gaudi/Property.h"
26#include "GaudiKernel/ISvcLocator.h"
27//
28#include "GaudiKernel/INTupleSvc.h"
29// #include "GaudiKernel/NTupleDirectory.h"
30#include "GaudiKernel/SmartDataPtr.h"
32
33//
34
35LArTTL1Calib::LArTTL1Calib(const std::string& name, ISvcLocator* pSvcLocator)
36 : AthAlgorithm(name, pSvcLocator)
37// + -------------------------------------------------------------------- +
38// + Author ........: F. Ledroit +
39// + Creation date .: 20/04/2004 +
40// + Subject: TTL1 Calib constructor +
41// + -------------------------------------------------------------------- +
42{
43 //
44 // ........ default values of private data
45 //
46 // m_thresholdGeVTTs = 0.1; // pb here: threshold depends on whether
47 // calib already applied or not... m_thresholdGeVTTs = 0.001; // and
48 // whether want to study calib or noise
50 m_maxNtt = 8000;
51 // m_maxNtt = 500;
52
53 m_pnt = nullptr;
54
55 m_lvl1Helper = nullptr;
56
57 //
58 return;
59}
60
63
64 return;
65}
66
68 // +======================================================================+
69 // + +
70 // + Author ........: F. Ledroit +
71 // + Creation date .: 09/01/2003 +
72 // + +
73 // +======================================================================+
74 //
75 // ......... declaration
76 //
77 ATH_MSG_DEBUG("in initialize()");
78
79 NTuple::Directory* dir = nullptr;
80 NTupleFilePtr file1(ntupleSvc(), "/NTUPLES/FILE1");
81
82 if (file1 != 0) {
83 if (!(dir = ntupleSvc()->createDirectory("/NTUPLES/FILE1/DIR"))) {
84 ATH_MSG_ERROR("Cannot create directory /NTUPLES/FILE1/DIR");
85 }
86 } else {
87 ATH_MSG_ERROR("Cannot access file /NTUPLES/FILE1");
88 return StatusCode::FAILURE;
89 }
90
91 ATH_MSG_DEBUG("created directory /NTUPLES/FILE1/DIR");
92
93 NTuplePtr pnt(ntupleSvc(), "/NTUPLES/FILE1/DIR/10");
94 if (!pnt) {
95 pnt = ntupleSvc()->book(dir, 10, CLID_ColumnWiseTuple, "LArLvl1TT");
96
97 if (pnt) {
98 ATH_MSG_DEBUG("booked ntuple LArLvl1TT");
99 m_pnt = pnt;
100
101 ATH_CHECK(pnt->addItem("nTotEm", m_ntotem));
102 ATH_CHECK(pnt->addItem("EtTotEm", m_etotem));
103 ATH_CHECK(pnt->addItem("n3x3Em", m_n3x3em));
104 ATH_CHECK(pnt->addItem("E3x3Em", m_e3x3em));
105 ATH_CHECK(pnt->addItem("EmostEm", m_emostem));
106 ATH_CHECK(pnt->addItem("BarrelECEm", m_bec_mostEem));
107 ATH_CHECK(pnt->addItem("EmFcalEm", m_emfcal_mostEem));
108 ATH_CHECK(pnt->addItem("IetaEm", m_Ieta_mostEem));
109 ATH_CHECK(pnt->addItem("LphiEm", m_Lphi_mostEem));
110 ATH_CHECK(pnt->addItem("nTTaboveThrEm", m_nttem, 0, m_maxNtt));
111 ATH_CHECK(pnt->addItem("EtTTEm", m_nttem, m_ettem));
112 ATH_CHECK(pnt->addItem("BECTTEm", m_nttem, m_becttem));
113 ATH_CHECK(pnt->addItem("EmFcalTTEm", m_nttem, m_emfcalttem));
114 ATH_CHECK(pnt->addItem("IetaTTEm", m_nttem, m_Ietattem));
115 ATH_CHECK(pnt->addItem("LphiTTEm", m_nttem, m_Lphittem));
116
117 ATH_CHECK(pnt->addItem("nTotHad", m_ntothad));
118 ATH_CHECK(pnt->addItem("EtTotHad", m_etothad));
119 ATH_CHECK(pnt->addItem("n3x3Had", m_n3x3had));
120 ATH_CHECK(pnt->addItem("E3x3Had", m_e3x3had));
121 ATH_CHECK(pnt->addItem("EmostHad", m_emosthad));
122 ATH_CHECK(pnt->addItem("HecFcalHad", m_hecfcal_mostEhad));
123 ATH_CHECK(pnt->addItem("IetaHad", m_Ieta_mostEhad));
124 ATH_CHECK(pnt->addItem("LphiHad", m_Lphi_mostEhad));
125 ATH_CHECK(pnt->addItem("nTTaboveThrHad", m_ntthad, 0, m_maxNtt));
126 ATH_CHECK(pnt->addItem("EtTTHad", m_ntthad, m_etthad));
127 ATH_CHECK(pnt->addItem("HecFcalTTHad", m_ntthad, m_hecfcaltthad));
128 ATH_CHECK(pnt->addItem("IetaTTHad", m_ntthad, m_Ietatthad));
129 ATH_CHECK(pnt->addItem("LphiTTHad", m_ntthad, m_Lphitthad));
130
131 } else {
132 ATH_MSG_ERROR("could not book Ntuple");
133 }
134 } else {
135 ATH_MSG_ERROR("Ntuple is already booked");
136 }
137 //
138
139 ATH_CHECK(detStore()->retrieve(m_lvl1Helper));
140
141 ATH_MSG_DEBUG("Initialization completed successfully");
142 return StatusCode::SUCCESS;
143}
144
146 // +======================================================================+
147 // + +
148 // + Author: F. Ledroit +
149 // + Creation date: 2003/01/13 +
150 // + +
151 // +======================================================================+
152 //
153 // ......... declarations
154 //
155 ATH_MSG_DEBUG("Begining of execution");
156
158 Identifier ttOffId;
159
160 std::vector<std::string> containerVec; // FIX ME USING PROPERTIES !!!
161 containerVec.push_back("LArTTL1EM");
162 containerVec.push_back("LArTTL1HAD");
163
164 //
165 // ............ loop over the wanted ttl1 containers (1 em, 1 had)
166 //
167
168 for (unsigned int iTTL1Container = 0; iTTL1Container < containerVec.size();
169 iTTL1Container++) {
170 //
171 // ..... Get the pointer to the TTL1 Container from StoreGate
172 //
173 ATH_MSG_DEBUG(" asking for: " << containerVec[iTTL1Container]);
174
175 const LArTTL1Container* ttl1_container;
176 ATH_CHECK(
177 evtStore()->retrieve(ttl1_container, containerVec[iTTL1Container]));
178
179 //
180 ATH_MSG_DEBUG("number of ttl1s: " << ttl1_container->size());
181
182 int samp = iTTL1Container;
183 int indexem = 0;
184 int indexhad = 0;
185
186 float e_mostE = 0.;
187 int bec_mostE = 99;
188 int hecfcal_mostE = 99;
189 int Ieta_mostE = 99;
190 int Lphi_mostE = 99;
191 int phiMax_mostE = -99;
192
193 //
194 // ....... loop over ttl1s and get informations
195 //
196
197 for (const LArTTL1* ttl1 : *ttl1_container) {
198 ttOffId = ttl1->ttOfflineID();
199 std::vector<float> sampleV = ttl1->samples();
200 float e = sampleV[3] * 1e-3; // go to GeV
201 int reg = m_lvl1Helper->region(ttOffId);
202 int eta = m_lvl1Helper->eta(ttOffId);
203 int bec = 99;
204 int hecfcal = 99;
205 int Ieta = 99;
206 decodeInverseTTChannel(reg, samp, eta, bec, hecfcal, Ieta);
207 int Lphi = m_lvl1Helper->phi(ttOffId) + 1;
208 int phiMax = m_lvl1Helper->phi_max(ttOffId);
209 if (e > e_mostE) {
210 e_mostE = e;
211 bec_mostE = bec;
212 hecfcal_mostE = hecfcal;
213 Ieta_mostE = Ieta;
214 Lphi_mostE = Lphi;
215 phiMax_mostE = phiMax;
216 }
217
218 if (samp == 0) {
219 // EM towers
220 m_etotem += e;
221 if (indexem < m_maxNtt) {
222 if (e > m_thresholdGeVTTs) {
223 m_ettem[indexem] = e;
224 m_becttem[indexem] = bec;
225 m_emfcalttem[indexem] = hecfcal;
226 m_Ietattem[indexem] = Ieta;
227 m_Lphittem[indexem] = Lphi;
228 indexem++;
229 }
230 } else {
231 if (m_maxNtt == indexem) {
232 ATH_MSG_WARNING("Too many em TT. Save only " << m_maxNtt);
233 break;
234 }
235 }
236 } else {
237 // HAD towers
238 m_etothad += e;
239 if (indexhad < m_maxNtt) {
240 if (e > m_thresholdGeVTTs) {
241 m_etthad[indexhad] = e;
242 m_hecfcaltthad[indexhad] = hecfcal;
243 m_Ietatthad[indexhad] = Ieta;
244 m_Lphitthad[indexhad] = Lphi;
245 indexhad++;
246 }
247 } else {
248 if (m_maxNtt == indexhad) {
249 ATH_MSG_WARNING("Too many had TT. Save only " << m_maxNtt);
250 break;
251 }
252 }
253 }
254
255 } // .... end of loop over ittl1s
256 ATH_MSG_DEBUG("number of em/had ttl1s: " << indexem << " / " << indexhad);
257
258 int etaLim = 13; // barrel-ec transition
259 if (hecfcal_mostE > 0) {
260 etaLim = 14;
261 }
262 if (samp == 0) {
263 // em:
264 m_ntotem = ttl1_container->size();
265 m_nttem = indexem;
266 for (int i = 0; i < indexem; ++i) {
267 int deltaEta = std::abs(Ieta_mostE - m_Ietattem[i]);
268 int deltaPhi = std::abs(Lphi_mostE - m_Lphittem[i]); // not quite 3x3
269 if ((deltaEta <= 1 ||
270 deltaEta >= etaLim) // because phi granularity changes
271 && (deltaPhi <= 1 ||
272 deltaPhi == phiMax_mostE)) { // at eta=2.5 and 3.2
273 m_n3x3em += 1;
274 m_e3x3em += m_ettem[i];
275 }
276 }
277 m_emostem = e_mostE;
278 m_bec_mostEem = bec_mostE;
279 m_emfcal_mostEem = hecfcal_mostE;
280 m_Ieta_mostEem = Ieta_mostE;
281 m_Lphi_mostEem = Lphi_mostE;
282 } else {
283 // had:
284 m_ntothad = ttl1_container->size();
285 m_ntthad = indexhad;
286 for (int i = 0; i < indexhad; ++i) {
287 int deltaEta = std::abs(Ieta_mostE - m_Ietatthad[i]);
288 int deltaPhi = std::abs(Lphi_mostE - m_Lphitthad[i]);
289 if ((deltaEta <= 1 || deltaEta >= etaLim) &&
290 (deltaPhi <= 1 || deltaPhi == phiMax_mostE)) {
291 m_n3x3had += 1;
292 m_e3x3had += m_etthad[i];
293 }
294 }
295 m_emosthad = e_mostE;
296 m_hecfcal_mostEhad = hecfcal_mostE;
297 m_Ieta_mostEhad = Ieta_mostE;
298 m_Lphi_mostEhad = Lphi_mostE;
299 }
300
301 } // .... end of loop over containers
302 ATH_MSG_DEBUG("end of loop over containers, write record");
303
304 ATH_CHECK(ntupleSvc()->writeRecord(m_pnt));
305 return StatusCode::SUCCESS;
306}
307
309 // +======================================================================+
310 // + +
311 // + Author: F. Ledroit +
312 // + Creation date: 2003/01/13 +
313 // + +
314 // +======================================================================+
315 //
316 ATH_MSG_DEBUG(" LArTTL1Calib finalize completed successfully");
317 return StatusCode::SUCCESS;
318}
319
320void LArTTL1Calib::decodeInverseTTChannel(int region, int layer, int eta,
321 int& bec, int& emhf,
322 int& Ieta) const {
323 // fix me !!! this method is duplicated from LArCablingService
324 if (region == 0) {
325 if (eta <= 14) {
326 bec = 0; // EM barrel
327 emhf = 0;
328 Ieta = eta + 1;
329 } else {
330 bec = 1; // EMEC or HEC
331 emhf = layer;
332 Ieta = eta - 13;
333 }
334 } else if (region == 1 || region == 2) {
335 bec = 1;
336 emhf = layer;
337 if (region == 1) {
338 Ieta = eta + 12;
339 } else {
340 Ieta = 15;
341 }
342 } else if (region == 3) { // FCAL only
343 bec = 1;
344 emhf = 2 + layer;
345 Ieta = eta + 1;
346 }
347}
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
INTupleSvc * ntupleSvc()
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
size_type size() const noexcept
Returns the number of elements in the collection.
virtual StatusCode initialize()
NTuple::Item< long > m_Lphi_mostEhad
LArTTL1Calib(const std::string &name, ISvcLocator *pSvcLocator)
constructor
NTuple::Item< float > m_e3x3em
NTuple::Item< long > m_Ieta_mostEem
NTuple::Item< long > m_ntothad
NTuple::Tuple * m_pnt
NTuple::Array< long > m_becttem
NTuple::Item< float > m_emosthad
NTuple::Item< long > m_Lphi_mostEem
const CaloLVL1_ID * m_lvl1Helper
float m_thresholdGeVTTs
NTuple::Item< long > m_emfcal_mostEem
NTuple::Item< long > m_hecfcal_mostEhad
virtual StatusCode finalize()
NTuple::Item< long > m_n3x3had
NTuple::Array< float > m_ettem
NTuple::Item< float > m_etothad
~LArTTL1Calib()
destructor
NTuple::Array< long > m_Lphitthad
NTuple::Array< long > m_Ietattem
NTuple::Item< long > m_bec_mostEem
NTuple::Array< long > m_Lphittem
virtual StatusCode execute()
NTuple::Array< long > m_hecfcaltthad
NTuple::Item< long > m_n3x3em
NTuple::Array< long > m_emfcalttem
NTuple::Item< float > m_etotem
NTuple::Item< long > m_ntthad
NTuple::Array< long > m_Ietatthad
NTuple::Item< long > m_nttem
NTuple::Item< float > m_e3x3had
NTuple::Item< float > m_emostem
NTuple::Item< long > m_ntotem
NTuple::Array< float > m_etthad
NTuple::Item< long > m_Ieta_mostEhad
void decodeInverseTTChannel(int region, int layer, int eta, int &bec, int &emhf, int &Ieta) const
Container class for LArTTL1.
Liquid Argon TT L1 sum class.
Definition LArTTL1.h:29