From 333b0b2e5e6dcc56528804aca8c67ecf8353772a Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Tue, 10 Sep 2019 20:37:57 -0400 Subject: [PATCH 1/7] monday_new_1 --- .../interface/HGCDigitizerBase.h | 13 +++++++++- .../interface/HGCFEElectronics.h | 2 +- .../python/hgcalDigitizer_cfi.py | 4 +++ .../HGCalSimProducers/src/HGCDigitizerBase.cc | 25 ++++++++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h index 0a540bef0e402..13471a7e02cfc 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h @@ -22,7 +22,7 @@ #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" #include "SimCalorimetry/HGCalSimAlgos/interface/HGCalSiNoiseMap.h" - +#include "TRandom.h" namespace hgc = hgc_digi; namespace hgc_digi_utils { @@ -68,6 +68,10 @@ class HGCDigitizerBase { @short CTOR */ HGCDigitizerBase(const edm::ParameterSet& ps); + /** + @short Gaussian Noise Generation Member Function + */ + void GenerateGaussianNoise(const double NoiseMean, const double NoiseStd); /** @short steer digitization mode */ @@ -150,6 +154,13 @@ class HGCDigitizerBase { //if set to true, threshold will be computed based on the expected meap peak/2 bool thresholdFollowsMIP_; + + // New NoiseArray Parameters + const double NoiseMean_, NoiseStd_; + static const size_t NoiseArrayLength_ = 50000; + static const size_t samplesize_ = 15; + std::array, NoiseArrayLength_> GaussianNoiseArray_; + unsigned int SeedOffset_; }; #endif diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h b/SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h index 6c0d6511e30da..a5989c2bf7ce1 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h @@ -6,7 +6,7 @@ #include "CLHEP/Random/RandGauss.h" #include "CLHEP/Random/RandGaussQ.h" - +#include "CLHEP/Random/RandFlat.h" #include "SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerTypes.h" /** diff --git a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py index 593c7bdb36848..a333de80baf06 100644 --- a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py +++ b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py @@ -66,6 +66,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsEE"), digiCollection = cms.string("HGCDigisEE"), + seedOffset = cms.uint32(9182), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), @@ -135,6 +136,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsHEfront"), digiCollection = cms.string("HGCDigisHEfront"), + seedOffset = cms.uint32(8273), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(5), @@ -203,6 +205,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HcalHits"), digiCollection = cms.string("HGCDigisHEback"), + seedOffset = cms.uint32(7364), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(1), @@ -246,6 +249,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HFNoseHits"), digiCollection = cms.string("HFNoseDigis"), + seedOffset = cms.uint32(5647), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index 94623b346e439..765fe090ab33e 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -6,9 +6,11 @@ using namespace hgc_digi; using namespace hgc_digi_utils; template -HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) : scaleByDose_(false) { +HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) + : scaleByDose_(false), NoiseMean_(0.0), NoiseStd_(1.0) { bxTime_ = ps.getParameter("bxTime"); myCfg_ = ps.getParameter("digiCfg"); + SeedOffset_ = ps.getParameter("seedOffset"), doTimeSamples_ = myCfg_.getParameter("doTimeSamples"); thresholdFollowsMIP_ = myCfg_.getParameter("thresholdFollowsMIP"); @@ -51,6 +53,19 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) : scaleByDo edm::ParameterSet feCfg = myCfg_.getParameter("feCfg"); myFEelectronics_ = std::unique_ptr>(new HGCFEElectronics(feCfg)); myFEelectronics_->SetNoiseValues(noise_fC_); + GenerateGaussianNoise(NoiseMean_, NoiseStd_); +} + +template +void HGCDigitizerBase::GenerateGaussianNoise(const double NoiseMean, const double NoiseStd) { + unsigned int seed = 123456; + seed = seed + SeedOffset_; + TRandom trandom(seed); + for (size_t i = 0; i < NoiseArrayLength_; i++) { + for (size_t j = 0; j < samplesize_; j++) { + GaussianNoiseArray_[i][j] = trandom.Gaus(NoiseMean, NoiseStd); + } + } } template @@ -87,7 +102,8 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCSimHitDataAccumulator::iterator it = simData.find(id); HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second); addCellMetadata(cell, theGeom, id); - + size_t hash_index = (CLHEP::RandFlat::shootInt(engine, (NoiseArrayLength_ - 1)) + id) % NoiseArrayLength_; + auto cellNoiseArray = GaussianNoiseArray_[hash_index]; //set the noise,cce, LSB and threshold to be used float cce(1.f), noiseWidth(0.f), lsbADC(-1.f), maxADC(-1.f); uint32_t thrADC(std::floor(myFEelectronics_->getTargetMipValue() / 2)); @@ -122,7 +138,7 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& toa[i] = cell.hit_info[1][i] / rawCharge; //final charge estimation - float noise = CLHEP::RandGaussQ::shoot(engine, 0.0, noiseWidth); + float noise = (float)cellNoiseArray[i] * noiseWidth; float totalCharge(rawCharge * cce + noise); if (totalCharge < 0.f) totalCharge = 0.f; @@ -131,7 +147,8 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& //run the shaper to create a new data frame DFr rawDataFrame(id); - myFEelectronics_->runShaper(rawDataFrame, chargeColl, toa, engine, thrADC, lsbADC, maxADC, cell.thickness); + int thickness = cell.thickness > 0 ? cell.thickness : 1; + myFEelectronics_->runShaper(rawDataFrame, chargeColl, toa, engine, thrADC, lsbADC, maxADC, thickness); //update the output according to the final shape updateOutput(coll, rawDataFrame); From 632427d394f76c0223131acf4dacef498c99d267 Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Wed, 11 Sep 2019 12:36:14 -0400 Subject: [PATCH 2/7] tue_new_1 --- SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index 765fe090ab33e..c2dd6fbd97fde 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -13,7 +13,6 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) SeedOffset_ = ps.getParameter("seedOffset"), doTimeSamples_ = myCfg_.getParameter("doTimeSamples"); thresholdFollowsMIP_ = myCfg_.getParameter("thresholdFollowsMIP"); - if (myCfg_.exists("keV2fC")) keV2fC_ = myCfg_.getParameter("keV2fC"); else From 835b9f1425cecebf4d1ea1dd5221779cbb17e489 Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Fri, 13 Sep 2019 06:44:52 -0400 Subject: [PATCH 3/7] friday1_EventwiseRandom --- .../HGCalSimProducers/interface/HGCDigitizerBase.h | 7 +++---- .../HGCalSimProducers/src/HGCDigitizerBase.cc | 14 +++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h index 13471a7e02cfc..fce37fe990a0e 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h @@ -22,7 +22,7 @@ #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h" #include "SimCalorimetry/HGCalSimAlgos/interface/HGCalSiNoiseMap.h" -#include "TRandom.h" + namespace hgc = hgc_digi; namespace hgc_digi_utils { @@ -71,7 +71,7 @@ class HGCDigitizerBase { /** @short Gaussian Noise Generation Member Function */ - void GenerateGaussianNoise(const double NoiseMean, const double NoiseStd); + void GenerateGaussianNoise(CLHEP::HepRandomEngine* engine, const double NoiseMean, const double NoiseStd); /** @short steer digitization mode */ @@ -157,10 +157,9 @@ class HGCDigitizerBase { // New NoiseArray Parameters const double NoiseMean_, NoiseStd_; - static const size_t NoiseArrayLength_ = 50000; + static const size_t NoiseArrayLength_ = 20000; static const size_t samplesize_ = 15; std::array, NoiseArrayLength_> GaussianNoiseArray_; - unsigned int SeedOffset_; }; #endif diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index c2dd6fbd97fde..dcb506008d08f 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -10,7 +10,6 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) : scaleByDose_(false), NoiseMean_(0.0), NoiseStd_(1.0) { bxTime_ = ps.getParameter("bxTime"); myCfg_ = ps.getParameter("digiCfg"); - SeedOffset_ = ps.getParameter("seedOffset"), doTimeSamples_ = myCfg_.getParameter("doTimeSamples"); thresholdFollowsMIP_ = myCfg_.getParameter("thresholdFollowsMIP"); if (myCfg_.exists("keV2fC")) @@ -52,17 +51,15 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) edm::ParameterSet feCfg = myCfg_.getParameter("feCfg"); myFEelectronics_ = std::unique_ptr>(new HGCFEElectronics(feCfg)); myFEelectronics_->SetNoiseValues(noise_fC_); - GenerateGaussianNoise(NoiseMean_, NoiseStd_); } template -void HGCDigitizerBase::GenerateGaussianNoise(const double NoiseMean, const double NoiseStd) { - unsigned int seed = 123456; - seed = seed + SeedOffset_; - TRandom trandom(seed); +void HGCDigitizerBase::GenerateGaussianNoise(CLHEP::HepRandomEngine* engine, + const double NoiseMean, + const double NoiseStd) { for (size_t i = 0; i < NoiseArrayLength_; i++) { for (size_t j = 0; j < samplesize_; j++) { - GaussianNoiseArray_[i][j] = trandom.Gaus(NoiseMean, NoiseStd); + GaussianNoiseArray_[i][j] = CLHEP::RandGaussQ::shoot(NoiseMean, NoiseStd); } } } @@ -94,6 +91,7 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCCellInfo zeroData; zeroData.hit_info[0].fill(0.f); //accumulated energy zeroData.hit_info[1].fill(0.f); //time-of-flight + GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); for (const auto& id : validIds) { chargeColl.fill(0.f); @@ -102,7 +100,9 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second); addCellMetadata(cell, theGeom, id); size_t hash_index = (CLHEP::RandFlat::shootInt(engine, (NoiseArrayLength_ - 1)) + id) % NoiseArrayLength_; + auto cellNoiseArray = GaussianNoiseArray_[hash_index]; + //set the noise,cce, LSB and threshold to be used float cce(1.f), noiseWidth(0.f), lsbADC(-1.f), maxADC(-1.f); uint32_t thrADC(std::floor(myFEelectronics_->getTargetMipValue() / 2)); From a999665da2363bad05b0037fa82a12445c5e65dc Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Sat, 14 Sep 2019 13:37:49 -0400 Subject: [PATCH 4/7] sat_1 --- .../HGCalSimProducers/interface/HGCDigitizerBase.h | 4 +++- SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h index fce37fe990a0e..1eb353b98ecd2 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h @@ -156,10 +156,12 @@ class HGCDigitizerBase { bool thresholdFollowsMIP_; // New NoiseArray Parameters + const double NoiseMean_, NoiseStd_; - static const size_t NoiseArrayLength_ = 20000; + static const size_t NoiseArrayLength_ = 100000; static const size_t samplesize_ = 15; std::array, NoiseArrayLength_> GaussianNoiseArray_; + int RandNoiseGenerationFlag_; }; #endif diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index dcb506008d08f..9e3758a70ff1d 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -51,6 +51,7 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) edm::ParameterSet feCfg = myCfg_.getParameter("feCfg"); myFEelectronics_ = std::unique_ptr>(new HGCFEElectronics(feCfg)); myFEelectronics_->SetNoiseValues(noise_fC_); + RandNoiseGenerationFlag_ = 0; } template @@ -73,6 +74,10 @@ void HGCDigitizerBase::run(std::unique_ptr& digiCo CLHEP::HepRandomEngine* engine) { if (scaleByDose_) scal_.setGeometry(theGeom); + if (RandNoiseGenerationFlag_ == 0) { + GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); + RandNoiseGenerationFlag_ = 1; + } if (digitizationType == 0) runSimple(digiColl, simData, theGeom, validIds, engine); else @@ -91,7 +96,7 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCCellInfo zeroData; zeroData.hit_info[0].fill(0.f); //accumulated energy zeroData.hit_info[1].fill(0.f); //time-of-flight - GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); + //GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); for (const auto& id : validIds) { chargeColl.fill(0.f); From 1d73f98788b4afa6f79bcf19801d3765436dbcdc Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Mon, 16 Sep 2019 18:09:59 -0400 Subject: [PATCH 5/7] monday1_revised --- .../HGCalSimProducers/interface/HGCDigitizerBase.h | 4 ++-- .../HGCalSimProducers/python/hgcalDigitizer_cfi.py | 4 ---- SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc | 7 +++---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h index 1eb353b98ecd2..6aaa4ef8bc871 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h @@ -158,10 +158,10 @@ class HGCDigitizerBase { // New NoiseArray Parameters const double NoiseMean_, NoiseStd_; - static const size_t NoiseArrayLength_ = 100000; + static const size_t NoiseArrayLength_ = 200000; static const size_t samplesize_ = 15; std::array, NoiseArrayLength_> GaussianNoiseArray_; - int RandNoiseGenerationFlag_; + bool RandNoiseGenerationFlag_; }; #endif diff --git a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py index a333de80baf06..593c7bdb36848 100644 --- a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py +++ b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py @@ -66,7 +66,6 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsEE"), digiCollection = cms.string("HGCDigisEE"), - seedOffset = cms.uint32(9182), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), @@ -136,7 +135,6 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsHEfront"), digiCollection = cms.string("HGCDigisHEfront"), - seedOffset = cms.uint32(8273), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(5), @@ -205,7 +203,6 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HcalHits"), digiCollection = cms.string("HGCDigisHEback"), - seedOffset = cms.uint32(7364), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(1), @@ -249,7 +246,6 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HFNoseHits"), digiCollection = cms.string("HFNoseDigis"), - seedOffset = cms.uint32(5647), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index 9e3758a70ff1d..67f247a897d44 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -60,7 +60,7 @@ void HGCDigitizerBase::GenerateGaussianNoise(CLHEP::HepRandomEngine* engine const double NoiseStd) { for (size_t i = 0; i < NoiseArrayLength_; i++) { for (size_t j = 0; j < samplesize_; j++) { - GaussianNoiseArray_[i][j] = CLHEP::RandGaussQ::shoot(NoiseMean, NoiseStd); + GaussianNoiseArray_[i][j] = CLHEP::RandGaussQ::shoot(engine, NoiseMean, NoiseStd); } } } @@ -74,9 +74,9 @@ void HGCDigitizerBase::run(std::unique_ptr& digiCo CLHEP::HepRandomEngine* engine) { if (scaleByDose_) scal_.setGeometry(theGeom); - if (RandNoiseGenerationFlag_ == 0) { + if (RandNoiseGenerationFlag_ == false) { GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); - RandNoiseGenerationFlag_ = 1; + RandNoiseGenerationFlag_ = true; } if (digitizationType == 0) runSimple(digiColl, simData, theGeom, validIds, engine); @@ -96,7 +96,6 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCCellInfo zeroData; zeroData.hit_info[0].fill(0.f); //accumulated energy zeroData.hit_info[1].fill(0.f); //time-of-flight - //GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); for (const auto& id : validIds) { chargeColl.fill(0.f); From befd79cf84e194aaab7a77035f62c29636b3bf71 Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Wed, 18 Sep 2019 16:36:51 -0400 Subject: [PATCH 6/7] wed_1 --- .../interface/HGCDigitizerBase.h | 2 ++ .../python/hgcalDigitizer_cfi.py | 4 ++++ .../HGCalSimProducers/src/HGCDigitizerBase.cc | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h index 6aaa4ef8bc871..cabd4d315a0c9 100644 --- a/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h +++ b/SimCalorimetry/HGCalSimProducers/interface/HGCDigitizerBase.h @@ -162,6 +162,8 @@ class HGCDigitizerBase { static const size_t samplesize_ = 15; std::array, NoiseArrayLength_> GaussianNoiseArray_; bool RandNoiseGenerationFlag_; + // A parameter configurable from python configuration to decide which noise generation model to use + bool NoiseGeneration_Method_; }; #endif diff --git a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py index 593c7bdb36848..2a894ad326f86 100644 --- a/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py +++ b/SimCalorimetry/HGCalSimProducers/python/hgcalDigitizer_cfi.py @@ -66,6 +66,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsEE"), digiCollection = cms.string("HGCDigisEE"), + NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), @@ -135,6 +136,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HGCHitsHEfront"), digiCollection = cms.string("HGCDigisHEfront"), + NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(5), @@ -203,6 +205,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HcalHits"), digiCollection = cms.string("HGCDigisHEback"), + NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), tofDelay = cms.double(1), @@ -246,6 +249,7 @@ accumulatorType = cms.string("HGCDigiProducer"), hitCollection = cms.string("HFNoseHits"), digiCollection = cms.string("HFNoseDigis"), + NoiseGeneration_Method = cms.bool(True), maxSimHitsAccTime = cms.uint32(100), bxTime = cms.double(25), eVPerEleHolePair = cms.double(eV_per_eh_pair), diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index 67f247a897d44..bfe4462d56325 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -10,6 +10,7 @@ HGCDigitizerBase::HGCDigitizerBase(const edm::ParameterSet& ps) : scaleByDose_(false), NoiseMean_(0.0), NoiseStd_(1.0) { bxTime_ = ps.getParameter("bxTime"); myCfg_ = ps.getParameter("digiCfg"); + NoiseGeneration_Method_ = ps.getParameter("NoiseGeneration_Method"); doTimeSamples_ = myCfg_.getParameter("doTimeSamples"); thresholdFollowsMIP_ = myCfg_.getParameter("thresholdFollowsMIP"); if (myCfg_.exists("keV2fC")) @@ -74,10 +75,12 @@ void HGCDigitizerBase::run(std::unique_ptr& digiCo CLHEP::HepRandomEngine* engine) { if (scaleByDose_) scal_.setGeometry(theGeom); + if (NoiseGeneration_Method_ == true){ if (RandNoiseGenerationFlag_ == false) { GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); RandNoiseGenerationFlag_ = true; } + } if (digitizationType == 0) runSimple(digiColl, simData, theGeom, validIds, engine); else @@ -96,17 +99,20 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& HGCCellInfo zeroData; zeroData.hit_info[0].fill(0.f); //accumulated energy zeroData.hit_info[1].fill(0.f); //time-of-flight - + std::array cellNoiseArray; + for(size_t i = 0; isecond); addCellMetadata(cell, theGeom, id); + if(NoiseGeneration_Method_ == true){ size_t hash_index = (CLHEP::RandFlat::shootInt(engine, (NoiseArrayLength_ - 1)) + id) % NoiseArrayLength_; - auto cellNoiseArray = GaussianNoiseArray_[hash_index]; - + cellNoiseArray = GaussianNoiseArray_[hash_index]; + } //set the noise,cce, LSB and threshold to be used float cce(1.f), noiseWidth(0.f), lsbADC(-1.f), maxADC(-1.f); uint32_t thrADC(std::floor(myFEelectronics_->getTargetMipValue() / 2)); @@ -141,7 +147,11 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& toa[i] = cell.hit_info[1][i] / rawCharge; //final charge estimation - float noise = (float)cellNoiseArray[i] * noiseWidth; + float noise; + if(NoiseGeneration_Method_ == true) + noise = (float)cellNoiseArray[i] * noiseWidth; + else + noise = CLHEP::RandGaussQ::shoot(engine, cellNoiseArray[i], noiseWidth); float totalCharge(rawCharge * cce + noise); if (totalCharge < 0.f) totalCharge = 0.f; From f4638e6cf133dbf830065af26646edcf2b3a0e00 Mon Sep 17 00:00:00 2001 From: Abhishek Das Date: Wed, 18 Sep 2019 16:41:26 -0400 Subject: [PATCH 7/7] PythonConfigurableRandNoiseMethod --- .../HGCalSimProducers/src/HGCDigitizerBase.cc | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc index bfe4462d56325..4a40cdad1bf26 100644 --- a/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc +++ b/SimCalorimetry/HGCalSimProducers/src/HGCDigitizerBase.cc @@ -75,11 +75,11 @@ void HGCDigitizerBase::run(std::unique_ptr& digiCo CLHEP::HepRandomEngine* engine) { if (scaleByDose_) scal_.setGeometry(theGeom); - if (NoiseGeneration_Method_ == true){ - if (RandNoiseGenerationFlag_ == false) { - GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); - RandNoiseGenerationFlag_ = true; - } + if (NoiseGeneration_Method_ == true) { + if (RandNoiseGenerationFlag_ == false) { + GenerateGaussianNoise(engine, NoiseMean_, NoiseStd_); + RandNoiseGenerationFlag_ = true; + } } if (digitizationType == 0) runSimple(digiColl, simData, theGeom, validIds, engine); @@ -100,7 +100,7 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& zeroData.hit_info[0].fill(0.f); //accumulated energy zeroData.hit_info[1].fill(0.f); //time-of-flight std::array cellNoiseArray; - for(size_t i = 0; i::runSimple(std::unique_ptr& HGCSimHitDataAccumulator::iterator it = simData.find(id); HGCCellInfo& cell = (simData.end() == it ? zeroData : it->second); addCellMetadata(cell, theGeom, id); - if(NoiseGeneration_Method_ == true){ - size_t hash_index = (CLHEP::RandFlat::shootInt(engine, (NoiseArrayLength_ - 1)) + id) % NoiseArrayLength_; + if (NoiseGeneration_Method_ == true) { + size_t hash_index = (CLHEP::RandFlat::shootInt(engine, (NoiseArrayLength_ - 1)) + id) % NoiseArrayLength_; - cellNoiseArray = GaussianNoiseArray_[hash_index]; + cellNoiseArray = GaussianNoiseArray_[hash_index]; } //set the noise,cce, LSB and threshold to be used float cce(1.f), noiseWidth(0.f), lsbADC(-1.f), maxADC(-1.f); @@ -148,10 +148,10 @@ void HGCDigitizerBase::runSimple(std::unique_ptr& //final charge estimation float noise; - if(NoiseGeneration_Method_ == true) - noise = (float)cellNoiseArray[i] * noiseWidth; + if (NoiseGeneration_Method_ == true) + noise = (float)cellNoiseArray[i] * noiseWidth; else - noise = CLHEP::RandGaussQ::shoot(engine, cellNoiseArray[i], noiseWidth); + noise = CLHEP::RandGaussQ::shoot(engine, cellNoiseArray[i], noiseWidth); float totalCharge(rawCharge * cce + noise); if (totalCharge < 0.f) totalCharge = 0.f;