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 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: "<<rr_cl;
89 for(
unsigned int i = 0 ;
i < clsForDetId.size();
i++){
91 if(rr_cl > clsForDetId[
i]){
94 else if(rr_cl < clsForDetId[i]){
110 double rr_cl = CLHEP::RandFlat::shoot(engine);
111 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: "<<rr_cl;
113 if(0.0 <= posX && posX < 0.2) {
114 func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
115 sum_clsize = clsMap[1];
117 if(0.2 <= posX && posX < 0.4) {
118 func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
119 sum_clsize = clsMap[2];
121 if(0.4 <= posX && posX < 0.6) {
122 func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
123 sum_clsize = clsMap[3];
125 if(0.6 <= posX && posX < 0.8) {
126 func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
127 sum_clsize = clsMap[4];
129 if(0.8 <= posX && posX < 1.0) {
130 func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
131 sum_clsize = clsMap[5];
134 for(vector<double>::iterator iter = sum_clsize.begin();
135 iter != sum_clsize.end(); ++iter){
140 else if(func < (*iter)){
150 CLHEP::HepRandomEngine* engine)
162 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
163 _hit != rpcHits.end(); ++_hit){
169 float posX = roll->
strip(_hit->localPosition())
170 - static_cast<int>(roll->
strip(_hit->localPosition()));
172 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
174 std::stringstream veffstream; veffstream<<
"[";
175 for(std::vector<float>::iterator veffIt = veff.begin(); veffIt != veff.end(); ++veffIt) { veffstream<<(*veffIt)<<
","; }
178 LogDebug(
"RPCSimAsymmetricCls")<<
"Get Eff from RPCSimSetup for detId = "<<rpcId.rawId()<<
" :: "<<veffstr;
182 int centralStrip = topology.
channel(entr)+1;
183 float fire = CLHEP::RandFlat::shoot(engine);
184 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire<<
" --> < "<<veff[centralStrip-1]<<
" ? --> "<<((fire < veff[centralStrip-1])?1:0);
186 if (fire < veff[centralStrip-1]) {
187 LogDebug (
"RPCSimAsymmetricCls")<<
"Detector is Efficient for this simhit";
189 int fstrip=centralStrip;
190 int lstrip=centralStrip;
198 int clsize = this->
getClSize(rpcId.rawId(),posX, engine);
199 LogDebug (
"RPCSimAsymmetricCls")<<
"Clustersize = "<<clsize;
201 std::vector<int> cls;
203 cls.push_back(centralStrip);
205 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
206 if (centralStrip -
cl -1 >= 1 ){
207 fstrip = centralStrip-
cl-1;
208 cls.push_back(fstrip);
210 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
211 lstrip = centralStrip+
cl+1;
212 cls.push_back(lstrip);
223 if (lstrip < roll->nstrips() ){
225 cls.push_back(lstrip);
230 cls.push_back(fstrip);
237 if (lstrip < roll->nstrips() ){
239 cls.push_back(lstrip);
246 float fire1 = CLHEP::RandFlat::shoot(engine);
247 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire1<<
" (fire1 is used for a shift of the cluster)";
265 std::vector<double> TMPclsAsymmForDetId
268 for(
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i ++){
269 if(fire1 < TMPclsAsymmForDetId[
i]){
276 vector<int> shifted_cls;
283 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
284 if(*
i+strip_shift < min_strip){
285 min_strip = *
i+strip_shift;
287 if(*
i+strip_shift > max_strip){
288 max_strip = *
i+strip_shift;
292 if(min_strip<1 || max_strip-roll->nstrips()>0){
297 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
298 shifted_cls.push_back(*
i+strip_shift);
300 for (std::vector<int>::iterator
i=shifted_cls.begin();
301 i!=shifted_cls.end();
i++){
303 if(*
i != centralStrip){
304 double fire2 = CLHEP::RandFlat::shoot(engine);
305 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire2<<
" (check whether adjacent strips are efficient)";
306 if(fire2 < veff[*
i-1]){
307 std::pair<int, int> digi(*
i,time_hit);
309 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
315 std::pair<int, int> digi(*
i,time_hit);
319 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
327 CLHEP::HepRandomEngine* engine)
338 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Treating DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" which has "<<roll->
nstrips()<<
" strips";
340 std::stringstream vnoisestream; vnoisestream<<
"[";
341 for(std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) { vnoisestream<<(*vnoiseIt)<<
","; }
344 LogDebug(
"RPCSimAsymmetricCls")<<
"Get Noise from RPCSimSetup for detId = "<<rpcId.
rawId()<<
" :: vector with "<<vnoise.size()<<
"entries :: "<<vnoisestr;
347 unsigned int nstrips = roll->
nstrips();
350 if ( rpcId.
region() == 0 )
357 area = striplength*(xmax-
xmin);
365 area = striplength*(xmax-
xmin);
368 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: vnoise.size() = "<<vnoise.size();
370 for(
unsigned int j = 0;
j < vnoise.size(); ++
j){
372 if(
j >= nstrips)
break;
383 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: strip "<<
j<<
" Average = "<<ave<<
" = vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips()) = "<<vnoise[
j]<<
"*"<<
nbxing<<
"*"<<
gate<<
"*"<<area<<
"*"<<1.0e-9<<
"*"<<
frate<<
"/"<<((float)roll->
nstrips());
385 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
386 N_hits = randPoissonQ.fire();
387 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: "<<
N_hits;
388 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: Amount of Noise Hits for DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" = N_hits = randPoissonQ.fire() = "<<
N_hits;
391 double time2 = CLHEP::RandFlat::shoot((
nbxing*
gate)/gate);
392 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: "<<time2;
393 int time_hit = (
static_cast<int>(time2) -
nbxing/2);
394 std::pair<int, int> digi(
j+1,time_hit);
396 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Noise :: DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
403 if(0.0 <= posX && posX < 0.2) {
406 else if(0.2 <= posX && posX < 0.4) {
409 else if(0.4 <= posX && posX < 0.6) {
412 else if(0.6 <= posX && posX < 0.8) {
415 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()
Container::value_type value_type
std::vector< double > sum_clsize
const std::map< int, std::vector< double > > & getClsMap()
virtual int channel(const LocalPoint &p) const =0
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.