CMS 3D CMS Logo

RPCSimParam.cc
Go to the documentation of this file.
6 
7 #include <cmath>
8 
9 #include "CLHEP/Random/RandFlat.h"
10 #include "CLHEP/Random/RandPoissonQ.h"
11 
13  aveEff = config.getParameter<double>("averageEfficiency");
14  aveCls = config.getParameter<double>("averageClusterSize");
15  resRPC = config.getParameter<double>("timeResolution");
16  timOff = config.getParameter<double>("timingRPCOffset");
17  dtimCs = config.getParameter<double>("deltatimeAdjacentStrip");
18  resEle = config.getParameter<double>("timeJitter");
19  sspeed = config.getParameter<double>("signalPropagationSpeed");
20  lbGate = config.getParameter<double>("linkGateWidth");
21  rpcdigiprint = config.getParameter<bool>("printOutDigitizer");
22 
23  rate=config.getParameter<double>("Rate");
24  nbxing=config.getParameter<int>("Nbxing");
25  gate=config.getParameter<double>("Gate");
26 
27  if (rpcdigiprint) {
28  std::cout <<"Average Efficiency = "<<aveEff<<std::endl;
29  std::cout <<"Average Cluster Size = "<<aveCls<<" strips"<<std::endl;
30  std::cout <<"RPC Time Resolution = "<<resRPC<<" ns"<<std::endl;
31  std::cout <<"RPC Signal formation time = "<<timOff<<" ns"<<std::endl;
32  std::cout <<"RPC adjacent strip delay = "<<dtimCs<<" ns"<<std::endl;
33  std::cout <<"Electronic Jitter = "<<resEle<<" ns"<<std::endl;
34  std::cout <<"Signal propagation time = "<<sspeed<<" x c"<<std::endl;
35  std::cout <<"Link Board Gate Width = "<<lbGate<<" ns"<<std::endl;
36  }
37 
38  _rpcSync = new RPCSynchronizer(config);
39 }
40 
42  delete _rpcSync;
43 }
44 
45 
46 void
48  const edm::PSimHitContainer& rpcHits,
49  CLHEP::HepRandomEngine* engine)
50 {
53  theDetectorHitMap.clear();
55 
56  const Topology& topology=roll->specs()->topology();
57 
58  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
59  _hit != rpcHits.end(); ++_hit){
60 
61  // Here I hould check if the RPC are up side down;
62  const LocalPoint& entr=_hit->entryPoint();
63  int time_hit = _rpcSync->getSimHitBx(&(*_hit), engine);
64 
65  // Effinciecy
66  float eff = CLHEP::RandFlat::shoot(engine);
67  if (eff < aveEff) {
68 
69  int centralStrip = topology.channel(entr)+1;
70  int fstrip=centralStrip;
71  int lstrip=centralStrip;
72  // Compute the cluster size
73  double w = CLHEP::RandFlat::shoot(engine);
74  if (w < 1.e-10) w=1.e-10;
75  int clsize = static_cast<int>( -1.*aveCls*log(w)+1.);
76  std::vector<int> cls;
77  cls.push_back(centralStrip);
78  if (clsize > 1){
79  for (int cl = 0; cl < (clsize-1)/2; cl++)
80  if (centralStrip - cl -1 >= 1 ){
81  fstrip = centralStrip-cl-1;
82  cls.push_back(fstrip);
83  }
84  for (int cl = 0; cl < (clsize-1)/2; cl++)
85  if (centralStrip + cl + 1 <= roll->nstrips() ){
86  lstrip = centralStrip+cl+1;
87  cls.push_back(lstrip);
88  }
89  if (clsize%2 == 0 ){
90  // insert the last strip according to the
91  // simhit position in the central strip
92  double deltaw=roll->centreOfStrip(centralStrip).x()-entr.x();
93  if (deltaw<0.) {
94  if (lstrip < roll->nstrips() ){
95  lstrip++;
96  cls.push_back(lstrip);
97  }
98  }else{
99  if (fstrip > 1 ){
100  fstrip--;
101  cls.push_back(fstrip);
102  }
103  }
104  }
105  }
106 
107  for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
108  // Check the timing of the adjacent strip
109  std::pair<unsigned int, int> digi(*i,time_hit);
110 
111  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
112  strips.insert(digi);
113  }
114  }
115  }
116 }
117 
118 
120  CLHEP::HepRandomEngine* engine)
121 {
122 
123  RPCDetId rpcId = roll->id();
124  int nstrips = roll->nstrips();
125  double area = 0.0;
126 
127  if ( rpcId.region() == 0 )
128  {
129  const RectangularStripTopology* top_ = dynamic_cast<const
130  RectangularStripTopology*>(&(roll->topology()));
131  float xmin = (top_->localPosition(0.)).x();
132  float xmax = (top_->localPosition((float)roll->nstrips())).x();
133  float striplength = (top_->stripLength());
134  area = striplength*(xmax-xmin);
135  }
136  else
137  {
138  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
139  float xmin = (top_->localPosition(0.)).x();
140  float xmax = (top_->localPosition((float)roll->nstrips())).x();
141  float striplength = (top_->stripLength());
142  area = striplength*(xmax-xmin);
143  }
144 
145  double ave = rate*nbxing*gate*area*1.0e-9;
146 
147  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
148  N_hits = randPoissonQ.fire();
149 
150  for (int i = 0; i < N_hits; i++ ){
151  int strip = static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips));
152  int time_hit;
153  time_hit = (static_cast<int>(CLHEP::RandFlat::shoot(engine, (nbxing*gate)/gate))) - nbxing/2;
154  std::pair<int, int> digi(strip,time_hit);
155  strips.insert(digi);
156  }
157 
158 }
bool rpcdigiprint
Definition: RPCSimParam.h:44
double resEle
Definition: RPCSimParam.h:41
T getParameter(std::string const &) const
const Topology & topology() const override
Definition: RPCRollSpecs.cc:43
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
LocalPoint localPosition(float strip) const override
const double w
Definition: UKUtility.cc:23
double aveEff
Definition: RPCSimParam.h:34
CaloTopology const * topology(0)
double gate
Definition: RPCSimParam.h:49
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:72
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:46
LocalPoint localPosition(float strip) const override
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
Definition: config.py:1
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:18
double aveCls
Definition: RPCSimParam.h:37
const Topology & topology() const override
Definition: RPCRoll.cc:30
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:35
RPCDetId id() const
Definition: RPCRoll.cc:24
double resRPC
Definition: RPCSimParam.h:38
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:119
float stripLength() const override
det heigth (strip length in the middle)
Definition: RPCSim.h:30
double dtimCs
Definition: RPCSimParam.h:40
double timOff
Definition: RPCSimParam.h:39
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:47
double lbGate
Definition: RPCSimParam.h:43
void clear()
Definition: DetSet.h:69
std::vector< PSimHit > PSimHitContainer
RPCSynchronizer * _rpcSync
Definition: RPCSimParam.h:51
RPCSimParam(const edm::ParameterSet &config)
Definition: RPCSimParam.cc:12
T x() const
Definition: PV3DBase.h:62
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:74
double rate
Definition: RPCSimParam.h:48
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
double sspeed
Definition: RPCSimParam.h:42
float stripLength() const override