35 #include "CLHEP/Random/RandFlat.h"
36 #include "CLHEP/Random/RandPoissonQ.h"
59 std::cout <<
"Average Cluster Size = " << aveCls <<
" strips" << std::endl;
60 std::cout <<
"RPC Time Resolution = " << resRPC <<
" ns" << std::endl;
61 std::cout <<
"RPC Signal formation time = " << timOff <<
" ns" << std::endl;
62 std::cout <<
"RPC adjacent strip delay = " << dtimCs <<
" ns" << std::endl;
63 std::cout <<
"Electronic Jitter = " << resEle <<
" 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;
81 for (
unsigned int i = 0;
i < clsForDetId.size();
i++) {
83 if (rr_cl > clsForDetId[
i]) {
85 }
else if (rr_cl < clsForDetId[i]) {
100 double rr_cl = CLHEP::RandFlat::shoot(engine);
101 LogDebug(
"RPCSimAsymmetricCls") <<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: " << rr_cl;
103 if (0.0 <= posX && posX < 0.2) {
104 func = (clsMap[1])[(clsMap[1]).size() - 1] * (rr_cl);
105 sum_clsize = clsMap[1];
107 if (0.2 <= posX && posX < 0.4) {
108 func = (clsMap[2])[(clsMap[2]).size() - 1] * (rr_cl);
109 sum_clsize = clsMap[2];
111 if (0.4 <= posX && posX < 0.6) {
112 func = (clsMap[3])[(clsMap[3]).size() - 1] * (rr_cl);
113 sum_clsize = clsMap[3];
115 if (0.6 <= posX && posX < 0.8) {
116 func = (clsMap[4])[(clsMap[4]).size() - 1] * (rr_cl);
117 sum_clsize = clsMap[4];
119 if (0.8 <= posX && posX < 1.0) {
120 func = (clsMap[5])[(clsMap[5]).size() - 1] * (rr_cl);
121 sum_clsize = clsMap[5];
124 for (vector<double>::iterator iter = sum_clsize.begin(); iter != sum_clsize.end(); ++iter) {
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;
188 int clsize = this->
getClSize(rpcId.rawId(), posX, engine);
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) {
347 area = striplength * (xmax -
xmin);
353 area = striplength * (xmax -
xmin);
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;
383 double time2 = CLHEP::RandFlat::shoot((
nbxing *
gate) / gate);
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 <<
">";
395 if (0.0 <= posX && posX < 0.2) {
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) {
float strip(const LocalPoint &lp) const
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
LocalPoint centreOfStrip(int strip) const
LocalPoint localPosition(float strip) const override
~RPCSimAsymmetricCls() override
DetectorHitMap theDetectorHitMap
void setRPCSimSetUp(RPCSimSetUp *simsetup)
constexpr uint32_t rawId() const
get the raw id
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
RPCSimSetUp * getRPCSimSetUp()
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t Func __host__ __device__ V int Func func
const RPCRollSpecs * specs() const
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()
virtual int channel(const LocalPoint &p) const =0
const Topology & topology() const override
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 *)
T getParameter(std::string const &) const
RPCSynchronizer * _rpcSync
tuple config
parse the configuration file
RPCSimAsymmetricCls(const edm::ParameterSet &config)
const Topology & topology() const override
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)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.