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 error_u(config.getParameter<double>(
"phiError")),
26 error_v(config.getParameter<double>(
"etaError")),
27 gaussianSmearing_(config.getParameter<bool>(
"gaussianSmearing")),
28 constPhiSmearing_(config.getParameter<bool>(
"constantPhiSpatialResolution")),
29 corr(config.getParameter<bool>(
"useCorrelation")),
30 etaproj(config.getParameter<bool>(
"useEtaProjectiveGEO")),
31 digitizeOnlyMuons_(config.getParameter<bool>(
"digitizeOnlyMuons")),
32 averageEfficiency_(config.getParameter<double>(
"averageEfficiency")),
35 simulateElectronBkg_(config.getParameter<bool>(
"simulateElectronBkg")),
36 simulateNeutralBkg_(config.getParameter<bool>(
"simulateNeutralBkg")),
37 minBunch_(config.getParameter<
int>(
"minBunch")),
38 maxBunch_(config.getParameter<
int>(
"maxBunch")),
39 instLumi_(config.getParameter<double>(
"instLumi")),
40 rateFact_(config.getParameter<double>(
"rateFact"))
56 for (
const auto &
hit: simHits)
73 x=CLHEP::RandGaussQ::shoot(engine,
entry.x(), sigma_u_new);
77 x=
entry.x()+(CLHEP::RandFlat::shoot(engine)-0.5)*sigma_u_new;
80 double ex=sigma_u_new;
83 double tof=CLHEP::RandGaussQ::shoot(engine,
hit.timeOfFlight(),
sigma_t);
88 int evtId =
hit.eventId().event();
89 int bx =
hit.eventId().bunchCrossing();
90 int procType =
hit.processType();
92 if(!(evtId == 0 && bx == 0 && procType == 0)) res = 2;
97 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: simhit in "<<roll->
id()<<
" at loc x = "<<std::setw(8)<<
entry.x()<<
" [cm]" 98 <<
" loc y = "<<std::setw(8)<<
entry.y()<<
" [cm] time = "<<std::setw(8)<<
hit.timeOfFlight()<<
" [ns] pdgid = "<<std::showpos<<std::setw(4)<<
pdgid;
99 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: digi in "<<roll->
id()<<
" at loc x = "<<std::setw(8)<<x<<
" [cm] loc y = "<<std::setw(8)<<
y<<
" [cm]" 100 <<
" time = "<<std::setw(8)<<tof<<
" [ns]";
101 edm::LogVerbatim(
"ME0PreRecoGaussianModel") <<
"[ME0PreRecoDigi :: simulateSignal] :: digi in "<<roll->
id()<<
" with DX = "<<std::setw(8)<<(
entry.x()-
x)<<
" [cm]" 102 <<
" DY = "<<std::setw(8)<<(
entry.y()-
y)<<
" [cm] DT = "<<std::setw(8)<<(
hit.timeOfFlight()-tof)<<
" [ns]";
115 if (me0Id.region() == 0) {
throw cms::Exception(
"Geometry") <<
"Asking TrapezoidalStripTopology from a ME0 will fail"; }
119 double bottomLength(
parameters[0]); bottomLength = 2*bottomLength;
120 double topLength(
parameters[1]); topLength = 2*topLength;
121 double height(
parameters[2]); height = 2*height;
122 double myTanPhi = (topLength - bottomLength) / (height * 2);
123 double rollRadius = top_->radius();
124 trArea = height * (topLength + bottomLength) / 2.0;
128 double initialHeight =
sigma_v;
129 if(
sigma_v < 1.0) initialHeight = 1.0;
130 double heightIt = initialHeight;
131 int heightbins = height/heightIt;
133 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: roll with id = "<<roll->
id();
134 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: extracting parameters from the TrapezoidalStripTopology";
135 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: bottom = "<<bottomLength<<
" [cm] top = "<<topLength<<
" [cm] height = "<<height<<
" [cm]" 136 <<
" area = "<<trArea<<
" [cm^2] Rmid = "<<rollRadius<<
" [cm] => Rmin = "<<rollRadius-height*1.0/2.0<<
" [cm] Rmax = "<<rollRadius+height*1.0/2.0<<
" [cm]";
137 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: heightbins = "<<heightbins;
139 for(
int hx=0; hx<heightbins; ++hx) {
140 double bottomIt = bottomLength + hx *2*
tan(10./180*3.14)*heightIt;
141 double topIt = bottomLength + (hx+1)*2*
tan(10./180*3.14)*heightIt;
142 if(hx==heightbins-1) {
144 heightIt = height-hx*heightIt;
146 double areaIt = heightIt*(bottomIt+topIt)*1.0/2;
148 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: sNoise]["<<roll->
id().
rawId()<<
"] :: height = "<<std::setw(12)<<heightIt<<
" [cm] bottom = "<<std::setw(12)<<bottomIt<<
" [cm]" 149 <<
" top = "<<std::setw(12)<<topIt<<
" [cm] area = "<<std::setw(12)<<areaIt<<
" [cm^2] || sin(10) = "<<
sin(10./180*3.14);
151 double myRandY = CLHEP::RandFlat::shoot(engine);
152 double y0_rand = (hx+myRandY)*heightIt;
153 if(hx==heightbins-1) y0_rand = hx*initialHeight + myRandY*heightIt;
154 double yy_rand = (y0_rand-height*1.0/2);
155 double yy_glob = rollRadius + yy_rand;
157 double xMax = topLength/2.0 - (height/2.0 - yy_rand) * myTanPhi;
177 double averageElectronRatePerRoll = 0.0;
178 double yy_helper = 1.0;
179 for(
int j=0; j<7; ++j) { averageElectronRatePerRoll +=
eleBkg[j]*yy_helper; yy_helper *= yy_glob; }
188 <<
" evaluation of Background Hit Rate at this coord :: "<<std::setw(12)<<averageElectronRatePerRoll<<
" [Hz/cm^2]" 189 <<
" x 9 x 25*10^-9 [s] x Area (of strip = "<<std::setw(12)<<areaIt<<
" [cm^2]) ==> "<<std::setw(12)<<averageElecRate<<
" [hits]";
191 bool ele_eff = (CLHEP::RandFlat::shoot(engine)<averageElecRate)?1:0;
193 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: elebkg]["<<roll->
id().
rawId()<<
"] :: myRandY = "<<std::setw(12)<<myRandY<<
" => local y = "<<std::setw(12)<<yy_rand<<
" [cm]" 194 <<
" => global y (global R) = "<<std::setw(12)<<yy_glob<<
" [cm] || Probability = "<<std::setw(12)<<averageElecRate
195 <<
" => efficient? "<<ele_eff<<std::endl;
199 double myRandX = CLHEP::RandFlat::shoot(engine);
200 double xx_rand = 2 * xMax * (myRandX - 0.5);
201 double ex = sigma_u_new;
205 double myrandBX = CLHEP::RandFlat::shoot(engine);
208 double myrandT = CLHEP::RandFlat::shoot(engine);
209 double minBXtime = (bx-0.5)*
bxwidth;
211 double myrandP = CLHEP::RandFlat::shoot(engine);
213 if (myrandP <= 0.5) pdgid = -11;
217 ME0DigiPreReco digi(xx_rand, yy_rand, ex, ey, corr, time, pdgid, 0);
219 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: elebkg]["<<roll->
id().
rawId()<<
"] =====> electron hit in "<<roll->
id()<<
" pdgid = "<<pdgid<<
" bx = "<<bx
221 <<
" at loc x = "<<xx_rand<<
" loc y = "<<yy_rand<<
" time = "<<time<<
" [ns]";
230 double averageNeutralRatePerRoll = 0.0;
231 double yy_helper = 1.0;
232 for(
int j=0; j<7; ++j) { averageNeutralRatePerRoll +=
neuBkg[j]*yy_helper; yy_helper *= yy_glob; }
241 <<
" evaluation of Background Hit Rate at this coord :: "<<std::setw(12)<<averageNeutralRatePerRoll<<
" [Hz/cm^2]" 242 <<
" x 9 x 25*10^-9 [s] x Area (of strip = "<<std::setw(12)<<areaIt<<
" [cm^2]) ==> "<<std::setw(12)<<averageNeutrRate<<
" [hits]";
244 bool neu_eff = (CLHEP::RandFlat::shoot(engine)<averageNeutrRate)?1:0;
246 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: neubkg]["<<roll->
id().
rawId()<<
"] :: myRandY = "<<std::setw(12)<<myRandY<<
" => local y = "<<std::setw(12)<<yy_rand<<
" [cm]" 247 <<
" => global y (global R) = "<<std::setw(12)<<yy_glob<<
" [cm] || Probability = "<<std::setw(12)<<averageNeutrRate
248 <<
" => efficient? "<<neu_eff<<std::endl;
252 double myRandX = CLHEP::RandFlat::shoot(engine);
253 double xx_rand = 2 * xMax * (myRandX - 0.5);
254 double ex = sigma_u_new;
258 double myrandBX= CLHEP::RandFlat::shoot(engine);
261 double myrandT = CLHEP::RandFlat::shoot(engine);
262 double minBXtime = (bx-0.5)*
bxwidth;
265 double myrandP = CLHEP::RandFlat::shoot(engine);
266 if (myrandP <= 0.08) pdgid = 2112;
270 ME0DigiPreReco digi(xx_rand, yy_rand, ex, ey, corr, time, pdgid, 0);
272 edm::LogVerbatim(
"ME0PreRecoGaussianModelNoise") <<
"[ME0PreRecoDigi :: neubkg]["<<roll->
id().
rawId()<<
"] ======> neutral hit in "<<roll->
id()<<
" pdgid = "<<pdgid<<
" bx = "<<bx
274 <<
" at loc x = "<<xx_rand<<
" loc y = "<<yy_rand<<
" time = "<<time<<
" [ns]";
285 double rollRadius = top_->radius();
286 double Rmax = rollRadius+height;
287 double Rx = rollRadius+
y;
288 double sigma_u_new = Rx/Rmax*
sigma_u;
const ME0EtaPartitionSpecs * specs() const
double averageEfficiency_
std::vector< double > neuBkg
Sin< T >::type sin(const T &t)
const ME0Specs & parameters() const
double correctSigmaU(const ME0EtaPartition *, double)
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 &)
const double Rmax[kNumberCalorimeter]
std::vector< PSimHit > PSimHitContainer
std::vector< double > eleBkg
bool simulateElectronBkg_
~ME0PreRecoGaussianModel()