220 {
221 bool createDigit_DigiHSTruth = true;
222
223
225 short Adc;
226 short Adc_DigiHSTruth;
227
229 std::vector<short> AdcSample_DigiHSTruth(
m_NSamples);
230
232 float SigmaNoise;
234
235
236 SG::ReadCondHandle<LArADC2MeV> adc2mevHdl(
m_adc2mevKey, ctx);
237 const LArADC2MeV* adc2MeVs=*adc2mevHdl;
238
239 SG::ReadCondHandle<ILArfSampl> fSamplHdl(
m_fSamplKey, ctx);
240 const ILArfSampl* fSampl=*fSamplHdl;
241
243 const ILArPedestal* pedestal=*pedHdl;
244
245 const ILArNoise*
noise=
nullptr;
247 SG::ReadCondHandle<ILArNoise> noiseHdl(
m_noiseKey, ctx);
249 }
250
251 const LArAutoCorrNoise* autoCorrNoise=nullptr;
254 autoCorrNoise=*autoCorrNoiseHdl;
255 }
256
260
266 else if (
m_larem_id->is_em_endcap_inner(cellId))
268
271
272
273
275
276
277
278
279#ifndef NDEBUG
282#endif
283
290
291
292
293
294
295#ifndef NDEBUG
296 ATH_MSG_DEBUG(
" number of hit for this cell " << TimeE->size());
297#endif
298
299
300
301
302 bool isDead =
m_bcMask.cellShouldBeMasked(bcCont,ch_id);
303
304
305 if (!isDead) {
306 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE, Samples).isFailure() ) {
307 return StatusCode::SUCCESS;
308 }
310 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,initialGain,TimeE_DigiHSTruth, Samples_DigiHSTruth).isFailure() ) {
311 return StatusCode::SUCCESS;
312 }
313 }
314 }
315
316
317
318
319 float energy2adc ;
320 float rAdc ;
322 {
323 rndmGain= rndmEvtDigit->gain();
324 auto polynom_adc2mev =adc2MeVs->
ADC2MEV(ch_id,rndmEvtDigit->gain());
325 if (polynom_adc2mev.size() > 1) {
326 float adc2energy =
SF * polynom_adc2mev[1];
327 const std::vector<short> & rndm_digit_samples = rndmEvtDigit->samples() ;
328 float Pedestal = pedestal->
pedestal(ch_id,rndmEvtDigit->gain());
330 ATH_MSG_WARNING(
" Pedestal not found in database for this channel offID " << cellId <<
" Use sample 0 for random");
331 Pedestal = rndm_digit_samples[0];
332 }
333 ATH_MSG_DEBUG(
" Params for inverting LAr Digitization: pedestal " << Pedestal <<
" adc2energy " << adc2energy);
334
335
336
337 float adc0=0.;
339 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
340 if (larOFC.cptr() != nullptr) {
342 float sumOfc=0.;
343 if (ofc_a.size()>0) {
344 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc += ofc_a.
at(j);
345 }
346 if (sumOfc>0) adc0 = polynom_adc2mev[0] *
SF /sumOfc;
347 }
348 }
349
351 if ((
int)(rndm_digit_samples.size()) <
m_NSamples) {
353 "Less digit Samples than requested in digitization for cell "
354 << ch_id.
get_compact() <<
" Digit has " << rndm_digit_samples.size()
355 <<
" samples. Digitization request " <<
m_NSamples);
356 nmax = rndm_digit_samples.size();
357 }
359 {
360 rAdc = (rndm_digit_samples[
i] - Pedestal ) * adc2energy + adc0;
361 rndm_energy_samples[
i] = rAdc ;
363 }
364 }
365 else {
366 ATH_MSG_WARNING(
" No ramp found for this random cell " <<
m_larem_id->show_to_string(cellId) <<
" for gain " << rndmEvtDigit->gain());
367 }
368 }
369
370
373 return StatusCode::FAILURE;
374 }
375
376
377 igain=std::max(rndmGain,igain);
378
379
380
381
382 if (igain != initialGain ){
386 else Samples[
i] = 0.;
387 }
388
389 if (!isDead) {
390 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,igain,TimeE, Samples) == StatusCode::FAILURE ) {
391 return StatusCode::SUCCESS;
392 }
394 if( this->
ConvertHits2Samples(ctx, cellId,ch_id,igain,TimeE_DigiHSTruth, Samples_DigiHSTruth) == StatusCode::FAILURE ) {
395 return StatusCode::SUCCESS;
396 }
397 }
398 }
399 }
400
401
402
403
404
405 double Rndm[32]{};
406 int BvsEC=0;
408
409 bool addedNoise=false;
413
414 {
417 SigmaNoise =
noise->noise(ch_id, igain);
418 } else {
422 else
423 SigmaNoise = 0.;
424 }
425
426 const std::vector<float>& CorGen =
432 return StatusCode::FAILURE;
433 }
434
435 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0., 1.);
436
440 for (
int j = 0; j <=
i; j++) {
442 Noise[
i] += Rndm[j] * CorGen[
index];
443 }
444 Noise[
i] = Noise[
i] * SigmaNoise;
445 }
446 addedNoise = true;
447 } else {
448
450 Noise[i] = 0.;
451
452
453
454
455 if (rndmEvtDigit) {
456
457 if (igain > rndmEvtDigit->gain()) {
458 double SigmaNoiseZB = 0.;
459 double SigmaNoise = 0.;
460 double SigmaExtraNoise = 0.;
462 SigmaNoiseZB =
noise->noise(ch_id, rndmEvtDigit->gain());
463 SigmaNoise =
noise->noise(ch_id, igain);
464 } else {
467 SigmaNoiseZB =
noise;
468 else
469 SigmaNoiseZB = 0.;
473 else
474 SigmaNoise = 0.;
475 }
476
477 auto polynom_adc2mevZB =
478 adc2MeVs->
ADC2MEV(cellId, rndmEvtDigit->gain());
479 auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId, igain);
480 if (polynom_adc2mevZB.size() > 1 && polynom_adc2mev.size() > 1) {
481 if (polynom_adc2mev[1] > 0.) {
482 SigmaNoiseZB = SigmaNoiseZB * (polynom_adc2mevZB[1]) /
483 (polynom_adc2mev[1]);
484 if (SigmaNoise > SigmaNoiseZB)
485 SigmaExtraNoise = sqrt(SigmaNoise * SigmaNoise -
486 SigmaNoiseZB * SigmaNoiseZB);
487 }
488 }
489 RandGaussZiggurat::shootArray(engine,
m_NSamples, Rndm, 0.,
490 1.);
492 Noise[i] = SigmaExtraNoise * Rndm[i];
493 addedNoise = true;
494 }
495 }
496 }
497 }
498
499
500
501 float Pedestal = pedestal->
pedestal(ch_id,igain);
503 ATH_MSG_WARNING(
" pedestal not found for cellId " << cellId <<
" assume 1000" );
504 Pedestal=1000.;
505 }
506 const auto polynom_adc2mev = adc2MeVs->
ADC2MEV(cellId,igain);
507 if (polynom_adc2mev.size() < 2) {
508 ATH_MSG_WARNING(
" No ramp found for requested gain " << igain <<
" for cell " <<
m_larem_id->show_to_string(cellId) <<
" no digit made...");
509 return StatusCode::SUCCESS;
510 }
511
512 energy2adc=1./(polynom_adc2mev[1])/SF;
513
514
515
517 {
518 SG::ReadCondHandle<ILArOFC> larOFC(
m_OFCKey, ctx);
519 if (larOFC.cptr() != nullptr) {
520 float sumOfc=0.;
522 if (ofc_a.size()>0) {
523 for (
unsigned int j=0;j<ofc_a.size();j++) sumOfc+= ofc_a.
at(j);
524 }
525 if ((polynom_adc2mev[1])>0 && sumOfc>0) Pedestal = Pedestal - (polynom_adc2mev[0])/(polynom_adc2mev[1])/sumOfc;
526 ATH_MSG_DEBUG(
" Params for final LAr Digitization gain: " << igain <<
" pedestal: " << Pedestal <<
" energy2adc: " << energy2adc);
527 }
528 }
530 {
531 double xAdc;
532 double xAdc_DigiHSTruth = 0;
533
534 if ( addedNoise ){
535 xAdc = Samples[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
537 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Noise[
i] + Pedestal + 0.5;
538 }
539 }
540
541 else {
543 float flatRndm = RandFlat::shoot(engine);
544 xAdc = Samples[
i]*energy2adc + Pedestal + flatRndm;
546 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + flatRndm;
547 }
548
549 }
550 else{
551 xAdc = Samples[
i]*energy2adc + Pedestal + 0.5;
553 xAdc_DigiHSTruth = Samples_DigiHSTruth[
i]*energy2adc + Pedestal + 0.5;
554 }
555 }
556
557 }
558
559
560
561
562
563 if (xAdc <0) Adc=0;
565 else Adc = (
short) xAdc;
566
568
570 if (xAdc_DigiHSTruth <0) Adc_DigiHSTruth=0;
572 else Adc_DigiHSTruth = (
short) xAdc_DigiHSTruth;
573 AdcSample_DigiHSTruth[
i] = Adc_DigiHSTruth;
574 }
575
576#ifndef NDEBUG
577 ATH_MSG_DEBUG(
" Sample " << i <<
" Energy= " << Samples[i] <<
" Adc=" << Adc);
578#endif
579
580 }
581
582
583
584
586 (*Digit)=LArDigit(ch_id,igain,std::move(AdcSample));
587
589 createDigit_DigiHSTruth = false;
590 Digit_DigiHSTruth = nullptr;
591
593 if (Samples_DigiHSTruth[i] != 0)
594 createDigit_DigiHSTruth = true;
595 }
596
597 Digit_DigiHSTruth =
598 new LArDigit(ch_id, igain, std::move(AdcSample_DigiHSTruth));
599 }
600
601 return StatusCode::SUCCESS;
602}
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.