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

#include <LArPhysWaveShifter.h>

Inheritance diagram for LArPhysWaveShifter:
Collaboration diagram for LArPhysWaveShifter:

Public Member Functions

 ~LArPhysWaveShifter ()
StatusCode initialize ()
StatusCode execute (const EventContext &)
 Execute method.
StatusCode stop ()
StatusCode finalize ()
 AthAlgorithm (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
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

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
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 ServiceHandle< StoreGateSvc > StoreGateSvc_t

Private Member Functions

StatusCode ComputeTimeShiftByFEB (unsigned mode)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const LArOnlineID_Base * m_onlineHelper {nullptr}
StringArrayProperty m_keylist {this, "KeyList", {}}
StringProperty m_keyout {this, "KeyOutput", "LArPhysWave"}
BooleanProperty m_compTimeShiftByFEB {this, "ComputeTimeShiftByFEB", false}
UnsignedIntegerProperty m_modeTimeShiftByFEB {this, "TimeShiftByFEBMode", 3}
StringProperty m_fileTimeShiftByFEB {this, "TimeShiftByFEBDumpFile", "TimeShiftFEB.py"}
BooleanProperty m_dumpTimeShiftByFEB {this, "TimeShiftByFEBDump", false}
LArFEBTimeOffset * m_larFEBTstart {nullptr}
IntegerProperty m_timeShiftByIndex {this, "TimeShiftByIndex", 0}
BooleanProperty m_timeShiftByHelper {this, "TimeShiftByHelper", false}
std::vector< unsigned int > m_TshiftLayer
BooleanProperty m_timeShiftFromPeak {this, "TimeShiftFromPeak", false}
IntegerProperty m_nIndexFromPeak {this, "NindexFromPeak", 0, "Number of data points before the peak"}
IntegerProperty m_nDelays {this, "Ndelays", 24, "Number of Delay steps between two ADC samples"}
IntegerProperty m_nSamplings {this, "Nsamplings", 3, "Number of ADC samples before the peak"}
BooleanProperty m_timeShiftByFEB {this, "TimeShiftByFEB", false}
IntegerProperty m_timeShiftGuardRegion {this, "TimeShiftGuardRegion", 0}
BooleanProperty m_usePhysCaliTdiff {this, "UsePhysCaliTdiff", true}
BooleanProperty m_isSC {this, "isSC", false}
BooleanProperty m_timeShiftOffset {this, "TimeShiftOffset", false}
FloatProperty m_timeShiftOffsetValue {this, "TimeShiftOffsetValue", 0.}
StringProperty m_groupingType {this, "GroupingType", "ExtendedSubDetector"}
StringProperty m_totalShiftsKey {this, "OutputShiftsKey", ""}
StringProperty m_cellByCellShiftsKey {this, "CellByCellShiftsKey", ""}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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 22 of file LArPhysWaveShifter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ~LArPhysWaveShifter()

LArPhysWaveShifter::~LArPhysWaveShifter ( )
default

Member Function Documentation

◆ AthAlgorithm()

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

Constructor.

Definition at line 31 of file AthAlgorithm.cxx.

11 :
12 AthCommonAlgorithm<Gaudi::Algorithm>( name, pSvcLocator )
13{
14 // default cardinality for non-reentrant algorithms
15 setProperty( "Cardinality", 1 ).orThrow("Unable to set property 'Cardinality'", name);
16}
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
AthCommonAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)

◆ ComputeTimeShiftByFEB()

StatusCode LArPhysWaveShifter::ComputeTimeShiftByFEB ( unsigned mode = 2)
private

Definition at line 271 of file LArPhysWaveShifter.cxx.

272{
273 StatusCode sc ;
274
275 LArWaveHelper larWaveHelper;
276
277 // This is to *compute* the smaller time shifts by FEB
278 m_larFEBTstart = new LArFEBTimeOffset();
279 m_larFEBTstart->setDefaultReturnValue(999);
280 if (mode==3) {
281 std::vector<HWIdentifier>::const_iterator it = m_onlineHelper->feb_begin();
282 std::vector<HWIdentifier>::const_iterator it_e = m_onlineHelper->feb_end();
283 for (;it!=it_e;++it)
284 m_larFEBTstart->setTimeOffset(*it,0);
285 }
286
287 // This is a counter to compute the average time shift per FEB
288 LArFEBTimeOffset nChanInFEB;
289 nChanInFEB.setDefaultReturnValue(0);
290
291 // Get the physics waveforms from the detector store
292 const LArPhysWaveContainer* larPhysWaveContainerOld;
293
294 for (const std::string& key : m_keylist) { // Loop over all containers that are to be processed
295
296 sc=detStore()->retrieve(larPhysWaveContainerOld,key);
297 if (sc.isFailure()) {
298 ATH_MSG_INFO( "LArPhysWaveContainer (key=" << key << ") not found in StoreGate" );
299 continue ;
300 }
301 if ( larPhysWaveContainerOld == nullptr ) {
302 ATH_MSG_INFO( "LArPhysWaveContainer (key=" << key << ") is empty" );
303 continue ;
304 }
305
306 ATH_MSG_INFO( "ComputeTimeShiftByFEB(): processing LArPhysWaveContainer from StoreGate, key = " << key );
307
308 for ( unsigned gain = CaloGain::LARHIGHGAIN ; gain < CaloGain::LARNGAIN; gain++ ) { // Loop over all gains
309
310 PhysWaveIt wave_it = larPhysWaveContainerOld->begin(gain);
311 PhysWaveIt wave_it_e = larPhysWaveContainerOld->end(gain);
312
313 if ( wave_it == wave_it_e ) {
314 ATH_MSG_INFO( "ComputeTimeShiftByFEB(): LArPhysWaveContainer (key = " << key << ") has no wave with gain = " << gain );
315 continue; // skip to next gain
316 }
317
318 for ( ; wave_it!=wave_it_e; wave_it++) {
319
320 const LArPhysWave* larPhysWave = &(*wave_it);
321 if ( larPhysWave->isEmpty() ) continue;
322
323 const HWIdentifier chid = wave_it.channelId();
324 const HWIdentifier febid = m_onlineHelper->feb_Id(chid);
325
326 unsigned oldFEBTstart = (unsigned)m_larFEBTstart->TimeOffset(febid);
327 unsigned newFEBTstart = 999;
328 unsigned theChanInFEB = 0;
329 float bindiff = 0.;
330
331 switch (mode) {
332 case 1 :
333 newFEBTstart = (unsigned)larWaveHelper.getStart(*larPhysWave);
334 if ( newFEBTstart < oldFEBTstart ) m_larFEBTstart->setTimeOffset(febid,newFEBTstart);
335 break;
336 case 2:
337 newFEBTstart = (unsigned)(larWaveHelper.getMax(*larPhysWave)-m_nIndexFromPeak);
338 if ( newFEBTstart < oldFEBTstart ) m_larFEBTstart->setTimeOffset(febid,newFEBTstart);
339 break;
340 case 3:
341 bindiff = larWaveHelper.getMax(*larPhysWave)-m_nIndexFromPeak;
342 ATH_MSG_VERBOSE(std::hex << chid << std::dec<< " TimeOffset: "<<bindiff);
343 if(bindiff >0.)
344 newFEBTstart = (unsigned)(bindiff);
345 else
346 newFEBTstart = 0;
347 m_larFEBTstart->setTimeOffset(febid,oldFEBTstart+newFEBTstart); // accumulate offsets per FEB
348 theChanInFEB = static_cast<unsigned>(nChanInFEB.TimeOffset(febid)+1);
349 nChanInFEB.setTimeOffset(febid,theChanInFEB); // increment channel counter;
350 break;
351 default:
352 newFEBTstart = 0;
353 break;
354 }
355
356 } // end loop over cells
357
358 } // end of loop over gains
359
360 } // end loop over all PhysWave containers in m_keylist
361
362 if ( m_larFEBTstart->size()>0) {
363
364 std::vector<HWIdentifier>::const_iterator it = m_onlineHelper->feb_begin();
365 std::vector<HWIdentifier>::const_iterator it_e = m_onlineHelper->feb_end();
366 unsigned int nFeb=0;
367 for (;it!=it_e;++it) {
368 if ( (int)m_larFEBTstart->TimeOffset(*it) != 999 ) {
369 nFeb++;
370 if ( mode==3 && nChanInFEB.TimeOffset(*it) ) { // average time offset
371 float timeoff = m_larFEBTstart->TimeOffset(*it)/nChanInFEB.TimeOffset(*it);
372 m_larFEBTstart->setTimeOffset(*it,timeoff);
373 }
374 ATH_MSG_INFO( nFeb << ". FEB ID 0x" << std::hex << (*it).get_compact() << std::dec
375 << " - Tstart = " << (int)m_larFEBTstart->TimeOffset(*it) ) ;
376
377 } else {
378 m_larFEBTstart->setTimeOffset(*it,0);
379 }
380
381 }
382
383 if ( m_dumpTimeShiftByFEB ) {
384 std::fstream outfile ;
385 outfile.open("TimeShiftFEB.py",std::ios::out) ;
386 outfile << "FakeLArTimeOffset.FEBids = [ " ;
387 it = m_onlineHelper->feb_begin();
388 unsigned i=0;
389 for (;it!=it_e;++it) {
390 outfile << "0x" << std::hex << (*it).get_compact() << std::dec ;
391 i++ ;
392 if ( i<nFeb ) outfile << ", " ;
393 }
394 outfile << " ]" << std::endl ;
395 outfile << "FakeLArTimeOffset.FEbTimeOffsets = [ " ;
396 it = m_onlineHelper->feb_begin();
397 i = 0 ;
398 for (;it!=it_e;++it) {
399 outfile << (int)m_larFEBTstart->TimeOffset(*it) ;
400 i++ ;
401 if ( i<nFeb ) outfile << ", " ;
402 }
403 outfile << " ]" << std::endl ;
404 outfile.close() ;
405 ATH_MSG_INFO( "Minimum Tstart per FEB (all gain) saved in " << m_fileTimeShiftByFEB.value() ) ;
406 }
407
408 } else {
409 return StatusCode::FAILURE;
410 }
411
412 sc=detStore()->record(m_larFEBTstart,"FebTimeOffset");
413 if(sc.isFailure()) {
414 ATH_MSG_ERROR( "Can't record LArFEBTimeOffset to DetectorStore" );
415 return StatusCode::FAILURE;
416 }
417
418 return StatusCode::SUCCESS;
419}
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
static Double_t sc
LArPhysWaveContainer::ConstConditionsMapIterator PhysWaveIt
const ServiceHandle< StoreGateSvc > & detStore() const
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
float TimeOffset(const HWIdentifier fId) const
void setDefaultReturnValue(const float value)
void setTimeOffset(const HWIdentifier fId, const float offset)
StringArrayProperty m_keylist
StringProperty m_fileTimeShiftByFEB
BooleanProperty m_dumpTimeShiftByFEB
const LArOnlineID_Base * m_onlineHelper
IntegerProperty m_nIndexFromPeak
LArFEBTimeOffset * m_larFEBTstart
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
unsigned getStart(const LArWave &theWave) const
bool isEmpty() const
is LArWave uninitialized?
Definition LArWave.h:183
@ LARNGAIN
Definition CaloGain.h:19
@ LARHIGHGAIN
Definition CaloGain.h:18
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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 LArPhysWaveShifter::execute ( const EventContext & ctx)
inlinevirtual

Execute method.

Implements AthAlgorithm.

Definition at line 32 of file LArPhysWaveShifter.h.

32{return StatusCode::SUCCESS;}

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::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 & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ finalize()

StatusCode LArPhysWaveShifter::finalize ( )
inline

Definition at line 34 of file LArPhysWaveShifter.h.

34{return StatusCode::SUCCESS;}

◆ initialize()

StatusCode LArPhysWaveShifter::initialize ( )
inline

Definition at line 31 of file LArPhysWaveShifter.h.

31{return StatusCode::SUCCESS;}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::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.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 47 of file AthAlgorithm.h.

47{ return false; }

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ stop()

StatusCode LArPhysWaveShifter::stop ( )

Definition at line 24 of file LArPhysWaveShifter.cxx.

24 {
25 ATH_MSG_INFO( "... in stop()" ) ;
26
27 LArWaveHelper larWaveHelper;
28
29 // get LArOnlineID helper
30 /*StatusCode sc = detStore()->retrieve(m_onlineHelper, "LArOnlineID");
31 if (sc.isFailure()) {
32 ATH_MSG_ERROR( "Could not get LArOnlineID" );
33 return sc;
34 }*/
36 if ( m_isSC ) {
37 const LArOnline_SuperCellID* ll;
38 sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
39 if (sc.isFailure()) {
40 msg(MSG::ERROR) << "Could not get LArOnlineID helper !" << endmsg;
41 return StatusCode::FAILURE;
42 }
43 else {
44 m_onlineHelper = static_cast<const LArOnlineID_Base*>(ll);
45 ATH_MSG_DEBUG("Found the LArOnlineID helper");
46 }
47 } else { // m_isSC
48 const LArOnlineID* ll;
49 sc = detStore()->retrieve(ll, "LArOnlineID");
50 if (sc.isFailure()) {
51 msg(MSG::ERROR) << "Could not get LArOnlineID helper !" << endmsg;
52 return StatusCode::FAILURE;
53 }
54 else {
55 m_onlineHelper = static_cast<const LArOnlineID_Base*>(ll);
56 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
57 }
58 }
59
60 // Retrieve LArPhysWaveTool
61 ToolHandle<LArPhysWaveTool> larPhysWaveTool("LArPhysWaveTool");
62 sc=larPhysWaveTool.retrieve();
63 if (sc!=StatusCode::SUCCESS) {
64 ATH_MSG_ERROR( " Can't get LArPhysWaveTool " );
65 return sc;
66 }
67
68 // retrieve PhysCaliTdiff
69 const ILArPhysCaliTdiff* larPhysCaliTdiff = nullptr;
71 sc = detStore()->retrieve(larPhysCaliTdiff,m_cellByCellShiftsKey);
72 if (sc!=StatusCode::SUCCESS) {
73 ATH_MSG_WARNING( "Cannot retrieve LArPhysCaliTdiff with key " << m_cellByCellShiftsKey.value()
74 << ". Disabling use of PhysCaliTdiff values in wave shift." );
75 m_usePhysCaliTdiff = false;
76 }else {
77 ATH_MSG_INFO( "LArPhysCaliTdiff successfully retrieved" );
78 }
79 }
80
81 // compute FEB time shifts
85 if(!sc.isSuccess()) {
86 ATH_MSG_ERROR( "Can't compute time shifts by FEB." );
87 return sc;
88 }
89 }
90
91 // apply time shifts
92 if ( m_timeShiftByHelper ) {
93 ATH_MSG_INFO( "Will use helper class for start time." );
95 m_timeShiftFromPeak = false ;
96 m_timeShiftByFEB = false ;
97 }
98
99 if ( m_timeShiftByIndex != 0 ) {
100 ATH_MSG_INFO( "Manually shifting pulses by time index " << m_timeShiftByIndex.value() );
101 m_timeShiftFromPeak = false ;
102 m_timeShiftByFEB = false ;
103 }
104
105 if ( m_timeShiftFromPeak ) {
106 ATH_MSG_INFO( "Manually shifting pulses by a constant index from peak." );
108 m_timeShiftByFEB = false ;
109 }
110
111 if (m_timeShiftOffset) {
112 m_timeShiftOffsetValue = m_timeShiftOffsetValue>0. ? (float)((long)(m_timeShiftOffsetValue+0.5)) : (float)((long)(m_timeShiftOffsetValue-0.5)); // round to nearest signed integer
113 if (m_timeShiftOffsetValue <= -999. || m_timeShiftOffsetValue >= 999.) m_timeShiftOffsetValue = 0.; // avoid clearly nonsense values
114 }
115
116 /*
117 Apply FEB time shifts:
118 - can be conputed in the same job...
119 - ...or simply read from DetStore (and leaded either from DB of jobOption using LArEventTest/FakeLArTimeOffset
120 */
121 const ILArFEBTimeOffset* larFebTshift = nullptr;
122 if ( m_timeShiftByFEB ) {
123 ATH_MSG_INFO( "Manually shifting pulses by *FEB* time indexes." );
124 sc = detStore()->retrieve(larFebTshift);
125 if (sc.isFailure()) {
126 ATH_MSG_ERROR( "Cannot find any FEB time offsets. Please check." );
127 return sc;
128 }
129 }
130
131 //New TPhysCaliTimeDiff Container to store the final shift
132 //LArPhysCaliTdiffComplete* totalShifts=new LArPhysCaliTdiffComplete();
133 auto totalShifts = std::make_unique<LArOFCBinComplete>();
134 if (totalShifts->setGroupingType(m_groupingType,msg()).isFailure()) {
135 ATH_MSG_ERROR( "Failed to set grouping type for LArPhysCaliTdiffComplete object" );
136 return StatusCode::FAILURE;
137 }
138
139 if(totalShifts->initialize().isFailure()) {
140 ATH_MSG_ERROR( "Failed to initialize LArPhysCaliTdiffComplete object" );
141 return StatusCode::FAILURE;
142 }
143
144
145 // Get the physics waveforms from the detector store
146 const LArPhysWaveContainer* larPhysWaveContainerOld;
147
148 int nchannel = 0 ;
149
150 for (const std::string& key : m_keylist) { // Loop over all containers that are to be processed
151
152 sc= detStore()->retrieve(larPhysWaveContainerOld,key);
153 if (sc.isFailure()) {
154 ATH_MSG_INFO( "LArPhysWaveContainer (key=" << key << ") not found in StoreGate" );
155 continue ;
156 }
157 ATH_MSG_INFO( "Processing LArPhysWaveContainer from StoreGate, key = " << key );
158
159 // loop over physwave in 'old' container
160 for ( unsigned gain = CaloGain::LARHIGHGAIN ; gain < CaloGain::LARNGAIN; gain++ ) { // Loop over all gains
161
162 // get iterator for all channels for a gain
163 PhysWaveIt wave_it = larPhysWaveContainerOld->begin(gain);
164 PhysWaveIt wave_it_e = larPhysWaveContainerOld->end(gain);
165
166 if ( wave_it == wave_it_e ) {
167 ATH_MSG_INFO( "LArPhysWaveContainer (key = " << key << ") has no wave with gain = " << gain );
168 continue; // skip to next gain
169 }
170
171 for ( ; wave_it!=wave_it_e; wave_it++) {
172
173 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
174 ATH_MSG_INFO( "Processing physics waveform number " << nchannel );
175 nchannel++ ;
176
177 const LArPhysWave* larPhysWave = &(*wave_it);
178 const HWIdentifier chid = wave_it.channelId();
179
180 if ( larPhysWave->isEmpty() ) {
181 ATH_MSG_VERBOSE("Channel 0x" << MSG::hex << chid.get_compact() << MSG::dec << " is empty. Skipping.");
182 continue;
183 }
184
185 float tstart = 0 ;
186
187 if ( m_timeShiftByHelper ) {
188 tstart = larWaveHelper.getStart(*larPhysWave) ;
190 }
191
192 if ( m_timeShiftByIndex != 0 ) {
194 }
195
196 if ( m_timeShiftFromPeak ) {
197 tstart = larWaveHelper.getMax(*larPhysWave)-m_nIndexFromPeak;
198 }
199
200 if ( m_timeShiftByFEB ) {
201 const HWIdentifier febid = m_onlineHelper->feb_Id(chid);
202 tstart = (int)larFebTshift->TimeOffset(febid);
204 }
205
206 if (m_usePhysCaliTdiff && larPhysCaliTdiff) {
207 float tdiff = larPhysCaliTdiff->Tdiff(chid,gain);
208 if (tdiff<=-999.) tdiff = 0.;
209 tdiff /= (25./24.); // in units of delay steps
210 tdiff = tdiff>0. ? (float)((long)(tdiff+0.5)) : (float)((long)(tdiff-0.5)); // round to nearest signed integer
211 ATH_MSG_VERBOSE("Channel 0x" << MSG::hex << chid.get_compact() << MSG::dec << " -> Tdiff = " << tdiff);
212 tstart -= tdiff; // subtract to tstart (should be used on top of timeShiftByFEB)
213 }
214
215 if (m_timeShiftOffset) {
217 }
218
219 totalShifts->set(chid,gain,(int)(tstart));
220
221 ATH_MSG_VERBOSE("PhysWave n. " << nchannel
222 << " --> Time shift for channel 0x" << MSG::hex << chid.get_compact() << MSG::dec
223 << " is " << tstart << " samples (" << tstart*larPhysWave->getDt() << " ns)");
224
225 /*
226 // apply time shift
227 LArPhysWave newLArPhysWave( (larWaveHelper.translate(*larPhysWave,-tstart,0)).getWave() ,
228 larPhysWave->getDt(),
229 larPhysWave->getFlag() ) ;
230
231
232 // save time shift in new LArPhysWave
233 if ( m_timeShiftByFEB ) {
234 // We save the timeShiftGuardRegion so that, when running
235 // the OFC iteration reconstruction, we can use it in
236 // association to the final phase to compute an absolute
237 // time with respect to the FEB "zero" time, defined as
238 // the peak time of the fastest pulse in the FEB
239 // -- Marco Delmastro and Guillaume Unal, June 2009
240 newLArPhysWave.setTimeOffset(-m_timeShiftGuardRegion);
241 } else {
242 newLArPhysWave.setTimeOffset(tstart);
243 }
244
245 // Add 'new' physics wave to 'new' container
246 larPhysWaveContainerNew->setPdata(chid, newLArPhysWave, gain);
247
248 // Clean the 'old' physics wave from memory (ok, not that elegant, but still...)
249 //LArPhysWave* oldLArPhysWave = const_cast<LArPhysWave*>(larPhysWave);
250 //oldLArPhysWave->clear(); // clear() method is (still) not implemeted on LArWave...
251 */
252 } // end loop over cells
253 } // end of loop over gains
254
255 } // End loop over all PhysWave containers in m_keylist
256
257
258 if (!m_totalShiftsKey.empty()) {
259 sc=detStore()->record(std::move(totalShifts),m_totalShiftsKey);
260 if (sc.isFailure()) {
261 ATH_MSG_ERROR( "Failed to recrod LArPhysCaliTdiffComplete with key " << m_totalShiftsKey.value() );
262 }
263 }
264
265 ATH_MSG_INFO( "LArPhysWaveShifter stopped!" );
266
267 return StatusCode::SUCCESS;
268}
#define endmsg
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
virtual float TimeOffset(const HWIdentifier fId) const =0
virtual const float & Tdiff(const HWIdentifier &id, int gain) const =0
BooleanProperty m_timeShiftOffset
IntegerProperty m_nSamplings
StringProperty m_cellByCellShiftsKey
StatusCode ComputeTimeShiftByFEB(unsigned mode)
BooleanProperty m_timeShiftFromPeak
IntegerProperty m_nDelays
StringProperty m_groupingType
BooleanProperty m_timeShiftByHelper
IntegerProperty m_timeShiftByIndex
BooleanProperty m_isSC
BooleanProperty m_usePhysCaliTdiff
FloatProperty m_timeShiftOffsetValue
BooleanProperty m_timeShiftByFEB
IntegerProperty m_timeShiftGuardRegion
BooleanProperty m_compTimeShiftByFEB
UnsignedIntegerProperty m_modeTimeShiftByFEB
StringProperty m_totalShiftsKey
const double & getDt() const
delta time
Definition LArWave.h:50
long long ll

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::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< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthHistogramAlgorithm, HypoBase, InputMakerBase, and PyAthena::Alg.

Definition at line 60 of file AthCommonAlgorithm.cxx.

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

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }

Member Data Documentation

◆ m_cellByCellShiftsKey

StringProperty LArPhysWaveShifter::m_cellByCellShiftsKey {this, "CellByCellShiftsKey", ""}
private

Definition at line 68 of file LArPhysWaveShifter.h.

68{this, "CellByCellShiftsKey", ""};

◆ m_compTimeShiftByFEB

BooleanProperty LArPhysWaveShifter::m_compTimeShiftByFEB {this, "ComputeTimeShiftByFEB", false}
private

Definition at line 43 of file LArPhysWaveShifter.h.

43{this, "ComputeTimeShiftByFEB", false};

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_dumpTimeShiftByFEB

BooleanProperty LArPhysWaveShifter::m_dumpTimeShiftByFEB {this, "TimeShiftByFEBDump", false}
private

Definition at line 46 of file LArPhysWaveShifter.h.

46{this, "TimeShiftByFEBDump", false};

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_fileTimeShiftByFEB

StringProperty LArPhysWaveShifter::m_fileTimeShiftByFEB {this, "TimeShiftByFEBDumpFile", "TimeShiftFEB.py"}
private

Definition at line 45 of file LArPhysWaveShifter.h.

45{this, "TimeShiftByFEBDumpFile", "TimeShiftFEB.py"};

◆ m_groupingType

StringProperty LArPhysWaveShifter::m_groupingType {this, "GroupingType", "ExtendedSubDetector"}
private

Definition at line 66 of file LArPhysWaveShifter.h.

66{this, "GroupingType", "ExtendedSubDetector"};

◆ m_isSC

BooleanProperty LArPhysWaveShifter::m_isSC {this, "isSC", false}
private

Definition at line 60 of file LArPhysWaveShifter.h.

60{this, "isSC", false};

◆ m_keylist

StringArrayProperty LArPhysWaveShifter::m_keylist {this, "KeyList", {}}
private

Definition at line 40 of file LArPhysWaveShifter.h.

40{this, "KeyList", {}};

◆ m_keyout

StringProperty LArPhysWaveShifter::m_keyout {this, "KeyOutput", "LArPhysWave"}
private

Definition at line 41 of file LArPhysWaveShifter.h.

41{this, "KeyOutput", "LArPhysWave"};

◆ m_larFEBTstart

LArFEBTimeOffset* LArPhysWaveShifter::m_larFEBTstart {nullptr}
private

Definition at line 48 of file LArPhysWaveShifter.h.

48{nullptr};

◆ m_modeTimeShiftByFEB

UnsignedIntegerProperty LArPhysWaveShifter::m_modeTimeShiftByFEB {this, "TimeShiftByFEBMode", 3}
private

Definition at line 44 of file LArPhysWaveShifter.h.

44{this, "TimeShiftByFEBMode", 3};

◆ m_nDelays

IntegerProperty LArPhysWaveShifter::m_nDelays {this, "Ndelays", 24, "Number of Delay steps between two ADC samples"}
private

Definition at line 55 of file LArPhysWaveShifter.h.

55{this, "Ndelays", 24, "Number of Delay steps between two ADC samples"};

◆ m_nIndexFromPeak

IntegerProperty LArPhysWaveShifter::m_nIndexFromPeak {this, "NindexFromPeak", 0, "Number of data points before the peak"}
private

Definition at line 54 of file LArPhysWaveShifter.h.

54{this, "NindexFromPeak", 0, "Number of data points before the peak"};

◆ m_nSamplings

IntegerProperty LArPhysWaveShifter::m_nSamplings {this, "Nsamplings", 3, "Number of ADC samples before the peak"}
private

Definition at line 56 of file LArPhysWaveShifter.h.

56{this, "Nsamplings", 3, "Number of ADC samples before the peak"};

◆ m_onlineHelper

const LArOnlineID_Base* LArPhysWaveShifter::m_onlineHelper {nullptr}
private

Definition at line 38 of file LArPhysWaveShifter.h.

38{nullptr};

◆ m_timeShiftByFEB

BooleanProperty LArPhysWaveShifter::m_timeShiftByFEB {this, "TimeShiftByFEB", false}
private

Definition at line 57 of file LArPhysWaveShifter.h.

57{this, "TimeShiftByFEB", false};

◆ m_timeShiftByHelper

BooleanProperty LArPhysWaveShifter::m_timeShiftByHelper {this, "TimeShiftByHelper", false}
private

Definition at line 51 of file LArPhysWaveShifter.h.

51{this, "TimeShiftByHelper", false};

◆ m_timeShiftByIndex

IntegerProperty LArPhysWaveShifter::m_timeShiftByIndex {this, "TimeShiftByIndex", 0}
private

Definition at line 50 of file LArPhysWaveShifter.h.

50{this, "TimeShiftByIndex", 0};

◆ m_timeShiftFromPeak

BooleanProperty LArPhysWaveShifter::m_timeShiftFromPeak {this, "TimeShiftFromPeak", false}
private

Definition at line 53 of file LArPhysWaveShifter.h.

53{this, "TimeShiftFromPeak", false};

◆ m_timeShiftGuardRegion

IntegerProperty LArPhysWaveShifter::m_timeShiftGuardRegion {this, "TimeShiftGuardRegion", 0}
private

Definition at line 58 of file LArPhysWaveShifter.h.

58{this, "TimeShiftGuardRegion", 0};

◆ m_timeShiftOffset

BooleanProperty LArPhysWaveShifter::m_timeShiftOffset {this, "TimeShiftOffset", false}
private

Definition at line 62 of file LArPhysWaveShifter.h.

62{this, "TimeShiftOffset", false};

◆ m_timeShiftOffsetValue

FloatProperty LArPhysWaveShifter::m_timeShiftOffsetValue {this, "TimeShiftOffsetValue", 0.}
private

Definition at line 63 of file LArPhysWaveShifter.h.

63{this, "TimeShiftOffsetValue", 0.};

◆ m_totalShiftsKey

StringProperty LArPhysWaveShifter::m_totalShiftsKey {this, "OutputShiftsKey", ""}
private

Definition at line 67 of file LArPhysWaveShifter.h.

67{this, "OutputShiftsKey", ""};

◆ m_TshiftLayer

std::vector<unsigned int> LArPhysWaveShifter::m_TshiftLayer
private

Definition at line 52 of file LArPhysWaveShifter.h.

◆ m_usePhysCaliTdiff

BooleanProperty LArPhysWaveShifter::m_usePhysCaliTdiff {this, "UsePhysCaliTdiff", true}
private

Definition at line 59 of file LArPhysWaveShifter.h.

59{this, "UsePhysCaliTdiff", true};

◆ m_varHandleArraysDeclared

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

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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