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;
133 if (counter % calibParams->
NTrigger(
HWIdentifier(1007091712)) != 0U)
return StatusCode::SUCCESS;
145 if(iDel<calibParams->getNumberDelays(
HWIdentifier(0)))
break;
156 return StatusCode::FAILURE;
165 ATH_MSG_ERROR(
"Key list is empty! No containers to process!" );
166 return StatusCode::FAILURE;
183 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
184 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
186 for (;key_it!=key_it_e; ++key_it) {
188 sc =
evtStore()->retrieve(larAccumulatedCalibDigitContainer,*key_it);
189 if (
sc.isFailure()) {
190 ATH_MSG_WARNING(
"Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << *key_it );
191 if ( (std::next(key_it) == key_it_e) && foundkey==0 ){
192 ATH_MSG_ERROR(
"None of the provided LArAccumulatedDigitContainer keys could be read");
193 return StatusCode::FAILURE;
203 if (
sc.isFailure()) {
204 ATH_MSG_ERROR(
"Failed to retrieve FebErrorSummary object!" );
210 ATH_MSG_WARNING(
"No FebErrorSummaryObject found! Feb errors not checked!" );
217 ATH_MSG_DEBUG(
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" is empty ");
221 const float delayScale = larAccumulatedCalibDigitContainer->
getDelayScale();
222 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
224 for (;it!=it_end; ++it) {
228 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
229 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
233 ispulsed=(*it)->isPulsed();
242 const uint16_t febErrs=febErrSum->
feb_error(febid);
244 if (febid!=lastFailedFEB) {
247 <<
" reports error(s):" << febErrSum->
error_to_string(febErrs) <<
". Data ignored." );
255 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
256 return StatusCode::FAILURE;
260 std::vector<double> samplesum;
261 std::vector < uint64_t >::const_iterator samplesum_it=(*it)->sampleSum().begin();
262 std::vector < uint64_t >::const_iterator samplesum_it_e=(*it)->sampleSum().end();
263 for (;samplesum_it!=samplesum_it_e; ++samplesum_it)
264 samplesum.push_back((
double)(*samplesum_it));
267 std::vector<double> sample2sum;
268 std::vector < uint64_t >::const_iterator sample2sum_it=(*it)->sample2Sum().begin();
269 std::vector < uint64_t >::const_iterator sample2sum_it_e=(*it)->sample2Sum().end();
270 for (;sample2sum_it!=sample2sum_it_e; ++sample2sum_it)
271 sample2sum.push_back((
double)(*sample2sum_it));
277 float delay = (*it)->delay();
278 int dac=(*it)->DAC();
282 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
283 if(calibLineLeg.empty()) {
284 ATH_MSG_WARNING(
"Why do not have calib lines for "<<(*it)->hardwareID()<<
" ?");
290 for (
unsigned i=0; i<calibLineLeg.size(); ++i) {
292 ATH_MSG_DEBUG((*it)->hardwareID().get_identifier32().get_compact() <<
" GR: line pulsed true, line="<<i+1);
293 dacPulsed=(dacPulsed | (0x1 << (15+i+1)));
294 pulsed=(pulsed | (0x1 << (15+i+1)));
299 dacPulsed=(*it)->DAC();
300 for(
int iLine=1;iLine<5;iLine++){
301 if((*it)->isPulsed(iLine)){
302 ATH_MSG_DEBUG((*it)->hardwareID().get_identifier32().get_compact() <<
" GRAV: line pulsed true, line="<<iLine);
303 dacPulsed=(dacPulsed | (0x1 << (15+iLine)));
304 pulsed=(pulsed | (0x1 << (15+iLine)));
316 ATH_MSG_DEBUG(
"with " << (*it)->sampleSum().size() <<
" samples " <<
index <<
" DAC " <<
delay <<
" delay " << dacPulsed <<
" dacPulsed " << pulsed <<
" pulsed");
318 WaveMap::iterator itm = waveMap.find(
index);
320 if ( itm == waveMap.end() ) {
322 itm = (waveMap.insert(WaveMap::value_type(
index,wave))).first;
325 (*itm).second.addAccumulatedEvent(
int(std::roundf(
delay/deltaDelay)),
m_NStep,
326 samplesum, sample2sum, (*it)->nTriggers());
331 return StatusCode::SUCCESS;
341 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
342 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
344 for (;key_it!=key_it_e; ++key_it) {
346 sc =
evtStore()->retrieve(larCalibDigitContainer,*key_it);
347 if (
sc.isFailure()) {
348 ATH_MSG_WARNING(
"Cannot read LArCalibDigitContainer from StoreGate! key=" << *key_it );
356 ATH_MSG_INFO(
"LArCalibDigitContainer with key=" << *key_it <<
" is empty " );
360 const float delayScale = larCalibDigitContainer->
getDelayScale();
361 const float deltaDelay = 25*ns/(delayScale*
m_NStep);
363 for (;it!=it_end; ++it) {
366 int dac = (*it)->DAC();
367 float delay= (*it)->delay();
369 const std::vector<HWIdentifier>& calibLineLeg = clcabling->
calibSlotLine((*it)->hardwareID());
372 for (
const HWIdentifier &calibLineHWID : calibLineLeg) {
376 pulsed=(*it)->isPulsed();
378 if ((!
m_recAll) && !pulsed ) continue ;
384 ATH_MSG_ERROR(
"Found not-matching gain number ("<< (
int)gain <<
")" );
385 return StatusCode::FAILURE;
389 std::vector<double> samples;
390 for (
short sample : (*it)->samples())
391 samples.push_back((
double)(sample));
394 WaveMap::iterator itm = waveMap.find(dac);
396 if ( itm == waveMap.end() ) {
398 itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(),wave))).first;
401 (*itm).second.addEvent((
int)roundf(
delay/deltaDelay),
m_NStep, samples);
406 return StatusCode::SUCCESS;
414 auto caliWaveContainer = std::make_unique<LArCaliWaveContainer>();
417 if (
sc.isFailure()) {
418 ATH_MSG_ERROR(
"Failed to set groupingType for LArCaliWaveContainer object" );
423 sc=caliWaveContainer->initialize();
424 if (
sc.isFailure()) {
425 ATH_MSG_ERROR(
"Failed initialize LArCaliWaveContainer object" );
429 const EventContext& ctx = Gaudi::Hive::currentContext();
433 cabling = {*cablingHdl};
436 return StatusCode::FAILURE;
441 cabling = {*cablingHdl};
444 return StatusCode::FAILURE;
451 ATH_MSG_INFO(
"Using fake (baseline) pedestal subtraction..." );
468 for (; cell_it!=cell_it_e; ++cell_it) {
479 if ((!
m_recAll) && (!cabling->isOnlineConnected(hwId))) {
485 const WaveMap& waveMap = (*cell_it);
486 if (waveMap.empty()) {
487 ATH_MSG_INFO(
"Empty accumulated wave. Last id: " << MSG::hex
489 << lastId <<
" this id: "<<hwId<<MSG::dec );
498 std::map<int, LArCaliWave>::const_iterator dac_it = cell_it->begin();
499 std::map<int, LArCaliWave>::const_iterator dac_it_e = cell_it->end();
503 for (; dac_it != dac_it_e; ++dac_it) {
508 const std::vector<int>& thisTriggers = thisWave.
getTriggers();
509 for (
unsigned i=0;i<thisTriggers.size();++i) {
510 if (thisTriggers[i]==0) {
511 ATH_MSG_FATAL(
"Empty phase found in channel 0x" << MSG::hex << chid << MSG::dec
512 <<
"., aborting reconstruction. Sorry." );
513 return StatusCode::FAILURE;
522 float pedestal = larPedestal->
pedestal(chid,gain);
524 ATH_MSG_DEBUG(
"No pedestal(s) found for channel 0x" << MSG::hex << chid << MSG::dec);
525 ATH_MSG_INFO(
"Using fake (baseline) pedestal subtraction..." );
533 ATH_MSG_DEBUG(
"Pedestal for channel 0x" << MSG::hex << chid << MSG::dec <<
" is = " << pedAve <<
" ADC");
538 ATH_MSG_INFO(
"Absolute ADC saturation at DAC = " << thisWave.
getDAC() <<
" ... skip!" ) ;
541 dacWaves.emplace_back(((thisWave)+(-pedAve)).getWave() ,
561 ATH_MSG_INFO(
" Summary : Number of cells with a CaliWave reconstructed : " << NCaliWave );
562 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 " );
563 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 " );
564 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 " );
565 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 " );
566 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 " );
572 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.
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()
StatusCode execute(const EventContext &ctx)
Execute method.
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