11#include "GaudiKernel/ToolHandle.h"
88 sc =
detStore()->retrieve(ll,
"LArOnline_SuperCellID");
90 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
91 return StatusCode::FAILURE;
100 if (
sc.isFailure()) {
101 msg(MSG::ERROR) <<
"Could not get LArOnlineID helper !" <<
endmsg;
102 return StatusCode::FAILURE;
111 ToolHandle<LArPhysWaveTool> larPhysWaveTool(
"LArPhysWaveTool");
112 sc=larPhysWaveTool.retrieve();
113 if (
sc!=StatusCode::SUCCESS) {
122 if (
sc!=StatusCode::SUCCESS) {
124 <<
". Disabling use of PhysCaliTdiff values in wave shift." );
127 ATH_MSG_INFO(
"LArPhysCaliTdiff successfully retrieved" );
135 if(!
sc.isSuccess()) {
143 ATH_MSG_INFO(
"Will use helper class for start time." );
156 ATH_MSG_INFO(
"Manually shifting pulses by a constant index from peak." );
173 ATH_MSG_INFO(
"Manually shifting pulses by *FEB* time indexes." );
175 if (
sc.isFailure()) {
176 ATH_MSG_ERROR(
"Cannot find any FEB time offsets. Please check." );
183 auto totalShifts = std::make_unique<LArOFCBinComplete>();
185 ATH_MSG_ERROR(
"Failed to set grouping type for LArPhysCaliTdiffComplete object" );
186 return StatusCode::FAILURE;
189 if(totalShifts->initialize().isFailure()) {
190 ATH_MSG_ERROR(
"Failed to initialize LArPhysCaliTdiffComplete object" );
191 return StatusCode::FAILURE;
200 for (
const std::string& key :
m_keylist) {
202 sc=
detStore()->retrieve(larPhysWaveContainerOld,key);
203 if (
sc.isFailure()) {
204 ATH_MSG_INFO(
"LArPhysWaveContainer (key=" << key <<
") not found in StoreGate" );
207 ATH_MSG_INFO(
"Processing LArPhysWaveContainer from StoreGate, key = " << key );
216 if ( wave_it == wave_it_e ) {
217 ATH_MSG_INFO(
"LArPhysWaveContainer (key = " << key <<
") has no wave with gain = " << gain );
221 for ( ; wave_it!=wave_it_e; wave_it++) {
223 if ( nchannel < 100 || ( nchannel < 1000 && nchannel%100==0 ) || nchannel%1000==0 )
224 ATH_MSG_INFO(
"Processing physics waveform number " << nchannel );
230 if ( larPhysWave->
isEmpty() ) {
238 tstart = larWaveHelper.
getStart(*larPhysWave) ;
252 tstart = (int)larFebTshift->
TimeOffset(febid);
257 float tdiff = larPhysCaliTdiff->
Tdiff(chid,gain);
258 if (tdiff<=-999.) tdiff = 0.;
260 tdiff = tdiff>0. ? (float)((
long)(tdiff+0.5)) : (float)((
long)(tdiff-0.5));
269 totalShifts->set(chid,gain,(
int)(tstart));
272 <<
" --> Time shift for channel 0x" << MSG::hex << chid.
get_compact() << MSG::dec
273 <<
" is " << tstart <<
" samples (" << tstart*larPhysWave->
getDt() <<
" ns)");
310 if (
sc.isFailure()) {
317 return StatusCode::SUCCESS;
331 std::vector<HWIdentifier>::const_iterator it =
m_onlineHelper->feb_begin();
332 std::vector<HWIdentifier>::const_iterator it_e =
m_onlineHelper->feb_end();
344 for (
const std::string& key :
m_keylist) {
346 sc=
detStore()->retrieve(larPhysWaveContainerOld,key);
347 if (
sc.isFailure()) {
348 ATH_MSG_INFO(
"LArPhysWaveContainer (key=" << key <<
") not found in StoreGate" );
351 if ( larPhysWaveContainerOld ==
nullptr ) {
352 ATH_MSG_INFO(
"LArPhysWaveContainer (key=" << key <<
") is empty" );
356 ATH_MSG_INFO(
"ComputeTimeShiftByFEB(): processing LArPhysWaveContainer from StoreGate, key = " << key );
363 if ( wave_it == wave_it_e ) {
364 ATH_MSG_INFO(
"ComputeTimeShiftByFEB(): LArPhysWaveContainer (key = " << key <<
") has no wave with gain = " << gain );
368 for ( ; wave_it!=wave_it_e; wave_it++) {
371 if ( larPhysWave->
isEmpty() )
continue;
376 unsigned oldFEBTstart = (unsigned)
m_larFEBTstart->TimeOffset(febid);
377 unsigned newFEBTstart = 999;
378 unsigned theChanInFEB = 0;
383 newFEBTstart = (unsigned)larWaveHelper.
getStart(*larPhysWave);
384 if ( newFEBTstart < oldFEBTstart )
m_larFEBTstart->setTimeOffset(febid,newFEBTstart);
388 if ( newFEBTstart < oldFEBTstart )
m_larFEBTstart->setTimeOffset(febid,newFEBTstart);
392 ATH_MSG_VERBOSE(std::hex << chid << std::dec<<
" TimeOffset: "<<bindiff);
394 newFEBTstart = (unsigned)(bindiff);
398 theChanInFEB =
static_cast<unsigned>(nChanInFEB.
TimeOffset(febid)+1);
414 std::vector<HWIdentifier>::const_iterator it =
m_onlineHelper->feb_begin();
415 std::vector<HWIdentifier>::const_iterator it_e =
m_onlineHelper->feb_end();
417 for (;it!=it_e;++it) {
420 if ( mode==3 && nChanInFEB.
TimeOffset(*it) ) {
424 ATH_MSG_INFO( nFeb <<
". FEB ID 0x" << std::hex << (*it).get_compact() << std::dec
434 std::fstream outfile ;
435 outfile.open(
"TimeShiftFEB.py",std::ios::out) ;
436 outfile <<
"FakeLArTimeOffset.FEBids = [ " ;
439 for (;it!=it_e;++it) {
440 outfile <<
"0x" << std::hex << (*it).get_compact() << std::dec ;
442 if ( i<nFeb ) outfile <<
", " ;
444 outfile <<
" ]" << std::endl ;
445 outfile <<
"FakeLArTimeOffset.FEbTimeOffsets = [ " ;
448 for (;it!=it_e;++it) {
451 if ( i<nFeb ) outfile <<
", " ;
453 outfile <<
" ]" << std::endl ;
459 return StatusCode::FAILURE;
464 ATH_MSG_ERROR(
"Can't record LArFEBTimeOffset to DetectorStore" );
465 return StatusCode::FAILURE;
471 ATH_MSG_ERROR(
"Can't symlink LArFEBTimeOffset to abstract interface in DetectorStore" );
472 return StatusCode::FAILURE;
475 return StatusCode::SUCCESS;
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
LArPhysWaveContainer::ConstConditionsMapIterator PhysWaveIt
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
virtual float TimeOffset(const HWIdentifier fId) const =0
virtual const float & Tdiff(const HWIdentifier &id, int gain) const =0
value_type get_compact() const
Get the compact id.
HWIdentifier channelId() const
ConditionsMap::const_iterator ConstConditionsMapIterator
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)
Helper for the Liquid Argon Calorimeter cell identifiers.
Liquid Argon Physics Wave Container.
std::string m_cellByCellShiftsKey
StatusCode ComputeTimeShiftByFEB(unsigned mode)
float m_timeShiftOffsetValue
const LArOnlineID_Base * m_onlineHelper
std::string m_totalShiftsKey
unsigned m_modeTimeShiftByFEB
std::string m_groupingType
int m_timeShiftGuardRegion
std::vector< std::string > m_keylist
LArPhysWaveShifter(const std::string &name, ISvcLocator *pSvcLocator)
std::string m_fileTimeShiftByFEB
LArFEBTimeOffset * m_larFEBTstart
bool m_compTimeShiftByFEB
bool m_dumpTimeShiftByFEB
unsigned int getMax(const LArWave &theWave) const
return index of maximum sample
unsigned getStart(const LArWave &theWave) const
bool isEmpty() const
is LArWave uninitialized?
const double & getDt() const
delta time