CMS 3D CMS Logo

RPCSimSimple.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 
12 #include <cstring>
13 #include <iostream>
14 #include <string>
15 #include <vector>
16 #include <cstdlib>
17 #include <utility>
18 #include <map>
19 
21 
22  rate=config.getParameter<double>("Rate");
23  nbxing=config.getParameter<int>("Nbxing");
24  gate=config.getParameter<double>("Gate");
25 
26  _rpcSync = new RPCSynchronizer(config);
27 }
28 
30  delete _rpcSync;
31 }
32 
33 
34 void
36  const edm::PSimHitContainer& rpcHits,
37  CLHEP::HepRandomEngine* engine)
38 {
41  theDetectorHitMap.clear();
43 
44  const Topology& topology=roll->specs()->topology();
45  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
46  _hit != rpcHits.end(); ++_hit){
47 
48 
49  // Here I hould check if the RPC are up side down;
50  const LocalPoint& entr=_hit->entryPoint();
51  int time_hit = _rpcSync->getSimHitBx(&(*_hit), engine);
52  // const LocalPoint& exit=_hit->exitPoint();
53 
54  std::pair<int, int> digi(topology.channel(entr)+1,
55  time_hit);
56 
57  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
58  strips.insert(digi);
59  }
60 }
61 
62 
64  CLHEP::HepRandomEngine* engine)
65 {
66 
67  RPCDetId rpcId = roll->id();
68  int nstrips = roll->nstrips();
69  double area = 0.0;
70 
71  if ( rpcId.region() == 0 )
72  {
73  const RectangularStripTopology* top_ = dynamic_cast<const
74  RectangularStripTopology*>(&(roll->topology()));
75  float xmin = (top_->localPosition(0.)).x();
76  float xmax = (top_->localPosition((float)roll->nstrips())).x();
77  float striplength = (top_->stripLength());
78  area = striplength*(xmax-xmin);
79  }
80  else
81  {
82  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
83  float xmin = (top_->localPosition(0.)).x();
84  float xmax = (top_->localPosition((float)roll->nstrips())).x();
85  float striplength = (top_->stripLength());
86  area = striplength*(xmax-xmin);
87  }
88 
89  double ave = rate*nbxing*gate*area*1.0e-9;
90 
91  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
92  N_hits = randPoissonQ.fire();
93 
94  for (int i = 0; i < N_hits; i++ ){
95  int strip = static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips));
96  int time_hit;
97  time_hit = (static_cast<int>(CLHEP::RandFlat::shoot(engine, (nbxing*gate)/gate))) - nbxing/2;
98  std::pair<int, int> digi(strip,time_hit);
99  strips.insert(digi);
100  }
101 }
T getParameter(std::string const &) const
const Topology & topology() const override
Definition: RPCRollSpecs.cc:43
LocalPoint localPosition(float strip) const override
CaloTopology const * topology(0)
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
Definition: RPCSimSimple.cc:63
RPCSynchronizer * _rpcSync
Definition: RPCSimSimple.h:32
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:72
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:46
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
LocalPoint localPosition(float strip) const override
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
Definition: config.py:1
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:18
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
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:35
RPCDetId id() const
Definition: RPCRoll.cc:24
RPCSimSimple(const edm::ParameterSet &config)
Definition: RPCSimSimple.cc:20
float stripLength() const override
det heigth (strip length in the middle)
Definition: RPCSim.h:30
void clear()
Definition: DetSet.h:71
~RPCSimSimple() override
Definition: RPCSimSimple.cc:29
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
Definition: RPCSimSimple.cc:35
std::vector< PSimHit > PSimHitContainer
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:74
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
float stripLength() const override