35 #include "CLHEP/Random/RandFlat.h"
36 #include "CLHEP/Random/RandPoissonQ.h"
41 aveEff =
config.getParameter<
double>(
"averageEfficiency");
42 aveCls =
config.getParameter<
double>(
"averageClusterSize");
45 dtimCs =
config.getParameter<
double>(
"deltatimeAdjacentStrip");
47 sspeed =
config.getParameter<
double>(
"signalPropagationSpeed");
59 std::cout <<
"Average Cluster Size = " <<
aveCls <<
" strips" << std::endl;
61 std::cout <<
"RPC Signal formation time = " <<
timOff <<
" ns" << std::endl;
62 std::cout <<
"RPC adjacent strip delay = " <<
dtimCs <<
" ns" << std::endl;
64 std::cout <<
"Signal propagation time = " <<
sspeed <<
" x c" << std::endl;
65 std::cout <<
"Link Board Gate Width = " <<
lbGate <<
" ns" << std::endl;
79 double rr_cl = CLHEP::RandFlat::shoot(engine);
80 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
100 double rr_cl = CLHEP::RandFlat::shoot(engine);
101 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
126 if (
func > (*iter)) {
128 }
else if (
func < (*iter)) {
137 CLHEP::HepRandomEngine* engine) {
148 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin(); _hit != rpcHits.end(); ++_hit) {
149 if (!
eledig && _hit->particleType() == 11)
155 float posX = roll->
strip(_hit->localPosition()) - static_cast<int>(roll->
strip(_hit->localPosition()));
157 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
160 std::stringstream veffstream;
162 for (std::vector<float>::iterator veffIt = veff.begin(); veffIt != veff.end(); ++veffIt) {
163 veffstream << (*veffIt) <<
",";
167 LogDebug(
"RPCSimAsymmetricCls") <<
"Get Eff from RPCSimSetup for detId = " << rpcId.rawId() <<
" :: " << veffstr;
171 int centralStrip = topology.
channel(entr) + 1;
172 float fire = CLHEP::RandFlat::shoot(engine);
173 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire <<
" --> < "
174 << veff[centralStrip - 1] <<
" ? --> " << ((fire < veff[centralStrip - 1]) ? 1 : 0);
176 if (fire < veff[centralStrip - 1]) {
177 LogDebug(
"RPCSimAsymmetricCls") <<
"Detector is Efficient for this simhit";
179 int fstrip = centralStrip;
180 int lstrip = centralStrip;
189 LogDebug(
"RPCSimAsymmetricCls") <<
"Clustersize = " << clsize;
191 std::vector<int> cls;
193 cls.push_back(centralStrip);
195 for (
int cl = 0;
cl < (clsize - 1) / 2;
cl++) {
196 if (centralStrip -
cl - 1 >= 1) {
197 fstrip = centralStrip -
cl - 1;
198 cls.push_back(fstrip);
200 if (centralStrip +
cl + 1 <= roll->
nstrips()) {
201 lstrip = centralStrip +
cl + 1;
202 cls.push_back(lstrip);
205 if (clsize % 2 == 0) {
213 if (lstrip < roll->nstrips()) {
215 cls.push_back(lstrip);
220 cls.push_back(fstrip);
226 if (lstrip < roll->nstrips()) {
228 cls.push_back(lstrip);
235 float fire1 = CLHEP::RandFlat::shoot(engine);
236 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire1
237 <<
" (fire1 is used for a shift of the cluster)";
243 if (clsize % 2 == 0) {
255 for (
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i++) {
256 if (fire1 < TMPclsAsymmForDetId[
i]) {
263 vector<int> shifted_cls;
270 for (std::vector<int>::iterator
i = cls.begin();
i != cls.end();
i++) {
271 if (*
i + strip_shift < min_strip) {
272 min_strip = *
i + strip_shift;
274 if (*
i + strip_shift > max_strip) {
275 max_strip = *
i + strip_shift;
279 if (min_strip < 1 || max_strip - roll->nstrips() > 0) {
284 for (std::vector<int>::iterator
i = cls.begin();
i != cls.end();
i++) {
285 shifted_cls.push_back(*
i + strip_shift);
287 for (std::vector<int>::iterator
i = shifted_cls.begin();
i != shifted_cls.end();
i++) {
289 if (*
i != centralStrip) {
290 double fire2 = CLHEP::RandFlat::shoot(engine);
291 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire2
292 <<
" (check whether adjacent strips are efficient)";
293 if (fire2 < veff[*
i - 1]) {
294 std::pair<int, int> digi(*
i, time_hit);
297 <<
"RPC Digi inserted :: Signl :: DetId :: " << rpcId <<
" = " << rpcId.rawId() <<
" ==> digi <"
298 << digi.first <<
"," << digi.second <<
">";
303 std::pair<int, int> digi(*
i, time_hit);
307 LogDebug(
"RPCSimAsymmetricCls") <<
"RPC Digi inserted :: Signl :: DetId :: " << rpcId <<
" = "
308 << rpcId.rawId() <<
" ==> digi <" << digi.first <<
"," << digi.second <<
">";
324 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Treating DetId :: " << rpcId <<
" = "
325 << rpcId.
rawId() <<
" which has " << roll->
nstrips() <<
" strips";
328 std::stringstream vnoisestream;
330 for (std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) {
331 vnoisestream << (*vnoiseIt) <<
",";
335 LogDebug(
"RPCSimAsymmetricCls") <<
"Get Noise from RPCSimSetup for detId = " << rpcId.
rawId() <<
" :: vector with "
336 << vnoise.size() <<
"entries :: " << vnoisestr;
339 unsigned int nstrips = roll->
nstrips();
342 if (rpcId.
region() == 0) {
356 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: vnoise.size() = " << vnoise.size();
358 for (
unsigned int j = 0;
j < vnoise.size(); ++
j) {
371 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: strip " <<
j <<
" Average = " << ave
372 <<
" = vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips()) = "
373 << vnoise[
j] <<
"*" <<
nbxing <<
"*" <<
gate <<
"*" <<
area <<
"*" << 1.0e-9 <<
"*"
376 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
377 N_hits = randPoissonQ.fire();
378 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: " <<
N_hits;
379 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: Amount of Noise Hits for DetId :: " << rpcId <<
" = " << rpcId.
rawId()
380 <<
" = N_hits = randPoissonQ.fire() = " <<
N_hits;
384 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: " << time2;
385 int time_hit = (static_cast<int>(time2) -
nbxing / 2);
386 std::pair<int, int> digi(
j + 1, time_hit);
388 LogDebug(
"RPCSimAsymmetricCls") <<
"RPC Digi inserted :: Noise :: DetId :: " << rpcId <<
" = " << rpcId.
rawId()
389 <<
" ==> digi <" << digi.first <<
"," << digi.second <<
">";
397 }
else if (0.2 <=
posX &&
posX < 0.4) {
399 }
else if (0.4 <=
posX &&
posX < 0.6) {
401 }
else if (0.6 <=
posX &&
posX < 0.8) {
403 }
else if (0.8 <=
posX &&
posX < 1.0) {