384{
386
387
390 SG::ReadCondHandle<LArBadChannelCont> bcContHdl{
m_bcContKey};
391 bcCont=(*bcContHdl);
392 }
393
395
396 std::unique_ptr<LArRampComplete> larRampComplete;
398 larRampComplete=std::make_unique<LArRampComplete>();
400 ATH_CHECK(larRampComplete->initialize());
401 }
402
403 const LArOnOffIdMapping*
cabling(
nullptr);
408 if(!cabling) {
410 return StatusCode::FAILURE;
411 }
412 }else{
414 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl{
m_cablingKey};
416 if(!cabling) {
418 return StatusCode::FAILURE;
419 }
420 }
421
422
423 const ILArRinj* rinj=nullptr;
426 }
427
428 int containerCounter=0;
429
430 int NRamp=0;
431
436 if (cell_it==cell_it_e) {
437 ATH_MSG_INFO(
"No ramp points found for gain " << gain);
438 continue;
439 }
440
441 std::unique_ptr<LArRawRampContainer> larRawRampContainer;
443 larRawRampContainer=std::make_unique<LArRawRampContainer>();
444 }
445
446
447 for (;cell_it!=cell_it_e;cell_it++){
448
449 const HWIdentifier chid = cell_it.
channelId();
450
451 ACCRAMP::const_iterator dac_it=cell_it->begin();
452 ACCRAMP::const_iterator dac_it_e=cell_it->end();
453 auto rawramp=std::make_unique<LArRawRamp>(chid,gain);
454
455 std::vector<float> peak;
456 float adcpeak, timepeak;
457 std::vector<float> adc0v;
458 bool isADCsat = false;
459
460
461
462
463 for (;dac_it!=dac_it_e;++dac_it) {
464
465 LArRawRamp::RAMPPOINT_t ramppoint;
466
467 adcpeak = -999.;
468 timepeak = -999.;
469
470 float MaxADC = 0;
471 int iMaxADC = 0;
472
474
475
476 if(dac_it!=cell_it->begin())
477 ATH_MSG_ERROR(
"DAC0 is not the first DAC ? This might be a problem... " );
478 adc0v = dac_it->second.mean();
480 ramppoint.
RMS = dac_it->second.RMS();
481 ramppoint.
NTriggers = dac_it->second.nTriggers();
482 }else{
483 const size_t nS=dac_it->second.nsamples();
484 adc0v.resize(nS,0.0);
486 ramppoint.
RMS.resize(nS);
487 ramppoint.
NTriggers = dac_it->second.nTriggers();
488 for(
size_t k=0;
k<nS;++
k){
489 ramppoint.
Samples[
k]=dac_it->second.mean(k) - adc0v[
k];
490 ramppoint.
RMS[
k]=dac_it->second.RMS(k);
491
492 if(ramppoint.
Samples[k]>MaxADC){
495 }
496 }
497 }
498
499
503 for (
size_t k=0;
k<ramppoint.
Samples.size();++
k) {
505 }
506 }
507
508
510 unsigned kMax = max_element(ramppoint.
Samples.begin(),ramppoint.
Samples.end()) - ramppoint.
Samples.begin() ;
511 unsigned kLow, kUp;
512
514 if ( kMax < 2 || kMax+2 >= ramppoint.
Samples.size() ) {
515
516 kMax=2;
517 bool isgood=true;
519 if (
cabling->isOnlineConnected(chid) && isgood) {
522 <<
", Amp[2]=" << ramppoint.
Samples[2] <<
" )" );
523 if (
msgLvl(MSG::VERBOSE)) {
524 msg(MSG::VERBOSE) <<
" Samples: ";
525 for (
unsigned k=0;
k<ramppoint.
Samples.size();
k++)
528 }
529 }
530 }
531
532
533
534
535
536
537
538
539 if (kMax==4) kMax=3;
544
545 kLow = kUp = kMax;
546 } else {
547 kLow = kMax - 2;
548 kUp = kMax + 2;
550
551 }
554 adcpeak =
results.getAmplitude();
556 }
557 else
558 ATH_MSG_ERROR(
"LArOFPeak reco tool returns invalid result.");
559
560
562
564
565
567
568
569 unsigned int GoodIndex = 9999;
571 if(dac_it->first ==
m_CaliDACs[gain][chid_hash][i]) GoodIndex=
i;
572 }
573 if(GoodIndex == 9999) {
574 ATH_MSG_WARNING(
"No wave found for cell = " << chid_hash <<
", DAC = " << dac_it->first);
579 {
582 }
583 }
585 }
586
589 }
590
591
595 }else{
597 peak.push_back(-999);
598 peak.push_back(-999);
599 }
600
601 if(peak.size()>1){
602 adcpeak = peak[0];
603 timepeak = peak[1];
604 }
605 }
607
609
611
612
613 Identifier
id=
cabling->cnvToIdentifier(chid);
616
617 }else{
618
620 }
621 adcpeak = peak[0];
622 timepeak = peak[1];
623
624
625 } else {
626 ATH_MSG_ERROR(
"Both OF and Parabola reconstruction modes not available!" ) ;
627 return StatusCode::FAILURE ;
628 }
629
630 ramppoint.
ADC = adcpeak;
631 ramppoint.
DAC = dac_it->first;
632
634 if(rinj) {
635 const float rinjval = rinj->
Rinj(chid);
636 if(rinjval < 4) ramppoint.
DAC /= 2;
637 }
638 }
639
642
643
644
645
646 if( (dac_it->first>=
m_minDAC) && ramppoint.
ADC > -998
648 rawramp->add(ramppoint);
649 }
651 isADCsat = true;
652 if(ramppoint.
DAC < 200){
654 } else {
656 }
657 }else{
659 }
660 }
661
662
663 if (larRampComplete) {
664 std::vector<LArRawRamp::RAMPPOINT_t>&
data=rawramp->theRamp();
666 std::vector<float> rampCoeffs;
667 std::vector<int> vSat;
669 if (
sc!=StatusCode::SUCCESS){
670 if (!
cabling->isOnlineConnected(chid))
674 else
676 }
677 else{
678 if(rampCoeffs[1]<0)
679 ATH_MSG_ERROR(
"Negative 1rst order coef for ramp = " << rampCoeffs[1] <<
" for channel "
681
682 if (vSat[0] != -1) { rawramp->setsat(vSat[0]); }
683 else {
684 if (isADCsat) { rawramp->setsat(
data.size()-1); }
685 if (!isADCsat) { rawramp->setsat(
data.size()); }
686 }
687
688
689 larRampComplete->set(chid,(int)gain,rampCoeffs);
690 NRamp++;
691 }
692 }
693
694 if (larRawRampContainer){
695 larRawRampContainer->push_back(std::move(rawramp));
696 }
697 }
698
699 if (larRawRampContainer) {
701 switch (gain) {
704 break;
707 break;
710 break;
711 default:
713 break;
714 }
716 ATH_MSG_INFO(
"Recording LArRawRampContainer for gain " << (
int)gain <<
" key=" << key);
717 sc=
detStore()->record(std::move(larRawRampContainer),key);
718 if (
sc.isFailure()) {
720 }
721 }
722 ++containerCounter;
723 }
724
725 if (containerCounter==0) {
727 return StatusCode::FAILURE;
728 }
729
730 if (larRampComplete){
731
732 ATH_MSG_INFO(
" Summary : Number of cells with a ramp value computed : " << NRamp );
733 ATH_MSG_INFO(
" Summary : Number of Barrel PS cells side A or C (connected+unconnected): 3904+ 192 = 4096 ");
734 ATH_MSG_INFO(
" Summary : Number of Barrel cells side A or C (connected+unconnected): 50944+2304 = 53248 ");
735 ATH_MSG_INFO(
" Summary : Number of EMEC cells side A or C (connected+unconnected): 31872+3456 = 35328 ");
736 ATH_MSG_INFO(
" Summary : Number of HEC cells side A or C (connected+unconnected): 2816+ 256 = 3072 ");
737 ATH_MSG_INFO(
" Summary : Number of FCAL cells side A or C (connected+unconnected): 1762+ 30 = 1792 ");
738
739
741 if (
sc.isFailure()) {
743 }
745 if (
sc.isFailure()) {
747 }
748 }
751 return StatusCode::SUCCESS;
752}
#define ATH_MSG_VERBOSE(x)
double delay(std::size_t d)
LArBadXCont< LArBadChannel > LArBadChannelCont
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
static const Attributes_t empty
bool msgLvl(const MSG::Level lvl) const
virtual const float & Rinj(const HWIdentifier &id) const =0
value_type get_compact() const
Get the compact id.
HWIdentifier channelId() const
ConditionsMap::iterator ConditionsMapIterator
Gaudi::Property< std::string > m_hec_key
Gaudi::Property< bool > m_ishec
Gaudi::Property< std::string > m_keyoutput
FloatProperty m_delayShift
StatusCode rampfit(unsigned deg, const std::vector< LArRawRamp::RAMPPOINT_t > &data, std::vector< float > &rampCoeffs, std::vector< int > &vSat, const HWIdentifier chid, const LArOnOffIdMapping *cabling, const LArBadChannelCont *bcCont)
UnsignedIntegerProperty m_minDAC
Gaudi::Property< bool > m_iterate
BooleanProperty m_saveRawRamp
BooleanProperty m_saveRecRamp
std::vector< float > Samples
retrieve(aClass, aKey=None)