9 #include "CLHEP/Random/RandFlat.h"
10 #include "CLHEP/Random/RandGaussQ.h"
11 #include "CLHEP/Random/RandPoissonQ.h"
22 sigma_t(config.getParameter<double>(
"timeResolution")),
23 sigma_u(config.getParameter<double>(
"phiResolution")),
24 sigma_v(config.getParameter<double>(
"etaResolution")),
25 corr(config.getParameter<bool>(
"useCorrelation")),
26 etaproj(config.getParameter<bool>(
"useEtaProjectiveGEO")),
27 digitizeOnlyMuons_(config.getParameter<bool>(
"digitizeOnlyMuons")),
28 gaussianSmearing_(config.getParameter<bool>(
"gaussianSmearing")),
29 averageEfficiency_(config.getParameter<double>(
"averageEfficiency")),
32 simulateElectronBkg_(config.getParameter<bool>(
"simulateElectronBkg")),
33 simulateNeutralBkg_(config.getParameter<bool>(
"simulateNeutralBkg")),
34 minBunch_(config.getParameter<int>(
"minBunch")),
35 maxBunch_(config.getParameter<int>(
"maxBunch"))
50 for (
const auto &
hit: simHits)
67 x=
entry.x()+(CLHEP::RandFlat::shoot(engine)-0.5)*
sigma_u;
73 double tof=CLHEP::RandGaussQ::shoot(engine,
hit.timeOfFlight(),
sigma_t);
74 int pdgid =
hit.particleType();
78 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: simhit in "<<roll->
id()<<
" at loc x = "<<std::setw(8)<<
entry.x()<<
" [cm]"
79 <<
" loc y = "<<std::setw(8)<<
entry.y()<<
" [cm] time = "<<std::setw(8)<<
hit.timeOfFlight()<<
" [ns] pdgid = "<<std::showpos<<std::setw(4)<<pdgid;
80 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: digi in "<<roll->
id()<<
" at loc x = "<<std::setw(8)<<x<<
" [cm] loc y = "<<std::setw(8)<<
y<<
" [cm]"
81 <<
" time = "<<std::setw(8)<<tof<<
" [ns]";
82 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: digi in "<<roll->
id()<<
" with DX = "<<std::setw(8)<<(
entry.x()-
x)<<
" [cm]"
83 <<
" DY = "<<std::setw(8)<<(
entry.y()-
y)<<
" [cm] DT = "<<std::setw(8)<<(
hit.timeOfFlight()-tof)<<
" [ns]";
96 if (me0Id.region() == 0) {
throw cms::Exception(
"Geometry") <<
"Asking TrapezoidalStripTopology from a ME0 will fail"; }
100 double bottomLength(
parameters[0]); bottomLength = 2*bottomLength;
101 double topLength(
parameters[1]); topLength = 2*topLength;
102 double height(
parameters[2]); height = 2*height;
103 double myTanPhi = (topLength - bottomLength) / (height * 2);
104 double rollRadius = top_->radius();
105 trArea = height * (topLength + bottomLength) / 2.0;
110 int heightbins = height/heightIt;
112 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: roll with id = "<<roll->
id();
113 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: extracting parameters from the TrapezoidalStripTopology";
114 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: bottom = "<<bottomLength<<
" [cm] top = "<<topLength<<
" [cm] height = "<<height<<
" [cm]"
115 <<
" area = "<<trArea<<
" [cm^2] Rmid = "<<rollRadius<<
" [cm] => Rmin = "<<rollRadius-height*1.0/2.0<<
" [cm] Rmax = "<<rollRadius+height*1.0/2.0<<
" [cm]";
116 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: heightbins = "<<heightbins;
118 for(
int hx=0; hx<heightbins; ++hx) {
119 double bottomIt = bottomLength + hx *2*
tan(10./180*3.14)*heightIt;
120 double topIt = bottomLength + (hx+1)*2*
tan(10./180*3.14)*heightIt;
121 if(hx==heightbins-1) {
123 heightIt = height-hx*heightIt;
125 double areaIt = heightIt*(bottomIt+topIt)*1.0/2;
127 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: height = "<<std::setw(12)<<heightIt<<
" [cm] bottom = "<<std::setw(12)<<bottomIt<<
" [cm]"
128 <<
" top = "<<std::setw(12)<<topIt<<
" [cm] area = "<<std::setw(12)<<areaIt<<
" [cm^2] || sin(10) = "<<
sin(10./180*3.14);
130 double myRandY = CLHEP::RandFlat::shoot(engine);
131 double y0_rand = (hx+myRandY)*heightIt;
132 double yy_rand = (y0_rand-height*1.0/2);
133 double yy_glob = rollRadius + yy_rand;
135 double xMax = topLength/2.0 - (height/2.0 - yy_rand) * myTanPhi;
151 double averageElectronRatePerRoll = 0.0;
152 double yy_helper = 1.0;
153 for(
int j=0;
j<7; ++
j) { averageElectronRatePerRoll +=
eleBkg[
j]*yy_helper; yy_helper *= yy_glob; }
159 <<
" evaluation of Background Hit Rate at this coord :: "<<std::setw(12)<<averageElectronRatePerRoll<<
" [Hz/cm^2]"
160 <<
" x 9 x 25*10^-9 [s] x Area (of strip = "<<std::setw(12)<<areaIt<<
" [cm^2]) ==> "<<std::setw(12)<<averageElecRate<<
" [hits]";
162 bool ele_eff = (CLHEP::RandFlat::shoot(engine)<averageElecRate)?1:0;
164 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: elebkg]["<<roll->
id().
rawId()<<
"] :: myRandY = "<<std::setw(12)<<myRandY<<
" => local y = "<<std::setw(12)<<yy_rand<<
" [cm]"
165 <<
" => global y (global R) = "<<std::setw(12)<<yy_glob<<
" [cm] || Probability = "<<std::setw(12)<<averageElecRate
166 <<
" => efficient? "<<ele_eff<<std::endl;
170 double myRandX = CLHEP::RandFlat::shoot(engine);
171 double xx_rand = 2 * xMax * (myRandX - 0.5);
176 double myrandBX = CLHEP::RandFlat::shoot(engine);
179 double myrandT = CLHEP::RandFlat::shoot(engine);
180 double minBXtime = (bx-0.5)*
bxwidth;
181 double time = myrandT*
bxwidth+minBXtime;
182 double myrandP = CLHEP::RandFlat::shoot(engine);
184 if (myrandP <= 0.5) pdgid = -11;
188 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: elebkg]["<<roll->
id().
rawId()<<
"] =====> electron hit in "<<roll->
id()<<
" pdgid = "<<pdgid<<
" bx = "<<bx
190 <<
" at loc x = "<<xx_rand<<
" loc y = "<<yy_rand<<
" time = "<<time<<
" [ns]";
199 double averageNeutralRatePerRoll = 0.0;
200 double yy_helper = 1.0;
201 for(
int j=0;
j<7; ++
j) { averageNeutralRatePerRoll +=
neuBkg[
j]*yy_helper; yy_helper *= yy_glob; }
207 <<
" evaluation of Background Hit Rate at this coord :: "<<std::setw(12)<<averageNeutralRatePerRoll<<
" [Hz/cm^2]"
208 <<
" x 9 x 25*10^-9 [s] x Area (of strip = "<<std::setw(12)<<areaIt<<
" [cm^2]) ==> "<<std::setw(12)<<averageNeutrRate<<
" [hits]";
210 bool neu_eff = (CLHEP::RandFlat::shoot(engine)<averageNeutrRate)?1:0;
212 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: neubkg]["<<roll->
id().
rawId()<<
"] :: myRandY = "<<std::setw(12)<<myRandY<<
" => local y = "<<std::setw(12)<<yy_rand<<
" [cm]"
213 <<
" => global y (global R) = "<<std::setw(12)<<yy_glob<<
" [cm] || Probability = "<<std::setw(12)<<averageNeutrRate
214 <<
" => efficient? "<<neu_eff<<std::endl;
218 double myRandX = CLHEP::RandFlat::shoot(engine);
219 double xx_rand = 2 * xMax * (myRandX - 0.5);
224 double myrandBX= CLHEP::RandFlat::shoot(engine);
227 double myrandT = CLHEP::RandFlat::shoot(engine);
228 double minBXtime = (bx-0.5)*
bxwidth;
229 double time = myrandT*
bxwidth+minBXtime;
231 double myrandP = CLHEP::RandFlat::shoot(engine);
232 if (myrandP <= 0.08) pdgid = 2112;
236 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: neubkg]["<<roll->
id().
rawId()<<
"] ======> neutral hit in "<<roll->
id()<<
" pdgid = "<<pdgid<<
" bx = "<<bx
238 <<
" at loc x = "<<xx_rand<<
" loc y = "<<yy_rand<<
" time = "<<time<<
" [ns]";
const ME0EtaPartitionSpecs * specs() const
double averageEfficiency_
std::vector< double > neuBkg
Sin< T >::type sin(const T &t)
const ME0Specs & parameters() const
uint32_t rawId() const
get the raw id
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
void simulateSignal(const ME0EtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *) override
std::set< ME0DigiPreReco > digi_
void simulateNoise(const ME0EtaPartition *, CLHEP::HepRandomEngine *) override
const Topology & topology() const
ME0PreRecoGaussianModel(const edm::ParameterSet &)
std::vector< PSimHit > PSimHitContainer
std::vector< double > eleBkg
bool simulateElectronBkg_
~ME0PreRecoGaussianModel()