36 #include "CLHEP/Random/RandFlat.h"
37 #include "CLHEP/Random/RandPoissonQ.h"
42 aveEff =
config.getParameter<
double>(
"averageEfficiency");
43 aveCls =
config.getParameter<
double>(
"averageClusterSize");
46 dtimCs =
config.getParameter<
double>(
"deltatimeAdjacentStrip");
48 sspeed =
config.getParameter<
double>(
"signalPropagationSpeed");
60 std::cout <<
"Average Cluster Size = " <<
aveCls <<
" strips" << std::endl;
62 std::cout <<
"RPC Signal formation time = " <<
timOff <<
" ns" << std::endl;
63 std::cout <<
"RPC adjacent strip delay = " <<
dtimCs <<
" ns" << std::endl;
65 std::cout <<
"Signal propagation time = " <<
sspeed <<
" x c" << std::endl;
66 std::cout <<
"Link Board Gate Width = " <<
lbGate <<
" ns" << std::endl;
80 double rr_cl = CLHEP::RandFlat::shoot(engine);
81 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
101 double rr_cl = CLHEP::RandFlat::shoot(engine);
102 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
127 if (
func > (*iter)) {
129 }
else if (
func < (*iter)) {
138 CLHEP::HepRandomEngine* engine) {
149 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin(); _hit != rpcHits.end(); ++_hit) {
150 if (!
eledig && _hit->particleType() == 11)
156 float posX = roll->
strip(_hit->localPosition()) - static_cast<int>(roll->
strip(_hit->localPosition()));
158 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;
170 int centralStrip =
topology.channel(entr) + 1;
171 float fire = CLHEP::RandFlat::shoot(engine);
172 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire <<
" --> < "
173 << veff[centralStrip - 1] <<
" ? --> " << ((fire < veff[centralStrip - 1]) ? 1 : 0);
175 if (fire < veff[centralStrip - 1]) {
176 LogDebug(
"RPCSimAsymmetricCls") <<
"Detector is Efficient for this simhit";
178 int fstrip = centralStrip;
179 int lstrip = centralStrip;
188 LogDebug(
"RPCSimAsymmetricCls") <<
"Clustersize = " << clsize;
190 std::vector<int> cls;
192 cls.push_back(centralStrip);
194 for (
int cl = 0;
cl < (clsize - 1) / 2;
cl++) {
195 if (centralStrip -
cl - 1 >= 1) {
196 fstrip = centralStrip -
cl - 1;
197 cls.push_back(fstrip);
199 if (centralStrip +
cl + 1 <= roll->
nstrips()) {
200 lstrip = centralStrip +
cl + 1;
201 cls.push_back(lstrip);
204 if (clsize % 2 == 0) {
212 if (lstrip < roll->nstrips()) {
214 cls.push_back(lstrip);
219 cls.push_back(fstrip);
225 if (lstrip < roll->nstrips()) {
227 cls.push_back(lstrip);
234 float fire1 = CLHEP::RandFlat::shoot(engine);
235 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire1
236 <<
" (fire1 is used for a shift of the cluster)";
242 if (clsize % 2 == 0) {
254 for (
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i++) {
255 if (fire1 < TMPclsAsymmForDetId[
i]) {
262 vector<int> shifted_cls;
269 for (std::vector<int>::iterator
i = cls.begin();
i != cls.end();
i++) {
270 if (*
i + strip_shift < min_strip) {
271 min_strip = *
i + strip_shift;
273 if (*
i + strip_shift > max_strip) {
274 max_strip = *
i + strip_shift;
278 if (min_strip < 1 || max_strip - roll->nstrips() > 0) {
283 for (std::vector<int>::iterator
i = cls.begin();
i != cls.end();
i++) {
284 shifted_cls.push_back(*
i + strip_shift);
286 for (std::vector<int>::iterator
i = shifted_cls.begin();
i != shifted_cls.end();
i++) {
288 if (*
i != centralStrip) {
289 double fire2 = CLHEP::RandFlat::shoot(engine);
290 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: " << fire2
291 <<
" (check whether adjacent strips are efficient)";
292 if (fire2 < veff[*
i - 1]) {
293 std::pair<int, int> digi(*
i, time_hit);
296 <<
"RPC Digi inserted :: Signl :: DetId :: " << rpcId <<
" = " << rpcId.rawId() <<
" ==> digi <"
297 << digi.first <<
"," << digi.second <<
">";
302 std::pair<int, int> digi(*
i, time_hit);
306 LogDebug(
"RPCSimAsymmetricCls") <<
"RPC Digi inserted :: Signl :: DetId :: " << rpcId <<
" = "
307 << rpcId.rawId() <<
" ==> digi <" << digi.first <<
"," << digi.second <<
">";
323 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Treating DetId :: " << rpcId <<
" = "
324 << rpcId.
rawId() <<
" which has " << roll->
nstrips() <<
" strips";
326 std::stringstream vnoisestream;
328 for (std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) {
329 vnoisestream << (*vnoiseIt) <<
",";
333 LogDebug(
"RPCSimAsymmetricCls") <<
"Get Noise from RPCSimSetup for detId = " << rpcId.
rawId() <<
" :: vector with "
334 << vnoise.size() <<
"entries :: " << vnoisestr;
336 unsigned int nstrips = roll->
nstrips();
339 if (rpcId.
region() == 0) {
353 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: vnoise.size() = " << vnoise.size();
355 for (
unsigned int j = 0;
j < vnoise.size(); ++
j) {
368 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: strip " <<
j <<
" Average = " << ave
369 <<
" = vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips()) = "
370 << vnoise[
j] <<
"*" <<
nbxing <<
"*" <<
gate <<
"*" <<
area <<
"*" << 1.0e-9 <<
"*"
373 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
374 N_hits = randPoissonQ.fire();
375 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: " <<
N_hits;
376 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: Amount of Noise Hits for DetId :: " << rpcId <<
" = " << rpcId.
rawId()
377 <<
" = N_hits = randPoissonQ.fire() = " <<
N_hits;
381 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: " << time2;
382 int time_hit = (static_cast<int>(time2) -
nbxing / 2);
383 std::pair<int, int> digi(
j + 1, time_hit);
385 LogDebug(
"RPCSimAsymmetricCls") <<
"RPC Digi inserted :: Noise :: DetId :: " << rpcId <<
" = " << rpcId.
rawId()
386 <<
" ==> digi <" << digi.first <<
"," << digi.second <<
">";
394 }
else if (0.2 <=
posX &&
posX < 0.4) {
396 }
else if (0.4 <=
posX &&
posX < 0.6) {
398 }
else if (0.6 <=
posX &&
posX < 0.8) {
400 }
else if (0.8 <=
posX &&
posX < 1.0) {