ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBRec
src
CBNT_BeamInstrumentation.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
#include "
CBNT_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
CBNT_BeamInstrumentation::CBNT_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
= 0;
38
m_clock
= 0;
39
m_trig
= 0;
40
m_trig_id
= 0;
41
}
42
43
CBNT_BeamInstrumentation::~CBNT_BeamInstrumentation
()
44
{
//Clean up arrays of ntuple entries (if they have been booked)
45
if
(
m_scint_adc
)
46
delete
[]
m_scint_adc
;
47
if
(
m_scint_tdc
)
48
delete
[]
m_scint_tdc
;
49
if
(
m_bpc_x
)
50
delete
[]
m_bpc_x
;
51
if
(
m_bpc_y
)
52
delete
[]
m_bpc_y
;
53
if
(
m_bpc_up
)
54
delete
[]
m_bpc_up
;
55
if
(
m_bpc_down
)
56
delete
[]
m_bpc_down
;
57
if
(
m_bpc_right
)
58
delete
[]
m_bpc_right
;
59
if
(
m_bpc_left
)
60
delete
[]
m_bpc_left
;
61
if
(
m_bpc_adc_ver
)
62
delete
[]
m_bpc_adc_ver
;
63
if
(
m_bpc_adc_hor
)
64
delete
[]
m_bpc_adc_hor
;
65
}
66
67
StatusCode
CBNT_BeamInstrumentation::CBNT_initialize
()
68
{
69
ATH_MSG_DEBUG
(
"in initialize()"
);
70
71
// NTuple::Tuple* ntuplePtr;
72
// ntuplePtr = this->nt();
73
const
unsigned
nScint=
m_scint_names
.size();
74
m_scint_adc
=
new
float
[nScint];
75
m_scint_tdc
=
new
float
[nScint];
76
for
(
unsigned
i=0;i<nScint;i++) {
77
const
std::string ADCItemName=
add_name
(
"Beam/sADC_"
,
m_scint_names
[i]);
78
const
std::string ADCItemNameDesc = ADCItemName +
"/F"
;
79
// sc=ntuplePtr->addItem(ADCItemName,m_scint_adc[i],0,4095);
80
addBranch
(ADCItemName,
m_scint_adc
[i],ADCItemNameDesc);
81
const
std::string TDCItemName=
add_name
(
"Beam/sTDC_"
,
m_scint_names
[i]);
82
const
std::string TDCItemNameDesc=TDCItemName+
"/F"
;
83
// sc=ntuplePtr->addItem(TDCItemName,m_scint_tdc[i],0,4095);
84
addBranch
(TDCItemName,
m_scint_tdc
[i],TDCItemNameDesc);
85
}
86
87
const
unsigned
nBPCs=
m_bpc_names
.size();
88
m_bpc_x
=
new
float
[nBPCs];
89
m_bpc_y
=
new
float
[nBPCs];
90
for
(
unsigned
i=0;i<nBPCs;i++) {
91
const
std::string BPCxItemName=
add_name
(
"Beam/bpcX_"
,
m_bpc_names
[i]);
92
const
std::string BPCxItemNameDesc=BPCxItemName+
"/F"
;
93
// sc = ntuplePtr->addItem (BPCxItemName,m_bpc_x[i],-150,150);
94
addBranch
(BPCxItemName,
m_bpc_x
[i],BPCxItemNameDesc);
95
const
std::string BPCyItemName=
add_name
(
"Beam/bpcY_"
,
m_bpc_names
[i]);
96
const
std::string BPCyItemNameDesc=BPCyItemName+
"/F"
;
97
addBranch
(BPCyItemName,
m_bpc_y
[i],BPCyItemNameDesc);
98
}
99
100
// BPC RAW, set to false by default
101
if
(
m_bpc_raw
==
true
) {
// bpc raw
102
103
m_bpc_up
=
new
float
[nBPCs];
104
m_bpc_down
=
new
float
[nBPCs];
105
m_bpc_left
=
new
float
[nBPCs];
106
m_bpc_right
=
new
float
[nBPCs];
107
m_bpc_adc_hor
=
new
float
[nBPCs];
108
m_bpc_adc_ver
=
new
float
[nBPCs];
109
110
for
(
unsigned
i=0;i<nBPCs;i++) {
111
const
std::string BPCupItemName=
add_name
(
"Beam/bpcUp_"
,
m_bpc_names
[i]);
112
const
std::string BPCupItemNameDesc=BPCupItemName+
"/F"
;
113
// sc = ntuplePtr->addItem(BPCupItemName,m_bpc_up[i],0,2056);
114
addBranch
(BPCupItemName,
m_bpc_up
[i],BPCupItemNameDesc);
115
const
std::string BPCdownItemName=
add_name
(
"Beam/bpcDown_"
,
m_bpc_names
[i]);
116
const
std::string BPCdownItemNameDesc=BPCdownItemName+
"/F"
;
117
addBranch
(BPCdownItemName,
m_bpc_down
[i],BPCdownItemNameDesc);
118
const
std::string BPCrightItemName=
add_name
(
"Beam/bpcRight_"
,
m_bpc_names
[i]);
119
const
std::string BPCrightItemNameDesc=BPCrightItemName+
"/F"
;
120
addBranch
(BPCrightItemName,
m_bpc_right
[i],BPCrightItemNameDesc);
121
const
std::string BPCleftItemName=
add_name
(
"Beam/bpcLeft_"
,
m_bpc_names
[i]);
122
const
std::string BPCleftItemNameDesc=BPCleftItemName+
"/F"
;
123
addBranch
(BPCleftItemName,
m_bpc_left
[i],BPCleftItemNameDesc);
124
const
std::string BPChorItemName=
add_name
(
"Beam/bpcADCHor_"
,
m_bpc_names
[i]);
125
const
std::string BPChorItemNameDesc=BPChorItemName+
"/F"
;
126
addBranch
(BPChorItemName,
m_bpc_adc_hor
[i],BPChorItemNameDesc);
127
const
std::string BPCverItemName=
add_name
(
"Beam/bpcADCVer_"
,
m_bpc_names
[i]);
128
const
std::string BPCverItemNameDesc=BPCverItemName+
"/F"
;
129
addBranch
(BPCverItemName,
m_bpc_adc_ver
[i],BPCverItemNameDesc);
130
}
131
}
//bpcraw
132
133
// sc = ntuplePtr->addItem ("Beam/Trigger",m_trig, 0, 20);
134
addBranch
(
"Beam/Trigger"
,
m_trig
,
"Trigger/I"
);
135
// trigger array
136
ATH_MSG_DEBUG
(
" m_trig_array"
<<
m_trig_array
);
137
if
(
m_trig_array
==
true
) {
138
139
ATH_MSG_DEBUG
(
" loading array ntuple"
);
140
// sc = ntuplePtr->addItem("Beam/NTrig",m_trig_id,0,50);
141
addBranch
(
"Beam/NTrig"
,
m_trig_id
,
"Ntrig/I"
);
142
143
// sc = ntuplePtr->addItem("Beam/Trig_Array",m_trig_id,m_trig_sel);
144
addBranch
(
"Beam/Trig_Array"
,
m_trig_sel
);
145
}
146
147
// sc = ntuplePtr->addItem ("Beam/Clock",m_clock, 0, 10000);
148
addBranch
(
"Beam/Clock"
,
m_clock
,
"Clock/F"
);
149
return
StatusCode::SUCCESS;
150
151
}
152
153
StatusCode
CBNT_BeamInstrumentation::CBNT_execute
()
154
{
155
ATH_MSG_DEBUG
(
"in execute()"
);
156
157
const
TBScintillatorCont
* scintc =
nullptr
;
158
StatusCode
sc
=
evtStore
()->retrieve(scintc,
m_containerKey1
);
159
if
(
sc
.isFailure())
160
{
161
ATH_MSG_ERROR
(
" Cannot read TBScintillatorCont from StoreGate! key= "
<<
m_containerKey1
);
162
if
(
m_neverReturnFailure
) {
163
return
StatusCode::SUCCESS;
164
}
else
{
165
return
StatusCode::FAILURE;
166
}
167
}
168
else
169
{
170
const
unsigned
nScint=
m_scint_names
.size();
171
for
(
const
TBScintillator
* scint : *scintc) {
172
const
std::string name = scint->getDetectorName();
173
//In the initialize method we build the vectors of ntuple-items for ADCs and BPCs that
174
//the same scintillators have the same index. We search the name-vector and use the index
175
//for m_scint_adc and m_scint_tdc
176
unsigned
NtupleVectorIndex;
177
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nScint; NtupleVectorIndex++)
178
if
(name==
m_scint_names
[NtupleVectorIndex]) {
179
// log << MSG::DEBUG << "Scintillator '" << name << "' not found." << endmsg;
180
break
;
181
}
182
if
(NtupleVectorIndex==nScint)
183
continue
;
//Name not found for this event
184
//Otherwise: Fill nutple
185
m_scint_adc
[NtupleVectorIndex] = scint->getSignal();
186
m_scint_tdc
[NtupleVectorIndex] = scint->getTimeSignal();
187
}
//end loop over scintillator-container
188
}
189
190
const
TBBPCCont
* bpcc =
nullptr
;
191
sc
=
evtStore
()->retrieve(bpcc,
m_containerKey2
);
192
if
(
sc
.isFailure())
193
{
194
ATH_MSG_ERROR
(
" Cannot read TBBPCCont from StoreGate! key= "
<<
m_containerKey2
);
195
if
(
m_neverReturnFailure
) {
196
return
StatusCode::SUCCESS;
197
}
else
{
198
return
StatusCode::FAILURE;
199
}
200
}
201
else
202
{
203
const
unsigned
nBPCs=
m_bpc_names
.size();
204
for
(
const
TBBPC
* bpc : *bpcc) {
205
std::string name = bpc->getDetectorName();
206
unsigned
NtupleVectorIndex;
207
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nBPCs; NtupleVectorIndex++)
208
if
(name==
m_bpc_names
[NtupleVectorIndex])
209
break
;
210
if
(NtupleVectorIndex==nBPCs)
211
continue
;
//Name not found for this event
212
//Otherwise: Fill nutple
213
m_bpc_x
[NtupleVectorIndex] = bpc->getXPos();
214
m_bpc_y
[NtupleVectorIndex] = bpc->getYPos();
215
}
//end loop over scintillator container
216
}
217
218
if
(
m_bpc_raw
==
true
) {
//bpc raw
219
TBBPCRawCont
* bpccr =
nullptr
;
220
sc
=
evtStore
()->retrieve(bpccr,
m_containerKey3
);
221
if
(
sc
.isFailure()){
222
ATH_MSG_ERROR
(
" Cannot read TBBPCRawCont from StoreGate! key= "
<<
m_containerKey3
);
223
}
else
{
224
const
unsigned
nBPCs=
m_bpc_names
.size();
225
for
(
const
TBBPCRaw
* bpcr : *bpccr) {
226
std::string name = bpcr->getDetectorName();
227
unsigned
NtupleVectorIndex;
228
for
( NtupleVectorIndex=0; NtupleVectorIndex!=nBPCs; NtupleVectorIndex++){
229
ATH_MSG_DEBUG
(
" loading 1"
);
230
if
(name==
m_bpc_names
[NtupleVectorIndex]){
231
ATH_MSG_DEBUG
(
" Ntuple Vector"
<<NtupleVectorIndex);
232
m_bpc_up
[NtupleVectorIndex] = bpcr->getTDCUp();
233
m_bpc_down
[NtupleVectorIndex] = bpcr->getTDCDown();
234
m_bpc_right
[NtupleVectorIndex] = bpcr->getTDCRight();
235
m_bpc_left
[NtupleVectorIndex] = bpcr->getTDCLeft();
236
m_bpc_adc_hor
[NtupleVectorIndex] = bpcr->getADCHorizontal();
237
m_bpc_adc_ver
[NtupleVectorIndex] = bpcr->getADCVertical();
238
}
239
}
240
}
241
}
242
}
//bpcraw
243
244
const
TBPhase
* phase =
nullptr
;
245
sc
=
evtStore
()->retrieve(phase,
m_containerKey4
);
246
if
(
sc
.isFailure())
247
{
248
ATH_MSG_ERROR
(
" Cannot read TBPhase from StoreGate! key= "
<<
m_containerKey4
);
249
if
(
m_neverReturnFailure
) {
250
return
StatusCode::SUCCESS;
251
}
else
{
252
return
StatusCode::FAILURE;
253
}
254
}
255
else
256
{
257
m_clock
= phase->getPhase();
258
}
259
260
const
TBTriggerPatternUnit
* trig =
nullptr
;
261
sc
=
evtStore
()->retrieve(trig,
m_containerKey5
);
262
if
(
sc
.isFailure())
263
{
264
ATH_MSG_ERROR
(
" Cannot read TBTriggerPatternUnit from StoreGate! key= "
<<
m_containerKey5
);
265
if
(
m_neverReturnFailure
) {
266
return
StatusCode::SUCCESS;
267
}
else
{
268
return
StatusCode::FAILURE;
269
}
270
}
271
else
272
{
273
m_trig
= trig->
getTriggerWord
();
274
}
275
276
277
//Trigger Array, returns array of triggers with corresponding 0 or 1 for each event
278
279
if
(
m_trig_array
==
true
) {
280
unsigned
int
word =trig->
getTriggerWord
();
281
282
// Checking if objects in triggflag triggered
283
ATH_MSG_DEBUG
(
m_triggflag
.size());
284
285
m_trig_sel
->reserve(
m_triggflag
.size()+1);
286
for
(
int
unsigned
i=0;i<
m_triggflag
.size()+1;i++){
287
bool
triggbol=0;
288
m_trig_id
=i;
289
triggbol=((word &
m_triggflag
[i])!=0);
290
if
(triggbol){
291
(*m_trig_sel)[i]=1;
292
}
293
}
294
}
295
296
return
StatusCode::SUCCESS;
297
}
298
299
StatusCode
CBNT_BeamInstrumentation::CBNT_finalize
()
300
{
301
ATH_MSG_DEBUG
(
"in finalize()"
);
302
return
StatusCode::SUCCESS;
303
}
304
305
std::string
CBNT_BeamInstrumentation::add_name
(
const
char
*
base
,
const
std::string& extension) {
306
std::string retval(
base
);
307
for
(
unsigned
i=0;i<extension.size();i++) {
308
const
char
& ch=extension[i];
309
if
(ch==
'='
|| ch==
':'
|| ch==
'/'
)
310
continue
;
//Inore these characters
311
else
if
(ch==
'-'
)
312
retval.append(
"m"
);
//replace by letter m
313
else
if
(ch==
'+'
)
314
retval.append(
"p"
);
//replace by letter p
315
else
316
retval.append(1,ch);
317
}
318
return
retval;
319
}
320
321
StatusCode
CBNT_BeamInstrumentation::CBNT_clear
()
322
{
323
if
(
m_trig_sel
)
m_trig_sel
->clear();
324
return
StatusCode::SUCCESS;
325
}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CBNT_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
CBNT_BeamInstrumentation::m_bpc_adc_ver
float * m_bpc_adc_ver
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition
CBNT_BeamInstrumentation.cxx:67
CBNT_BeamInstrumentation::m_bpc_up
float * m_bpc_up
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::m_bpc_raw
bool m_bpc_raw
Definition
CBNT_BeamInstrumentation.h:42
CBNT_BeamInstrumentation::m_scint_names
std::vector< std::string > m_scint_names
Definition
CBNT_BeamInstrumentation.h:34
CBNT_BeamInstrumentation::m_scint_adc
float * m_scint_adc
Definition
CBNT_BeamInstrumentation.h:37
CBNT_BeamInstrumentation::m_bpc_right
float * m_bpc_right
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::m_bpc_y
float * m_bpc_y
Definition
CBNT_BeamInstrumentation.h:37
CBNT_BeamInstrumentation::m_clock
float m_clock
Definition
CBNT_BeamInstrumentation.h:39
CBNT_BeamInstrumentation::m_bpc_names
std::vector< std::string > m_bpc_names
Definition
CBNT_BeamInstrumentation.h:35
CBNT_BeamInstrumentation::m_containerKey5
std::string m_containerKey5
Definition
CBNT_BeamInstrumentation.h:33
CBNT_BeamInstrumentation::add_name
std::string add_name(const char *base, const std::string &extension)
Definition
CBNT_BeamInstrumentation.cxx:305
CBNT_BeamInstrumentation::m_triggflag
std::vector< unsigned int > m_triggflag
Definition
CBNT_BeamInstrumentation.h:47
CBNT_BeamInstrumentation::m_bpc_x
float * m_bpc_x
Definition
CBNT_BeamInstrumentation.h:37
CBNT_BeamInstrumentation::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition
CBNT_BeamInstrumentation.cxx:299
CBNT_BeamInstrumentation::m_containerKey3
std::string m_containerKey3
Definition
CBNT_BeamInstrumentation.h:31
CBNT_BeamInstrumentation::m_bpc_down
float * m_bpc_down
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition
CBNT_BeamInstrumentation.cxx:321
CBNT_BeamInstrumentation::m_trig
int m_trig
Definition
CBNT_BeamInstrumentation.h:38
CBNT_BeamInstrumentation::m_neverReturnFailure
bool m_neverReturnFailure
Definition
CBNT_BeamInstrumentation.h:27
CBNT_BeamInstrumentation::m_containerKey2
std::string m_containerKey2
Definition
CBNT_BeamInstrumentation.h:30
CBNT_BeamInstrumentation::CBNT_BeamInstrumentation
CBNT_BeamInstrumentation(const std::string &name, ISvcLocator *pSvcLocator)
Definition
CBNT_BeamInstrumentation.cxx:14
CBNT_BeamInstrumentation::m_bpc_left
float * m_bpc_left
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::m_containerKey4
std::string m_containerKey4
Definition
CBNT_BeamInstrumentation.h:32
CBNT_BeamInstrumentation::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition
CBNT_BeamInstrumentation.cxx:153
CBNT_BeamInstrumentation::m_trig_sel
std::vector< long > * m_trig_sel
Definition
CBNT_BeamInstrumentation.h:50
CBNT_BeamInstrumentation::m_trig_array
bool m_trig_array
Definition
CBNT_BeamInstrumentation.h:46
CBNT_BeamInstrumentation::~CBNT_BeamInstrumentation
virtual ~CBNT_BeamInstrumentation()
Definition
CBNT_BeamInstrumentation.cxx:43
CBNT_BeamInstrumentation::m_trig_id
int m_trig_id
Definition
CBNT_BeamInstrumentation.h:49
CBNT_BeamInstrumentation::m_bpc_adc_hor
float * m_bpc_adc_hor
Definition
CBNT_BeamInstrumentation.h:43
CBNT_BeamInstrumentation::m_scint_tdc
float * m_scint_tdc
Definition
CBNT_BeamInstrumentation.h:37
CBNT_BeamInstrumentation::m_containerKey1
std::string m_containerKey1
Definition
CBNT_BeamInstrumentation.h:29
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