ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
9#include "Identifier/Identifier.h"
10
11// Constructor
13 ISvcLocator* pSvcLocator)
14 : AthReentrantAlgorithm(name, pSvcLocator) {}
15
16//__________________________________________________________________________
17// Destructor
19
20//__________________________________________________________________________
22 ATH_CHECK(m_bcmContainerName.initialize());
24 return StatusCode::SUCCESS;
25}
26
27StatusCode 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
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
An algorithm that can be simultaneously executed in multiple threads.
SG::ReadHandleKey< BCM_RDO_Container > m_bcmContainerName
SG::WriteHandleKey< BcmCollisionTime > m_bcmCollisionTimeName
virtual ~BcmCollisionTimeAlg()
Default Destructor.
virtual StatusCode initialize() override
standard Athena-Algorithm method
virtual StatusCode execute(const EventContext &ctx) const override
standard Athena-Algorithm method
BcmCollisionTimeAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.