36 #include "CLHEP/Random/RandFlat.h"
37 #include "CLHEP/Random/RandPoissonQ.h"
62 std::cout <<
"Average Cluster Size = "<<aveCls<<
" strips"<<std::endl;
63 std::cout <<
"RPC Time Resolution = "<<resRPC<<
" ns"<<std::endl;
64 std::cout <<
"RPC Signal formation time = "<<timOff<<
" ns"<<std::endl;
65 std::cout <<
"RPC adjacent strip delay = "<<dtimCs<<
" ns"<<std::endl;
66 std::cout <<
"Electronic Jitter = "<<resEle<<
" ns"<<std::endl;
67 std::cout <<
"Signal propagation time = "<<sspeed<<
" x c"<<std::endl;
68 std::cout <<
"Link Board Gate Width = "<<lbGate<<
" ns"<<std::endl;
87 double rr_cl = CLHEP::RandFlat::shoot(engine);
88 for(
unsigned int i = 0 ;
i < clsForDetId.size();
i++){
90 if(rr_cl > clsForDetId[
i]){
93 else if(rr_cl < clsForDetId[i]){
109 double rr_cl = CLHEP::RandFlat::shoot(engine);
110 if(0.0 <= posX && posX < 0.2) {
111 func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
112 sum_clsize = clsMap[1];
114 if(0.2 <= posX && posX < 0.4) {
115 func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
116 sum_clsize = clsMap[2];
118 if(0.4 <= posX && posX < 0.6) {
119 func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
120 sum_clsize = clsMap[3];
122 if(0.6 <= posX && posX < 0.8) {
123 func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
124 sum_clsize = clsMap[4];
126 if(0.8 <= posX && posX < 1.0) {
127 func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
128 sum_clsize = clsMap[5];
131 for(vector<double>::iterator
iter = sum_clsize.begin();
137 else if(func < (*
iter)){
147 CLHEP::HepRandomEngine* engine)
159 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
160 _hit != rpcHits.end(); ++_hit){
166 float posX = roll->
strip(_hit->localPosition())
167 - static_cast<int>(roll->
strip(_hit->localPosition()));
169 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
172 int centralStrip = topology.
channel(entr)+1;
173 float fire = CLHEP::RandFlat::shoot(engine);
175 if (fire < veff[centralStrip-1]) {
177 int fstrip=centralStrip;
178 int lstrip=centralStrip;
181 double w = CLHEP::RandFlat::shoot(engine);
182 if (w < 1.
e-10) w=1.e-10;
184 int clsize = this->
getClSize(rpcId.rawId(),posX, engine);
186 std::vector<int> cls;
188 cls.push_back(centralStrip);
190 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
191 if (centralStrip -
cl -1 >= 1 ){
192 fstrip = centralStrip-
cl-1;
193 cls.push_back(fstrip);
195 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
196 lstrip = centralStrip+
cl+1;
197 cls.push_back(lstrip);
208 if (lstrip < roll->nstrips() ){
210 cls.push_back(lstrip);
215 cls.push_back(fstrip);
222 if (lstrip < roll->nstrips() ){
224 cls.push_back(lstrip);
231 float fire1 = CLHEP::RandFlat::shoot(engine);
248 std::vector<double> TMPclsAsymmForDetId
251 for(
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i ++){
252 if(fire1 < TMPclsAsymmForDetId[
i]){
259 vector<int> shifted_cls;
266 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
267 if(*
i+strip_shift < min_strip){
268 min_strip = *
i+strip_shift;
270 if(*
i+strip_shift > max_strip){
271 max_strip = *
i+strip_shift;
275 if(min_strip<1 || max_strip-roll->nstrips()>0){
280 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
281 shifted_cls.push_back(*
i+strip_shift);
283 for (std::vector<int>::iterator
i=shifted_cls.begin();
284 i!=shifted_cls.end();
i++){
286 if(*
i != centralStrip){
287 if(CLHEP::RandFlat::shoot(engine) < veff[*
i-1]){
288 std::pair<int, int> digi(*
i,time_hit);
295 std::pair<int, int> digi(*
i,time_hit);
306 CLHEP::HepRandomEngine* engine)
317 unsigned int nstrips = roll->
nstrips();
320 if ( rpcId.
region() == 0 )
327 area = striplength*(xmax-
xmin);
335 area = striplength*(xmax-
xmin);
338 for(
unsigned int j = 0;
j < vnoise.size(); ++
j){
340 if(
j >= nstrips)
break;
353 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
354 N_hits = randPoissonQ.fire();
357 int time_hit = (
static_cast<int>(CLHEP::RandFlat::shoot((
nbxing*
gate)/gate))) -
nbxing/2;
358 std::pair<int, int> digi(
j+1,time_hit);
366 if(0.0 <= posX && posX < 0.2) {
369 else if(0.2 <= posX && posX < 0.4) {
372 else if(0.4 <= posX && posX < 0.6) {
375 else if(0.6 <= posX && posX < 0.8) {
378 else if(0.8 <= posX && posX < 1.0) {
T getParameter(std::string const &) const
float strip(const LocalPoint &lp) const
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
LocalPoint centreOfStrip(int strip) const
const Topology & topology() const
virtual float stripLength() const
std::map< int, std::vector< double > > clsMap
CaloTopology const * topology(0)
DetectorHitMap theDetectorHitMap
void setRPCSimSetUp(RPCSimSetUp *simsetup)
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
RPCSimSetUp * getRPCSimSetUp()
const RPCRollSpecs * specs() const
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
std::set< std::pair< int, int > > strips
uint32_t rawId() const
get the raw id
std::vector< double > clsForDetId
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
virtual std::string name()
std::vector< double > sum_clsize
const std::map< int, std::vector< double > > & getClsMap()
virtual int channel(const LocalPoint &p) const =0
Container::value_type value_type
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 *)
virtual LocalPoint localPosition(float strip) const
RPCSynchronizer * _rpcSync
RPCSimAsymmetricCls(const edm::ParameterSet &config)
std::vector< PSimHit > PSimHitContainer
virtual LocalPoint localPosition(float strip) const
virtual float stripLength() const
det heigth (strip length in the middle)
RPCDigiSimLinks theRpcDigiSimLinks
unsigned int slice(float posX)
const Topology & topology() const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.