34 #include "CLHEP/Random/RandFlat.h" 35 #include "CLHEP/Random/RandPoissonQ.h" 40 aveEff =
config.getParameter<
double>(
"averageEfficiency");
41 aveCls =
config.getParameter<
double>(
"averageClusterSize");
44 dtimCs =
config.getParameter<
double>(
"deltatimeAdjacentStrip");
46 sspeed =
config.getParameter<
double>(
"signalPropagationSpeed");
58 std::cout <<
"Average Cluster Size = " <<
aveCls <<
" strips" << std::endl;
60 std::cout <<
"RPC Signal formation time = " <<
timOff <<
" ns" << std::endl;
61 std::cout <<
"RPC adjacent strip delay = " <<
dtimCs <<
" ns" << std::endl;
63 std::cout <<
"Signal propagation time = " <<
sspeed <<
" x c" << std::endl;
64 std::cout <<
"Link Board Gate Width = " <<
lbGate <<
" ns" << std::endl;
78 double rr_cl = CLHEP::RandFlat::shoot(engine);
79 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
99 double rr_cl = CLHEP::RandFlat::shoot(engine);
100 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
125 if (
func > (*iter)) {
127 }
else if (
func < (*iter)) {
136 CLHEP::HepRandomEngine* engine) {
147 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin(); _hit != rpcHits.end(); ++_hit) {
148 if (!
eledig && _hit->particleType() == 11)
154 float posX =
roll->strip(_hit->localPosition()) - static_cast<int>(
roll->strip(_hit->localPosition()));
156 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
159 std::stringstream veffstream;
161 for (std::vector<float>::iterator veffIt = veff.begin(); veffIt != veff.end(); ++veffIt) {
162 veffstream << (*veffIt) <<
",";
166 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) {
210 double deltaw =
roll->centreOfStrip(centralStrip).x() - entr.
x();
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";
327 std::stringstream vnoisestream;
329 for (std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) {
330 vnoisestream << (*vnoiseIt) <<
",";
334 LogDebug(
"RPCSimAsymmetricCls") <<
"Get Noise from RPCSimSetup for detId = " << rpcId.
rawId() <<
" :: vector with " 335 << vnoise.size() <<
"entries :: " << vnoisestr;
338 unsigned int nstrips =
roll->nstrips();
341 if (rpcId.
region() == 0) {
355 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: vnoise.size() = " << vnoise.size();
357 for (
unsigned int j = 0;
j < vnoise.size(); ++
j) {
370 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: strip " <<
j <<
" Average = " << ave
371 <<
" = vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips()) = " 372 << vnoise[
j] <<
"*" <<
nbxing <<
"*" <<
gate <<
"*" <<
area <<
"*" << 1.0e-9 <<
"*" 375 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
376 N_hits = randPoissonQ.fire();
377 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: " <<
N_hits;
378 LogDebug(
"RPCSimAsymmetricCls") <<
"Noise :: Amount of Noise Hits for DetId :: " << rpcId <<
" = " << rpcId.
rawId()
379 <<
" = N_hits = randPoissonQ.fire() = " <<
N_hits;
383 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: " << time2;
384 int time_hit = (
static_cast<int>(time2) -
nbxing / 2);
385 std::pair<int, int> digi(
j + 1, time_hit);
387 LogDebug(
"RPCSimAsymmetricCls") <<
"RPC Digi inserted :: Noise :: DetId :: " << rpcId <<
" = " << rpcId.
rawId()
388 <<
" ==> digi <" << digi.first <<
"," << digi.second <<
">";
396 }
else if (0.2 <=
posX &&
posX < 0.4) {
398 }
else if (0.4 <=
posX &&
posX < 0.6) {
400 }
else if (0.6 <=
posX &&
posX < 0.8) {
402 }
else if (0.8 <=
posX &&
posX < 1.0) {
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
LocalPoint localPosition(float strip) const override
~RPCSimAsymmetricCls() override
DetectorHitMap theDetectorHitMap
void setRPCSimSetUp(RPCSimSetUp *simsetup)
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
RPCSimSetUp * getRPCSimSetUp()
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
float stripLength() const override
std::vector< double > clsForDetId
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
std::map< int, std::vector< double > > clsMap
virtual std::string name()
Container::value_type value_type
std::set< std::pair< int, int > > strips
std::vector< double > sum_clsize
const std::map< int, std::vector< double > > & getClsMap()
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
const std::vector< double > & getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls)
int getClSize(float posX, CLHEP::HepRandomEngine *)
constexpr uint32_t rawId() const
get the raw id
RPCSynchronizer * _rpcSync
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
RPCSimAsymmetricCls(const edm::ParameterSet &config)
std::vector< PSimHit > PSimHitContainer
float stripLength() const override
det heigth (strip length in the middle)
RPCDigiSimLinks theRpcDigiSimLinks
LocalPoint localPosition(float strip) const override
unsigned int slice(float posX)