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;
193 double w = CLHEP::RandFlat::shoot(engine);
194 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<w<<
" (w is not used)";
195 if (w < 1.
e-10) w=1.e-10;
197 int clsize = this->
getClSize(rpcId.rawId(),posX, engine);
198 LogDebug (
"RPCSimAsymmetricCls")<<
"Clustersize = "<<clsize;
200 std::vector<int> cls;
202 cls.push_back(centralStrip);
204 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
205 if (centralStrip -
cl -1 >= 1 ){
206 fstrip = centralStrip-
cl-1;
207 cls.push_back(fstrip);
209 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
210 lstrip = centralStrip+
cl+1;
211 cls.push_back(lstrip);
222 if (lstrip < roll->nstrips() ){
224 cls.push_back(lstrip);
229 cls.push_back(fstrip);
236 if (lstrip < roll->nstrips() ){
238 cls.push_back(lstrip);
245 float fire1 = CLHEP::RandFlat::shoot(engine);
246 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire1<<
" (fire1 is used for a shift of the cluster)";
264 std::vector<double> TMPclsAsymmForDetId
267 for(
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i ++){
268 if(fire1 < TMPclsAsymmForDetId[
i]){
275 vector<int> shifted_cls;
282 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
283 if(*
i+strip_shift < min_strip){
284 min_strip = *
i+strip_shift;
286 if(*
i+strip_shift > max_strip){
287 max_strip = *
i+strip_shift;
291 if(min_strip<1 || max_strip-roll->nstrips()>0){
296 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
297 shifted_cls.push_back(*
i+strip_shift);
299 for (std::vector<int>::iterator
i=shifted_cls.begin();
300 i!=shifted_cls.end();
i++){
302 if(*
i != centralStrip){
303 double fire2 = CLHEP::RandFlat::shoot(engine);
304 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire2<<
" (check whether adjacent strips are efficient)";
305 if(fire2 < veff[*
i-1]){
306 std::pair<int, int> digi(*
i,time_hit);
308 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
314 std::pair<int, int> digi(*
i,time_hit);
318 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
326 CLHEP::HepRandomEngine* engine)
337 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Treating DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" which has "<<roll->
nstrips()<<
" strips";
339 std::stringstream vnoisestream; vnoisestream<<
"[";
340 for(std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) { vnoisestream<<(*vnoiseIt)<<
","; }
343 LogDebug(
"RPCSimAsymmetricCls")<<
"Get Noise from RPCSimSetup for detId = "<<rpcId.
rawId()<<
" :: vector with "<<vnoise.size()<<
"entries :: "<<vnoisestr;
346 unsigned int nstrips = roll->
nstrips();
349 if ( rpcId.
region() == 0 )
356 area = striplength*(xmax-
xmin);
364 area = striplength*(xmax-
xmin);
367 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: vnoise.size() = "<<vnoise.size();
369 for(
unsigned int j = 0;
j < vnoise.size(); ++
j){
371 if(
j >= nstrips)
break;
382 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());
384 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
385 N_hits = randPoissonQ.fire();
386 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: "<<
N_hits;
387 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: Amount of Noise Hits for DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" = N_hits = randPoissonQ.fire() = "<<
N_hits;
390 double time2 = CLHEP::RandFlat::shoot((
nbxing*
gate)/gate);
391 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: "<<time2;
392 int time_hit = (
static_cast<int>(time2) -
nbxing/2);
393 std::pair<int, int> digi(
j+1,time_hit);
395 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Noise :: DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
402 if(0.0 <= posX && posX < 0.2) {
405 else if(0.2 <= posX && posX < 0.4) {
408 else if(0.4 <= posX && posX < 0.6) {
411 else if(0.6 <= posX && posX < 0.8) {
414 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.