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){
161 if(_hit-> particleType() == 11)
continue;
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 std::vector<double> TMPclsAsymmForDetId
191 cls.push_back(centralStrip);
193 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
194 if (centralStrip -
cl -1 >= 1 ){
195 fstrip = centralStrip-
cl-1;
196 cls.push_back(fstrip);
198 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
199 lstrip = centralStrip+
cl+1;
200 cls.push_back(lstrip);
208 if (lstrip < roll->nstrips() ){
210 cls.push_back(lstrip);
215 cls.push_back(fstrip);
223 float fire1 = CLHEP::RandFlat::shoot(engine);
235 for(
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i ++){
236 if(fire1 < TMPclsAsymmForDetId[
i]){
242 vector<int> shifted_cls;
249 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
250 if(*
i+strip_shift < min_strip){
251 min_strip = *
i+strip_shift;
253 if(*
i+strip_shift > max_strip){
254 max_strip = *
i+strip_shift;
258 if(min_strip<1 || max_strip-roll->nstrips()>0){
274 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
275 shifted_cls.push_back(*
i+strip_shift);
277 for (std::vector<int>::iterator
i=shifted_cls.begin();
i!=shifted_cls.end();
i++){
279 if(*
i != centralStrip){
280 if(CLHEP::RandFlat::shoot(engine) < veff[*
i-1]){
281 std::pair<int, int> digi(*
i,time_hit);
288 std::pair<int, int> digi(*
i,time_hit);
299 CLHEP::HepRandomEngine* engine)
310 unsigned int nstrips = roll->
nstrips();
313 if ( rpcId.
region() == 0 )
320 area = striplength*(xmax-
xmin);
328 area = striplength*(xmax-
xmin);
331 for(
unsigned int j = 0;
j < vnoise.size(); ++
j){
333 if(
j >= nstrips)
break;
346 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
347 N_hits = randPoissonQ.fire();
350 int time_hit = (
static_cast<int>(CLHEP::RandFlat::shoot((
nbxing*
gate)/gate))) -
nbxing/2;
351 std::pair<int, int> digi(
j+1,time_hit);
359 if(0.0 <= posX && posX < 0.2) {
362 else if(0.2 <= posX && posX < 0.4) {
365 else if(0.4 <= posX && posX < 0.6) {
368 else if(0.6 <= posX && posX < 0.8) {
371 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
unsigned int offset(bool)
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.