ATLAS Offline Software
TestBeam
TBRec
src
CBNTAA_TBScint.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CBNTAA_TBScint.h
"
6
7
#include "
LArG4TBSimEvent/LArG4H6FrontHitCollection.h
"
8
#include <fstream>
9
#include <string>
10
#include "
PathResolver/PathResolver.h
"
11
12
13
CBNTAA_TBScint::CBNTAA_TBScint
(
const
std::string &
name
, ISvcLocator * pSvcLocator) :
CBNT_TBRecBase
(
name
, pSvcLocator),m_scint_num(0),m_scint_en(0),m_scint_trackid(0),m_scint_pdg(0) {
14
}
15
16
StatusCode
CBNTAA_TBScint::CBNT_initialize
() {
17
ATH_MSG_DEBUG
(
"in initialize()"
);
18
19
// Add scint parameters
20
addBranch
(
"bm_scint_num"
,
m_scint_num
);
21
addBranch
(
"bm_scint_en"
,
m_scint_en
);
22
addBranch
(
"bm_scint_trackid"
,
m_scint_trackid
);
23
addBranch
(
"bm_scint_pdg"
,
m_scint_pdg
);
24
25
return
StatusCode::SUCCESS;
26
}
27
28
StatusCode
CBNTAA_TBScint::CBNT_execute
() {
29
ATH_MSG_DEBUG
(
"in execute()"
);
30
31
double
edep;
32
int
scnum, pcode, trid;
33
unsigned
i
;
34
35
// Get scint. hits
36
const
LArG4H6FrontHitCollection
*frontcoll =
nullptr
;
37
const
LArG4H6FrontHitCollection
*movecoll =
nullptr
;
38
StatusCode
sc
=
evtStore
()->retrieve(frontcoll,
"Front::Hits"
);
39
if
(
sc
.isSuccess()){
40
for
(
const
LArG4H6FrontHit
* hit : *frontcoll) {
41
scnum = hit->GetSC();
42
if
(scnum <= 0)
continue
;
// not a scintilator hit
43
edep = hit->GetEdep();
44
pcode = hit->GetPcode();
45
trid = hit->GetTrackID();
46
// Check if we have already such combination
47
for
(
i
=0;
i
<
m_scint_num
->size(); ++
i
){
48
if
( (scnum == (*
m_scint_num
)[
i
]) && (pcode == (*
m_scint_pdg
)[
i
]) &&
49
(trid == (*
m_scint_trackid
)[
i
]) ) {
//add energy
50
51
(*m_scint_en)[
i
] += edep;
52
break
;
53
}
54
}
55
if
(
i
==
m_scint_num
->size()) {
// new combination
56
m_scint_num
->push_back(scnum);
57
m_scint_pdg
->push_back(pcode);
58
m_scint_trackid
->push_back(trid);
59
m_scint_en
->push_back(edep);
60
}
61
}
62
}
else
{
63
ATH_MSG_WARNING
(
"Retrieval of Front Hits failed..."
);
64
return
StatusCode::FAILURE;
65
}
66
67
sc
=
evtStore
()->retrieve(movecoll,
"Movable::Hits"
);
68
if
(
sc
.isSuccess()){
69
for
(
const
LArG4H6FrontHit
* hit : *movecoll) {
70
scnum = hit->GetSC();
71
if
(scnum <= 0)
continue
;
// not a scintilator hit
72
edep = hit->GetEdep();
73
pcode = hit->GetPcode();
74
trid = hit->GetTrackID();
75
// Check if we have already such combination
76
for
(
i
=0;
i
<
m_scint_num
->size(); ++
i
){
77
if
( (scnum == (*
m_scint_num
)[
i
]) && (pcode == (*
m_scint_pdg
)[
i
]) &&
78
(trid == (*
m_scint_trackid
)[
i
]) ) {
//add energy
79
80
(*m_scint_en)[
i
] += edep;
81
break
;
82
}
83
}
84
if
(
i
==
m_scint_num
->size()) {
// new combination
85
m_scint_num
->push_back(scnum);
86
m_scint_pdg
->push_back(pcode);
87
m_scint_trackid
->push_back(trid);
88
m_scint_en
->push_back(edep);
89
}
90
}
91
}
else
{
92
ATH_MSG_WARNING
(
"Retrieval of Movable Hits failed"
);
93
}
94
95
return
StatusCode::SUCCESS;
96
}
97
98
StatusCode
CBNTAA_TBScint::CBNT_finalize
() {
99
ATH_MSG_DEBUG
(
"in finalize()"
);
100
return
StatusCode::SUCCESS;
101
}
102
103
104
StatusCode
CBNTAA_TBScint::CBNT_clear
()
105
{
106
if
(
m_scint_num
)
m_scint_num
->clear();
107
if
(
m_scint_en
)
m_scint_en
->clear();
108
if
(
m_scint_trackid
)
m_scint_trackid
->clear();
109
if
(
m_scint_pdg
)
m_scint_pdg
->clear();
110
return
StatusCode::SUCCESS;
111
}
CBNTAA_TBScint::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition:
CBNTAA_TBScint.cxx:104
CBNTAA_TBScint::m_scint_num
std::vector< int > * m_scint_num
Definition:
CBNTAA_TBScint.h:30
AthenaPoolTestRead.sc
sc
Definition:
AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition:
AthCommonDataStore.h:85
CBNT_TBRecBase
Definition:
CBNT_TBRecBase.h:21
lumiFormat.i
int i
Definition:
lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition:
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition:
AthMsgStreamMacros.h:29
CBNT_TBRecBase::addBranch
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
Definition:
CBNT_TBRecBase.h:44
CBNTAA_TBScint::CBNTAA_TBScint
CBNTAA_TBScint(const std::string &name, ISvcLocator *pSvcLocator)
Definition:
CBNTAA_TBScint.cxx:13
CBNTAA_TBScint::m_scint_trackid
std::vector< int > * m_scint_trackid
Definition:
CBNTAA_TBScint.h:32
LArG4H6FrontHitCollection.h
PathResolver.h
name
std::string name
Definition:
Control/AthContainers/Root/debug.cxx:221
CBNTAA_TBScint::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition:
CBNTAA_TBScint.cxx:28
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition:
AthMsgStreamMacros.h:32
CBNTAA_TBScint::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition:
CBNTAA_TBScint.cxx:98
CBNTAA_TBScint::m_scint_pdg
std::vector< int > * m_scint_pdg
Definition:
CBNTAA_TBScint.h:33
LArG4H6FrontHit
Definition:
LArG4H6FrontHit.h:23
CBNTAA_TBScint.h
AthenaHitsVector
Definition:
AthenaHitsVector.h:39
CBNTAA_TBScint::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition:
CBNTAA_TBScint.cxx:16
CBNTAA_TBScint::m_scint_en
std::vector< float > * m_scint_en
Definition:
CBNTAA_TBScint.h:31
Generated on Thu Nov 7 2024 21:11:50 for ATLAS Offline Software by
1.8.18