ATLAS Offline Software
BCM_RDOAnalysis.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include "BCM_RDOAnalysis.h"
7 #include "StoreGate/ReadHandle.h"
8 
10  ATH_MSG_DEBUG( "Initializing BCM_RDOAnalysis" );
11 
12  // This will check that the properties were initialized
13  // properly by job configuration.
16 
17 
18  m_tree = new TTree(m_ntupleTreeName.value().c_str(), "BCM_RDOAna");
19  std::string fullNtupleName = "/" + m_ntupleFileName + "/" + m_ntupleDirName + "/" + m_ntupleTreeName;
20  ATH_CHECK(histSvc()->regTree(fullNtupleName,m_tree));
21  // BCM RDO
22  m_tree->Branch("word1", &m_word1);
23  m_tree->Branch("word2", &m_word2);
24  m_tree->Branch("chan", &m_chan);
25  m_tree->Branch("pulse1Pos", &m_pulse1Pos);
26  m_tree->Branch("pulse1Width", &m_pulse1Width);
27  m_tree->Branch("pulse2Pos", &m_pulse2Pos);
28  m_tree->Branch("pulse2Width", &m_pulse2Width);
29  m_tree->Branch("LVL1A", &m_LVL1A);
30  m_tree->Branch("BCID", &m_BCID);
31  m_tree->Branch("LVL1ID", &m_LVL1ID);
32  m_tree->Branch("err", &m_err);
33  // BCM SDO
34  m_tree->Branch("sdoID", &m_sdoID);
35  m_tree->Branch("sdoWord", &m_sdoWord);
36  m_tree->Branch("barcode", &m_barcode);
37  m_tree->Branch("eventIndex", &m_eventIndex);
38  m_tree->Branch("charge", &m_charge);
39  m_tree->Branch("barcode_vec", &m_barcode_vec);
40  m_tree->Branch("eventIndex_vec", &m_eventIndex_vec);
41  m_tree->Branch("charge_vec", &m_charge_vec);
42 
43  // HISTOGRAMS
44  m_h_word1 = new TH1F("h_word1", "word 1", 100, 0, 4.5e7);
45  m_h_word1->StatOverflows();
46  ATH_CHECK(histSvc()->regHist(m_path + m_h_word1->GetName(), m_h_word1));
47 
48  m_h_word2 = new TH1F("h_word2", "word 2", 100, 0, 10);
49  m_h_word2->StatOverflows();
50  ATH_CHECK(histSvc()->regHist(m_path + m_h_word2->GetName(), m_h_word2));
51 
52  m_h_chan = new TH1F("h_chan", "channel ID", 100, 0, 20);
53  m_h_chan->StatOverflows();
54  ATH_CHECK(histSvc()->regHist(m_path + m_h_chan->GetName(), m_h_chan));
55 
56  m_h_pulse1Pos = new TH1F("h_pulse1Pos", "pulse 1 position", 100, 0, 70);
57  m_h_pulse1Pos->StatOverflows();
58  ATH_CHECK(histSvc()->regHist(m_path + m_h_pulse1Pos->GetName(), m_h_pulse1Pos));
59 
60  m_h_pulse1Width = new TH1F("h_pulse1Width", "pulse 1 width", 100, 0, 30);
61  m_h_pulse1Width->StatOverflows();
62  ATH_CHECK(histSvc()->regHist(m_path + m_h_pulse1Width->GetName(), m_h_pulse1Width));
63 
64  m_h_pulse2Pos = new TH1F("h_pulse2Pos", "pulse 2 position", 100, 0, 70);
65  m_h_pulse2Pos->StatOverflows();
66  ATH_CHECK(histSvc()->regHist(m_path + m_h_pulse2Pos->GetName(), m_h_pulse2Pos));
67 
68  m_h_pulse2Width = new TH1F("h_pulse2Width", "pulse 2 width", 100, 0, 30);
69  m_h_pulse2Width->StatOverflows();
70  ATH_CHECK(histSvc()->regHist(m_path + m_h_pulse2Width->GetName(), m_h_pulse2Width));
71 
72  m_h_sdoID = new TH1F("h_sdoID", "sdoID", 100, 0, 10);
73  m_h_sdoID->StatOverflows();
74  ATH_CHECK(histSvc()->regHist(m_path + m_h_sdoID->GetName(), m_h_sdoID));
75 
76  m_h_sdoWord = new TH1F("h_sdoWord", "sdoWord", 100, 0, 10);
77  m_h_sdoWord->StatOverflows();
78  ATH_CHECK(histSvc()->regHist(m_path + m_h_sdoWord->GetName(), m_h_sdoWord));
79 
80  m_h_barcode = new TH1F("h_barcode", "Barcode (SDO)", 100, 0, 2.2e9);
81  m_h_barcode->StatOverflows();
82  ATH_CHECK(histSvc()->regHist(m_path + m_h_barcode->GetName(), m_h_barcode));
83 
84  m_h_eventIndex = new TH1F("h_eventIndex", "Event index (SDO)", 100, 0, 1000);
85  m_h_eventIndex->StatOverflows();
86  ATH_CHECK(histSvc()->regHist(m_path + m_h_eventIndex->GetName(), m_h_eventIndex));
87 
88  m_h_charge = new TH1F("h_charge", "Charge (SDO)", 100, 0, 10);
89  m_h_charge->StatOverflows();
90  ATH_CHECK(histSvc()->regHist(m_path + m_h_charge->GetName(), m_h_charge));
91 
92  return StatusCode::SUCCESS;
93 
94 }
95 
97  ATH_MSG_DEBUG( "In BCM_RDOAnalysis::execute()" );
98 
99  m_word1->clear();
100  m_word2->clear();
101  m_chan->clear();
102  m_pulse1Pos->clear();
103  m_pulse1Width->clear();
104  m_pulse2Pos->clear();
105  m_pulse2Width->clear();
106  m_LVL1A->clear();
107  m_BCID->clear();
108  m_LVL1ID->clear();
109  m_err->clear();
110  m_sdoID->clear();
111  m_sdoWord->clear();
112  m_barcode->clear();
113  m_eventIndex->clear();
114  m_charge->clear();
115  m_barcode_vec->clear();
116  m_eventIndex_vec->clear();
117  m_charge_vec->clear();
118 
119  // RDO
120  const EventContext& ctx{Gaudi::Hive::currentContext()};
121  const BCM_RDO_Container* p_BCM_RDO_cont{nullptr};
122 
123  ATH_CHECK(SG::get(p_BCM_RDO_cont, m_inputKey, ctx));
124  if(p_BCM_RDO_cont) {
125  // loop over RDO container
126  BCM_RDO_Container::const_iterator rdoCont_itr(p_BCM_RDO_cont->begin());
127  const BCM_RDO_Container::const_iterator rdoCont_end(p_BCM_RDO_cont->end());
128 
129  for ( ; rdoCont_itr != rdoCont_end; ++rdoCont_itr ) {
130  const DataVector<BCM_RawData>* p_BCM_RDO_coll(*rdoCont_itr);
131  DataVector<BCM_RawData>::const_iterator rdo_itr(p_BCM_RDO_coll->begin());
132  const DataVector<BCM_RawData>::const_iterator rdo_end(p_BCM_RDO_coll->end());
133 
134  for ( ; rdo_itr != rdo_end; ++rdo_itr ) {
135  const int word1((*rdo_itr)->getWord1());
136  const int word2((*rdo_itr)->getWord2());
137  const int chan((*rdo_itr)->getChannel());
138  const int pulse1Pos((*rdo_itr)->getPulse1Position());
139  const int pulse1Width((*rdo_itr)->getPulse1Width());
140  const int pulse2Pos((*rdo_itr)->getPulse2Position());
141  const int pulse2Width((*rdo_itr)->getPulse2Width());
142  const int LVL1A((*rdo_itr)->getLVL1A());
143  const int BCID((*rdo_itr)->getBCID());
144  const int LVL1ID((*rdo_itr)->getLVL1ID());
145  const int err((*rdo_itr)->getError());
146 
147  m_word1->push_back(word1);
148  m_word2->push_back(word2);
149  m_chan->push_back(chan);
150  m_pulse1Pos->push_back(pulse1Pos);
151  m_pulse1Width->push_back(pulse1Width);
152  m_pulse2Pos->push_back(pulse2Pos);
153  m_pulse2Width->push_back(pulse2Width);
154  m_LVL1A->push_back(LVL1A);
155  m_BCID->push_back(BCID);
156  m_LVL1ID->push_back(LVL1ID);
157  m_err->push_back(err);
158 
159  m_h_word1->Fill(word1);
160  m_h_word2->Fill(word2);
161  m_h_chan->Fill(chan);
162  m_h_pulse1Pos->Fill(pulse1Pos);
163  m_h_pulse1Width->Fill(pulse1Width);
164  m_h_pulse2Pos->Fill(pulse2Pos);
165  m_h_pulse2Width->Fill(pulse2Width);
166  }
167  }
168  }
169 
170  // SDO
171  const InDetSimDataCollection* simDataMapBCM{nullptr};
172  ATH_CHECK(SG::get(simDataMapBCM, m_inputTruthKey, ctx));
173  if(simDataMapBCM) {
174  // loop over SDO container
175  InDetSimDataCollection::const_iterator sdo_itr(simDataMapBCM->begin());
176  const InDetSimDataCollection::const_iterator sdo_end(simDataMapBCM->end());
177 
178  std::vector<int> barcode_vec;
179  std::vector<int> eventIndex_vec;
180  std::vector<float> charge_vec;
181  for ( ; sdo_itr != sdo_end; ++sdo_itr ) {
182  const Identifier sdoID((*sdo_itr).first);
183  const InDetSimData& sdo((*sdo_itr).second);
184 
185  const unsigned long long sdoID_int = sdoID.get_compact();
186  const int sdoWord(sdo.word());
187 
188  m_sdoID->push_back(sdoID_int);
189  m_sdoWord->push_back(sdoWord);
190 
191  m_h_sdoID->Fill(sdoID_int);
192  m_h_sdoWord->Fill(sdoWord);
193 
194  // loop over deposits
195  const std::vector<InDetSimData::Deposit>& deposits = sdo.getdeposits();
196  std::vector<InDetSimData::Deposit>::const_iterator dep_itr(deposits.begin());
197  const std::vector<InDetSimData::Deposit>::const_iterator dep_end(deposits.end());
198 
199  for ( ; dep_itr != dep_end; ++dep_itr ) {
200  const HepMcParticleLink& particleLink = (*dep_itr).first;
201  const int bar(HepMC::barcode(particleLink)); // FIXME barcode-based
202  const int eventIx(particleLink.eventIndex());
203  const float charge((*dep_itr).second);
204 
205  m_barcode->push_back(bar);
206  m_eventIndex->push_back(eventIx);
207  m_charge->push_back(charge);
208 
209  m_h_barcode->Fill(bar);
210  m_h_eventIndex->Fill(eventIx);
211  m_h_charge->Fill(charge);
212 
213  barcode_vec.push_back(bar);
214  eventIndex_vec.push_back(eventIx);
215  charge_vec.push_back(charge);
216  }
217  m_barcode_vec->push_back(barcode_vec);
218  m_eventIndex_vec->push_back(eventIndex_vec);
219  m_charge_vec->push_back(charge_vec);
220  barcode_vec.clear();
221  eventIndex_vec.clear();
222  charge_vec.clear();
223  }
224  }
225 
226  m_tree->Fill();
227 
228  return StatusCode::SUCCESS;
229 
230 }
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition: AthHistogramAlgorithm.h:113
BCM_RDOAnalysis::m_barcode
std::vector< int > * m_barcode
Definition: BCM_RDOAnalysis.h:56
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
BCM_RDOAnalysis::m_barcode_vec
std::vector< std::vector< int > > * m_barcode_vec
Definition: BCM_RDOAnalysis.h:59
xAOD::word1
word1
Definition: eFexEMRoI_v1.cxx:87
BCM_RDOAnalysis::m_BCID
std::vector< int > * m_BCID
Definition: BCM_RDOAnalysis.h:50
InDetSimData::getdeposits
const std::vector< Deposit > & getdeposits() const
Definition: InDetSimData.h:74
BCM_RDOAnalysis::m_word1
std::vector< int > * m_word1
Definition: BCM_RDOAnalysis.h:42
BCM_RDOAnalysis::m_h_word2
TH1 * m_h_word2
Definition: BCM_RDOAnalysis.h:65
BCM_RDOAnalysis::m_h_word1
TH1 * m_h_word1
Definition: BCM_RDOAnalysis.h:64
BCM_RDOAnalysis::m_LVL1A
std::vector< int > * m_LVL1A
Definition: BCM_RDOAnalysis.h:49
BCM_RDOAnalysis::m_ntupleFileName
Gaudi::Property< std::string > m_ntupleFileName
Definition: BCM_RDOAnalysis.h:36
Identifier::get_compact
value_type get_compact() const
Get the compact id.
BCM_RDOAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition: BCM_RDOAnalysis.h:39
InDetSimDataCollection
Definition: InDetSimDataCollection.h:25
BCM_RDOAnalysis::m_LVL1ID
std::vector< int > * m_LVL1ID
Definition: BCM_RDOAnalysis.h:51
BCM_RDOAnalysis::m_h_sdoWord
TH1 * m_h_sdoWord
Definition: BCM_RDOAnalysis.h:73
BCM_RDOAnalysis::m_word2
std::vector< int > * m_word2
Definition: BCM_RDOAnalysis.h:43
BCM_RDOAnalysis::m_eventIndex
std::vector< int > * m_eventIndex
Definition: BCM_RDOAnalysis.h:57
BCM_RDOAnalysis::m_h_barcode
TH1 * m_h_barcode
Definition: BCM_RDOAnalysis.h:74
PixelByteStreamErrors::BCID
@ BCID
Definition: PixelByteStreamErrors.h:13
BCM_RDOAnalysis::m_inputTruthKey
SG::ReadHandleKey< InDetSimDataCollection > m_inputTruthKey
Definition: BCM_RDOAnalysis.h:33
BCM_RDOAnalysis::m_h_eventIndex
TH1 * m_h_eventIndex
Definition: BCM_RDOAnalysis.h:75
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:183
BCM_RDO_Container
Definition: BCM_RDO_Container.h:27
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
BCM_RDOAnalysis::m_chan
std::vector< int > * m_chan
Definition: BCM_RDOAnalysis.h:44
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_RDOAnalysis::execute
virtual StatusCode execute() override final
Definition: BCM_RDOAnalysis.cxx:96
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
InDetSimData
Definition: InDetSimData.h:42
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
BCM_RDOAnalysis::m_sdoWord
std::vector< int > * m_sdoWord
Definition: BCM_RDOAnalysis.h:55
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
DataVector< BCM_RawData >
BCM_RDOAnalysis::m_eventIndex_vec
std::vector< std::vector< int > > * m_eventIndex_vec
Definition: BCM_RDOAnalysis.h:60
BCM_RDOAnalysis::m_sdoID
std::vector< unsigned long long > * m_sdoID
Definition: BCM_RDOAnalysis.h:54
BCM_RDOAnalysis::m_pulse1Width
std::vector< int > * m_pulse1Width
Definition: BCM_RDOAnalysis.h:46
BCM_RDOAnalysis::m_err
std::vector< int > * m_err
Definition: BCM_RDOAnalysis.h:52
BCM_RDOAnalysis::m_charge
std::vector< float > * m_charge
Definition: BCM_RDOAnalysis.h:58
python.SystemOfUnits.bar
int bar
Definition: SystemOfUnits.py:206
BCM_RDOAnalysis::m_pulse2Pos
std::vector< int > * m_pulse2Pos
Definition: BCM_RDOAnalysis.h:47
BCM_RDOAnalysis::m_h_pulse1Width
TH1 * m_h_pulse1Width
Definition: BCM_RDOAnalysis.h:68
BCM_RDOAnalysis::m_tree
TTree * m_tree
Definition: BCM_RDOAnalysis.h:78
charge
double charge(const T &p)
Definition: AtlasPID.h:991
BCM_RDOAnalysis::m_charge_vec
std::vector< std::vector< float > > * m_charge_vec
Definition: BCM_RDOAnalysis.h:61
BCM_RDOAnalysis::m_h_pulse2Width
TH1 * m_h_pulse2Width
Definition: BCM_RDOAnalysis.h:70
BCM_RDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: BCM_RDOAnalysis.cxx:9
BCM_RDOAnalysis::m_ntupleTreeName
Gaudi::Property< std::string > m_ntupleTreeName
Definition: BCM_RDOAnalysis.h:38
BCM_RDOAnalysis::m_h_pulse1Pos
TH1 * m_h_pulse1Pos
Definition: BCM_RDOAnalysis.h:67
BCM_RDOAnalysis::m_ntupleDirName
Gaudi::Property< std::string > m_ntupleDirName
Definition: BCM_RDOAnalysis.h:37
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
InDetSimData::word
int word() const
Definition: InDetSimData.h:69
BCM_RDOAnalysis::m_h_chan
TH1 * m_h_chan
Definition: BCM_RDOAnalysis.h:66
BCM_RDOAnalysis::m_h_charge
TH1 * m_h_charge
Definition: BCM_RDOAnalysis.h:76
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
BCM_RDOAnalysis::m_pulse2Width
std::vector< int > * m_pulse2Width
Definition: BCM_RDOAnalysis.h:48
BCM_RDOAnalysis::m_pulse1Pos
std::vector< int > * m_pulse1Pos
Definition: BCM_RDOAnalysis.h:45
BCM_RDOAnalysis::m_inputKey
SG::ReadHandleKey< BCM_RDO_Container > m_inputKey
Definition: BCM_RDOAnalysis.h:32
ReadHandle.h
Handle class for reading from StoreGate.
BCM_RDOAnalysis::m_h_sdoID
TH1 * m_h_sdoID
Definition: BCM_RDOAnalysis.h:72
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
BCM_RDOAnalysis::m_h_pulse2Pos
TH1 * m_h_pulse2Pos
Definition: BCM_RDOAnalysis.h:69
PixelByteStreamErrors::LVL1ID
@ LVL1ID
Definition: PixelByteStreamErrors.h:13
BCM_RDOAnalysis.h
Identifier
Definition: IdentifierFieldParser.cxx:14