ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBRec
src
CBNTAA_BeamInstrumentation.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CBNTAA_BeamInstrumentation.h
"
6
7
#include "
TBEvent/TBScintillatorCont.h
"
8
#include "
TBEvent/TBBPCCont.h
"
9
#include "
TBEvent/TBBPCRawCont.h
"
10
#include "
TBEvent/TBPhase.h
"
11
#include "
TBEvent/TBTriggerPatternUnit.h
"
12
#include <vector>
13
14
CBNTAA_BeamInstrumentation::CBNTAA_BeamInstrumentation
(
const
std::string & name, ISvcLocator * pSvcLocator) :
CBNT_TBRecBase
(name, pSvcLocator)
15
{
16
declareProperty
(
"ContainerKey1"
,
m_containerKey1
=
"ScintillatorCont"
);
17
declareProperty
(
"ContainerKey2"
,
m_containerKey2
=
"BPCCont"
);
18
declareProperty
(
"ContainerKey3"
,
m_containerKey3
=
"BPCRawCont"
);
19
declareProperty
(
"ContainerKey4"
,
m_containerKey4
=
"TBPhase"
);
20
declareProperty
(
"ContainerKey5"
,
m_containerKey5
=
"TBTrigPat"
);
21
declareProperty
(
"BPCRAW"
,
m_bpc_raw
=
false
);
22
declareProperty
(
"BPCnames"
,
m_bpc_names
);
23
declareProperty
(
"Scintnames"
,
m_scint_names
);
24
declareProperty
(
"TrigArray"
,
m_trig_array
=
false
);
25
declareProperty
(
"TrigPattern"
,
m_triggflag
);
26
declareProperty
(
"NeverReturnFailure"
,
m_neverReturnFailure
=
false
);
27
m_scint_adc
=NULL;
28
m_scint_tdc
=NULL;
29
m_bpc_x
=NULL;
30
m_bpc_y
=NULL;
31
m_bpc_up
=NULL;
32
m_bpc_down
=NULL;
33
m_bpc_left
=NULL;
34
m_bpc_right
=NULL;
35
m_bpc_adc_hor
=NULL;
36
m_bpc_adc_ver
=NULL;
37
m_trig_sel
=NULL;
38
m_bpc_ntnames
=NULL;
39
m_scint_ntnames
=NULL;
40
m_clock
= 0;
41
m_trig
= 0;
42
m_trig_id
= 0;
43
}
44
45
CBNTAA_BeamInstrumentation::~CBNTAA_BeamInstrumentation
()
46
{
//Clean up arrays of ntuple entries (if they have been booked)
47
if
(
m_scint_adc
)
48
delete
m_scint_adc
;
49
if
(
m_scint_tdc
)
50
delete
m_scint_tdc
;
51
if
(
m_bpc_x
)
52
delete
m_bpc_x
;
53
if
(
m_bpc_y
)
54
delete
m_bpc_y
;
55
if
(
m_bpc_up
)
56
delete
m_bpc_up
;
57
if
(
m_bpc_down
)
58
delete
m_bpc_down
;
59
if
(
m_bpc_right
)
60
delete
m_bpc_right
;
61
if
(
m_bpc_left
)
62
delete
m_bpc_left
;
63
if
(
m_bpc_adc_ver
)
64
delete
m_bpc_adc_ver
;
65
if
(
m_bpc_adc_hor
)
66
delete
m_bpc_adc_hor
;
67
if
(
m_trig_sel
)
68
delete
m_trig_sel
;
69
}
70
71
StatusCode
CBNTAA_BeamInstrumentation::CBNT_initialize
()
72
{
73
ATH_MSG_DEBUG
(
"in initialize()"
);
74
75
const
unsigned
nScint=
m_scint_names
.size();
76
addBranch
(
"Beam_sNames"
,
m_scint_ntnames
);
77
for
(
unsigned
i=0;i<nScint;i++) {
78
m_scint_ntnames
->push_back(
add_name
(
"scint_"
,
m_scint_names
[i]));
79
}
80
addBranch
(
"Beam_sADC"
,
m_scint_adc
);
81
addBranch
(
"Beam_sTDC"
,
m_scint_tdc
);
82
83
const
unsigned
nBPCs=
m_bpc_names
.size();
84
addBranch
(
"Beam_bNames"
,
m_bpc_ntnames
);
85
for
(
unsigned
i=0;i<nBPCs;i++) {
86
m_bpc_ntnames
->push_back(
add_name
(
"bpc_"
,
m_bpc_names
[i]));
87
}
88
addBranch
(
"Beam_bpcX"
,
m_bpc_x
);
89
addBranch
(
"Beam_bpcY"
,
m_bpc_y
);
90
91
// BPC RAW, set to false by default
92
if
(
m_bpc_raw
==
true
) {
// bpc raw
93
94
addBranch
(
"Beam_bpcUp"
,
m_bpc_up
);
95
addBranch
(
"Beam_bpcDown"
,
m_bpc_down
);
96
addBranch
(
"Beam_bpcRight"
,
m_bpc_right
);
97
addBranch
(
"Beam_bpcLeft"
,
m_bpc_left
);
98
addBranch
(
"Beam_bpcADCHor"
,
m_bpc_adc_hor
);
99
addBranch
(
"Beam_bpcADCVer"
,
m_bpc_adc_ver
);
100
101
}
//bpcraw
102
103
addBranch
(
"Beam_Trigger"
,
m_trig
,
"Trigger/l"
);
104
// trigger array
105
ATH_MSG_DEBUG
(
" m_trig_array"
<<
m_trig_array
);
106
if
(
m_trig_array
==
true
) {
107
108
ATH_MSG_DEBUG
(
" loading array ntuple"
);
109
addBranch
(
"Beam_NTrig"
,
m_trig_id
,
"/l"
);
110
111
addBranch
(
"Beam_Trig_Array"
,
m_trig_sel
);
112
}
113
114
addBranch
(
"Beam_Clock"
,
m_clock
,
"Clock/f"
);
115
116
return
StatusCode::SUCCESS;
117
118
}
119
120
StatusCode
CBNTAA_BeamInstrumentation::CBNT_execute
()
121
{
122
const
TBScintillatorCont
* scintc =
nullptr
;
123
StatusCode
sc
=
evtStore
()->retrieve(scintc,
m_containerKey1
);
124
if
(
sc
.isFailure())
125
{
126
ATH_MSG_ERROR
(
" Cannot read TBScintillatorCont from StoreGate! key= "
<<
m_containerKey1
);
127
if
(
m_neverReturnFailure
) {
128
return
StatusCode::SUCCESS;
129
}
else
{
130
return
StatusCode::FAILURE;
131
}
132
}
133
else
134
{
135
const
unsigned
nScint=
m_scint_names
.size();
136
ATH_MSG_DEBUG
(
"Filling for "
<<nScint<<
" scintilators"
);
137
// m_scint_adc->reserve(nScint);
138
// m_scint_tdc->reserve(nScint);
139
m_scint_adc
->resize(nScint);
140
m_scint_tdc
->resize(nScint);
141
for
(
const
TBScintillator
* scint : *scintc) {
142
const
std::string name = scint->getDetectorName();
143
//In the initialize method we build the vectors of ntuple-items for ADCs and BPCs that
144
//the same scintillators have the same index. We search the name-vector and use the index
145
//for m_scint_adc and m_scint_tdc
146
unsigned
NtupleVectorIndex;
147
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nScint; NtupleVectorIndex++)
148
if
(name==
m_scint_names
[NtupleVectorIndex]) {
149
// log << MSG::DEBUG << "Scintillator '" << name << "' not found." << endmsg;
150
break
;
151
}
152
if
(NtupleVectorIndex==nScint) {
153
ATH_MSG_DEBUG
(
"Not found a scint name: "
<<name);
154
continue
;
//Name not found for this event
155
}
156
//Otherwise: Fill nutple
157
(*m_scint_adc)[NtupleVectorIndex] = scint->getSignal();
158
(*m_scint_tdc)[NtupleVectorIndex] = scint->getTimeSignal();
159
}
//end loop over scintillator-container
160
}
161
162
const
TBBPCCont
* bpcc =
nullptr
;
163
sc
=
evtStore
()->retrieve(bpcc,
m_containerKey2
);
164
if
(
sc
.isFailure())
165
{
166
ATH_MSG_ERROR
(
" Cannot read TBBPCCont from StoreGate! key= "
<<
m_containerKey2
);
167
if
(
m_neverReturnFailure
) {
168
return
StatusCode::SUCCESS;
169
}
else
{
170
return
StatusCode::FAILURE;
171
}
172
}
173
else
174
{
175
const
unsigned
nBPCs=
m_bpc_names
.size();
176
m_bpc_x
->reserve(nBPCs);
177
m_bpc_y
->reserve(nBPCs);
178
for
(
const
TBBPC
* bpc : *bpcc) {
179
std::string name = bpc->getDetectorName();
180
unsigned
NtupleVectorIndex;
181
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nBPCs; NtupleVectorIndex++)
182
if
(name==
m_bpc_names
[NtupleVectorIndex])
183
break
;
184
if
(NtupleVectorIndex==nBPCs)
185
continue
;
//Name not found for this event
186
//Otherwise: Fill nutple
187
(*m_bpc_x)[NtupleVectorIndex] = bpc->getXPos();
188
(*m_bpc_y)[NtupleVectorIndex] = bpc->getYPos();
189
}
//end loop over scintillator container
190
}
191
192
if
(
m_bpc_raw
==
true
) {
//bpc raw
193
TBBPCRawCont
* bpccr =
nullptr
;
194
sc
=
evtStore
()->retrieve(bpccr,
m_containerKey3
);
195
if
(
sc
.isFailure()){
196
ATH_MSG_ERROR
(
" Cannot read TBBPCRawCont from StoreGate! key= "
<<
m_containerKey3
);
197
}
else
{
198
const
unsigned
nBPCs=
m_bpc_names
.size();
199
m_bpc_up
->reserve(nBPCs);
200
m_bpc_down
->reserve(nBPCs);
201
m_bpc_right
->reserve(nBPCs);
202
m_bpc_left
->reserve(nBPCs);
203
m_bpc_adc_hor
->reserve(nBPCs);
204
m_bpc_adc_ver
->reserve(nBPCs);
205
for
(
const
TBBPCRaw
* bpcr : *bpccr) {
206
std::string name = bpcr->getDetectorName();
207
unsigned
NtupleVectorIndex;
208
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nBPCs; NtupleVectorIndex++){
209
ATH_MSG_DEBUG
(
" loading 1"
);
210
if
(name==
m_bpc_names
[NtupleVectorIndex]){
211
ATH_MSG_DEBUG
(
" Ntuple Vector"
<<NtupleVectorIndex);
212
(*m_bpc_up)[NtupleVectorIndex] = bpcr->getTDCUp();
213
(*m_bpc_down)[NtupleVectorIndex] = bpcr->getTDCDown();
214
(*m_bpc_right)[NtupleVectorIndex] = bpcr->getTDCRight();
215
(*m_bpc_left)[NtupleVectorIndex] = bpcr->getTDCLeft();
216
(*m_bpc_adc_hor)[NtupleVectorIndex] = bpcr->getADCHorizontal();
217
(*m_bpc_adc_ver)[NtupleVectorIndex] = bpcr->getADCVertical();
218
}
219
}
220
}
221
}
222
}
//bpcraw
223
224
const
TBPhase
* phase =
nullptr
;
225
sc
=
evtStore
()->retrieve(phase,
m_containerKey4
);
226
if
(
sc
.isFailure())
227
{
228
ATH_MSG_ERROR
(
" Cannot read TBPhase from StoreGate! key= "
<<
m_containerKey4
);
229
if
(
m_neverReturnFailure
) {
230
return
StatusCode::SUCCESS;
231
}
else
{
232
return
StatusCode::FAILURE;
233
}
234
}
235
else
236
{
237
m_clock
= phase->getPhase();
238
}
239
240
const
TBTriggerPatternUnit
* trig =
nullptr
;
241
sc
=
evtStore
()->retrieve(trig,
m_containerKey5
);
242
if
(
sc
.isFailure())
243
{
244
ATH_MSG_ERROR
(
" Cannot read TBTriggerPatternUnit from StoreGate! key= "
<<
m_containerKey5
);
245
if
(
m_neverReturnFailure
) {
246
return
StatusCode::SUCCESS;
247
}
else
{
248
return
StatusCode::FAILURE;
249
}
250
}
251
else
252
{
253
m_trig
= trig->
getTriggerWord
();
254
}
255
256
257
//Trigger Array, returns array of triggers with corresponding 0 or 1 for each event
258
259
if
(
m_trig_array
==
true
) {
260
unsigned
int
word =trig->
getTriggerWord
();
261
262
// Checking if objects in triggflag triggered
263
ATH_MSG_DEBUG
(
m_triggflag
.size());
264
m_trig_sel
->reserve(
m_triggflag
.size()+1);
265
for
(
int
unsigned
i=0;i<
m_triggflag
.size()+1;i++){
266
bool
triggbol=0;
267
m_trig_id
=i;
268
triggbol=((word &
m_triggflag
[i])!=0);
269
if
(triggbol){
270
(*m_trig_sel)[i]=1;
271
}
272
}
273
}
274
275
return
StatusCode::SUCCESS;
276
}
277
278
StatusCode
CBNTAA_BeamInstrumentation::CBNT_clear
()
279
{
280
if
(
m_scint_adc
)
281
m_scint_adc
->clear();
282
if
(
m_scint_tdc
)
283
m_scint_tdc
->clear();
284
if
(
m_bpc_x
)
285
m_bpc_x
->clear();
286
if
(
m_bpc_y
)
287
m_bpc_y
->clear();
288
if
(
m_bpc_up
)
289
m_bpc_up
->clear();
290
if
(
m_bpc_down
)
291
m_bpc_down
->clear();
292
if
(
m_bpc_right
)
293
m_bpc_right
->clear();
294
if
(
m_bpc_left
)
295
m_bpc_left
->clear();
296
if
(
m_bpc_adc_ver
)
297
m_bpc_adc_ver
->clear();
298
if
(
m_bpc_adc_hor
)
299
m_bpc_adc_hor
->clear();
300
if
(
m_trig_sel
)
301
m_trig_sel
->clear();
302
303
return
StatusCode::SUCCESS;
304
}
305
306
StatusCode
CBNTAA_BeamInstrumentation::CBNT_finalize
()
307
{
308
ATH_MSG_DEBUG
(
"in finalize()"
);
309
return
StatusCode::SUCCESS;
310
}
311
312
std::string
CBNTAA_BeamInstrumentation::add_name
(
const
char
*
base
,
const
std::string& extension) {
313
std::string retval(
base
);
314
for
(
unsigned
i=0;i<extension.size();i++) {
315
const
char
& ch=extension[i];
316
if
(ch==
'='
|| ch==
':'
|| ch==
'/'
)
317
continue
;
//Inore these characters
318
else
if
(ch==
'-'
)
319
retval.append(
"m"
);
//replace by letter m
320
else
if
(ch==
'+'
)
321
retval.append(
"p"
);
//replace by letter p
322
else
323
retval.append(1,ch);
324
}
325
return
retval;
326
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CBNTAA_BeamInstrumentation.h
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
TBBPCCont.h
TBBPCRawCont.h
TBPhase.h
TBScintillatorCont.h
TBTriggerPatternUnit.h
AthCommonAlgorithm< Gaudi::Algorithm >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CBNTAA_BeamInstrumentation::m_bpc_names
std::vector< std::string > m_bpc_names
Definition
CBNTAA_BeamInstrumentation.h:36
CBNTAA_BeamInstrumentation::m_trig_array
bool m_trig_array
Definition
CBNTAA_BeamInstrumentation.h:48
CBNTAA_BeamInstrumentation::m_containerKey3
std::string m_containerKey3
Definition
CBNTAA_BeamInstrumentation.h:32
CBNTAA_BeamInstrumentation::m_containerKey2
std::string m_containerKey2
Definition
CBNTAA_BeamInstrumentation.h:31
CBNTAA_BeamInstrumentation::m_bpc_raw
bool m_bpc_raw
Definition
CBNTAA_BeamInstrumentation.h:44
CBNTAA_BeamInstrumentation::m_clock
float m_clock
Definition
CBNTAA_BeamInstrumentation.h:41
CBNTAA_BeamInstrumentation::m_bpc_up
std::vector< float > * m_bpc_up
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::m_containerKey1
std::string m_containerKey1
Definition
CBNTAA_BeamInstrumentation.h:30
CBNTAA_BeamInstrumentation::m_bpc_adc_ver
std::vector< float > * m_bpc_adc_ver
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::m_bpc_ntnames
std::vector< std::string > * m_bpc_ntnames
Definition
CBNTAA_BeamInstrumentation.h:38
CBNTAA_BeamInstrumentation::add_name
std::string add_name(const char *base, const std::string &extension)
Definition
CBNTAA_BeamInstrumentation.cxx:312
CBNTAA_BeamInstrumentation::m_bpc_x
std::vector< float > * m_bpc_x
Definition
CBNTAA_BeamInstrumentation.h:39
CBNTAA_BeamInstrumentation::m_triggflag
std::vector< unsigned int > m_triggflag
Definition
CBNTAA_BeamInstrumentation.h:49
CBNTAA_BeamInstrumentation::~CBNTAA_BeamInstrumentation
virtual ~CBNTAA_BeamInstrumentation()
Definition
CBNTAA_BeamInstrumentation.cxx:45
CBNTAA_BeamInstrumentation::m_bpc_down
std::vector< float > * m_bpc_down
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition
CBNTAA_BeamInstrumentation.cxx:306
CBNTAA_BeamInstrumentation::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition
CBNTAA_BeamInstrumentation.cxx:120
CBNTAA_BeamInstrumentation::m_neverReturnFailure
bool m_neverReturnFailure
Definition
CBNTAA_BeamInstrumentation.h:28
CBNTAA_BeamInstrumentation::CBNTAA_BeamInstrumentation
CBNTAA_BeamInstrumentation(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CBNTAA_BeamInstrumentation.cxx:14
CBNTAA_BeamInstrumentation::m_trig_sel
std::vector< long > * m_trig_sel
Definition
CBNTAA_BeamInstrumentation.h:52
CBNTAA_BeamInstrumentation::m_scint_names
std::vector< std::string > m_scint_names
Definition
CBNTAA_BeamInstrumentation.h:35
CBNTAA_BeamInstrumentation::m_scint_tdc
std::vector< float > * m_scint_tdc
Definition
CBNTAA_BeamInstrumentation.h:39
CBNTAA_BeamInstrumentation::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition
CBNTAA_BeamInstrumentation.cxx:71
CBNTAA_BeamInstrumentation::m_bpc_left
std::vector< float > * m_bpc_left
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::m_containerKey5
std::string m_containerKey5
Definition
CBNTAA_BeamInstrumentation.h:34
CBNTAA_BeamInstrumentation::m_bpc_y
std::vector< float > * m_bpc_y
Definition
CBNTAA_BeamInstrumentation.h:39
CBNTAA_BeamInstrumentation::m_containerKey4
std::string m_containerKey4
Definition
CBNTAA_BeamInstrumentation.h:33
CBNTAA_BeamInstrumentation::m_scint_ntnames
std::vector< std::string > * m_scint_ntnames
Definition
CBNTAA_BeamInstrumentation.h:38
CBNTAA_BeamInstrumentation::m_bpc_right
std::vector< float > * m_bpc_right
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::m_bpc_adc_hor
std::vector< float > * m_bpc_adc_hor
Definition
CBNTAA_BeamInstrumentation.h:45
CBNTAA_BeamInstrumentation::m_trig_id
long m_trig_id
Definition
CBNTAA_BeamInstrumentation.h:51
CBNTAA_BeamInstrumentation::m_trig
long m_trig
Definition
CBNTAA_BeamInstrumentation.h:40
CBNTAA_BeamInstrumentation::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition
CBNTAA_BeamInstrumentation.cxx:278
CBNTAA_BeamInstrumentation::m_scint_adc
std::vector< float > * m_scint_adc
Definition
CBNTAA_BeamInstrumentation.h:39
CBNT_TBRecBase::addBranch
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
Definition
CBNT_TBRecBase.h:44
CBNT_TBRecBase::CBNT_TBRecBase
CBNT_TBRecBase(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CBNT_TBRecBase.cxx:12
TBBPCCont
"TBEvent/TBBPCCont.h"
Definition
TBBPCCont.h:17
TBBPCRawCont
"TBEvent/TBBPCRawCont.h"
Definition
TBBPCRawCont.h:17
TBBPCRaw
raw data class for BPC measurement
Definition
TBBPCRaw.h:34
TBBPC
Definition
TBBPC.h:23
TBPhase
Definition
TBPhase.h:22
TBScintillatorCont
"TBEvent/TBScintillatorCont.h"
Definition
TBScintillatorCont.h:19
TBScintillator
Definition
TBScintillator.h:25
TBTriggerPatternUnit
Definition
TBTriggerPatternUnit.h:27
TBTriggerPatternUnit::getTriggerWord
unsigned int getTriggerWord() const
Definition
TBTriggerPatternUnit.h:50
base
std::string base
Definition
hcg.cxx:83
Generated on
for ATLAS Offline Software by
1.17.0