ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
BCM_BackgroundAlgs
src
BcmCollisionTimeAlg.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 "
BcmCollisionTimeAlg.h
"
6
7
#include "
AthenaKernel/errorcheck.h
"
8
#include "
BCM_CollisionTime/BcmCollisionTime.h
"
9
#include "Identifier/Identifier.h"
10
11
// Constructor
12
BcmCollisionTimeAlg::BcmCollisionTimeAlg
(
const
std::string& name,
13
ISvcLocator* pSvcLocator)
14
:
AthReentrantAlgorithm
(name, pSvcLocator) {}
15
16
//__________________________________________________________________________
17
// Destructor
18
BcmCollisionTimeAlg::~BcmCollisionTimeAlg
() =
default
;
19
20
//__________________________________________________________________________
21
StatusCode
BcmCollisionTimeAlg::initialize
() {
22
ATH_CHECK
(
m_bcmContainerName
.initialize());
23
ATH_CHECK
(
m_bcmCollisionTimeName
.initialize());
24
return
StatusCode::SUCCESS;
25
}
26
27
StatusCode
BcmCollisionTimeAlg::execute
(
const
EventContext& ctx)
const
{
28
29
ATH_MSG_DEBUG
(
"BcmCollisionTimeAlg execute()"
);
30
31
// declare variables here
32
std::vector<float> deltaT;
33
unsigned
int
multiLG = 0;
34
unsigned
int
multiHG = 0;
35
std::vector<deltat_data> deltaTdataA_HG;
36
std::vector<deltat_data> deltaTdataC_HG;
37
38
SG::ReadHandle<BCM_RDO_Container>
bcmRDO(
m_bcmContainerName
, ctx);
39
if
(!bcmRDO.
isValid
()) {
40
ATH_MSG_WARNING
(
"Cannot find BCM RDO "
<<
m_bcmContainerName
.key()
41
<<
" ! "
);
42
return
StatusCode::SUCCESS;
43
}
else
{
44
int
num_collect = bcmRDO->size();
45
if
(num_collect != 16) {
46
ATH_MSG_WARNING
(
" Number of collections: "
<< num_collect);
47
}
48
int
channelID = 0;
49
50
for
(
const
BCM_RDO_Collection
* chan : *bcmRDO) {
51
channelID = chan->getChannel();
52
53
// Loop over all BCM hits in this collection
54
for
(
const
BCM_RawData
* bcm : *chan) {
55
if
(bcm->getPulse1Width() != 0 && bcm->getLVL1A() == 18) {
56
if
(channelID < 8) {
57
multiLG++;
58
}
else
{
59
multiHG++;
60
}
61
deltat_data
hit
(channelID, bcm->getLVL1A(), bcm->getPulse1Position());
62
if
(channelID > 7 && channelID < 12) {
63
deltaTdataA_HG.push_back(
hit
);
64
}
65
if
(channelID > 11) {
66
deltaTdataC_HG.push_back(
hit
);
67
}
68
69
if
(bcm->getPulse2Width() != 0) {
70
if
(channelID < 8) {
71
multiLG++;
72
}
else
{
73
multiHG++;
74
}
75
deltat_data
hit2(channelID, bcm->getLVL1A(),
76
bcm->getPulse2Position());
77
if
(channelID > 7 && channelID < 12) {
78
deltaTdataA_HG.push_back(hit2);
79
}
80
if
(channelID > 11 && bcm->getPulse2Width() != 0) {
81
deltaTdataC_HG.push_back(hit2);
82
}
83
}
84
}
85
}
// end of loop over raw data
86
}
// end of loop over collections
87
88
// calculate deltaTs from deltatdata now
89
for
(
auto
& i : deltaTdataA_HG) {
90
for
(
auto
& j : deltaTdataC_HG) {
91
if
(i.m_bcid == j.m_bcid) {
92
float
deltaTtime = (
static_cast<
float
>
(i.m_position) -
93
static_cast<
float
>
(j.m_position)) /
94
64 * 25;
95
deltaT.push_back(deltaTtime);
96
}
97
}
98
}
99
}
100
101
SG::WriteHandle<BcmCollisionTime>
bbw(
m_bcmCollisionTimeName
, ctx);
102
if
(bbw.
record
(std::make_unique<BcmCollisionTime>(multiLG, multiHG, deltaT))
103
.isFailure()) {
104
ATH_MSG_WARNING
(
" Cannot record BcmCollisionTime "
);
105
return
StatusCode::FAILURE;
106
}
107
return
StatusCode::SUCCESS;
108
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
BcmCollisionTimeAlg.h
BcmCollisionTime.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
BCM_RDO_Collection
Definition
BCM_RDO_Collection.h:27
BCM_RawData
Definition
BCM_RawData.h:36
BcmCollisionTimeAlg::m_bcmContainerName
SG::ReadHandleKey< BCM_RDO_Container > m_bcmContainerName
Definition
BcmCollisionTimeAlg.h:32
BcmCollisionTimeAlg::m_bcmCollisionTimeName
SG::WriteHandleKey< BcmCollisionTime > m_bcmCollisionTimeName
Definition
BcmCollisionTimeAlg.h:34
BcmCollisionTimeAlg::~BcmCollisionTimeAlg
virtual ~BcmCollisionTimeAlg()
Default Destructor.
BcmCollisionTimeAlg::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition
BcmCollisionTimeAlg.cxx:21
BcmCollisionTimeAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
standard Athena-Algorithm method
Definition
BcmCollisionTimeAlg.cxx:27
BcmCollisionTimeAlg::BcmCollisionTimeAlg
BcmCollisionTimeAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition
BcmCollisionTimeAlg.cxx:12
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
deltat_data
Definition
BcmCollisionTimeAlg.h:38
Generated on
for ATLAS Offline Software by
1.17.0