ATLAS Offline Software
Loading...
Searching...
No Matches
LArCaliWaveBuilder Class Reference

#include <LArCaliWaveBuilder.h>

Inheritance diagram for LArCaliWaveBuilder:
Collaboration diagram for LArCaliWaveBuilder:

Public Member Functions

 LArCaliWaveBuilder (const std::string &name, ISvcLocator *pSvcLocator)
 ~LArCaliWaveBuilder ()
StatusCode initialize ()
StatusCode execute ()
virtual StatusCode stop ()
StatusCode finalize ()
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef std::map< int, LArCaliWaveWaveMap
typedef LArConditionsContainer< WaveMapWaveContainer
typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode executeWithAccumulatedDigits (const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
StatusCode executeWithStandardDigits (const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadCondHandleKey< LArOnOffIdMappingm_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
SG::ReadCondHandleKey< LArOnOffIdMappingm_cablingKeySC {this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}
SG::ReadCondHandleKey< LArCalibLineMappingm_calibMapKey {this,"CalibLineKey","LArCalibLineMap","SG Key of calib. line mapping object"}
SG::ReadCondHandleKey< ILArPedestalm_pedKey {this,"PedestalKey","Pedestal","SG Key of pedestal object"}
bool m_useAccumulatedDigits
std::vector< std::string > m_keylist
std::vector< std::string > m_keylistproperty
std::string m_keyoutput
std::string m_groupingType
WaveContainer m_waves
bool m_pedSub
unsigned m_baseline
bool m_recAll
bool m_isSC
bool m_useDacAndIsPulsedIndex
int m_ADCsatur
bool m_checkEmptyPhases
const LArOnlineID_Basem_onlineID
unsigned m_event_counter
int m_NStep
float m_SamplingPeriod
float m_dt
uint16_t m_fatalFebErrorPattern
int m_usePatt
bool m_useParams
bool m_useParamsSel
int m_NSubStep
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 28 of file LArCaliWaveBuilder.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

◆ WaveContainer

◆ WaveMap

typedef std::map<int, LArCaliWave> LArCaliWaveBuilder::WaveMap
private

Definition at line 56 of file LArCaliWaveBuilder.h.

Constructor & Destructor Documentation

◆ LArCaliWaveBuilder()

LArCaliWaveBuilder::LArCaliWaveBuilder ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 25 of file LArCaliWaveBuilder.cxx.

26 : AthAlgorithm(name, pSvcLocator),
27 m_groupingType("ExtendedFeedThrough"), // SubDetector, Single, FeedThrough
28 m_onlineID(nullptr),
30{
31 declareProperty("UseAccumulatedDigits", m_useAccumulatedDigits=true);
33 declareProperty("KeyOutput", m_keyoutput="LArCaliWave");
34 declareProperty("SubtractPed", m_pedSub=true);
35 declareProperty("NBaseline", m_baseline=1);
36 declareProperty("SamplingPeriod", m_SamplingPeriod=1./(40.08*megahertz));
37 declareProperty("NSteps", m_NStep=24); // Number of Delay Steps. FIXME: Try to get this information for somewhere else
38 declareProperty("ADCsaturation", m_ADCsatur=0) ;
39 declareProperty("GroupingType", m_groupingType);
40 declareProperty("UseDacAndIsPulsedIndex", m_useDacAndIsPulsedIndex=false);
41 declareProperty("CheckEmptyPhases", m_checkEmptyPhases=false);
42 declareProperty("RecAllCells", m_recAll=false);
43 declareProperty("UsePattern", m_usePatt=-1);
44 declareProperty("UseParams", m_useParams=false); // Read LArCalibParams from DetStore ?
45 declareProperty("UseParamsSel", m_useParamsSel=false); // Use LArCalibParams from DetStore for event selection ?
46 declareProperty("isSC", m_isSC=false);
47 declareProperty("NumSubStep", m_NSubStep=1);
48
49
51
53
54}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const LArOnlineID_Base * m_onlineID
std::vector< std::string > m_keylistproperty

◆ ~LArCaliWaveBuilder()

LArCaliWaveBuilder::~LArCaliWaveBuilder ( )
default

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode LArCaliWaveBuilder::execute ( )

Definition at line 119 of file LArCaliWaveBuilder.cxx.

120{
121 // using EvtId
122 const EventContext& ctx = getContext();
123 m_event_counter=ctx.eventID().event_number()+1;// evt. starts from 0
124
125 const LArCalibParams* calibParams = nullptr;
126 const LArCalibLineMapping *clcabling=nullptr;
127 if(m_useParamsSel || m_useParams) { // we have to check in which event we are, reading only ones corresponding
128 // to our pattern
129 ATH_CHECK(detStore()->retrieve(calibParams,"LArCalibParams"));
130 unsigned numPatt=calibParams->getNumberPatterns(HWIdentifier(0));
131
132 unsigned counter=m_event_counter;
134 if (counter % calibParams->NTrigger(HWIdentifier(1007091712)) != 0U) return StatusCode::SUCCESS;
135 }
136
137 counter /= calibParams->NTrigger(HWIdentifier(1007091712));
138 unsigned iDAC;
139 unsigned iDel;
140 for(iDAC=1; iDAC<=calibParams->getNumberDACs(HWIdentifier(0)); ++iDAC) {
141 for(iDel=0; iDel<calibParams->getNumberDelays(HWIdentifier(0)); ++iDel) {
142 if(counter <= m_NSubStep*iDAC*iDel*numPatt + m_NSubStep*m_usePatt && counter > m_NSubStep*iDAC*iDel*numPatt+ m_NSubStep*(m_usePatt-1) ) {
143 break;
144 }
145 }
146 if(iDel<calibParams->getNumberDelays(HWIdentifier(0))) break;
147 }
148 if(iDAC>calibParams->getNumberDACs(HWIdentifier(0))) return StatusCode::SUCCESS;
149
150 ATH_MSG_DEBUG("Good event "<<m_event_counter<<" : "<<counter<<" for pattern " << m_usePatt << " out of " << numPatt << " patterns " << calibParams->NTrigger(HWIdentifier(1007091712)) <<" triggers "<<iDAC<<" iDAC "<<iDel<<" iDel");
151 ATH_MSG_DEBUG("Good event "<<m_NSubStep*iDAC*iDel*numPatt+ m_NSubStep*(m_usePatt-1) <<" : " << m_NSubStep*iDAC*iDel*numPatt + m_NSubStep*m_usePatt);
152
153 SG::ReadCondHandle<LArCalibLineMapping> clHdl{m_calibMapKey, ctx};
154 clcabling =*clHdl;
155 if(!clcabling) {
156 ATH_MSG_WARNING( "Do not have calib line mapping from key " << m_calibMapKey.key() );
157 return StatusCode::FAILURE;
158 }
159
160 }
161
162 if ( m_event_counter < 100 || m_event_counter%100==0 )
163 ATH_MSG_INFO( "Processing event " << m_event_counter );
164
165 if (m_keylist.empty()) {
166 ATH_MSG_ERROR( "Key list is empty! No containers to process!" );
167 return StatusCode::FAILURE;
168 }
169
170
171 // execute() method...
173 return executeWithAccumulatedDigits(calibParams, clcabling);
174 else
175 return executeWithStandardDigits(calibParams, clcabling);
176}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
const ServiceHandle< StoreGateSvc > & detStore() const
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapKey
StatusCode executeWithStandardDigits(const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
std::vector< std::string > m_keylist
StatusCode executeWithAccumulatedDigits(const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
unsigned getNumberDelays(const HWIdentifier calibModuleID) const
unsigned getNumberPatterns(const HWIdentifier calibModuleID) const
unsigned getNumberDACs(const HWIdentifier calibModuleID) const
unsigned NTrigger(const HWIdentifier calibModuleID) const

◆ executeWithAccumulatedDigits()

StatusCode LArCaliWaveBuilder::executeWithAccumulatedDigits ( const LArCalibParams * calibParams,
const LArCalibLineMapping * clcabling )
private

Definition at line 178 of file LArCaliWaveBuilder.cxx.

179{
181
182 const LArAccumulatedCalibDigitContainer* larAccumulatedCalibDigitContainer = nullptr;
183
184 std::vector<std::string>::const_iterator key_it=m_keylist.begin();
185 std::vector<std::string>::const_iterator key_it_e=m_keylist.end();
186 int foundkey = 0;
187 for (;key_it!=key_it_e; ++key_it) { //Loop over all containers that are to be processed (e.g. different gains)
188
189 sc = evtStore()->retrieve(larAccumulatedCalibDigitContainer,*key_it);
190 if (sc.isFailure()) {
191 ATH_MSG_WARNING( "Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << *key_it );
192 if ( (std::next(key_it) == key_it_e) && foundkey==0 ){
193 ATH_MSG_ERROR("None of the provided LArAccumulatedDigitContainer keys could be read");
194 return StatusCode::FAILURE;
195 }else{
196 continue;
197 }
198 }
199 foundkey+=1;
200
201 const LArFebErrorSummary* febErrSum=nullptr;
202 if (evtStore()->contains<LArFebErrorSummary>("LArFebErrorSummary")) {
203 sc=evtStore()->retrieve(febErrSum);
204 if (sc.isFailure()) {
205 ATH_MSG_ERROR( "Failed to retrieve FebErrorSummary object!" );
206 return sc;
207 }
208 }
209 else
210 if (m_event_counter==0)
211 ATH_MSG_WARNING( "No FebErrorSummaryObject found! Feb errors not checked!" );
212
213 HWIdentifier lastFailedFEB(0);
214 LArAccumulatedCalibDigitContainer::const_iterator it=larAccumulatedCalibDigitContainer->begin();
215 LArAccumulatedCalibDigitContainer::const_iterator it_end=larAccumulatedCalibDigitContainer->end();
216
217 if (it == it_end) {
218 ATH_MSG_DEBUG("LArAccumulatedCalibDigitContainer with key=" << *key_it << " is empty ");
219 continue; // at this event LArAccumulatedCalibDigitContainer is empty, do not even try to loop on it...
220 }
221
222 const float delayScale = larAccumulatedCalibDigitContainer->getDelayScale();
223 const float deltaDelay = 25*ns/(delayScale*m_NStep);
224
225 for (;it!=it_end; ++it) { // Loop over all cells
226
227 bool ispulsed=false;
228 if(m_useParams && calibParams && clcabling) { // got LArCalibParams from DetStore
229 const std::vector<HWIdentifier>& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID());
230 for (const HWIdentifier &calibLineHWID : calibLineLeg) {// loop calib lines
231 ispulsed |= calibParams->isPulsed(m_event_counter,calibLineHWID);
232 }
233 } else {
234 ispulsed=(*it)->isPulsed();
235 }
236 if ( (!m_recAll) && !ispulsed ) {
237 ATH_MSG_DEBUG( "Non pulsed cell " << m_onlineID->channel_name((*it)->hardwareID())<<" in evt. "<<m_event_counter );
238 continue; // Check if cell is pulsed
239 }
240 HWIdentifier chid=(*it)->hardwareID();
241 HWIdentifier febid=m_onlineID->feb_Id(chid);
242 if (febErrSum) {
243 const uint16_t febErrs=febErrSum->feb_error(febid);
244 if (febErrs & m_fatalFebErrorPattern) {
245 if (febid!=lastFailedFEB) {
246 lastFailedFEB=febid;
247 ATH_MSG_ERROR( "Event " << m_event_counter << " Feb " << m_onlineID->channel_name(febid)
248 << " reports error(s):" << febErrSum->error_to_string(febErrs) << ". Data ignored." );
249 }
250 continue;
251 }
252 }
253 CaloGain::CaloGain gain=(*it)->gain();
254
255 if (gain<0 || gain>CaloGain::LARNGAIN) {
256 ATH_MSG_ERROR( "Found not-matching gain number ("<< (int)gain <<")" );
257 return StatusCode::FAILURE;
258 }
259
260 // transform sampleSum vector from uint32_t to double
261 std::vector<double> samplesum;
262 std::vector < uint64_t >::const_iterator samplesum_it=(*it)->sampleSum().begin();
263 std::vector < uint64_t >::const_iterator samplesum_it_e=(*it)->sampleSum().end();
264 for (;samplesum_it!=samplesum_it_e; ++samplesum_it)
265 samplesum.push_back((double)(*samplesum_it));
266
267 // transform sample2Sum vector from uint32_t to double
268 std::vector<double> sample2sum;
269 std::vector < uint64_t >::const_iterator sample2sum_it=(*it)->sample2Sum().begin();
270 std::vector < uint64_t >::const_iterator sample2sum_it_e=(*it)->sample2Sum().end();
271 for (;sample2sum_it!=sample2sum_it_e; ++sample2sum_it)
272 sample2sum.push_back((double)(*sample2sum_it));
273
274 WaveMap& waveMap = m_waves.get(chid,gain);
275
276 //make dacPulsed which has dac and four bits of is pulsed info
277 int dacPulsed;
278 float delay = (*it)->delay();
279 int dac=(*it)->DAC();
280 int index;
281 int pulsed=0;
282 if(m_useParams && calibParams && clcabling) { // get LArCalibParams from DetStore
283 const std::vector<HWIdentifier>& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID());
284 if(calibLineLeg.empty()) {
285 ATH_MSG_WARNING("Why do not have calib lines for "<<(*it)->hardwareID()<<" ?");
286 continue;
287 }
288 dac=calibParams->DAC(m_event_counter,calibLineLeg[0]);
289 dacPulsed=dac;
290 delay = calibParams->Delay(m_event_counter,calibLineLeg[0]);
291 for (unsigned i=0; i<calibLineLeg.size(); ++i) {// loop calib lines
292 if(calibParams->isPulsed(m_event_counter,calibLineLeg[i])){
293 ATH_MSG_DEBUG((*it)->hardwareID().get_identifier32().get_compact() << " GR: line pulsed true, line="<<i+1);
294 dacPulsed=(dacPulsed | (0x1 << (15+i+1)));
295 pulsed=(pulsed | (0x1 << (15+i+1)));
296 }
297
298 }
299 } else {
300 dacPulsed=(*it)->DAC();
301 for(int iLine=1;iLine<5;iLine++){
302 if((*it)->isPulsed(iLine)){
303 ATH_MSG_DEBUG((*it)->hardwareID().get_identifier32().get_compact() <<" GRAV: line pulsed true, line="<<iLine);
304 dacPulsed=(dacPulsed | (0x1 << (15+iLine)));
305 pulsed=(pulsed | (0x1 << (15+iLine)));
306 }
307 }
308 }
309
310 if(m_useDacAndIsPulsedIndex){//switch used to turn on the option to have indexs that are DAC and isPulsed info
311 index = dacPulsed;
312 } else {
313 index = dac;
314 }
315
316 ATH_MSG_DEBUG( "Cell " << m_onlineID->channel_name(chid) << " gain: "<<gain );
317 ATH_MSG_DEBUG( "with " << (*it)->sampleSum().size() << " samples " << index << " DAC " << delay << " delay " << dacPulsed << " dacPulsed " << pulsed << " pulsed");
318
319 WaveMap::iterator itm = waveMap.find(index);
320
321 if ( itm == waveMap.end() ) { // A new LArCaliWave is booked
322 LArCaliWave wave(samplesum.size()*m_NStep, m_dt, dac, pulsed, LArWave::meas);
323 itm = (waveMap.insert(WaveMap::value_type(index,wave))).first;
324 ATH_MSG_DEBUG("index: "<<index<<" new wave inserted");
325 }
326 (*itm).second.addAccumulatedEvent(int(std::roundf(delay/deltaDelay)), m_NStep,
327 samplesum, sample2sum, (*it)->nTriggers());
328
329 } //End loop over all cells
330 } //End loop over all containers
331
332 return StatusCode::SUCCESS;
333}
double delay(std::size_t d)
static Double_t sc
LArFebErrorSummary
Definition LArTPCnv.cxx:56
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.
double getDelayScale() const
get the delay Scale
std::map< int, LArCaliWave > WaveMap
const std::vector< HWIdentifier > & calibSlotLine(const HWIdentifier id) const
unsigned Delay(const unsigned event, const HWIdentifier calibLineID) const
bool isPulsed(const unsigned event, const HWIdentifier calibLineID) const
unsigned DAC(const unsigned event, const HWIdentifier calibLineID) const
static std::string error_to_string(uint16_t error)
interpret the error in string
uint16_t feb_error(HWIdentifier febid) const
get error for feb
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
@ LARNGAIN
Definition CaloGain.h:19
str index
Definition DeMoScan.py:362
::StatusCode StatusCode
StatusCode definition for legacy code.
setWord1 uint16_t

◆ executeWithStandardDigits()

StatusCode LArCaliWaveBuilder::executeWithStandardDigits ( const LArCalibParams * calibParams,
const LArCalibLineMapping * clcabling )
private

Definition at line 336 of file LArCaliWaveBuilder.cxx.

337{
339
340 const LArCalibDigitContainer* larCalibDigitContainer = nullptr;
341
342 std::vector<std::string>::const_iterator key_it=m_keylist.begin();
343 std::vector<std::string>::const_iterator key_it_e=m_keylist.end();
344
345 for (;key_it!=key_it_e; ++key_it) { //Loop over all containers that are to be processed (e.g. different gains)
346
347 sc = evtStore()->retrieve(larCalibDigitContainer,*key_it);
348 if (sc.isFailure()) {
349 ATH_MSG_WARNING( "Cannot read LArCalibDigitContainer from StoreGate! key=" << *key_it );
350 continue; // Try next container
351 }
352
353 LArCalibDigitContainer::const_iterator it=larCalibDigitContainer->begin();
354 LArCalibDigitContainer::const_iterator it_end=larCalibDigitContainer->end();
355
356 if (it == it_end) {
357 ATH_MSG_INFO( "LArCalibDigitContainer with key=" << *key_it << " is empty " );
358 continue; // at this event LArCalibDigitContainer is empty, do not even try to loop on it...
359 }
360
361 const float delayScale = larCalibDigitContainer->getDelayScale();
362 const float deltaDelay = 25*ns/(delayScale*m_NStep);
363
364 for (;it!=it_end; ++it) { // Loop over all cells
365
366 bool pulsed=false;
367 int dac = (*it)->DAC();
368 float delay= (*it)->delay();
369 if(m_useParams && calibParams && clcabling) { // get LArCalibParams from DetStore
370 const std::vector<HWIdentifier>& calibLineLeg = clcabling->calibSlotLine((*it)->hardwareID());
371 dac=calibParams->DAC(m_event_counter,calibLineLeg[0]); // assuming all calib. boards configured equally
372 delay = calibParams->Delay(m_event_counter,calibLineLeg[0]);
373 for (const HWIdentifier &calibLineHWID : calibLineLeg) {// loop calib lines
374 pulsed |= calibParams->isPulsed(m_event_counter,calibLineHWID);
375 }
376 } else {
377 pulsed=(*it)->isPulsed();
378 }
379 if ((!m_recAll) && !pulsed ) continue ; // Check if cell is pulsed
380
381 HWIdentifier chid=(*it)->hardwareID();
382 CaloGain::CaloGain gain=(*it)->gain();
383
384 if (gain<0 || gain>CaloGain::LARNGAIN) {
385 ATH_MSG_ERROR( "Found not-matching gain number ("<< (int)gain <<")" );
386 return StatusCode::FAILURE;
387 }
388
389 // transform samples vector from uint32_t to double
390 std::vector<double> samples;
391 for (short sample : (*it)->samples())
392 samples.push_back((double)(sample));
393
394 WaveMap& waveMap = m_waves.get(chid,gain);
395 WaveMap::iterator itm = waveMap.find(dac);
396
397 if ( itm == waveMap.end() ) { // A new LArCaliWave is booked
398 LArCaliWave wave(samples.size()*m_NStep, m_dt, (*it)->DAC(), 0x1, LArWave::meas );
399 itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(),wave))).first;
400 }
401
402 (*itm).second.addEvent((int)roundf(delay/deltaDelay), m_NStep, samples);
403
404 } //End loop over all cells
405 } //End loop over all containers
406
407 return StatusCode::SUCCESS;
408}
double getDelayScale() const
get delay scale

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode LArCaliWaveBuilder::finalize ( )
inline

Definition at line 37 of file LArCaliWaveBuilder.h.

37{return StatusCode::SUCCESS;}

◆ initialize()

StatusCode LArCaliWaveBuilder::initialize ( )

Definition at line 59 of file LArCaliWaveBuilder.cxx.

60{
61 if (m_keylistproperty.empty()) {
62 m_keylistproperty.emplace_back("HIGH");
63 m_keylistproperty.emplace_back("MEDIUM");
64 m_keylistproperty.emplace_back("LOW");
65 }
67
68 //FIXME probably useless because m_wave isn't written anywhere
69 StatusCode sc=m_waves.setGroupingType(m_groupingType,msg());
70 if (sc.isFailure()) {
71 ATH_MSG_ERROR( "Failed to set groupingType for LArCaliWave intermediate object" );
72 return sc;
73 }
74
75 ATH_MSG_INFO( "Initialize intermediate Wave object" );
76 sc=m_waves.initialize();
77 if (sc.isFailure()) {
78 ATH_MSG_ERROR( "Failed initialize LArCaliWave intermediate object" );
79 return sc;
80 }
81
84
85
87 ATH_MSG_INFO( "Empty phases check selected." );
88
89 //Get pedestal from CondStore
90 ATH_CHECK( m_pedKey.initialize(m_pedSub) );
91
92 //Get Online helper from DetStore
93 if ( m_isSC ) {
94 const LArOnline_SuperCellID* ll;
95 ATH_CHECK( detStore()->retrieve(ll, "LArOnline_SuperCellID") );
96 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
97 ATH_MSG_DEBUG(" Found the LArOnline_SuperCellID helper. ");
98 } else { // m_isSC
99 const LArOnlineID* ll;
100 ATH_CHECK( detStore()->retrieve(ll, "LArOnlineID") );
101 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
102 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
103 }
104
105 ATH_CHECK( m_cablingKey.initialize() );
106 ATH_CHECK( m_cablingKeySC.initialize(m_isSC) );
107
108 if(m_usePatt >= 0 && !m_useParamsSel) {
109 ATH_MSG_ERROR("Inconsistent configuration, for UsePattern > 0 the UseParams must be true");
110 return StatusCode::FAILURE;
111 }
112
114
115 return StatusCode::SUCCESS;
116}
MsgStream & msg() const
SG::ReadCondHandleKey< ILArPedestal > m_pedKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
long long ll

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ stop()

StatusCode LArCaliWaveBuilder::stop ( )
virtual

get iterator for all channels for a gain

Definition at line 412 of file LArCaliWaveBuilder.cxx.

413{
414 // Create wave container using feedthru grouping and initialize
415 auto caliWaveContainer = std::make_unique<LArCaliWaveContainer>();
416
417 StatusCode sc=caliWaveContainer->setGroupingType(m_groupingType,msg());
418 if (sc.isFailure()) {
419 ATH_MSG_ERROR( "Failed to set groupingType for LArCaliWaveContainer object" );
420 return sc;
421 }
422
423 ATH_MSG_INFO( "Initialize final Wave object" );
424 sc=caliWaveContainer->initialize();
425 if (sc.isFailure()) {
426 ATH_MSG_ERROR( "Failed initialize LArCaliWaveContainer object" );
427 return sc;
428 }
429
430 const EventContext& ctx = Gaudi::Hive::currentContext();
431 const LArOnOffIdMapping* cabling(nullptr);
432 if( m_isSC ){
433 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKeySC, ctx};
434 cabling = {*cablingHdl};
435 if(!cabling) {
436 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKeySC.key());
437 return StatusCode::FAILURE;
438 }
439
440 }else{
441 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{m_cablingKey, ctx};
442 cabling = {*cablingHdl};
443 if(!cabling) {
444 ATH_MSG_ERROR("Do not have mapping object " << m_cablingKey.key());
445 return StatusCode::FAILURE;
446 }
447 }
448 SG::ReadCondHandle<ILArPedestal> pedHdl{m_pedKey, ctx};
449 const ILArPedestal* larPedestal{*pedHdl};
450 if(m_pedSub && !larPedestal) {
451 ATH_MSG_DEBUG("No pedestal(s) found ");
452 ATH_MSG_INFO( "Using fake (baseline) pedestal subtraction..." );
453 }
454
455 LArWaveHelper wHelper;
456 int NCaliWave=0;
457
458 // Loop over all gains
459 for (unsigned k=0;k<(int)CaloGain::LARNGAIN;k++) {
460
462
464 WaveContainer::ConditionsMapIterator cell_it = m_waves.begin(gain) ;
465 WaveContainer::ConditionsMapIterator cell_it_e = m_waves.end(gain);
466
467 HWIdentifier lastId;
468
469 for (; cell_it!=cell_it_e; ++cell_it) {
470
471
472 // Get id of this cell - use id from first cell in map
473 //
474 // Some accumulations may be empty and we must skip this
475 // cell. WaveContainer has all 128 channels for each FEB
476 // with at least ONE being read out.
477 //
478
479 const HWIdentifier hwId = cell_it.channelId();
480 if ((!m_recAll) && (!cabling->isOnlineConnected(hwId))) {
481
482 //ATH_MSG_INFO( "Skipping disconnected channel: "<<MSG::hex<<hwId<<MSG::dec );
483 continue; //Ignore disconnected channels
484 }
485
486 const WaveMap& waveMap = (*cell_it);
487 if (waveMap.empty()) {
488 ATH_MSG_INFO( "Empty accumulated wave. Last id: " << MSG::hex
489 //<< lastId << " " << emId->show_to_string(lastId) );
490 << lastId << " this id: "<<hwId<<MSG::dec );
491 continue;
492 }
493
494 lastId = hwId; // save previous id for debug printout
495
496 // Get the vector of waves for this chid,gain
497 LArCaliWaveContainer::LArCaliWaves& dacWaves = caliWaveContainer->get(hwId, gain);
498
499 std::map<int, LArCaliWave>::const_iterator dac_it = cell_it->begin();
500 std::map<int, LArCaliWave>::const_iterator dac_it_e = cell_it->end();
501
502 HWIdentifier chid = cell_it.channelId();
503
504 for (; dac_it != dac_it_e; ++dac_it) {
505
506 const LArCaliWave& thisWave = dac_it->second ;
507
508 if (m_checkEmptyPhases) {
509 const std::vector<int>& thisTriggers = thisWave.getTriggers();
510 for (unsigned i=0;i<thisTriggers.size();++i) {
511 if (thisTriggers[i]==0) {
512 ATH_MSG_FATAL( "Empty phase found in channel 0x" << MSG::hex << chid << MSG::dec
513 << "., aborting reconstruction. Sorry." );
514 return StatusCode::FAILURE;
515 }
516 }
517 }
518
519 float pedAve = 0.;
520
521 if ( m_pedSub ) {
522 if ( larPedestal ) {
523 float pedestal = larPedestal->pedestal(chid,gain);
524 if (pedestal <= (1.0+LArElecCalib::ERRORCODE)) {
525 ATH_MSG_DEBUG("No pedestal(s) found for channel 0x" << MSG::hex << chid << MSG::dec);
526 ATH_MSG_INFO( "Using fake (baseline) pedestal subtraction..." );
527 pedAve = wHelper.getBaseline(thisWave,m_baseline) ;
528 } else {
529 pedAve = pedestal;
530 }
531 } else {
532 pedAve = wHelper.getBaseline(thisWave,m_baseline) ;
533 }
534 ATH_MSG_DEBUG("Pedestal for channel 0x" << MSG::hex << chid << MSG::dec << " is = " << pedAve << " ADC");
535 }
536
537 double waveMax = thisWave.getSample( wHelper.getMax(thisWave) ) ;
538 if ( (!m_recAll) && m_ADCsatur>0 && waveMax>=m_ADCsatur ) {
539 ATH_MSG_INFO( "Absolute ADC saturation at DAC = " << thisWave.getDAC() << " ... skip!" ) ;
540 continue ;
541 } else {
542 dacWaves.emplace_back(((thisWave)+(-pedAve)).getWave() ,
543 thisWave.getErrors(),
544 thisWave.getTriggers(),
545 thisWave.getDt(),
546 thisWave.getDAC(),
547 thisWave.getIsPulsedInt(),
548 thisWave.getFlag() );
549
550 NCaliWave++;
551 }
552
553 } // end of loop DACs
554
555 // intermediate map cleanup (save memory)
556 cell_it->clear();
557
558 } //end loop cells
559
560 } //end loop over m_keyList
561
562 ATH_MSG_INFO( " Summary : Number of cells with a CaliWave reconstructed : " << NCaliWave );
563 ATH_MSG_INFO( " Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 " );
564 ATH_MSG_INFO( " Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 " );
565 ATH_MSG_INFO( " Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 " );
566 ATH_MSG_INFO( " Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 " );
567 ATH_MSG_INFO( " Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 " );
568
569 // Record in detector store with key (m_keyoutput)
570 ATH_CHECK( detStore()->record(std::move(caliWaveContainer), m_keyoutput) );
571
572 ATH_MSG_INFO( "LArCaliWaveBuilder has finished." );
573 return StatusCode::SUCCESS;
574}
#define ATH_MSG_FATAL(x)
virtual float pedestal(const HWIdentifier &id, int gain) const =0
int getIsPulsedInt() const
isPulsed value
int getDAC() const
DAC value.
ConditionsMap::iterator ConditionsMapIterator
const std::vector< int > & getTriggers() const
trigger vector
const std::vector< double > & getErrors() const
error vector
double getBaseline(const LArWave &theWave, unsigned nBase) const
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
const double & getSample(const unsigned int i) const
Amplitude per time bin.
Definition LArWave.h:53
const double & getDt() const
delta time
Definition LArWave.h:50
unsigned getFlag() const
flag: ...
Definition LArWave.h:178

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_ADCsatur

int LArCaliWaveBuilder::m_ADCsatur
private

Definition at line 74 of file LArCaliWaveBuilder.h.

◆ m_baseline

unsigned LArCaliWaveBuilder::m_baseline
private

Definition at line 62 of file LArCaliWaveBuilder.h.

◆ m_cablingKey

SG::ReadCondHandleKey<LArOnOffIdMapping> LArCaliWaveBuilder::m_cablingKey {this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"}
private

Definition at line 41 of file LArCaliWaveBuilder.h.

41{this,"CablingKey","LArOnOffIdMap","SG Key of LArOnOffIdMapping object"};

◆ m_cablingKeySC

SG::ReadCondHandleKey<LArOnOffIdMapping> LArCaliWaveBuilder::m_cablingKeySC {this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"}
private

Definition at line 42 of file LArCaliWaveBuilder.h.

42{this,"ScCablingKey","LArOnOffIdMapSC","SG Key of SC LArOnOffIdMapping object"};

◆ m_calibMapKey

SG::ReadCondHandleKey<LArCalibLineMapping> LArCaliWaveBuilder::m_calibMapKey {this,"CalibLineKey","LArCalibLineMap","SG Key of calib. line mapping object"}
private

Definition at line 43 of file LArCaliWaveBuilder.h.

43{this,"CalibLineKey","LArCalibLineMap","SG Key of calib. line mapping object"};

◆ m_checkEmptyPhases

bool LArCaliWaveBuilder::m_checkEmptyPhases
private

Definition at line 77 of file LArCaliWaveBuilder.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_dt

float LArCaliWaveBuilder::m_dt
private

Definition at line 84 of file LArCaliWaveBuilder.h.

◆ m_event_counter

unsigned LArCaliWaveBuilder::m_event_counter
private

Definition at line 81 of file LArCaliWaveBuilder.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_fatalFebErrorPattern

uint16_t LArCaliWaveBuilder::m_fatalFebErrorPattern
private

Definition at line 86 of file LArCaliWaveBuilder.h.

◆ m_groupingType

std::string LArCaliWaveBuilder::m_groupingType
private

Definition at line 53 of file LArCaliWaveBuilder.h.

◆ m_isSC

bool LArCaliWaveBuilder::m_isSC
private

Definition at line 68 of file LArCaliWaveBuilder.h.

◆ m_keylist

std::vector<std::string> LArCaliWaveBuilder::m_keylist
private

Definition at line 50 of file LArCaliWaveBuilder.h.

◆ m_keylistproperty

std::vector<std::string> LArCaliWaveBuilder::m_keylistproperty
private

Definition at line 51 of file LArCaliWaveBuilder.h.

◆ m_keyoutput

std::string LArCaliWaveBuilder::m_keyoutput
private

Definition at line 52 of file LArCaliWaveBuilder.h.

◆ m_NStep

int LArCaliWaveBuilder::m_NStep
private

Definition at line 82 of file LArCaliWaveBuilder.h.

◆ m_NSubStep

int LArCaliWaveBuilder::m_NSubStep
private

Definition at line 91 of file LArCaliWaveBuilder.h.

◆ m_onlineID

const LArOnlineID_Base* LArCaliWaveBuilder::m_onlineID
private

Definition at line 79 of file LArCaliWaveBuilder.h.

◆ m_pedKey

SG::ReadCondHandleKey<ILArPedestal> LArCaliWaveBuilder::m_pedKey {this,"PedestalKey","Pedestal","SG Key of pedestal object"}
private

Definition at line 44 of file LArCaliWaveBuilder.h.

44{this,"PedestalKey","Pedestal","SG Key of pedestal object"};

◆ m_pedSub

bool LArCaliWaveBuilder::m_pedSub
private

Definition at line 61 of file LArCaliWaveBuilder.h.

◆ m_recAll

bool LArCaliWaveBuilder::m_recAll
private

Definition at line 65 of file LArCaliWaveBuilder.h.

◆ m_SamplingPeriod

float LArCaliWaveBuilder::m_SamplingPeriod
private

Definition at line 83 of file LArCaliWaveBuilder.h.

◆ m_useAccumulatedDigits

bool LArCaliWaveBuilder::m_useAccumulatedDigits
private

Definition at line 46 of file LArCaliWaveBuilder.h.

◆ m_useDacAndIsPulsedIndex

bool LArCaliWaveBuilder::m_useDacAndIsPulsedIndex
private

Definition at line 71 of file LArCaliWaveBuilder.h.

◆ m_useParams

bool LArCaliWaveBuilder::m_useParams
private

Definition at line 89 of file LArCaliWaveBuilder.h.

◆ m_useParamsSel

bool LArCaliWaveBuilder::m_useParamsSel
private

Definition at line 90 of file LArCaliWaveBuilder.h.

◆ m_usePatt

int LArCaliWaveBuilder::m_usePatt
private

Definition at line 88 of file LArCaliWaveBuilder.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_waves

WaveContainer LArCaliWaveBuilder::m_waves
private

Definition at line 58 of file LArCaliWaveBuilder.h.


The documentation for this class was generated from the following files: