225 {
226 bool createDigit_DigiHSTruth = true;
227
228
230 short Adc;
231 short Adc_DigiHSTruth;
232
234 std::vector<short> AdcSample_DigiHSTruth(
m_NSamples);
235
237 float SigmaNoise;
239
240
241 SG::ReadCondHandle<LArADC2MeV> adc2mevHdl(
m_adc2mevKey, ctx);
242 const LArADC2MeV* adc2MeVs=*adc2mevHdl;
243
244 SG::ReadCondHandle<ILArfSampl> fSamplHdl(
m_fSamplKey, ctx);
245 const ILArfSampl* fSampl=*fSamplHdl;
246
248 const ILArPedestal* pedestal=*pedHdl;
249
250 const ILArNoise*
noise=
nullptr;
252 SG::ReadCondHandle<ILArNoise> noiseHdl(
m_noiseKey, ctx);
254 }
255
256 const LArAutoCorrNoise* autoCorrNoise=nullptr;
259 autoCorrNoise=*autoCorrNoiseHdl;
260 }
261
265
271 else if (
m_larem_id->is_em_endcap_inner(cellId))
273
276
277
278
280
281
282
283
284#ifndef NDEBUG
287#endif
288
295
296
297
298
299
300#ifndef NDEBUG
301 ATH_MSG_DEBUG(
" number of hit for this cell " << TimeE->size());
302#endif
303
304
305
306
307 bool isDead =
m_bcMask.cellShouldBeMasked(bcCont,ch_id);
308
309
310 if (!isDead) {
311 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE, Samples).isFailure() ) {
312 return StatusCode::SUCCESS;
313 }
315 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE_DigiHSTruth, Samples_DigiHSTruth).isFailure() ) {
316 return StatusCode::SUCCESS;
317 }
318 }
319 }
320
321
322
323
324 float energy2adc ;
325 float rAdc ;
327 {
328 rndmGain= rndmEvtDigit->gain();
329 auto polynom_adc2mev =adc2MeVs->
ADC2MEV(ch_id,rndmEvtDigit->gain());
330 if (polynom_adc2mev.size() > 1) {
331 float adc2energy =
SF * polynom_adc2mev[1];
332 const std::vector<short> & rndm_digit_samples = rndmEvtDigit->samples() ;
333 float Pedestal = pedestal->
pedestal(ch_id,rndmEvtDigit->gain());
335 ATH_MSG_WARNING(
" Pedestal not found in database for this channel offID " << cellId <<
" Use sample 0 for random");
336 Pedestal = rndm_digit_samples[0];
337 }
338 ATH_MSG_DEBUG(
" Params for inverting LAr Digitization: pedestal " << Pedestal <<
" adc2energy " << adc2energy);
339
340
341
342 float adc0=0.;
344 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
345 if (larOFC.cptr() != nullptr) {
347 float sumOfc=0.;
348 if (ofc_a.size()>0) {
349 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc += ofc_a.
at(j);
350 }
351 if (sumOfc>0) adc0 = polynom_adc2mev[0] *
SF /sumOfc;
352 }
353 }
354
356 if ((
int)(rndm_digit_samples.size()) <
m_NSamples) {
358 "Less digit Samples than requested in digitization for cell "
359 << ch_id.
get_compact() <<
" Digit has " << rndm_digit_samples.size()
360 <<
" samples. Digitization request " <<
m_NSamples);
361 nmax = rndm_digit_samples.size();
362 }
364 {
365 rAdc = (rndm_digit_samples[
i] - Pedestal ) * adc2energy + adc0;
366 rndm_energy_samples[
i] = rAdc ;
368 }
369 }
370 else {
371 ATH_MSG_WARNING(
" No ramp found for this random cell " <<
m_larem_id->show_to_string(cellId) <<
" for gain " << rndmEvtDigit->gain());
372 }
373 }
374
375
378 return StatusCode::FAILURE;
379 }
380
381
382 igain=std::max(rndmGain,igain);
383
384
385
386
387 if (igain != initialGain ){
391 else Samples[
i] = 0.;
392 }
393
394 if (!isDead) {
395 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,igain,TimeE, Samples) == StatusCode::FAILURE ) {
396 return StatusCode::SUCCESS;
397 }
399 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,igain,TimeE_DigiHSTruth, Samples_DigiHSTruth) == StatusCode::FAILURE ) {
400 return StatusCode::SUCCESS;
401 }
402 }
403 }
404 }
405
406
407
408
409
410 double Rndm[32]{};
411 int BvsEC=0;
413
414 bool addedNoise=false;
418
419 {
422 SigmaNoise =
noise->noise(ch_id, igain);
423 } else {
427 else
428 SigmaNoise = 0.;
429 }
430
431 const std::vector<float>& CorGen =
437 return StatusCode::FAILURE;
438 }
439
440 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0., 1.);
441
445 for (
int j = 0; j <=
i; j++) {
447 Noise[
i] += Rndm[j] * CorGen[
index];
448 }
449 Noise[
i] = Noise[
i] * SigmaNoise;
450 }
451 addedNoise = true;
452 } else {
453
455 Noise[i] = 0.;
456
457
458
459
460 if (rndmEvtDigit) {
461
462 if (igain > rndmEvtDigit->gain()) {
463 double SigmaNoiseZB = 0.;
464 double SigmaNoise = 0.;
465 double SigmaExtraNoise = 0.;
467 SigmaNoiseZB =
noise->noise(ch_id, rndmEvtDigit->gain());
468 SigmaNoise =
noise->noise(ch_id, igain);
469 } else {
472 SigmaNoiseZB =
noise;
473 else
474 SigmaNoiseZB = 0.;
478 else
479 SigmaNoise = 0.;
480 }
481
482 auto polynom_adc2mevZB =
483 adc2MeVs->
ADC2MEV(cellId, rndmEvtDigit->gain());
484 auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId, igain);
485 if (polynom_adc2mevZB.size() > 1 && polynom_adc2mev.size() > 1) {
486 if (polynom_adc2mev[1] > 0.) {
487 SigmaNoiseZB = SigmaNoiseZB * (polynom_adc2mevZB[1]) /
488 (polynom_adc2mev[1]);
489 if (SigmaNoise > SigmaNoiseZB)
490 SigmaExtraNoise = sqrt(SigmaNoise * SigmaNoise -
491 SigmaNoiseZB * SigmaNoiseZB);
492 }
493 }
494 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0.,
495 1.);
497 Noise[i] = SigmaExtraNoise * Rndm[i];
498 addedNoise = true;
499 }
500 }
501 }
502 }
503
504
505
506 float Pedestal = pedestal->
pedestal(ch_id,igain);
508 ATH_MSG_WARNING(
" pedestal not found for cellId " << cellId <<
" assume 1000" );
509 Pedestal=1000.;
510 }
511 const auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId,igain);
512 if (polynom_adc2mev.size() < 2) {
513 ATH_MSG_WARNING(
" No ramp found for requested gain " << igain <<
" for cell " <<
m_larem_id->show_to_string(cellId) <<
" no digit made...");
514 return StatusCode::SUCCESS;
515 }
516
517 energy2adc=1./(polynom_adc2mev[1])/SF;
518
519
520
522 {
523 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
524 if (larOFC.cptr() != nullptr) {
525 float sumOfc=0.;
527 if (ofc_a.size()>0) {
528 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc+= ofc_a.
at(j);
529 }
530 if ((polynom_adc2mev[1])>0 && sumOfc>0) Pedestal = Pedestal - (polynom_adc2mev[0])/(polynom_adc2mev[1])/sumOfc;
531 ATH_MSG_DEBUG(
" Params for final LAr Digitization gain: " << igain <<
" pedestal: " << Pedestal <<
" energy2adc: " << energy2adc);
532 }
533 }
535 {
536 double xAdc;
537 double xAdc_DigiHSTruth = 0;
538
539 if ( addedNoise ){
540 xAdc = Samples[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
542 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
543 }
544 }
545
546 else {
548 float flatRndm = RandFlat::shoot(engine);
549 xAdc = Samples[
i]*energy2adc + Pedestal + flatRndm;
551 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + flatRndm;
552 }
553
554 }
555 else{
556 xAdc = Samples[
i]*energy2adc + Pedestal + 0.5;
558 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + 0.5;
559 }
560 }
561
562 }
563
564
565
566
567
568 if (xAdc <0) Adc=0;
570 else Adc = (
short) xAdc;
571
573
575 if (xAdc_DigiHSTruth <0) Adc_DigiHSTruth=0;
577 else Adc_DigiHSTruth = (
short) xAdc_DigiHSTruth;
578 AdcSample_DigiHSTruth[
i] = Adc_DigiHSTruth;
579 }
580
581#ifndef NDEBUG
582 ATH_MSG_DEBUG(
" Sample " << i <<
" Energy= " << Samples[i] <<
" Adc=" << Adc);
583#endif
584
585 }
586
587
588
589
591 (*Digit)=LArDigit(ch_id,igain,std::move(AdcSample));
592
594 createDigit_DigiHSTruth = false;
595 Digit_DigiHSTruth = nullptr;
596
598 if (Samples_DigiHSTruth[i] != 0)
599 createDigit_DigiHSTruth = true;
600 }
601
602 Digit_DigiHSTruth =
603 new LArDigit(ch_id, igain, std::move(AdcSample_DigiHSTruth));
604 }
605
606 return StatusCode::SUCCESS;
607}
LArBadXCont< LArBadChannel > LArBadChannelCont
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
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
StatusCode ConvertHits2Samples(const EventContext &ctx, const Identifier &cellId, HWIdentifier ch_id, CaloGain::CaloGain igain, const std::vector< std::pair< float, float > > *TimeE, staticVecDouble_t &sampleList) 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.