ATLAS Offline Software
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 
9 #include "Identifier/Identifier.h"
10 
11 // Constructor
13  ISvcLocator* pSvcLocator)
14  : AthReentrantAlgorithm(name, pSvcLocator) {}
15 
16 //__________________________________________________________________________
17 // Destructor
19 
20 //__________________________________________________________________________
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 
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 }
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
BcmCollisionTimeAlg::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: BcmCollisionTimeAlg.cxx:21
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
BcmCollisionTimeAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
standard Athena-Algorithm method
Definition: BcmCollisionTimeAlg.cxx:27
BcmCollisionTimeAlg::~BcmCollisionTimeAlg
virtual ~BcmCollisionTimeAlg()
Default Destructor.
BcmCollisionTimeAlg.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
BcmCollisionTime.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
BcmCollisionTimeAlg::m_bcmContainerName
SG::ReadHandleKey< BCM_RDO_Container > m_bcmContainerName
Definition: BcmCollisionTimeAlg.h:32
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
BCM_RawData
Definition: BCM_RawData.h:36
deltat_data
Definition: InDetGlobalBCMTool.h:142
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
BcmCollisionTimeAlg::BcmCollisionTimeAlg
BcmCollisionTimeAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: BcmCollisionTimeAlg.cxx:12
BcmCollisionTimeAlg::m_bcmCollisionTimeName
SG::WriteHandleKey< BcmCollisionTime > m_bcmCollisionTimeName
Definition: BcmCollisionTimeAlg.h:34
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
BCM_RDO_Collection
Definition: BCM_RDO_Collection.h:27
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.