CMS 3D CMS Logo

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