CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
43 void RPCSimParam::simulate(const RPCRoll* roll, const edm::PSimHitContainer& rpcHits, CLHEP::HepRandomEngine* engine) {
46  theDetectorHitMap.clear();
48 
49  const Topology& topology = roll->specs()->topology();
50 
51  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin(); _hit != rpcHits.end(); ++_hit) {
52  // Here I hould check if the RPC are up side down;
53  const LocalPoint& entr = _hit->entryPoint();
54  int time_hit = _rpcSync->getSimHitBx(&(*_hit), engine);
55 
56  // Effinciecy
57  float eff = CLHEP::RandFlat::shoot(engine);
58  if (eff < aveEff) {
59  int centralStrip = topology.channel(entr) + 1;
60  int fstrip = centralStrip;
61  int lstrip = centralStrip;
62  // Compute the cluster size
63  double w = CLHEP::RandFlat::shoot(engine);
64  if (w < 1.e-10)
65  w = 1.e-10;
66  int clsize = static_cast<int>(-1. * aveCls * log(w) + 1.);
67  std::vector<int> cls;
68  cls.push_back(centralStrip);
69  if (clsize > 1) {
70  for (int cl = 0; cl < (clsize - 1) / 2; cl++)
71  if (centralStrip - cl - 1 >= 1) {
72  fstrip = centralStrip - cl - 1;
73  cls.push_back(fstrip);
74  }
75  for (int cl = 0; cl < (clsize - 1) / 2; cl++)
76  if (centralStrip + cl + 1 <= roll->nstrips()) {
77  lstrip = centralStrip + cl + 1;
78  cls.push_back(lstrip);
79  }
80  if (clsize % 2 == 0) {
81  // insert the last strip according to the
82  // simhit position in the central strip
83  double deltaw = roll->centreOfStrip(centralStrip).x() - entr.x();
84  if (deltaw < 0.) {
85  if (lstrip < roll->nstrips()) {
86  lstrip++;
87  cls.push_back(lstrip);
88  }
89  } else {
90  if (fstrip > 1) {
91  fstrip--;
92  cls.push_back(fstrip);
93  }
94  }
95  }
96  }
97 
98  for (std::vector<int>::iterator i = cls.begin(); i != cls.end(); i++) {
99  // Check the timing of the adjacent strip
100  std::pair<unsigned int, int> digi(*i, time_hit);
101 
102  theDetectorHitMap.insert(DetectorHitMap::value_type(digi, &(*_hit)));
103  strips.insert(digi);
104  }
105  }
106  }
107 }
108 
109 void RPCSimParam::simulateNoise(const RPCRoll* roll, CLHEP::HepRandomEngine* engine) {
110  RPCDetId rpcId = roll->id();
111  int nstrips = roll->nstrips();
112  double area = 0.0;
113 
114  if (rpcId.region() == 0) {
115  const RectangularStripTopology* top_ = dynamic_cast<const RectangularStripTopology*>(&(roll->topology()));
116  float xmin = (top_->localPosition(0.)).x();
117  float xmax = (top_->localPosition((float)roll->nstrips())).x();
118  float striplength = (top_->stripLength());
119  area = striplength * (xmax - xmin);
120  } else {
121  const TrapezoidalStripTopology* top_ = dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
122  float xmin = (top_->localPosition(0.)).x();
123  float xmax = (top_->localPosition((float)roll->nstrips())).x();
124  float striplength = (top_->stripLength());
125  area = striplength * (xmax - xmin);
126  }
127 
128  double ave = rate * nbxing * gate * area * 1.0e-9;
129 
130  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
131  N_hits = randPoissonQ.fire();
132 
133  for (int i = 0; i < N_hits; i++) {
134  int strip = static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips));
135  int time_hit;
136  time_hit = (static_cast<int>(CLHEP::RandFlat::shoot(engine, (nbxing * gate) / gate))) - nbxing / 2;
137  std::pair<int, int> digi(strip, time_hit);
138  strips.insert(digi);
139  }
140 }
bool rpcdigiprint
Definition: RPCSimParam.h:41
double resEle
Definition: RPCSimParam.h:38
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
LocalPoint localPosition(float strip) const override
static std::vector< std::string > checklist log
const double w
Definition: UKUtility.cc:23
double aveEff
Definition: RPCSimParam.h:30
double gate
Definition: RPCSimParam.h:46
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:68
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:24
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:45
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:14
double aveCls
Definition: RPCSimParam.h:34
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
tuple cl
Definition: haddnano.py:49
float stripLength() const override
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:33
RPCDetId id() const
Definition: RPCRoll.cc:16
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:55
double resRPC
Definition: RPCSimParam.h:35
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:109
Definition: RPCSim.h:30
double dtimCs
Definition: RPCSimParam.h:37
double timOff
Definition: RPCSimParam.h:36
const Topology & topology() const override
Definition: RPCRollSpecs.cc:36
~RPCSimParam() override
Definition: RPCSimParam.cc:41
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:43
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
tuple config
parse the configuration file
double lbGate
Definition: RPCSimParam.h:40
const Topology & topology() const override
Definition: RPCRoll.cc:18
void clear()
Definition: DetSet.h:71
tuple cout
Definition: gather_cfg.py:144
std::vector< PSimHit > PSimHitContainer
RPCSynchronizer * _rpcSync
Definition: RPCSimParam.h:48
float stripLength() const override
det heigth (strip length in the middle)
RPCSimParam(const edm::ParameterSet &config)
Definition: RPCSimParam.cc:12
T x() const
Definition: PV3DBase.h:59
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:70
double rate
Definition: RPCSimParam.h:45
LocalPoint localPosition(float strip) const override
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
double sspeed
Definition: RPCSimParam.h:39