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;
94 double rr_cl = CLHEP::RandFlat::shoot(engine);
96 if(0.0 <= posX && posX < 0.2) {
97 func = clsForDetId[19]*(rr_cl);
100 if(0.2 <= posX && posX < 0.4) {
101 func = clsForDetId[39]*(rr_cl);
104 if(0.4 <= posX && posX < 0.6) {
105 func = clsForDetId[59]*(rr_cl);
108 if(0.6 <= posX && posX < 0.8) {
109 func = clsForDetId[79]*(rr_cl);
112 if(0.8 <= posX && posX < 1.0) {
113 func = clsForDetId[89]*(rr_cl);
118 for(
int i = vectOffset;
i<(vectOffset+20);
i++){
120 if(func > clsForDetId[
i]){
123 else if(func < clsForDetId[i]){
140 double rr_cl = CLHEP::RandFlat::shoot(engine);
141 if(0.0 <= posX && posX < 0.2) {
142 func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
143 sum_clsize = clsMap[1];
145 if(0.2 <= posX && posX < 0.4) {
146 func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
147 sum_clsize = clsMap[2];
149 if(0.4 <= posX && posX < 0.6) {
150 func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
151 sum_clsize = clsMap[3];
153 if(0.6 <= posX && posX < 0.8) {
154 func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
155 sum_clsize = clsMap[4];
157 if(0.8 <= posX && posX < 1.0) {
158 func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
159 sum_clsize = clsMap[5];
162 for(vector<double>::iterator
iter = sum_clsize.begin();
168 else if(func < (*
iter)){
178 CLHEP::HepRandomEngine* engine)
192 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
193 _hit != rpcHits.end(); ++_hit){
195 if(_hit-> particleType() == 11)
continue;
201 float posX = roll->
strip(_hit->localPosition()) - static_cast<int>(roll->
strip(_hit->localPosition()));
203 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
206 int centralStrip = topology.
channel(entr)+1;;
207 float fire = CLHEP::RandFlat::shoot(engine);
209 if (fire < veff[centralStrip-1]) {
211 int fstrip=centralStrip;
212 int lstrip=centralStrip;
215 double w = CLHEP::RandFlat::shoot(engine);
216 if (w < 1.
e-10) w=1.e-10;
218 int clsize = this->
getClSize(rpcId.rawId(),posX, engine);
219 std::vector<int> cls;
220 cls.push_back(centralStrip);
222 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
223 if (centralStrip -
cl -1 >= 1 ){
224 fstrip = centralStrip-
cl-1;
225 cls.push_back(fstrip);
227 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
228 lstrip = centralStrip+
cl+1;
229 cls.push_back(lstrip);
237 if (lstrip < roll->nstrips() ){
239 cls.push_back(lstrip);
244 cls.push_back(fstrip);
250 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
252 if(*
i != centralStrip){
253 if(CLHEP::RandFlat::shoot(engine) < veff[*
i-1]){
254 std::pair<int, int> digi(*
i,time_hit);
261 std::pair<int, int> digi(*
i,time_hit);
272 CLHEP::HepRandomEngine* engine)
283 unsigned int nstrips = roll->
nstrips();
286 if ( rpcId.
region() == 0 )
293 area = striplength*(xmax-
xmin);
301 area = striplength*(xmax-
xmin);
304 for(
unsigned int j = 0;
j < vnoise.size(); ++
j){
306 if(
j >= nstrips)
break;
319 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
320 N_hits = randPoissonQ.fire();
324 int time_hit = (
static_cast<int>(CLHEP::RandFlat::shoot(engine, (
nbxing*
gate)/gate))) -
nbxing/2;
325 std::pair<int, int> digi(
j+1,time_hit);
T getParameter(std::string const &) const
float strip(const LocalPoint &lp) const
int getClSize(float posX, CLHEP::HepRandomEngine *)
LocalPoint centreOfStrip(int strip) const
const Topology & topology() const
virtual float stripLength() const
CaloTopology const * topology(0)
DetectorHitMap theDetectorHitMap
void setRPCSimSetUp(RPCSimSetUp *simsetup)
RPCSimSetUp * getRPCSimSetUp()
std::vector< double > clsForDetId
const RPCRollSpecs * specs() const
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
~RPCSimAverageNoiseEffCls()
std::set< std::pair< int, int > > strips
uint32_t rawId() const
get the raw id
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
std::vector< double > sum_clsize
RPCSynchronizer * _rpcSync
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
const std::vector< double > & getCls(uint32_t id)
const std::map< int, std::vector< double > > & getClsMap()
virtual int channel(const LocalPoint &p) const =0
Container::value_type value_type
std::map< int, std::vector< double > > clsMap
virtual LocalPoint localPosition(float strip) const
RPCSimAverageNoiseEffCls(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
const Topology & topology() const
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.