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 
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 }
RPCRoll
Definition: RPCRoll.h:12
RPCSynchronizer::setRPCSimSetUp
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCSynchronizer.h:43
RPCSim::getRPCSimSetUp
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:45
RPCSimParam::_rpcSync
RPCSynchronizer * _rpcSync
Definition: RPCSimParam.h:48
mps_fire.i
i
Definition: mps_fire.py:428
TrapezoidalStripTopology::stripLength
float stripLength() const override
det heigth (strip length in the middle)
Definition: TrapezoidalStripTopology.h:63
RPCSimParam::rpcdigiprint
bool rpcdigiprint
Definition: RPCSimParam.h:41
RPCSimParam::N_hits
int N_hits
Definition: RPCSimParam.h:43
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
RPCSimParam::aveEff
double aveEff
Definition: RPCSimParam.h:30
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
edm::DetSet::clear
void clear()
Definition: DetSet.h:71
RPCSimParam::aveCls
double aveCls
Definition: RPCSimParam.h:34
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
RPCSimParam::sspeed
double sspeed
Definition: RPCSimParam.h:39
RPCDetId
Definition: RPCDetId.h:16
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RPCSynchronizer
Definition: RPCSynchronizer.h:36
RPCSimParam::resEle
double resEle
Definition: RPCSimParam.h:38
RPCSynchronizer::getSimHitBx
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
Definition: RPCSynchronizer.cc:57
RPCRoll.h
DDAxes::x
RPCSim::strips
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:55
RectangularStripTopology.h
RectangularStripTopology::localPosition
LocalPoint localPosition(float strip) const override
Definition: RectangularStripTopology.cc:17
RPCRoll::topology
const Topology & topology() const override
Definition: RPCRoll.cc:18
RPCSimParam::gate
double gate
Definition: RPCSimParam.h:46
RPCSimParam::simulateNoise
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:109
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
config
Definition: config.py:1
RPCRoll::id
RPCDetId id() const
Definition: RPCRoll.cc:16
RPCSimParam::resRPC
double resRPC
Definition: RPCSimParam.h:35
RectangularStripTopology
Definition: RectangularStripTopology.h:11
RPCSim::theDetectorHitMap
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:68
TrapezoidalStripTopology
Definition: TrapezoidalStripTopology.h:21
w
const double w
Definition: UKUtility.cc:23
RPCSim::theRpcDigiSimLinks
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:70
RPCRollSpecs::topology
const Topology & topology() const override
Definition: RPCRollSpecs.cc:36
Point3DBase< float, LocalTag >
RPCSimParam::nbxing
int nbxing
Definition: RPCSimParam.h:44
RPCSimParam::simulate
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
Definition: RPCSimParam.cc:43
RPCRoll::centreOfStrip
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:26
RPCSimParam::timOff
double timOff
Definition: RPCSimParam.h:36
RectangularStripTopology::stripLength
float stripLength() const override
Definition: RectangularStripTopology.h:44
RPCRollSpecs.h
edm::ParameterSet
Definition: ParameterSet.h:47
RPCRoll::nstrips
int nstrips() const
Definition: RPCRoll.cc:24
RPCSimParam.h
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
RPCSim
Definition: RPCSim.h:30
RPCSimParam::dtimCs
double dtimCs
Definition: RPCSimParam.h:37
RPCSimParam::lbGate
double lbGate
Definition: RPCSimParam.h:40
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
TrapezoidalStripTopology.h
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
RPCSimParam::~RPCSimParam
~RPCSimParam() override
Definition: RPCSimParam.cc:41
RPCRoll::specs
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:14
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
TrapezoidalStripTopology::localPosition
LocalPoint localPosition(float strip) const override
Definition: TrapezoidalStripTopology.cc:27
Topology
Definition: Topology.h:39
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
RPCSimParam::rate
double rate
Definition: RPCSimParam.h:45
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
RPCSim::RPCDigiSimLinks
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:33
custom_jme_cff.area
area
Definition: custom_jme_cff.py:140
RPCSimParam::RPCSimParam
RPCSimParam(const edm::ParameterSet &config)
Definition: RPCSimParam.cc:12
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37