21using CLHEP::megahertz;
69 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWave intermediate object" );
76 ATH_MSG_ERROR(
"Failed initialize LArCaliWave intermediate object" );
107 ATH_MSG_ERROR(
"Inconsistent configuration, for UsePattern > 0 the UseParams must be true");
108 return StatusCode::FAILURE;
113 return StatusCode::SUCCESS;
120 const EventContext& ctx = getContext();
132 if(
m_usePatt >= 0 && numPatt > 0 &&
static_cast<int>(counter % numPatt) !=
m_usePatt) {
133 return StatusCode::SUCCESS;
137 const EventContext& ctx = Gaudi::Hive::currentContext();
142 return StatusCode::FAILURE;
151 ATH_MSG_ERROR(
"Key list is empty! No containers to process!" );
152 return StatusCode::FAILURE;
169 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
170 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
172 for (;key_it!=key_it_e; ++key_it) {
174 sc =
evtStore()->retrieve(larAccumulatedCalibDigitContainer,*key_it);
175 if (
sc.isFailure()) {
176 ATH_MSG_WARNING(
"Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << *key_it );
177 if ( (std::next(key_it) == key_it_e) && foundkey==0 ){
178 ATH_MSG_ERROR(
"None of the provided LArAccumulatedDigitContainer keys could be read");
179 return StatusCode::FAILURE;
189 if (
sc.isFailure()) {
190 ATH_MSG_ERROR(
"Failed to retrieve FebErrorSummary object!" );
196 ATH_MSG_WARNING(
"No FebErrorSummaryObject found! Feb errors not checked!" );
203 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" is empty ");
207 const float delayScale = larAccumulatedCalibDigitContainer->
getDelayScale();
208 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
210 for (;it!=it_end; ++it) {
214 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
215 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
219 ispulsed=(*it)->isPulsed();
228 const uint16_t febErrs=febErrSum->
feb_error(febid);
230 if (febid!=lastFailedFEB) {
233 <<
" reports error(s):" << febErrSum->
error_to_string(febErrs) <<
". Data ignored." );
241 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
242 return StatusCode::FAILURE;
246 std::vector<double> samplesum;
247 std::vector < uint64_t >::const_iterator samplesum_it=(*it)->sampleSum().begin();
248 std::vector < uint64_t >::const_iterator samplesum_it_e=(*it)->sampleSum().end();
249 for (;samplesum_it!=samplesum_it_e; ++samplesum_it)
250 samplesum.push_back((
double)(*samplesum_it));
253 std::vector<double> sample2sum;
254 std::vector < uint64_t >::const_iterator sample2sum_it=(*it)->sample2Sum().begin();
255 std::vector < uint64_t >::const_iterator sample2sum_it_e=(*it)->sample2Sum().end();
256 for (;sample2sum_it!=sample2sum_it_e; ++sample2sum_it)
257 sample2sum.push_back((
double)(*sample2sum_it));
263 float delay = (*it)->delay();
264 int dac=(*it)->DAC();
268 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
269 if(calibLineLeg.empty()) {
270 ATH_MSG_WARNING(
"Why do not have calib lines for "<<(*it)->hardwareID()<<
" ?");
276 for (
unsigned i=0; i<calibLineLeg.size(); ++i) {
279 dacPulsed=(dacPulsed | (0x1 << (15+i+1)));
280 pulsed=(pulsed | (0x1 << (15+i+1)));
285 dacPulsed=(*it)->DAC();
286 for(
int iLine=1;iLine<5;iLine++){
287 if((*it)->isPulsed(iLine)){
289 dacPulsed=(dacPulsed | (0x1 << (15+iLine)));
290 pulsed=(pulsed | (0x1 << (15+iLine)));
302 ATH_MSG_DEBUG(
"with " << (*it)->sampleSum().size() <<
" samples " <<
index <<
" DAC " <<
delay <<
" delay " << dacPulsed <<
" dacPulsed " );
304 WaveMap::iterator itm = waveMap.find(
index);
306 if ( itm == waveMap.end() ) {
308 itm = (waveMap.insert(WaveMap::value_type(
index,wave))).first;
311 (*itm).second.addAccumulatedEvent(
int(std::roundf(
delay/deltaDelay)),
m_NStep,
312 samplesum, sample2sum, (*it)->nTriggers());
317 return StatusCode::SUCCESS;
327 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
328 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
330 for (;key_it!=key_it_e; ++key_it) {
332 sc =
evtStore()->retrieve(larCalibDigitContainer,*key_it);
333 if (
sc.isFailure()) {
334 ATH_MSG_WARNING(
"Cannot read LArCalibDigitContainer from StoreGate! key=" << *key_it );
342 ATH_MSG_INFO(
"LArCalibDigitContainer with key=" << *key_it <<
" is empty " );
346 const float delayScale = larCalibDigitContainer->
getDelayScale();
347 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
349 for (;it!=it_end; ++it) {
352 int dac = (*it)->DAC();
353 float delay= (*it)->delay();
355 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
358 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
362 pulsed=(*it)->isPulsed();
364 if ((!
m_recAll) && !pulsed ) continue ;
370 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
371 return StatusCode::FAILURE;
375 std::vector<double> samples;
376 for (
short sample : (*it)->samples())
377 samples.push_back((
double)(sample));
380 WaveMap::iterator itm = waveMap.find(dac);
382 if ( itm == waveMap.end() ) {
384 itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(),wave))).first;
387 (*itm).second.addEvent((
int)roundf(
delay/deltaDelay),
m_NStep, samples);
392 return StatusCode::SUCCESS;
400 auto caliWaveContainer = std::make_unique<LArCaliWaveContainer>();
403 if (
sc.isFailure()) {
404 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
409 sc=caliWaveContainer->initialize();
410 if (
sc.isFailure()) {
411 ATH_MSG_ERROR(
"Failed initialize LArCaliWaveContainer object" );
415 const EventContext& ctx = Gaudi::Hive::currentContext();
419 cabling = {*cablingHdl};
422 return StatusCode::FAILURE;
427 cabling = {*cablingHdl};
430 return StatusCode::FAILURE;
437 ATH_MSG_INFO(
"Using fake (baseline) pedestal subtraction..." );
454 for (; cell_it!=cell_it_e; ++cell_it) {
465 if ((!
m_recAll) && (!cabling->isOnlineConnected(hwId))) {
471 const WaveMap& waveMap = (*cell_it);
472 if (waveMap.empty()) {
473 ATH_MSG_INFO(
"Empty accumulated wave. Last id: " << MSG::hex
475 << lastId <<
" this id: "<<hwId<<MSG::dec );
484 std::map<int, LArCaliWave>::const_iterator dac_it = cell_it->begin();
485 std::map<int, LArCaliWave>::const_iterator dac_it_e = cell_it->end();
489 for (; dac_it != dac_it_e; ++dac_it) {
494 const std::vector<int>& thisTriggers = thisWave.
getTriggers();
495 for (
unsigned i=0;i<thisTriggers.size();++i) {
496 if (thisTriggers[i]==0) {
497 ATH_MSG_FATAL(
"Empty phase found in channel 0x" << MSG::hex << chid << MSG::dec
498 <<
"., aborting reconstruction. Sorry." );
499 return StatusCode::FAILURE;
508 float pedestal = larPedestal->
pedestal(chid,gain);
510 ATH_MSG_DEBUG(
"No pedestal(s) found for channel 0x" << MSG::hex << chid << MSG::dec);
511 ATH_MSG_INFO(
"Using fake (baseline) pedestal subtraction..." );
519 ATH_MSG_DEBUG(
"Pedestal for channel 0x" << MSG::hex << chid << MSG::dec <<
" is = " << pedAve <<
" ADC");
524 ATH_MSG_INFO(
"Absolute ADC saturation at DAC = " << thisWave.
getDAC() <<
" ... skip!" ) ;
527 dacWaves.emplace_back(((thisWave)+(-pedAve)).getWave() ,
547 ATH_MSG_INFO(
" Summary : Number of cells with a CaliWave reconstructed : " << NCaliWave );
548 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 " );
549 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 " );
550 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 " );
551 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 " );
552 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 " );
558 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double delay(std::size_t d)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const ServiceHandle< StoreGateSvc > & detStore() const
DataModel_detail::const_iterator< DataVector > const_iterator
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.
virtual float pedestal(const HWIdentifier &id, int gain) const =0
Container class for LArAccumulatedCalibDigit.
double getDelayScale() const
get the delay Scale
uint16_t m_fatalFebErrorPattern
const LArOnlineID_Base * m_onlineID
virtual StatusCode stop()
bool m_useAccumulatedDigits
bool m_useDacAndIsPulsedIndex
SG::ReadCondHandleKey< LArCalibLineMapping > m_calibMapKey
SG::ReadCondHandleKey< ILArPedestal > m_pedKey
std::vector< std::string > m_keylistproperty
StatusCode executeWithStandardDigits(const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
std::vector< std::string > m_keylist
std::map< int, LArCaliWave > WaveMap
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
std::string m_groupingType
LArCaliWaveBuilder(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode executeWithAccumulatedDigits(const LArCalibParams *calibParams, const LArCalibLineMapping *clcabling)
LArCaliWaveVec LArCaliWaves
int getIsPulsedInt() const
isPulsed value
int getDAC() const
DAC value.
Container class for LArCalibDigit.
double getDelayScale() const
get delay scale
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 getNumberPatterns(const HWIdentifier calibModuleID) const
unsigned DAC(const unsigned event, const HWIdentifier calibLineID) const
unsigned NTrigger(const HWIdentifier calibModuleID) const
HWIdentifier channelId() const
ConditionsMap::iterator ConditionsMapIterator
Holds information from the FEB Error Summary.
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
Helper for the Liquid Argon Calorimeter cell identifiers.
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.
const double & getDt() const
delta time
unsigned getFlag() const
flag: ...
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring