21using CLHEP::megahertz;
71 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWave intermediate object" );
78 ATH_MSG_ERROR(
"Failed initialize LArCaliWave intermediate object" );
109 ATH_MSG_ERROR(
"Inconsistent configuration, for UsePattern > 0 the UseParams must be true");
110 return StatusCode::FAILURE;
115 return StatusCode::SUCCESS;
122 const EventContext& ctx = getContext();
134 if (counter % calibParams->
NTrigger(
HWIdentifier(1007091712)) != 0U)
return StatusCode::SUCCESS;
146 if(iDel<calibParams->getNumberDelays(
HWIdentifier(0)))
break;
157 return StatusCode::FAILURE;
166 ATH_MSG_ERROR(
"Key list is empty! No containers to process!" );
167 return StatusCode::FAILURE;
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();
187 for (;key_it!=key_it_e; ++key_it) {
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;
204 if (
sc.isFailure()) {
205 ATH_MSG_ERROR(
"Failed to retrieve FebErrorSummary object!" );
211 ATH_MSG_WARNING(
"No FebErrorSummaryObject found! Feb errors not checked!" );
218 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" is empty ");
222 const float delayScale = larAccumulatedCalibDigitContainer->
getDelayScale();
223 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
225 for (;it!=it_end; ++it) {
229 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
230 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
234 ispulsed=(*it)->isPulsed();
243 const uint16_t febErrs=febErrSum->
feb_error(febid);
245 if (febid!=lastFailedFEB) {
248 <<
" reports error(s):" << febErrSum->
error_to_string(febErrs) <<
". Data ignored." );
256 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
257 return StatusCode::FAILURE;
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));
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));
278 float delay = (*it)->delay();
279 int dac=(*it)->DAC();
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()<<
" ?");
291 for (
unsigned i=0; i<calibLineLeg.size(); ++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)));
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)));
317 ATH_MSG_DEBUG(
"with " << (*it)->sampleSum().size() <<
" samples " <<
index <<
" DAC " <<
delay <<
" delay " << dacPulsed <<
" dacPulsed " << pulsed <<
" pulsed");
319 WaveMap::iterator itm = waveMap.find(
index);
321 if ( itm == waveMap.end() ) {
323 itm = (waveMap.insert(WaveMap::value_type(
index,wave))).first;
326 (*itm).second.addAccumulatedEvent(
int(std::roundf(
delay/deltaDelay)),
m_NStep,
327 samplesum, sample2sum, (*it)->nTriggers());
332 return StatusCode::SUCCESS;
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();
345 for (;key_it!=key_it_e; ++key_it) {
347 sc =
evtStore()->retrieve(larCalibDigitContainer,*key_it);
348 if (
sc.isFailure()) {
349 ATH_MSG_WARNING(
"Cannot read LArCalibDigitContainer from StoreGate! key=" << *key_it );
357 ATH_MSG_INFO(
"LArCalibDigitContainer with key=" << *key_it <<
" is empty " );
361 const float delayScale = larCalibDigitContainer->
getDelayScale();
362 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
364 for (;it!=it_end; ++it) {
367 int dac = (*it)->DAC();
368 float delay= (*it)->delay();
370 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
373 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
377 pulsed=(*it)->isPulsed();
379 if ((!
m_recAll) && !pulsed ) continue ;
385 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
386 return StatusCode::FAILURE;
390 std::vector<double> samples;
391 for (
short sample : (*it)->samples())
392 samples.push_back((
double)(sample));
395 WaveMap::iterator itm = waveMap.find(dac);
397 if ( itm == waveMap.end() ) {
399 itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(),wave))).first;
402 (*itm).second.addEvent((
int)roundf(
delay/deltaDelay),
m_NStep, samples);
407 return StatusCode::SUCCESS;
415 auto caliWaveContainer = std::make_unique<LArCaliWaveContainer>();
418 if (
sc.isFailure()) {
419 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
424 sc=caliWaveContainer->initialize();
425 if (
sc.isFailure()) {
426 ATH_MSG_ERROR(
"Failed initialize LArCaliWaveContainer object" );
430 const EventContext& ctx = Gaudi::Hive::currentContext();
434 cabling = {*cablingHdl};
437 return StatusCode::FAILURE;
442 cabling = {*cablingHdl};
445 return StatusCode::FAILURE;
452 ATH_MSG_INFO(
"Using fake (baseline) pedestal subtraction..." );
469 for (; cell_it!=cell_it_e; ++cell_it) {
480 if ((!
m_recAll) && (!cabling->isOnlineConnected(hwId))) {
486 const WaveMap& waveMap = (*cell_it);
487 if (waveMap.empty()) {
488 ATH_MSG_INFO(
"Empty accumulated wave. Last id: " << MSG::hex
490 << lastId <<
" this id: "<<hwId<<MSG::dec );
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();
504 for (; dac_it != dac_it_e; ++dac_it) {
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;
523 float pedestal = larPedestal->
pedestal(chid,gain);
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..." );
534 ATH_MSG_DEBUG(
"Pedestal for channel 0x" << MSG::hex << chid << MSG::dec <<
" is = " << pedAve <<
" ADC");
539 ATH_MSG_INFO(
"Absolute ADC saturation at DAC = " << thisWave.
getDAC() <<
" ... skip!" ) ;
542 dacWaves.emplace_back(((thisWave)+(-pedAve)).getWave() ,
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 " );
573 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 getNumberDelays(const HWIdentifier calibModuleID) 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 getNumberDACs(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