ATLAS Offline Software
Loading...
Searching...
No Matches
LArPulseShape.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
14#include "TFile.h"
15#include "TKey.h"
16#include "TTree.h"
17#include "TSystem.h"
18
19LArPulseShape::LArPulseShape(const std::string& name, ISvcLocator* pSvcLocator):
20 AthAlgorithm(name, pSvcLocator), m_initialized(false), m_calo_id(nullptr),
21 m_nt(nullptr)
22{
23 declareProperty("NtupleTitle",m_ntTitle="Pulse shape");
24 m_ntpath="/NTUPLES/PULSE/"+m_ntname;
25}
26
28
30 const CaloIdManager* caloIdMgr{nullptr};
31 ATH_CHECK( detStore()->retrieve( caloIdMgr ) );
32 m_calo_id = caloIdMgr->getCaloCell_ID();
33
34 ATH_CHECK( m_lumiDataKey.initialize() );
35
36 ATH_CHECK( m_cablingKey.initialize() );
37
38 ATH_CHECK( m_BCKey.initialize() );
39
40 ATH_CHECK( m_trigDec.retrieve() );
41
42 if (m_ntpath.empty() || m_ntTitle.empty()) {
43 ATH_MSG_ERROR( "Need to set variable 'm_ntpath' and 'm_ntTitle' in constructor of deriving class!" );
44 return StatusCode::FAILURE;
45 }
46
47 size_t i=m_ntpath.rfind('/');
48 if (i==std::string::npos) {
49 ATH_MSG_ERROR( "Expected at least on '/' in path " << m_ntpath );
50 return StatusCode::FAILURE;
51 }
52 std::string basepath(m_ntpath.begin(),m_ntpath.begin()+i);
53
54 NTupleFilePtr PULSE(ntupleSvc(),basepath);
55 if (!PULSE){
56 ATH_MSG_ERROR( "Could not get NTupleFilePtr with path " << basepath << " failed" );
57 return StatusCode::FAILURE;
58 }
59 NTuplePtr nt(ntupleSvc(),m_ntpath);
60 if (!nt) {
61 nt=ntupleSvc()->book(m_ntpath,CLID_ColumnWiseTuple,m_ntTitle);
62 }
63 if (!nt){
64 ATH_MSG_ERROR( "Booking of NTuple at "<< m_ntpath << " and name " << m_ntTitle << " failed" );
65 return StatusCode::FAILURE;
66 }
67
68 m_nt=nt;
69
70 int ncell=m_calo_id->calo_cell_hash_max();
71
72 for (int i=0;i<ncell;i++) { // loop over cells to book profiles
73
74 IdentifierHash idHash=i;
75 Identifier id=m_calo_id->cell_id(idHash);
76
77 const int sampl = m_calo_id->sampling( id );
78 m_OffId = (int)(id.get_identifier32().get_compact());
79 std::string idoff_str = std::to_string(m_OffId);
80 const char* id_char = (idoff_str).c_str();
81
82 if (m_calo_id->is_em(id)) { // EM calo
83 if (m_calo_id->is_em_barrel(id)) { //EMB
84 if (m_calo_id->pos_neg(id) > 0 ) { //A-side
85
86 SmartDataPtr<NTuple::Directory> dir_EMBA(ntupleSvc(),"/NTUPLES/PULSE/EMBA");
87 if ( !dir_EMBA ) dir_EMBA = ntupleSvc()->createDirectory(PULSE,"EMBA");
88 if ( !dir_EMBA ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
89
90 if (sampl==0){ // if it's EMBA Presampler
91 SmartDataPtr<NTuple::Directory> dir_EMBA_0(ntupleSvc(),"/NTUPLES/PULSE/EMBA/Presampler");
92 if ( !dir_EMBA_0 ) dir_EMBA_0 = ntupleSvc()->createDirectory(PULSE,"EMBA/Presampler");
93 if ( !dir_EMBA_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
94 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
95 }
96
97 if (sampl==1){ // if it's EMBA Sampling1
98 SmartDataPtr<NTuple::Directory> dir_EMBA_1(ntupleSvc(),"/NTUPLES/PULSE/EMBA/Sampling1");
99 if ( !dir_EMBA_1 ) dir_EMBA_1 = ntupleSvc()->createDirectory(PULSE,"EMBA/Sampling1");
100 if ( !dir_EMBA_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
101 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
102 }
103
104 if (sampl==2){ // if it's EMBA Sampling2
105 SmartDataPtr<NTuple::Directory> dir_EMBA_2(ntupleSvc(),"/NTUPLES/PULSE/EMBA/Sampling2");
106 if ( !dir_EMBA_2 ) dir_EMBA_2 = ntupleSvc()->createDirectory(PULSE,"EMBA/Sampling2");
107 if ( !dir_EMBA_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
108 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
109 }
110
111 if (sampl==3){ // if it's EMBA Sampling3
112 SmartDataPtr<NTuple::Directory> dir_EMBA_3(ntupleSvc(),"/NTUPLES/PULSE/EMBA/Sampling3");
113 if ( !dir_EMBA_3 ) dir_EMBA_3 = ntupleSvc()->createDirectory(PULSE,"EMBA/Sampling3");
114 if ( !dir_EMBA_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
115 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
116 }
117
118 } else { // C-side
119
120 SmartDataPtr<NTuple::Directory> dir_EMBC(ntupleSvc(),"/NTUPLES/PULSE/EMBC");
121 if ( !dir_EMBC ) dir_EMBC = ntupleSvc()->createDirectory(PULSE,"EMBC");
122 if ( !dir_EMBC ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
123 if (sampl==0){ // if it's EMBC Presampler
124 SmartDataPtr<NTuple::Directory> dir_EMBC_0(ntupleSvc(),"/NTUPLES/PULSE/EMBC/Presampler");
125 if ( !dir_EMBC_0 ) dir_EMBC_0 = ntupleSvc()->createDirectory(PULSE,"EMBC/Presampler");
126 if ( !dir_EMBC_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
127 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
128 }
129
130 if (sampl==1){ // if it's EMBC Sampling1
131 SmartDataPtr<NTuple::Directory> dir_EMBC_1(ntupleSvc(),"/NTUPLES/PULSE/EMBC/Sampling1");
132 if ( !dir_EMBC_1 ) dir_EMBC_1 = ntupleSvc()->createDirectory(PULSE,"EMBC/Sampling1");
133 if ( !dir_EMBC_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
134 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
135 }
136
137 if (sampl==2){ // if it's EMBC Sampling2
138 SmartDataPtr<NTuple::Directory> dir_EMBC_2(ntupleSvc(),"/NTUPLES/PULSE/EMBC/Sampling2");
139 if ( !dir_EMBC_2 ) dir_EMBC_2 = ntupleSvc()->createDirectory(PULSE,"EMBC/Sampling2");
140 if ( !dir_EMBC_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
141 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
142 }
143
144 if (sampl==3){ // if it's EMBC Sampling3
145 SmartDataPtr<NTuple::Directory> dir_EMBC_3(ntupleSvc(),"/NTUPLES/PULSE/EMBC/Sampling3");
146 if ( !dir_EMBC_3 ) dir_EMBC_3 = ntupleSvc()->createDirectory(PULSE,"EMBC/Sampling3");
147 if ( !dir_EMBC_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
148 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
149 }
150
151 }
152
153 } // end EMB
154
155 if( m_calo_id->is_em_endcap(id) ){ //EMEC
156
157 if (m_calo_id->pos_neg(id) > 0 ) { //A-side
158
159 SmartDataPtr<NTuple::Directory> dir_EMECA(ntupleSvc(),"/NTUPLES/PULSE/EMECA");
160 if ( !dir_EMECA ) dir_EMECA = ntupleSvc()->createDirectory(PULSE,"EMECA");
161 if ( !dir_EMECA ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
162
163 if (sampl==0){ // if it's EMECA Presampler
164 SmartDataPtr<NTuple::Directory> dir_EMECA_0(ntupleSvc(),"/NTUPLES/PULSE/EMECA/Presampler");
165 if ( !dir_EMECA_0 ) dir_EMECA_0 = ntupleSvc()->createDirectory(PULSE,"EMECA/Presampler");
166 if ( !dir_EMECA_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
167
168 //stopper++;
169 //if (stopper<=10)
170 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
171 }
172
173 if (sampl==1){ // if it's EMECA Sampling1
174 SmartDataPtr<NTuple::Directory> dir_EMECA_1(ntupleSvc(),"/NTUPLES/PULSE/EMECA/Sampling1");
175 if ( !dir_EMECA_1 ) dir_EMECA_1 = ntupleSvc()->createDirectory(PULSE,"EMECA/Sampling1");
176 if ( !dir_EMECA_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
177 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
178 }
179
180 if (sampl==2){ // if it's EMECA Sampling2
181 SmartDataPtr<NTuple::Directory> dir_EMECA_2(ntupleSvc(),"/NTUPLES/PULSE/EMECA/Sampling2");
182 if ( !dir_EMECA_2 ) dir_EMECA_2 = ntupleSvc()->createDirectory(PULSE,"EMECA/Sampling2");
183 if ( !dir_EMECA_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
184 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
185 }
186
187 if (sampl==3){ // if it's EMECA Sampling3
188 SmartDataPtr<NTuple::Directory> dir_EMECA_3(ntupleSvc(),"/NTUPLES/PULSE/EMECA/Sampling3");
189 if ( !dir_EMECA_3 ) dir_EMECA_3 = ntupleSvc()->createDirectory(PULSE,"EMECA/Sampling3");
190 if ( !dir_EMECA_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
191 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
192 }
193
194 } else { // C-side
195
196 SmartDataPtr<NTuple::Directory> dir_EMECC(ntupleSvc(),"/NTUPLES/PULSE/EMECC");
197 if ( !dir_EMECC ) dir_EMECC = ntupleSvc()->createDirectory(PULSE,"EMECC");
198 if ( !dir_EMECC ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
199 if (sampl==0){ // if it's EMECC Presampler
200 SmartDataPtr<NTuple::Directory> dir_EMECC_0(ntupleSvc(),"/NTUPLES/PULSE/EMECC/Presampler");
201 if ( !dir_EMECC_0 ) dir_EMECC_0 = ntupleSvc()->createDirectory(PULSE,"EMECC/Presampler");
202 if ( !dir_EMECC_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
203 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
204 }
205
206 if (sampl==1){ // if it's EMECC Sampling1
207 SmartDataPtr<NTuple::Directory> dir_EMECC_1(ntupleSvc(),"/NTUPLES/PULSE/EMECC/Sampling1");
208 if ( !dir_EMECC_1 ) dir_EMECC_1 = ntupleSvc()->createDirectory(PULSE,"EMECC/Sampling1");
209 if ( !dir_EMECC_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
210 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
211 }
212
213 if (sampl==2){ // if it's EMECC Sampling2
214 SmartDataPtr<NTuple::Directory> dir_EMECC_2(ntupleSvc(),"/NTUPLES/PULSE/EMECC/Sampling2");
215 if ( !dir_EMECC_2 ) dir_EMECC_2 = ntupleSvc()->createDirectory(PULSE,"EMECC/Sampling2");
216 if ( !dir_EMECC_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
217 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
218 }
219
220 if (sampl==3){ // if it's EMECC Sampling3
221 SmartDataPtr<NTuple::Directory> dir_EMECC_3(ntupleSvc(),"/NTUPLES/PULSE/EMECC/Sampling3");
222 if ( !dir_EMECC_3 ) dir_EMECC_3 = ntupleSvc()->createDirectory(PULSE,"EMECC/Sampling3");
223 if ( !dir_EMECC_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
224 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
225 }
226
227 }
228 } // end EMEC
229
230
231
232 } // end EM calo
233
234 if( m_calo_id->is_hec(id) ){ //HEC
235
236 if (m_calo_id->pos_neg(id) > 0 ) { //A-side
237
238 SmartDataPtr<NTuple::Directory> dir_HECA(ntupleSvc(),"/NTUPLES/PULSE/HECA");
239 if ( !dir_HECA ) dir_HECA = ntupleSvc()->createDirectory(PULSE,"HECA");
240 if ( !dir_HECA ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
241
242 if (sampl==0){
243 SmartDataPtr<NTuple::Directory> dir_HECA_0(ntupleSvc(),"/NTUPLES/PULSE/HECA/Layer1");
244 if ( !dir_HECA_0 ) dir_HECA_0 = ntupleSvc()->createDirectory(PULSE,"HECA/Layer1");
245 if ( !dir_HECA_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
246 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
247 }
248
249 if (sampl==1){
250 SmartDataPtr<NTuple::Directory> dir_HECA_1(ntupleSvc(),"/NTUPLES/PULSE/HECA/Layer2");
251 if ( !dir_HECA_1 ) dir_HECA_1 = ntupleSvc()->createDirectory(PULSE,"HECA/Layer2");
252 if ( !dir_HECA_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
253 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
254 }
255
256 if (sampl==2){
257 SmartDataPtr<NTuple::Directory> dir_HECA_2(ntupleSvc(),"/NTUPLES/PULSE/HECA/Layer3");
258 if ( !dir_HECA_2 ) dir_HECA_2 = ntupleSvc()->createDirectory(PULSE,"HECA/Layer3");
259 if ( !dir_HECA_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
260 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
261 }
262
263 if (sampl==3){
264 SmartDataPtr<NTuple::Directory> dir_HECA_3(ntupleSvc(),"/NTUPLES/PULSE/HECA/Layer4");
265 if ( !dir_HECA_3 ) dir_HECA_3 = ntupleSvc()->createDirectory(PULSE,"HECA/Layer4");
266 if ( !dir_HECA_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
267 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
268 }
269
270 } else { // C-side
271
272 SmartDataPtr<NTuple::Directory> dir_HECC(ntupleSvc(),"/NTUPLES/PULSE/HECC");
273 if ( !dir_HECC ) dir_HECC = ntupleSvc()->createDirectory(PULSE,"HECC");
274 if ( !dir_HECC ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
275 if (sampl==0){
276 SmartDataPtr<NTuple::Directory> dir_HECC_0(ntupleSvc(),"/NTUPLES/PULSE/HECC/Layer1");
277 if ( !dir_HECC_0 ) dir_HECC_0 = ntupleSvc()->createDirectory(PULSE,"HECC/Layer1");
278 if ( !dir_HECC_0 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
279 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
280 }
281
282 if (sampl==1){
283 SmartDataPtr<NTuple::Directory> dir_HECC_1(ntupleSvc(),"/NTUPLES/PULSE/HECC/Layer2");
284 if ( !dir_HECC_1 ) dir_HECC_1 = ntupleSvc()->createDirectory(PULSE,"HECC/Layer2");
285 if ( !dir_HECC_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
286 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
287 }
288
289 if (sampl==2){
290 SmartDataPtr<NTuple::Directory> dir_HECC_2(ntupleSvc(),"/NTUPLES/PULSE/HECC/Layer3");
291 if ( !dir_HECC_2 ) dir_HECC_2 = ntupleSvc()->createDirectory(PULSE,"HECC/Layer3");
292 if ( !dir_HECC_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
293 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
294 }
295
296 if (sampl==3){
297 SmartDataPtr<NTuple::Directory> dir_HECC_3(ntupleSvc(),"/NTUPLES/PULSE/HECC/Layer4");
298 if ( !dir_HECC_3 ) dir_HECC_3 = ntupleSvc()->createDirectory(PULSE,"HECC/Layer4");
299 if ( !dir_HECC_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
300 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
301 }
302
303 }
304 } // end HEC
305 if( m_calo_id->is_fcal(id) ){ //FCAL
306
307 if (m_calo_id->pos_neg(id) > 0 ) { //A-side
308
309 SmartDataPtr<NTuple::Directory> dir_FCALA(ntupleSvc(),"/NTUPLES/PULSE/FCALA");
310 if ( !dir_FCALA ) dir_FCALA = ntupleSvc()->createDirectory(PULSE,"FCALA");
311 if ( !dir_FCALA ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
312
313 if (sampl==1){ // if it's FCALA Sampling1
314 SmartDataPtr<NTuple::Directory> dir_FCALA_1(ntupleSvc(),"/NTUPLES/PULSE/FCALA/Sampling1");
315 if ( !dir_FCALA_1 ) dir_FCALA_1 = ntupleSvc()->createDirectory(PULSE,"FCALA/Sampling1");
316 if ( !dir_FCALA_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
317 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
318 }
319
320 if (sampl==2){ // if it's FCALA Sampling2
321 SmartDataPtr<NTuple::Directory> dir_FCALA_2(ntupleSvc(),"/NTUPLES/PULSE/FCALA/Sampling2");
322 if ( !dir_FCALA_2 ) dir_FCALA_2 = ntupleSvc()->createDirectory(PULSE,"FCALA/Sampling2");
323 if ( !dir_FCALA_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
324 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
325 }
326
327 if (sampl==3){ // if it's FCALA Sampling3
328 SmartDataPtr<NTuple::Directory> dir_FCALA_3(ntupleSvc(),"/NTUPLES/PULSE/FCALA/Sampling3");
329 if ( !dir_FCALA_3 ) dir_FCALA_3 = ntupleSvc()->createDirectory(PULSE,"FCALA/Sampling3");
330 if ( !dir_FCALA_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
331 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
332 }
333
334 } else { // C-side
335
336 SmartDataPtr<NTuple::Directory> dir_FCALC(ntupleSvc(),"/NTUPLES/PULSE/FCALC");
337 if ( !dir_FCALC ) dir_FCALC = ntupleSvc()->createDirectory(PULSE,"FCALC");
338 if ( !dir_FCALC ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
339
340 if (sampl==1){ // if it's FCALC Sampling1
341 SmartDataPtr<NTuple::Directory> dir_FCALC_1(ntupleSvc(),"/NTUPLES/PULSE/FCALC/Sampling1");
342 if ( !dir_FCALC_1 ) dir_FCALC_1 = ntupleSvc()->createDirectory(PULSE,"FCALC/Sampling1");
343 if ( !dir_FCALC_1 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
344 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
345 }
346
347 if (sampl==2){ // if it's FCALC Sampling2
348 SmartDataPtr<NTuple::Directory> dir_FCALC_2(ntupleSvc(),"/NTUPLES/PULSE/FCALC/Sampling2");
349 if ( !dir_FCALC_2 ) dir_FCALC_2 = ntupleSvc()->createDirectory(PULSE,"FCALC/Sampling2");
350 if ( !dir_FCALC_2 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
351 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
352 }
353
354 if (sampl==3){ // if it's FCALC Sampling3
355 SmartDataPtr<NTuple::Directory> dir_FCALC_3(ntupleSvc(),"/NTUPLES/PULSE/FCALC/Sampling3");
356 if ( !dir_FCALC_3 ) dir_FCALC_3 = ntupleSvc()->createDirectory(PULSE,"FCALC/Sampling3");
357 if ( !dir_FCALC_3 ) ATH_MSG_ERROR ( " failed to get ntuple directory" );
358 m_cellHistos.insert(std::make_pair(m_OffId, new TProfile(id_char, id_char, 40, -4 , 36, "s" )));
359 }
360 }
361 } // end FCAL
362
363 } // loop over cells
364
365 SmartDataPtr<NTuple::Directory> dir_FCALC_3(ntupleSvc(),"/NTUPLES/PULSE/Check");
366 if ( !dir_FCALC_3 ) dir_FCALC_3 = ntupleSvc()->createDirectory(PULSE,"Check");
367
368 m_TProfpulse_diff = new TProfile("test_diff", "test_diff",500, 0, 500, "s");
369
370 m_BCID = new TH1D("BCID", "BCID",3564, 0, 3564);
371 m_diffBCID = new TH1D("diffBCID", "BCID",3564, 0, 3564);
372 m_actualInt = new TH1D("ActualInt", "ActInt", 60, 0, 20);
373
375
379 m_initialized=true;
380 return StatusCode::SUCCESS;
381}
382
384
385
386 const EventContext& ctx = Gaudi::Hive::currentContext();
387 short int bunchStr[8] = {1, 101, 201, 301, 1786, 1886, 1986, 2086}; //move to JO
388
389 std::vector<std::string> chains = m_trigDec->getListOfTriggers();
390 std::vector<std::string> myChains;
391
393
394 if (m_trigDec->isPassed("L1_RD1_BGRP10")) {
395
396 int bunchId = ctx.eventID().bunch_crossing_id();
397
398 m_mindist = 3564;
399 m_closestBC = 0;
400 for (int i = 0; i < 8; i++) {
401 if ( (fabs(bunchId - bunchStr[i]) < m_mindist) || (fabs(bunchId - (bunchStr[i]+3564)) < m_mindist)) {
402 m_mindist = std::min(fabs(bunchId - bunchStr[i]),(fabs(bunchId - (bunchStr[i]+3564))));
403 m_closestBC = bunchStr[i];
404 }
405 }
406 if (fabs(bunchId - m_closestBC) < (fabs(bunchId - (m_closestBC+3564)))) {
407 m_mindist = bunchId - m_closestBC;
408 } else {
409 m_mindist = bunchId - (m_closestBC+3564);
410 }
411
412 //std::cout << "bunchID = " << bunchId<< ", m_mindist = " << m_mindist << ", m_closestBC = " << m_closestBC << std::endl;
413 m_BCID->Fill(bunchId);
414 m_diffBCID->Fill(m_mindist);
415
416 m_actualInt->Fill(lumi->lbLuminosityPerBCIDVector().at(m_closestBC));
417
418 const LArDigitContainer* larDigitContainer;
419 ATH_CHECK( evtStore()->retrieve(larDigitContainer, "FREE") );
420 ATH_CHECK( detStore()->retrieve(m_larPedestal) );
421 if (larDigitContainer->empty()) {
422 ATH_MSG_WARNING ( "LArDigitContainer with key= is empty!" );
423
424 return StatusCode::SUCCESS;
425 }
426
428 const LArOnOffIdMapping* cabling=*larCablingHdl;
429 if(!cabling) {
430 ATH_MSG_ERROR("Could not get LArOnOffIdMapping !!");
431 return StatusCode::FAILURE;
432 }
433 for (LArDigitContainer::const_iterator digit = larDigitContainer->begin(); digit != larDigitContainer->end(); ++digit) {
434
435 HWIdentifier channelID = (*digit)->hardwareID();
436
437 if (cabling->isOnlineConnected(channelID)) {
438
439 CaloGain::CaloGain gain=(*digit)->gain();
440
441 float pedestal = m_larPedestal->pedestal(channelID, gain);
442
443 m_OffId_conv = (int)(cabling->cnvToIdentifier(channelID).get_identifier32().get_compact());
444
445 const std::vector<short>& samples = (*digit)->samples();
446
447 m_isample=0;
448 for (short sample : samples) {
449 m_isample++;
450 if (lumi->lbLuminosityPerBCIDVector().at(m_closestBC)!=0){
451 m_TProfpulse_diff->Fill(m_mindist+m_isample, (sample-pedestal)/lumi->lbLuminosityPerBCIDVector().at(m_closestBC));//+0,1,2,3
452 m_cellHistos[m_OffId_conv]->Fill(m_mindist+m_isample, (sample-pedestal)/lumi->lbLuminosityPerBCIDVector().at(m_closestBC));
453 }
454 } //loop over samples
455 }
456 }
457
458 }//trigger
459 return StatusCode::SUCCESS;
460}
461
464
465 ATH_MSG_INFO( "LArPulseShape has finished." );
466 return StatusCode::SUCCESS;
467
468}// end finalize-method.
469
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
INTupleSvc * ntupleSvc()
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
This class initializes the Calo (LAr and Tile) offline identifiers.
const CaloCell_ID * getCaloCell_ID(void) const
Access to IdHelper.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This is a "hash" representation of an Identifier.
Container class for LArDigit.
std::string m_ntpath
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
virtual StatusCode initialize() override
void addHistogram(TH1 *h)
std::map< int, TProfile * > m_cellHistos
virtual StatusCode stop() override
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
TProfile * m_TProfpulse_diff
const ILArPedestal * m_larPedestal
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
std::string m_ntname
virtual StatusCode execute() override
NTuple::Tuple * m_nt
const CaloCell_ID * m_calo_id
std::string m_ntTitle
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
LArPulseShape(const std::string &name, ISvcLocator *pSvcLocator)