282 {
283
284 bool createDigit_DigiHSTruth = true;
285
286
288 short Adc;
289 short Adc_DigiHSTruth;
290
292 std::vector<short> AdcSample_DigiHSTruth(
m_NSamples);
293
295 float SigmaNoise;
297
303 else if (
m_larem_id->is_em_endcap_inner(cellId))
305
308
309
310
312
313
314
315
316#ifndef NDEBUG
319#endif
320
327
328
329
330
331
332#ifndef NDEBUG
333 ATH_MSG_DEBUG(
" number of hit for this cell " << TimeE->size());
334#endif
335
336
337
338
339 bool isDead =
m_bcMask.cellShouldBeMasked(bcCont,ch_id);
340
341
342 if (!isDead) {
343 if( this->
ConvertHits2Samples(cellId,ch_id,initialGain,TimeE, Samples, shape).isFailure() ) {
344 return StatusCode::SUCCESS;
345 }
347 if( this->
ConvertHits2Samples(cellId,ch_id,initialGain,TimeE_DigiHSTruth, Samples_DigiHSTruth, shape).isFailure() ) {
348 return StatusCode::SUCCESS;
349 }
350 }
351 }
352
353
354
355
356 float energy2adc ;
357 float rAdc ;
359 {
360 rndmGain= rndmEvtDigit->gain();
361 auto polynom_adc2mev =adc2MeVs->
ADC2MEV(ch_id,rndmEvtDigit->gain());
362 if (polynom_adc2mev.size() > 1) {
363 float adc2energy =
SF * polynom_adc2mev[1];
364 const std::vector<short> & rndm_digit_samples = rndmEvtDigit->samples() ;
365 float Pedestal = pedestal->
pedestal(ch_id,rndmEvtDigit->gain());
367 ATH_MSG_WARNING(
" Pedestal not found in database for this channel offID " << cellId <<
" Use sample 0 for random");
368 Pedestal = rndm_digit_samples[0];
369 }
370 ATH_MSG_DEBUG(
" Params for inverting LAr Digitization: pedestal " << Pedestal <<
" adc2energy " << adc2energy);
371
372
373
374 float adc0=0.;
376 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
377 if (larOFC.cptr() != nullptr) {
379 float sumOfc=0.;
380 if (ofc_a.size()>0) {
381 for (
unsigned int j=0;
j<ofc_a.size();
j++) sumOfc += ofc_a.
at(j);
382 }
383 if (sumOfc>0) adc0 = polynom_adc2mev[0] *
SF /sumOfc;
384 }
385 }
386
388 if ((
int)(rndm_digit_samples.size()) <
m_NSamples) {
390 "Less digit Samples than requested in digitization for cell "
391 << ch_id.
get_compact() <<
" Digit has " << rndm_digit_samples.size()
392 <<
" samples. Digitization request " <<
m_NSamples);
393 nmax = rndm_digit_samples.size();
394 }
396 {
397 rAdc = (rndm_digit_samples[
i] - Pedestal ) * adc2energy + adc0;
398 rndm_energy_samples[
i] = rAdc ;
400 }
401 }
402 else {
403 ATH_MSG_ERROR(
" No ramp found for this random cell " <<
m_larem_id->show_to_string(cellId) <<
" for gain " << rndmEvtDigit->gain());
404 if (adc2MeVs->
nGains()<=(
int)rndmEvtDigit->gain()) {
405 ATH_MSG_ERROR(
"Found ramp for only " << adc2MeVs->
nGains() <<
" gains. Are you trying to overlay of Run 3 random with run 4 signal?");
406 }
407 return StatusCode::FAILURE;
408 }
409 }
410
411
414 return StatusCode::FAILURE;
415 }
416
417
418 igain=std::max(rndmGain,igain);
419
420
421
422
423 if (igain != initialGain ){
427 else Samples[
i] = 0.;
428 }
429
430 if (!isDead) {
431 if( this->
ConvertHits2Samples(cellId,ch_id,igain,TimeE, Samples, shape) == StatusCode::FAILURE ) {
432 return StatusCode::SUCCESS;
433 }
435 if( this->
ConvertHits2Samples(cellId,ch_id,igain,TimeE_DigiHSTruth, Samples_DigiHSTruth, shape) == StatusCode::FAILURE ) {
436 return StatusCode::SUCCESS;
437 }
438 }
439 }
440 }
441
442
443
444
445
446 double Rndm[32]{};
447 int BvsEC=0;
449
450
451
452
453
455
457
458 std::span<double>(Samples.data(), Samples.size()));
459
461
463
464 std::span<double>(Samples_DigiHSTruth.data(), Samples_DigiHSTruth.size()));
465
466 }
467
468 }
469
470
471
472
473 bool addedNoise=false;
477
478 {
481 SigmaNoise =
noise->noise(ch_id, igain);
482 } else {
483 float thisNoise = pedestal->
pedestalRMS(ch_id, igain);
485 SigmaNoise = thisNoise;
486 else
487 SigmaNoise = 0.;
488 }
489
490 const std::vector<float>& CorGen =
496 return StatusCode::FAILURE;
497 }
498
499 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0., 1.);
500
504 for (
int j = 0;
j <=
i;
j++) {
506 Noise[
i] += Rndm[
j] * CorGen[
index];
507 }
508 Noise[
i] = Noise[
i] * SigmaNoise;
509 }
510 addedNoise = true;
511 } else {
512
514 Noise[i] = 0.;
515
516
517
518
519 if (rndmEvtDigit) {
520
521 if (igain > rndmEvtDigit->gain()) {
522 double SigmaNoiseZB = 0.;
523 double SigmaNoise = 0.;
524 double SigmaExtraNoise = 0.;
526 SigmaNoiseZB =
noise->noise(ch_id, rndmEvtDigit->gain());
527 SigmaNoise =
noise->noise(ch_id, igain);
528 } else {
529 float thisNoise = pedestal->
pedestalRMS(ch_id, rndmEvtDigit->gain());
531 SigmaNoiseZB = thisNoise;
532 else
533 SigmaNoiseZB = 0.;
536 SigmaNoise = thisNoise;
537 else
538 SigmaNoise = 0.;
539 }
540
541 auto polynom_adc2mevZB =
542 adc2MeVs->
ADC2MEV(cellId, rndmEvtDigit->gain());
543 auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId, igain);
544 if (polynom_adc2mevZB.size() > 1 && polynom_adc2mev.size() > 1) {
545 if (polynom_adc2mev[1] > 0.) {
546 SigmaNoiseZB = SigmaNoiseZB * (polynom_adc2mevZB[1]) /
547 (polynom_adc2mev[1]);
548 if (SigmaNoise > SigmaNoiseZB)
549 SigmaExtraNoise = sqrt(SigmaNoise * SigmaNoise -
550 SigmaNoiseZB * SigmaNoiseZB);
551 }
552 }
553 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0.,
554 1.);
556 Noise[i] = SigmaExtraNoise * Rndm[i];
557 addedNoise = true;
558 }
559 }
560 }
561 }
562
563
564
565 float Pedestal = pedestal->
pedestal(ch_id,igain);
567 ATH_MSG_WARNING(
" pedestal not found for cellId " << cellId <<
" assume 1000" );
568 Pedestal=1000.;
569 }
570 const auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId,igain);
571 if (polynom_adc2mev.size() < 2) {
572 ATH_MSG_WARNING(
" No ramp found for requested gain " << igain <<
" for cell " <<
m_larem_id->show_to_string(cellId) <<
" no digit made...");
573 return StatusCode::SUCCESS;
574 }
575
576 energy2adc=1./(polynom_adc2mev[1])/SF;
577
578
579
581 {
582 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
583 if (larOFC.cptr() != nullptr) {
584 float sumOfc=0.;
586 if (ofc_a.size()>0) {
587 for (
unsigned int j=0;
j<ofc_a.size();
j++) sumOfc+= ofc_a.
at(j);
588 }
589 if ((polynom_adc2mev[1])>0 && sumOfc>0) Pedestal = Pedestal - (polynom_adc2mev[0])/(polynom_adc2mev[1])/sumOfc;
590 ATH_MSG_DEBUG(
" Params for final LAr Digitization gain: " << igain <<
" pedestal: " << Pedestal <<
" energy2adc: " << energy2adc);
591 }
592 }
594 {
595 double xAdc;
596 double xAdc_DigiHSTruth = 0;
597
598 if ( addedNoise ){
599 xAdc = Samples[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
601 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
602 }
603 }
604
605 else {
607 float flatRndm = RandFlat::shoot(engine);
608 xAdc = Samples[
i]*energy2adc + Pedestal + flatRndm;
610 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + flatRndm;
611 }
612
613 }
614 else{
615 xAdc = Samples[
i]*energy2adc + Pedestal + 0.5;
617 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + 0.5;
618 }
619 }
620
621 }
622
623
624
625
626
627 if (xAdc <0) {
629 Adc=0;
630 }
633 ", energy2adc=" << energy2adc << ", E[0]= " << (TimeE->size()>0 ? std::format("{}",TimeE->at(0).first) : "No value"));
635 }
636 else
638
640
642 if (xAdc_DigiHSTruth <0) Adc_DigiHSTruth=0;
644 else Adc_DigiHSTruth = (
short) xAdc_DigiHSTruth;
645 AdcSample_DigiHSTruth[
i] = Adc_DigiHSTruth;
646 }
647
648#ifndef NDEBUG
649 ATH_MSG_DEBUG(
" Sample " << i <<
" Energy= " << Samples[i] <<
" Adc=" << Adc);
650#endif
651
652 }
653
654
655
656
658 (*Digit)=LArDigit(ch_id,igain,std::move(AdcSample));
659
661 createDigit_DigiHSTruth = false;
662 Digit_DigiHSTruth = nullptr;
663
665 if (Samples_DigiHSTruth[i] != 0)
666 createDigit_DigiHSTruth = true;
667 }
668
669 Digit_DigiHSTruth =
670 new LArDigit(ch_id, igain, std::move(AdcSample_DigiHSTruth));
671 }
672
673 return StatusCode::SUCCESS;
674}
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
LArVectorProxy OFCRef_t
This class defines the interface for accessing Optimal Filtering coefficients for each channel provid...
virtual float pedestal(const HWIdentifier &id, int gain) const =0
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
virtual const float & FSAMPL(const HWIdentifier &id) const =0
value_type get_compact() const
Get the compact id.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
const std::vector< float > & autoCorrSqrt(const HWIdentifier &id, int gain) const
Gaudi::Property< bool > m_NoiseInEMEC
StatusCode ConvertHits2Samples(const Identifier &cellId, HWIdentifier ch_id, CaloGain::CaloGain igain, const std::vector< std::pair< float, float > > *TimeE, staticVecDouble_t &sampleList, const ILArShape *shape) const
Gaudi::Property< bool > m_roundingNoNoise
Gaudi::Property< bool > m_NoiseInEMB
Gaudi::Property< bool > m_NoiseInHEC
boost::container::static_vector< double, s_MaxNSamples > staticVecDouble_t
CaloGain::CaloGain chooseGain(const staticVecDouble_t &samples, const HWIdentifier id, const CaloNum iCalo, const ILArPedestal *ped, const LArADC2MeV *ramp, const float SF) const
boost::container::static_vector< float, s_MaxNSamples > staticVecFloat_t
Gaudi::Property< bool > m_NoiseInFCAL
value_type at(size_t i) const
Vector indexing with bounds check.
const float SF[NF]
Cross sections for Fluor.