ATLAS Offline Software
LArRDOAnalysis.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 "LArRDOAnalysis.h"
7 #include "StoreGate/ReadHandle.h"
8 
9 #include <format>
10 
12  ATH_MSG_DEBUG( "Initializing LArRDOAnalysis" );
13 
14  // This will check that the properties were initialized
15  // properly by job configuration.
20 
21 
22  m_tree = new TTree(m_ntupleTreeName.value().c_str(), "LArRDOAna");
23  std::string fullNtupleName =std::format("{}{}{}",m_ntupleFileName.value(), m_ntupleDirName.value(),
24  m_ntupleTreeName.value());
25  ATH_CHECK(histSvc()->regTree(fullNtupleName, m_tree));
26  m_tree->Branch("larID", &m_larID);
27  m_tree->Branch("energy", &m_energy);
28  m_tree->Branch("time", &m_time);
29  m_tree->Branch("qual", &m_qual);
30  m_tree->Branch("prov", &m_prov);
31  m_tree->Branch("gain", &m_gain);
32  m_tree->Branch("hadOnID", &m_hadOnID);
33  m_tree->Branch("hadOffID", &m_hadOffID);
34  m_tree->Branch("hadSamples", &m_hadSamples);
35  m_tree->Branch("emOnID", &m_emOnID);
36  m_tree->Branch("emOffID", &m_emOffID);
37  m_tree->Branch("emSamples", &m_emSamples);
38  m_tree->Branch("digiID", &m_digiID);
39  m_tree->Branch("digiGain", &m_digiGain);
40  m_tree->Branch("digiSamples", &m_digiSamples);
41 
42  m_h_larID = new TH1F("h_larID", "LAr ID", 100, 0, 5e18);
43  m_h_larID->StatOverflows();
44  ATH_CHECK(histSvc()->regHist(m_path + m_h_larID->GetName(), m_h_larID));
45 
46  m_h_energy = new TH1F("h_energy", "LAr energy", 100, -1e5, 5e5);
47  m_h_energy->StatOverflows();
48  ATH_CHECK(histSvc()->regHist(m_path + m_h_energy->GetName(), m_h_energy));
49 
50  m_h_time = new TH1F("h_time", "LAr time", 100, -1e7, 1e7);
51  m_h_time->StatOverflows();
52  ATH_CHECK(histSvc()->regHist(m_path + m_h_time->GetName(), m_h_time));
53 
54  m_h_qual = new TH1F("h_qual", "LAr quality", 100, 0, 70000);
55  m_h_qual->StatOverflows();
56  ATH_CHECK(histSvc()->regHist(m_path + m_h_qual->GetName(), m_h_qual));
57 
58  m_h_prov = new TH1F("h_prov", "LAr provenance", 100, 0, 9000);
59  m_h_prov->StatOverflows();
60  ATH_CHECK(histSvc()->regHist(m_path + m_h_prov->GetName(), m_h_prov));
61 
62  m_h_gain = new TH1F("h_gain", "LAr gain", 100, 0, 5);
63  m_h_gain->StatOverflows();
64  ATH_CHECK(histSvc()->regHist(m_path + m_h_gain->GetName(), m_h_gain));
65 
66  m_h_hadOnID = new TH1F("h_hadOnID", "Had LAr TTL1 online ID", 100, 0, 3e19);
67  m_h_hadOnID->StatOverflows();
68  ATH_CHECK(histSvc()->regHist(m_path + m_h_hadOnID->GetName(), m_h_hadOnID));
69 
70  m_h_hadOffID = new TH1F("h_hadOffID", "Had LAr TTL1 offline ID", 100, 0, 3e19);
71  m_h_hadOffID->StatOverflows();
72  ATH_CHECK(histSvc()->regHist(m_path + m_h_hadOffID->GetName(), m_h_hadOffID));
73 
74  m_h_hadSamples = new TH1F("h_hadSamples", "Had LAr TTL1 sample values", 100, -15000, 35000);
75  m_h_hadSamples->StatOverflows();
76  ATH_CHECK(histSvc()->regHist(m_path + m_h_hadSamples->GetName(), m_h_hadSamples));
77 
78  m_h_emOnID = new TH1F("h_emOnID", "EM LAr TTL1 online ID", 100, 0, 3e19);
79  m_h_emOnID->StatOverflows();
80  ATH_CHECK(histSvc()->regHist(m_path + m_h_emOnID->GetName(), m_h_emOnID));
81 
82  m_h_emOffID = new TH1F("h_emOffID", "EM LAr TTL1 offline ID", 100, 0, 3e19);
83  m_h_emOffID->StatOverflows();
84  ATH_CHECK(histSvc()->regHist(m_path + m_h_emOffID->GetName(), m_h_emOffID));
85 
86  m_h_emSamples = new TH1F("h_emSamples", "EM LAr TTL1 sample values", 100, -1e5, 3.5e5);
87  m_h_emSamples->StatOverflows();
88  ATH_CHECK(histSvc()->regHist(m_path + m_h_emSamples->GetName(), m_h_emSamples));
89 
90  m_h_digiID = new TH1F("h_digiID", "LAr digit ID", 100, 0, 5e18);
91  m_h_digiID->StatOverflows();
92  ATH_CHECK(histSvc()->regHist(m_path + m_h_digiID->GetName(), m_h_digiID));
93 
94  m_h_digiGain = new TH1F("h_digiGain", "LAr digit gain", 100, 0, 5);
95  m_h_digiGain->StatOverflows();
96  ATH_CHECK(histSvc()->regHist(m_path + m_h_digiGain->GetName(), m_h_digiGain));
97 
98  m_h_digiSamples = new TH1F("h_digiSamples", "LAr digit sample values", 100, 0, 5000);
99  m_h_digiSamples->StatOverflows();
100  ATH_CHECK(histSvc()->regHist(m_path + m_h_digiSamples->GetName(), m_h_digiSamples));
101 
102  return StatusCode::SUCCESS;
103 }
104 
106  ATH_MSG_DEBUG( "In LArRDOAnalysis::execute()" );
107 
108  m_larID->clear();
109  m_energy->clear();
110  m_time->clear();
111  m_qual->clear();
112  m_prov->clear();
113  m_gain->clear();
114  m_hadOnID->clear();
115  m_hadOffID->clear();
116  m_hadSamples->clear();
117  m_emOnID->clear();
118  m_emOffID->clear();
119  m_emSamples->clear();
120  m_digiID->clear();
121  m_digiGain->clear();
122  m_digiSamples->clear();
123 
124  const EventContext& ctx{Gaudi::Hive::currentContext()};
125  const LArRawChannelContainer* p_larRawCont{nullptr};
126  ATH_CHECK(SG::get(p_larRawCont, m_inputRawChannelKey, ctx));
127 
128  const LArTTL1Container* p_larTTL1Cont_had{nullptr};
129  ATH_CHECK(SG::get(p_larTTL1Cont_had, m_inputTTL1HADKey, ctx));
130 
131  const LArTTL1Container* p_larTTL1Cont_em{nullptr};
132  ATH_CHECK(SG::get(p_larTTL1Cont_em, m_inputTTL1EMKey, ctx));
133 
134  const LArDigitContainer* p_larDigiCont{nullptr};
135  ATH_CHECK(SG::get(p_larDigiCont, m_inputDigitKey, ctx));
136 
137 
138  if (p_larRawCont) {
139  // loop over LAr raw channels container
140  LArRawChannelContainer::const_iterator lar_itr(p_larRawCont->begin());
141  const LArRawChannelContainer::const_iterator lar_end(p_larRawCont->end());
142  for ( ; lar_itr != lar_end; ++lar_itr ) {
143  const HWIdentifier larID(lar_itr->identify());
144  const int rawEnergy(lar_itr->energy());
145  const int rawTime(lar_itr->time());
146  const uint16_t rawQual(lar_itr->quality());
147  const uint16_t rawProv(lar_itr->provenance());
148  CaloGain::CaloGain larGain(lar_itr->gain());
149 
150  const unsigned long long larID_int = larID.get_compact();
151  const int larGain_int = (int)larGain;
152  m_larID->push_back(larID_int);
153  m_energy->push_back(rawEnergy);
154  m_time->push_back(rawTime);
155  m_qual->push_back(rawQual);
156  m_prov->push_back(rawProv);
157  m_gain->push_back(larGain_int);
158 
159  m_h_larID->Fill(larID_int);
160  m_h_energy->Fill(rawEnergy);
161  m_h_time->Fill(rawTime);
162  m_h_qual->Fill(rawQual);
163  m_h_prov->Fill(rawProv);
164  m_h_gain->Fill(larGain_int);
165  }
166  }
167  if (p_larTTL1Cont_had) {
168  LArTTL1Container::const_iterator ttl1Had_itr(p_larTTL1Cont_had->begin());
169  const LArTTL1Container::const_iterator ttl1Had_end(p_larTTL1Cont_had->end());
170  for ( ; ttl1Had_itr != ttl1Had_end; ++ttl1Had_itr ) {
171  const HWIdentifier& hadOnID((*ttl1Had_itr)->ttOnlineID());
172  const Identifier& hadOffID((*ttl1Had_itr)->ttOfflineID());
173  const std::vector<float>& hadSamples = (*ttl1Had_itr)->samples();
174 
175  const unsigned long long hadOnID_int = hadOnID.get_compact();
176  const unsigned long long hadOffID_int = hadOffID.get_compact();
177  m_hadOnID->push_back(hadOnID_int);
178  m_hadOffID->push_back(hadOffID_int);
179  for (std::vector<float>::size_type i = 0; i != hadSamples.size(); ++i) {
180  m_hadSamples->push_back(hadSamples.at(i));
181  m_h_hadSamples->Fill(hadSamples.at(i));
182  }
183 
184  m_h_hadOnID->Fill(hadOnID_int);
185  m_h_hadOffID->Fill(hadOffID_int);
186  }
187  }
188 
189  if (p_larTTL1Cont_em) {
190  LArTTL1Container::const_iterator ttl1EM_itr(p_larTTL1Cont_em->begin());
191  const LArTTL1Container::const_iterator ttl1EM_end(p_larTTL1Cont_em->end());
192  for ( ; ttl1EM_itr != ttl1EM_end; ++ttl1EM_itr ) {
193  const HWIdentifier& emOnID((*ttl1EM_itr)->ttOnlineID());
194  const Identifier& emOffID((*ttl1EM_itr)->ttOfflineID());
195  const std::vector<float>& emSamples((*ttl1EM_itr)->samples());
196 
197  const unsigned long long emOnID_int = emOnID.get_compact();
198  const unsigned long long emOffID_int = emOffID.get_compact();
199  m_emOnID->push_back(emOnID_int);
200  m_emOffID->push_back(emOffID_int);
201  for (std::vector<float>::size_type j = 0; j != emSamples.size(); ++j) {
202  m_emSamples->push_back(emSamples.at(j));
203  m_h_emSamples->Fill(emSamples.at(j));
204  }
205 
206  m_h_emOnID->Fill(emOnID_int);
207  m_h_emOffID->Fill(emOffID_int);
208  }
209  }
210 
211 
212  // LAr Digits
213  if (p_larDigiCont) {
214  LArDigitContainer::const_iterator digi_itr(p_larDigiCont->begin());
215  const LArDigitContainer::const_iterator digi_end(p_larDigiCont->end());
216  for ( ; digi_itr != digi_end; ++digi_itr ) {
217  const HWIdentifier& digiID((*digi_itr)->hardwareID());
218  CaloGain::CaloGain digiGain((*digi_itr)->gain());
219  const std::vector<short>& digiSamples = (*digi_itr)->samples();
220 
221  const unsigned long long digiID_int = digiID.get_compact();
222  const int digiGain_int = (int)digiGain;
223  m_digiID->push_back(digiID_int);
224  m_digiGain->push_back(digiGain_int);
225  for (std::vector<short>::size_type k = 0; k != digiSamples.size(); ++k) {
226  m_digiSamples->push_back(digiSamples.at(k));
227  m_h_digiSamples->Fill(digiSamples.at(k));
228  }
229 
230  m_h_digiID->Fill(digiID_int);
231  m_h_digiGain->Fill(digiGain_int);
232  }
233  }
234 
235 
236  m_tree->Fill();
237 
238  return StatusCode::SUCCESS;
239 }
240 
LArRDOAnalysis::m_gain
std::vector< int > * m_gain
Definition: LArRDOAnalysis.h:46
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
LArRDOAnalysis::m_h_qual
TH1 * m_h_qual
Definition: LArRDOAnalysis.h:63
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArRDOAnalysis::m_hadOnID
std::vector< unsigned long long > * m_hadOnID
Definition: LArRDOAnalysis.h:48
vtune_athena.format
format
Definition: vtune_athena.py:14
LArRDOAnalysis::m_inputTTL1EMKey
SG::ReadHandleKey< LArTTL1Container > m_inputTTL1EMKey
Definition: LArRDOAnalysis.h:30
LArRDOAnalysis::initialize
virtual StatusCode initialize() override final
Definition: LArRDOAnalysis.cxx:11
LArRDOAnalysis::m_h_emOffID
TH1 * m_h_emOffID
Definition: LArRDOAnalysis.h:70
LArRDOAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition: LArRDOAnalysis.h:37
LArRDOAnalysis::m_qual
std::vector< uint16_t > * m_qual
Definition: LArRDOAnalysis.h:44
LArRDOAnalysis::m_h_time
TH1 * m_h_time
Definition: LArRDOAnalysis.h:62
Identifier::get_compact
value_type get_compact() const
Get the compact id.
LArRDOAnalysis::m_time
std::vector< int > * m_time
Definition: LArRDOAnalysis.h:43
LArRDOAnalysis::m_prov
std::vector< uint16_t > * m_prov
Definition: LArRDOAnalysis.h:45
LArRDOAnalysis::m_h_hadOffID
TH1 * m_h_hadOffID
Definition: LArRDOAnalysis.h:67
LArRDOAnalysis::m_hadOffID
std::vector< unsigned long long > * m_hadOffID
Definition: LArRDOAnalysis.h:49
LArRDOAnalysis::m_h_emSamples
TH1 * m_h_emSamples
Definition: LArRDOAnalysis.h:71
HWIdentifier
Definition: HWIdentifier.h:13
LArRDOAnalysis::m_hadSamples
std::vector< float > * m_hadSamples
Definition: LArRDOAnalysis.h:50
LArRDOAnalysis::m_h_emOnID
TH1 * m_h_emOnID
Definition: LArRDOAnalysis.h:69
LArRDOAnalysis::m_h_hadSamples
TH1 * m_h_hadSamples
Definition: LArRDOAnalysis.h:68
LArRDOAnalysis::m_h_digiID
TH1 * m_h_digiID
Definition: LArRDOAnalysis.h:72
LArRDOAnalysis.h
LArRDOAnalysis::m_inputTTL1HADKey
SG::ReadHandleKey< LArTTL1Container > m_inputTTL1HADKey
Definition: LArRDOAnalysis.h:29
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
LArRDOAnalysis::m_emOffID
std::vector< unsigned long long > * m_emOffID
Definition: LArRDOAnalysis.h:52
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArRDOAnalysis::m_h_digiGain
TH1 * m_h_digiGain
Definition: LArRDOAnalysis.h:73
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
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArRDOAnalysis::m_inputRawChannelKey
SG::ReadHandleKey< LArRawChannelContainer > m_inputRawChannelKey
Definition: LArRDOAnalysis.h:28
LArRDOAnalysis::m_larID
std::vector< unsigned long long > * m_larID
Definition: LArRDOAnalysis.h:41
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArRDOAnalysis::m_emOnID
std::vector< unsigned long long > * m_emOnID
Definition: LArRDOAnalysis.h:51
LArRDOAnalysis::m_energy
std::vector< int > * m_energy
Definition: LArRDOAnalysis.h:42
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
LArTTL1Container
Container class for LArTTL1.
Definition: LArTTL1Container.h:24
LArRDOAnalysis::m_tree
TTree * m_tree
Definition: LArRDOAnalysis.h:76
LArRDOAnalysis::execute
virtual StatusCode execute() override final
Definition: LArRDOAnalysis.cxx:105
LArRDOAnalysis::m_ntupleFileName
Gaudi::Property< std::string > m_ntupleFileName
Definition: LArRDOAnalysis.h:34
LArRDOAnalysis::m_h_larID
TH1 * m_h_larID
Definition: LArRDOAnalysis.h:60
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArRDOAnalysis::m_h_energy
TH1 * m_h_energy
Definition: LArRDOAnalysis.h:61
LArRDOAnalysis::m_ntupleDirName
Gaudi::Property< std::string > m_ntupleDirName
Definition: LArRDOAnalysis.h:35
LArRDOAnalysis::m_ntupleTreeName
Gaudi::Property< std::string > m_ntupleTreeName
Definition: LArRDOAnalysis.h:36
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
LArRDOAnalysis::m_inputDigitKey
SG::ReadHandleKey< LArDigitContainer > m_inputDigitKey
Definition: LArRDOAnalysis.h:31
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
LArRDOAnalysis::m_h_digiSamples
TH1 * m_h_digiSamples
Definition: LArRDOAnalysis.h:74
LArRDOAnalysis::m_digiGain
std::vector< int > * m_digiGain
Definition: LArRDOAnalysis.h:56
LArRDOAnalysis::m_h_prov
TH1 * m_h_prov
Definition: LArRDOAnalysis.h:64
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
ReadHandle.h
Handle class for reading from StoreGate.
LArRDOAnalysis::m_h_gain
TH1 * m_h_gain
Definition: LArRDOAnalysis.h:65
LArRDOAnalysis::m_emSamples
std::vector< float > * m_emSamples
Definition: LArRDOAnalysis.h:53
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
LArRDOAnalysis::m_digiSamples
std::vector< short > * m_digiSamples
Definition: LArRDOAnalysis.h:57
LArRDOAnalysis::m_h_hadOnID
TH1 * m_h_hadOnID
Definition: LArRDOAnalysis.h:66
LArRDOAnalysis::m_digiID
std::vector< unsigned long long > * m_digiID
Definition: LArRDOAnalysis.h:55
fitman.k
k
Definition: fitman.py:528
LArRawChannelContainer
Container for LArRawChannel (IDC using LArRawChannelCollection)
Definition: LArRawChannelContainer.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14