269 {
270
271 bool createDigit_DigiHSTruth = true;
272
273
275 short Adc;
276 short Adc_DigiHSTruth;
277
279 std::vector<short> AdcSample_DigiHSTruth(
m_NSamples);
280
282 float SigmaNoise;
284
290 else if (
m_larem_id->is_em_endcap_inner(cellId))
292
295
296
297
299
300
301
302
303#ifndef NDEBUG
306#endif
307
314
315
316
317
318
319#ifndef NDEBUG
320 ATH_MSG_DEBUG(
" number of hit for this cell " << TimeE->size());
321#endif
322
323
324
325
326 bool isDead =
m_bcMask.cellShouldBeMasked(bcCont,ch_id);
327
328
329 if (!isDead) {
330 if( this->
ConvertHits2Samples(cellId,ch_id,initialGain,TimeE, Samples, shape).isFailure() ) {
331 return StatusCode::SUCCESS;
332 }
334 if( this->
ConvertHits2Samples(cellId,ch_id,initialGain,TimeE_DigiHSTruth, Samples_DigiHSTruth, shape).isFailure() ) {
335 return StatusCode::SUCCESS;
336 }
337 }
338 }
339
340
341
342
343 float energy2adc ;
344 float rAdc ;
346 {
347 rndmGain= rndmEvtDigit->gain();
348 auto polynom_adc2mev =adc2MeVs->
ADC2MEV(ch_id,rndmEvtDigit->gain());
349 if (polynom_adc2mev.size() > 1) {
350 float adc2energy =
SF * polynom_adc2mev[1];
351 const std::vector<short> & rndm_digit_samples = rndmEvtDigit->samples() ;
352 float Pedestal = pedestal->
pedestal(ch_id,rndmEvtDigit->gain());
354 ATH_MSG_WARNING(
" Pedestal not found in database for this channel offID " << cellId <<
" Use sample 0 for random");
355 Pedestal = rndm_digit_samples[0];
356 }
357 ATH_MSG_DEBUG(
" Params for inverting LAr Digitization: pedestal " << Pedestal <<
" adc2energy " << adc2energy);
358
359
360
361 float adc0=0.;
363 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
364 if (larOFC.cptr() != nullptr) {
366 float sumOfc=0.;
367 if (ofc_a.size()>0) {
368 for (
unsigned int j=0;
j<ofc_a.size();
j++) sumOfc += ofc_a.
at(j);
369 }
370 if (sumOfc>0) adc0 = polynom_adc2mev[0] *
SF /sumOfc;
371 }
372 }
373
375 if ((
int)(rndm_digit_samples.size()) <
m_NSamples) {
377 "Less digit Samples than requested in digitization for cell "
378 << ch_id.
get_compact() <<
" Digit has " << rndm_digit_samples.size()
379 <<
" samples. Digitization request " <<
m_NSamples);
380 nmax = rndm_digit_samples.size();
381 }
383 {
384 rAdc = (rndm_digit_samples[
i] - Pedestal ) * adc2energy + adc0;
385 rndm_energy_samples[
i] = rAdc ;
387 }
388 }
389 else {
390 ATH_MSG_WARNING(
" No ramp found for this random cell " <<
m_larem_id->show_to_string(cellId) <<
" for gain " << rndmEvtDigit->gain());
391 }
392 }
393
394
397 return StatusCode::FAILURE;
398 }
399
400
401 igain=std::max(rndmGain,igain);
402
403
404
405
406 if (igain != initialGain ){
410 else Samples[
i] = 0.;
411 }
412
413 if (!isDead) {
414 if( this->
ConvertHits2Samples(cellId,ch_id,igain,TimeE, Samples, shape) == StatusCode::FAILURE ) {
415 return StatusCode::SUCCESS;
416 }
418 if( this->
ConvertHits2Samples(cellId,ch_id,igain,TimeE_DigiHSTruth, Samples_DigiHSTruth, shape) == StatusCode::FAILURE ) {
419 return StatusCode::SUCCESS;
420 }
421 }
422 }
423 }
424
425
426
427
428
429 double Rndm[32]{};
430 int BvsEC=0;
432
433 bool addedNoise=false;
437
438 {
441 SigmaNoise =
noise->noise(ch_id, igain);
442 } else {
443 float thisNoise = pedestal->
pedestalRMS(ch_id, igain);
445 SigmaNoise = thisNoise;
446 else
447 SigmaNoise = 0.;
448 }
449
450 const std::vector<float>& CorGen =
456 return StatusCode::FAILURE;
457 }
458
459 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0., 1.);
460
464 for (
int j = 0;
j <=
i;
j++) {
466 Noise[
i] += Rndm[
j] * CorGen[
index];
467 }
468 Noise[
i] = Noise[
i] * SigmaNoise;
469 }
470 addedNoise = true;
471 } else {
472
474 Noise[i] = 0.;
475
476
477
478
479 if (rndmEvtDigit) {
480
481 if (igain > rndmEvtDigit->gain()) {
482 double SigmaNoiseZB = 0.;
483 double SigmaNoise = 0.;
484 double SigmaExtraNoise = 0.;
486 SigmaNoiseZB =
noise->noise(ch_id, rndmEvtDigit->gain());
487 SigmaNoise =
noise->noise(ch_id, igain);
488 } else {
489 float thisNoise = pedestal->
pedestalRMS(ch_id, rndmEvtDigit->gain());
491 SigmaNoiseZB = thisNoise;
492 else
493 SigmaNoiseZB = 0.;
496 SigmaNoise = thisNoise;
497 else
498 SigmaNoise = 0.;
499 }
500
501 auto polynom_adc2mevZB =
502 adc2MeVs->
ADC2MEV(cellId, rndmEvtDigit->gain());
503 auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId, igain);
504 if (polynom_adc2mevZB.size() > 1 && polynom_adc2mev.size() > 1) {
505 if (polynom_adc2mev[1] > 0.) {
506 SigmaNoiseZB = SigmaNoiseZB * (polynom_adc2mevZB[1]) /
507 (polynom_adc2mev[1]);
508 if (SigmaNoise > SigmaNoiseZB)
509 SigmaExtraNoise = sqrt(SigmaNoise * SigmaNoise -
510 SigmaNoiseZB * SigmaNoiseZB);
511 }
512 }
513 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0.,
514 1.);
516 Noise[i] = SigmaExtraNoise * Rndm[i];
517 addedNoise = true;
518 }
519 }
520 }
521 }
522
523
524
525 float Pedestal = pedestal->
pedestal(ch_id,igain);
527 ATH_MSG_WARNING(
" pedestal not found for cellId " << cellId <<
" assume 1000" );
528 Pedestal=1000.;
529 }
530 const auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId,igain);
531 if (polynom_adc2mev.size() < 2) {
532 ATH_MSG_WARNING(
" No ramp found for requested gain " << igain <<
" for cell " <<
m_larem_id->show_to_string(cellId) <<
" no digit made...");
533 return StatusCode::SUCCESS;
534 }
535
536 energy2adc=1./(polynom_adc2mev[1])/SF;
537
538
539
541 {
542 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
543 if (larOFC.cptr() != nullptr) {
544 float sumOfc=0.;
546 if (ofc_a.size()>0) {
547 for (
unsigned int j=0;
j<ofc_a.size();
j++) sumOfc+= ofc_a.
at(j);
548 }
549 if ((polynom_adc2mev[1])>0 && sumOfc>0) Pedestal = Pedestal - (polynom_adc2mev[0])/(polynom_adc2mev[1])/sumOfc;
550 ATH_MSG_DEBUG(
" Params for final LAr Digitization gain: " << igain <<
" pedestal: " << Pedestal <<
" energy2adc: " << energy2adc);
551 }
552 }
554 {
555 double xAdc;
556 double xAdc_DigiHSTruth = 0;
557
558 if ( addedNoise ){
559 xAdc = Samples[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
561 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
562 }
563 }
564
565 else {
567 float flatRndm = RandFlat::shoot(engine);
568 xAdc = Samples[
i]*energy2adc + Pedestal + flatRndm;
570 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + flatRndm;
571 }
572
573 }
574 else{
575 xAdc = Samples[
i]*energy2adc + Pedestal + 0.5;
577 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + 0.5;
578 }
579 }
580
581 }
582
583
584
585
586
587 if (xAdc <0) Adc=0;
589 else Adc = (
short) xAdc;
590
592
594 if (xAdc_DigiHSTruth <0) Adc_DigiHSTruth=0;
596 else Adc_DigiHSTruth = (
short) xAdc_DigiHSTruth;
597 AdcSample_DigiHSTruth[
i] = Adc_DigiHSTruth;
598 }
599
600#ifndef NDEBUG
601 ATH_MSG_DEBUG(
" Sample " << i <<
" Energy= " << Samples[i] <<
" Adc=" << Adc);
602#endif
603
604 }
605
606
607
608
610 (*Digit)=LArDigit(ch_id,igain,std::move(AdcSample));
611
613 createDigit_DigiHSTruth = false;
614 Digit_DigiHSTruth = nullptr;
615
617 if (Samples_DigiHSTruth[i] != 0)
618 createDigit_DigiHSTruth = true;
619 }
620
621 Digit_DigiHSTruth =
622 new LArDigit(ch_id, igain, std::move(AdcSample_DigiHSTruth));
623 }
624
625 return StatusCode::SUCCESS;
626}
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.
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.