6 #include "CLHEP/Units/SystemOfUnits.h"
8 #include "GaudiKernel/ToolHandle.h"
27 m_groupingType(
"ExtendedFeedThrough"),
28 m_onlineHelper(nullptr),
78 log << MSG::INFO <<
"Initialize LArCaliWaveBuilderXtalk" <<
endmsg;
98 emecSpecialRegion_test.ToLower();
99 if (emecSpecialRegion_test.Contains(
"inner"))
103 if (! emecSpecialRegion_test.Contains(
"outer"))
104 ATH_MSG_WARNING (
"Can't read EMEC special region (Inner/Outer Wheel) - set SpecialRegion to OuterWheel." );
165 return StatusCode::SUCCESS;
201 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
204 ATH_MSG_DEBUG (
"Number of associated calib line " << calibLine.size() );
205 if (!calibLine.empty()) {
224 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
226 if (!calibLine.empty()) {
241 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
243 if (!calibLine.empty()) {
260 ATH_MSG_WARNING (
"There is no StripSingle pattern for EMEC inner wheel. You should try another pattern (MiddleSingle[1-4] or BackSingle[1-4])." );
261 else if(
m_calibPattern.find(
"StripSingle",0) != std::string::npos ){
272 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
275 ATH_MSG_DEBUG (
"Number of associated calib line " << calibLine.size() );
276 if (!calibLine.empty()) {
304 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
307 ATH_MSG_DEBUG (
"Number of associated calib line " << calibLine.size() );
308 if (!calibLine.empty()) {
321 int pulsedCell3 = 33;
322 int pulsedCell4 = 34;
343 const std::vector<HWIdentifier>& calibLine = clCont->
calibSlotLine(theConsidChannel);
345 if (!calibLine.empty()) {
353 return StatusCode::SUCCESS;
364 return StatusCode::FAILURE;
371 return StatusCode::FAILURE;
384 ATH_MSG_ERROR (
"Key list is empty! No containers to process!" );
385 return StatusCode::FAILURE;
390 std::vector<std::string>::const_iterator key_it=
m_keylist.begin();
391 std::vector<std::string>::const_iterator key_it_e=
m_keylist.end();
393 for (;key_it!=key_it_e; ++key_it) {
396 if (
sc.isFailure()) {
397 ATH_MSG_WARNING (
"Cannot read LArAccumulatedCalibDigitContainer from StoreGate! key=" << *key_it );
405 ATH_MSG_DEBUG (
"LArAccumulatedCalibDigitContainer with key=" << *key_it <<
" is empty " );
409 const float delayScale = larAccumulatedCalibDigitContainer->
getDelayScale();
410 const float deltaDelay = 25*
ns/(delayScale*
m_NStep);
413 bool relevantForXtalk =
false;
416 std::vector<int> nbOfEventSlot;
417 nbOfEventSlot.resize(15);
419 std::vector<int> nbOfEventPart;
420 nbOfEventPart.resize(8);
428 const std::vector<HWIdentifier>& calibLine = clCont->calibSlotLine((*it)->hardwareID());
429 if (!calibLine.empty()) {
433 relevantForXtalk =
true;
440 if ((*it)->isPulsed()){
445 nbOfEventSlot[iSlot-1]++;
447 if (ipos_neg==1)
sideA++;
451 if (iSlot==1) nbOfEventPart[4*ibarrel_ec]++;
452 else if (iSlot < 9 - ibarrel_ec) nbOfEventPart[4*ibarrel_ec + 1]++;
453 else if (iSlot > 10 - ibarrel_ec) nbOfEventPart[4*ibarrel_ec + 2]++;
454 else nbOfEventPart[4*ibarrel_ec + 3]++;
460 while ((!relevantForXtalk) && (
it != it_end));
473 msg() <<
MSG::DEBUG <<
"Entries : EMB PS/F/M/B=" << nbOfEventPart[0] <<
"/" << nbOfEventPart[1] <<
"/" << nbOfEventPart[2] <<
"/" << nbOfEventPart[3];
474 msg() <<
MSG::DEBUG <<
" - EMEC Std PS/F/M/B=" << nbOfEventPart[4] <<
"/" << nbOfEventPart[5] <<
"/" << nbOfEventPart[6] <<
"/" << nbOfEventPart[7];
476 if (!relevantForXtalk)
483 if (relevantForXtalk){
484 bool hasbeenprinted =
false;
485 for (
it=larAccumulatedCalibDigitContainer->
begin();
it!=it_end; ++
it) {
493 if (
m_isInnerWheel) {
if (iFT!=3 && iFT!=10 && iFT!=16 && iFT!=22)
continue;}
494 else {
if (iFT!=2 && iFT!=9 && iFT!=15 && iFT!=21)
continue;}
495 else if (iFT==2 || iFT==9 || iFT==15 || iFT==21 || iFT==3 || iFT==10 || iFT==16 || iFT==22 || iFT==6)
502 if (!hasbeenprinted){
503 ATH_MSG_DEBUG (
"This event is relevant for the studied partition" );
504 hasbeenprinted =
true;
511 return StatusCode::FAILURE;
516 std::vector<double> samplesum;
517 std::vector < uint64_t >::const_iterator samplesum_it=(*it)->sampleSum().begin();
518 std::vector < uint64_t >::const_iterator samplesum_it_e=(*it)->sampleSum().end();
521 samplesum.push_back((
double)(*samplesum_it));
525 while ( (samplesum_it!=samplesum_it_e) && (nSample!=0) );
529 std::vector<double> sample2sum;
530 std::vector < uint64_t >::const_iterator sample2sum_it=(*it)->sample2Sum().begin();
531 std::vector < uint64_t >::const_iterator sample2sum_it_e=(*it)->sample2Sum().end();
534 sample2sum.push_back((
double)(*sample2sum_it));
538 while ( (sample2sum_it!=sample2sum_it_e) && (nSample!=0) );
543 if ( itm == waveMap.end() ) {
551 itm = (waveMap.insert(WaveMap::value_type((*it)->DAC(), wave))).
first;
554 (*itm).second.addAccumulatedEvent((
int)roundf((*it)->delay()/deltaDelay),
m_NStep,
555 samplesum, sample2sum, (*it)->nTriggers());
561 return StatusCode::SUCCESS;
569 auto caliWaveContainer = std::make_unique<LArCaliWaveContainer>();
572 ATH_MSG_DEBUG (
"Set groupingType for LArCaliWaveContainer object" );
574 ATH_CHECK( caliWaveContainer->initialize() );
596 return StatusCode::FAILURE;
614 for (; cell_it!=cell_it_e; ++cell_it) {
624 if (!
cabling->isOnlineConnected(hwId))
continue;
626 const WaveMap& waveMap = (*cell_it);
627 if (waveMap.empty()) {
628 ATH_MSG_INFO (
"Empty accumulated wave. Last id: " << MSG::hex
629 << lastId << MSG::dec );
639 if (
m_isInnerWheel) {
if (iFT!=3 && iFT!=10 && iFT!=16 && iFT!=22)
continue;}
640 else {
if (iFT!=2 && iFT!=9 && iFT!=15 && iFT!=21)
continue;}
641 else if (iFT==2 || iFT==9 || iFT==15 || iFT==21 || iFT==3 || iFT==10 || iFT==16 || iFT==22 || iFT==6)
648 std::map<int, LArCaliWave>::const_iterator dac_it = cell_it->begin();
649 std::map<int, LArCaliWave>::const_iterator dac_it_e = cell_it->end();
651 for (; dac_it != dac_it_e; ++dac_it) {
658 ATH_MSG_INFO (
"Absolute ADC saturation at DAC = " << thisWave.
getDAC() <<
" ... skip!" );
662 LArCaliWave newWave( ((thisWave)+(-pedAve)).getWave() ,
670 dacWaves.push_back(newWave);
682 ATH_MSG_INFO (
"Summary : Number of cells with a CaliWave reconstructed : " << NCaliWave );
683 ATH_MSG_INFO (
"Size of LAr calibration waves container : " << caliWaveContainer->size() );
688 ATH_MSG_INFO (
"LArCaliWaveBuilderXtalk has finished." );
689 return StatusCode::SUCCESS;