Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:45

0001 #include "SimMuon/GEMDigitizer/interface/GEMNoiseModel.h"
0002 #include "Geometry/GEMGeometry/interface/GEMEtaPartitionSpecs.h"
0003 #include "Geometry/CommonTopologies/interface/GEMStripTopology.h"
0004 #include "Geometry/GEMGeometry/interface/GEMGeometry.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "CLHEP/Random/RandFlat.h"
0007 #include "CLHEP/Random/RandPoissonQ.h"
0008 #include "CLHEP/Random/RandGaussQ.h"
0009 #include <cmath>
0010 #include <utility>
0011 #include <map>
0012 
0013 GEMNoiseModel::GEMNoiseModel(const edm::ParameterSet& config)
0014     : GEMDigiModel(config),
0015       averageNoiseRate_(config.getParameter<double>("averageNoiseRate")),
0016       bxWidth_(config.getParameter<double>("bxWidth")),
0017       minBunch_(config.getParameter<int>("minBunch")),
0018       maxBunch_(config.getParameter<int>("maxBunch")) {}
0019 
0020 GEMNoiseModel::~GEMNoiseModel() {}
0021 
0022 void GEMNoiseModel::simulate(const GEMEtaPartition* roll,
0023                              const edm::PSimHitContainer&,
0024                              CLHEP::HepRandomEngine* engine,
0025                              Strips& strips_,
0026                              DetectorHitMap& detectorHitMap_) {
0027   const GEMDetId& gemId(roll->id());
0028   const int nstrips(roll->nstrips());
0029   double trStripArea(0.0);
0030   if (gemId.region() == 0) {
0031     throw cms::Exception("Geometry") << "GEMNoiseModel::simulate() - this GEM id is from barrel, which cannot happen.";
0032   }
0033   const GEMStripTopology* top_(dynamic_cast<const GEMStripTopology*>(&(roll->topology())));
0034   const float striplength(top_->stripLength());
0035   trStripArea = (roll->pitch()) * striplength;
0036   float trArea(trStripArea * nstrips);
0037   const int nBxing(maxBunch_ - minBunch_ + 1);
0038   //simulate intrinsic noise
0039   const double aveIntrinsicNoise(averageNoiseRate_ * nBxing * trArea * bxWidth_);
0040   CLHEP::RandPoissonQ randPoissonQ(*engine, aveIntrinsicNoise);
0041   const int n_intrHits(randPoissonQ.fire());
0042 
0043   for (int k = 0; k < n_intrHits; k++) {
0044     const int centralStrip(static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips)));
0045     const int time_hit(static_cast<int>(CLHEP::RandFlat::shoot(engine, nBxing)) + minBunch_);
0046     strips_.emplace(centralStrip, time_hit);
0047   }
0048   //end simulate intrinsic noise
0049 
0050   return;
0051 }