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