36 #include "CLHEP/Random/RandFlat.h" 37 #include "CLHEP/Random/RandPoissonQ.h" 63 std::cout <<
"Average Cluster Size = "<<aveCls<<
" strips"<<std::endl;
64 std::cout <<
"RPC Time Resolution = "<<resRPC<<
" ns"<<std::endl;
65 std::cout <<
"RPC Signal formation time = "<<timOff<<
" ns"<<std::endl;
66 std::cout <<
"RPC adjacent strip delay = "<<dtimCs<<
" ns"<<std::endl;
67 std::cout <<
"Electronic Jitter = "<<resEle<<
" ns"<<std::endl;
68 std::cout <<
"Signal propagation time = "<<sspeed<<
" x c"<<std::endl;
69 std::cout <<
"Link Board Gate Width = "<<lbGate<<
" ns"<<std::endl;
88 double rr_cl = CLHEP::RandFlat::shoot(engine);
89 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: "<<rr_cl;
90 for(
unsigned int i = 0 ;
i < clsForDetId.size();
i++){
92 if(rr_cl > clsForDetId[
i]){
95 else if(rr_cl < clsForDetId[i]){
111 double rr_cl = CLHEP::RandFlat::shoot(engine);
112 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::getClSize] Fired RandFlat :: "<<rr_cl;
114 if(0.0 <= posX && posX < 0.2) {
115 func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
116 sum_clsize = clsMap[1];
118 if(0.2 <= posX && posX < 0.4) {
119 func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
120 sum_clsize = clsMap[2];
122 if(0.4 <= posX && posX < 0.6) {
123 func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
124 sum_clsize = clsMap[3];
126 if(0.6 <= posX && posX < 0.8) {
127 func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
128 sum_clsize = clsMap[4];
130 if(0.8 <= posX && posX < 1.0) {
131 func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
132 sum_clsize = clsMap[5];
135 for(vector<double>::iterator iter = sum_clsize.begin();
136 iter != sum_clsize.end(); ++iter){
141 else if(func < (*iter)){
151 CLHEP::HepRandomEngine* engine)
163 for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
164 _hit != rpcHits.end(); ++_hit){
170 float posX = roll->
strip(_hit->localPosition())
171 - static_cast<int>(roll->
strip(_hit->localPosition()));
173 std::vector<float> veff = (
getRPCSimSetUp())->getEff(rpcId.rawId());
175 std::stringstream veffstream; veffstream<<
"[";
176 for(std::vector<float>::iterator veffIt = veff.begin(); veffIt != veff.end(); ++veffIt) { veffstream<<(*veffIt)<<
","; }
179 LogDebug(
"RPCSimAsymmetricCls")<<
"Get Eff from RPCSimSetup for detId = "<<rpcId.rawId()<<
" :: "<<veffstr;
183 int centralStrip = topology.
channel(entr)+1;
184 float fire = CLHEP::RandFlat::shoot(engine);
185 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire<<
" --> < "<<veff[centralStrip-1]<<
" ? --> "<<((fire < veff[centralStrip-1])?1:0);
187 if (fire < veff[centralStrip-1]) {
188 LogDebug (
"RPCSimAsymmetricCls")<<
"Detector is Efficient for this simhit";
190 int fstrip=centralStrip;
191 int lstrip=centralStrip;
200 LogDebug (
"RPCSimAsymmetricCls")<<
"Clustersize = "<<clsize;
202 std::vector<int> cls;
204 cls.push_back(centralStrip);
206 for (
int cl = 0;
cl < (clsize-1)/2;
cl++){
207 if (centralStrip -
cl -1 >= 1 ){
208 fstrip = centralStrip-
cl-1;
209 cls.push_back(fstrip);
211 if (centralStrip +
cl + 1 <= roll->
nstrips() ){
212 lstrip = centralStrip+
cl+1;
213 cls.push_back(lstrip);
224 if (lstrip < roll->nstrips() ){
226 cls.push_back(lstrip);
231 cls.push_back(fstrip);
238 if (lstrip < roll->nstrips() ){
240 cls.push_back(lstrip);
247 float fire1 = CLHEP::RandFlat::shoot(engine);
248 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire1<<
" (fire1 is used for a shift of the cluster)";
266 std::vector<double> TMPclsAsymmForDetId
269 for(
unsigned int i = 0;
i < TMPclsAsymmForDetId.size();
i ++){
270 if(fire1 < TMPclsAsymmForDetId[
i]){
277 vector<int> shifted_cls;
284 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
285 if(*
i+strip_shift < min_strip){
286 min_strip = *
i+strip_shift;
288 if(*
i+strip_shift > max_strip){
289 max_strip = *
i+strip_shift;
293 if(min_strip<1 || max_strip-roll->nstrips()>0){
298 for (std::vector<int>::iterator
i=cls.begin();
i!=cls.end();
i++){
299 shifted_cls.push_back(*
i+strip_shift);
301 for (std::vector<int>::iterator
i=shifted_cls.begin();
302 i!=shifted_cls.end();
i++){
304 if(*
i != centralStrip){
305 double fire2 = CLHEP::RandFlat::shoot(engine);
306 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulate] Fired RandFlat :: "<<fire2<<
" (check whether adjacent strips are efficient)";
307 if(fire2 < veff[*
i-1]){
308 std::pair<int, int> digi(*
i,time_hit);
310 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
316 std::pair<int, int> digi(*
i,time_hit);
320 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Signl :: DetId :: "<<rpcId<<
" = "<<rpcId.rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
328 CLHEP::HepRandomEngine* engine)
339 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Treating DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" which has "<<roll->
nstrips()<<
" strips";
341 std::stringstream vnoisestream; vnoisestream<<
"[";
342 for(std::vector<float>::iterator vnoiseIt = vnoise.begin(); vnoiseIt != vnoise.end(); ++vnoiseIt) { vnoisestream<<(*vnoiseIt)<<
","; }
345 LogDebug(
"RPCSimAsymmetricCls")<<
"Get Noise from RPCSimSetup for detId = "<<rpcId.
rawId()<<
" :: vector with "<<vnoise.size()<<
"entries :: "<<vnoisestr;
348 unsigned int nstrips = roll->
nstrips();
351 if ( rpcId.
region() == 0 )
358 area = striplength*(xmax-
xmin);
366 area = striplength*(xmax-
xmin);
369 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: vnoise.size() = "<<vnoise.size();
371 for(
unsigned int j = 0; j < vnoise.size(); ++j){
373 if(j >= nstrips)
break;
384 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());
386 CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
387 N_hits = randPoissonQ.fire();
388 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandPoissonQ :: "<<
N_hits;
389 LogDebug (
"RPCSimAsymmetricCls")<<
"Noise :: Amount of Noise Hits for DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" = N_hits = randPoissonQ.fire() = "<<
N_hits;
392 double time2 = CLHEP::RandFlat::shoot((
nbxing*
gate)/gate);
393 LogDebug (
"RPCSimAsymmetricCls")<<
"[RPCSimAsymmetricCls::simulateNoise] Fired RandFlat :: "<<time2;
394 int time_hit = (
static_cast<int>(time2) -
nbxing/2);
395 std::pair<int, int> digi(j+1,time_hit);
397 LogDebug (
"RPCSimAsymmetricCls")<<
"RPC Digi inserted :: Noise :: DetId :: "<<rpcId<<
" = "<<rpcId.
rawId()<<
" ==> digi <"<<digi.first<<
","<<digi.second<<
">";
404 if(0.0 <= posX && posX < 0.2) {
407 else if(0.2 <= posX && posX < 0.4) {
410 else if(0.4 <= posX && posX < 0.6) {
413 else if(0.6 <= posX && posX < 0.8) {
416 else if(0.8 <= posX && posX < 1.0) {
T getParameter(std::string const &) const
float strip(const LocalPoint &lp) const
const Topology & topology() const override
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
LocalPoint centreOfStrip(int strip) const
LocalPoint localPosition(float strip) const override
std::map< int, std::vector< double > > clsMap
~RPCSimAsymmetricCls() override
CaloTopology const * topology(0)
DetectorHitMap theDetectorHitMap
void setRPCSimSetUp(RPCSimSetUp *simsetup)
constexpr uint32_t rawId() const
get the raw id
LocalPoint localPosition(float strip) const override
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
RPCSimSetUp * getRPCSimSetUp()
const RPCRollSpecs * specs() const
const Topology & topology() const override
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
std::set< std::pair< int, int > > strips
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()
float stripLength() const override
det heigth (strip length in the middle)
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 *)
RPCSynchronizer * _rpcSync
RPCSimAsymmetricCls(const edm::ParameterSet &config)
std::vector< PSimHit > PSimHitContainer
RPCDigiSimLinks theRpcDigiSimLinks
unsigned int slice(float posX)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
float stripLength() const override