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  rate = config.getParameter<double>("Rate");
22  nbxing = config.getParameter<int>("Nbxing");
23  gate = config.getParameter<double>("Gate");
24 
26 }
27 
29 
30 void RPCSimSimple::simulate(const RPCRoll* roll, const edm::PSimHitContainer& rpcHits, CLHEP::HepRandomEngine* engine) {
33  theDetectorHitMap.clear();
35 
36  const Topology& topology = roll->specs()->topology();
37  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin(); _hit != rpcHits.end(); ++_hit) {
38  // Here I hould check if the RPC are up side down;
39  const LocalPoint& entr = _hit->entryPoint();
40  int time_hit = _rpcSync->getSimHitBx(&(*_hit), engine);
41  // const LocalPoint& exit=_hit->exitPoint();
42 
43  std::pair<int, int> digi(topology.channel(entr) + 1, time_hit);
44 
45  theDetectorHitMap.insert(DetectorHitMap::value_type(digi, &(*_hit)));
46  strips.insert(digi);
47  }
48 }
49 
50 void RPCSimSimple::simulateNoise(const RPCRoll* roll, CLHEP::HepRandomEngine* engine) {
51  RPCDetId rpcId = roll->id();
52  int nstrips = roll->nstrips();
53  double area = 0.0;
54 
55  if (rpcId.region() == 0) {
56  const RectangularStripTopology* top_ = dynamic_cast<const RectangularStripTopology*>(&(roll->topology()));
57  float xmin = (top_->localPosition(0.)).x();
58  float xmax = (top_->localPosition((float)roll->nstrips())).x();
59  float striplength = (top_->stripLength());
60  area = striplength * (xmax - xmin);
61  } else {
62  const TrapezoidalStripTopology* top_ = dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
63  float xmin = (top_->localPosition(0.)).x();
64  float xmax = (top_->localPosition((float)roll->nstrips())).x();
65  float striplength = (top_->stripLength());
66  area = striplength * (xmax - xmin);
67  }
68 
69  double ave = rate * nbxing * gate * area * 1.0e-9;
70 
71  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
72  N_hits = randPoissonQ.fire();
73 
74  for (int i = 0; i < N_hits; i++) {
75  int strip = static_cast<int>(CLHEP::RandFlat::shoot(engine, 1, nstrips));
76  int time_hit;
77  time_hit = (static_cast<int>(CLHEP::RandFlat::shoot(engine, (nbxing * gate) / gate))) - nbxing / 2;
78  std::pair<int, int> digi(strip, time_hit);
79  strips.insert(digi);
80  }
81 }
RPCRoll
Definition: RPCRoll.h:12
RPCSynchronizer::setRPCSimSetUp
void setRPCSimSetUp(RPCSimSetUp *simsetup)
Definition: RPCSynchronizer.h:43
RPCSim::getRPCSimSetUp
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:45
RPCSimSimple::RPCSimSimple
RPCSimSimple(const edm::ParameterSet &config)
Definition: RPCSimSimple.cc:20
mps_fire.i
i
Definition: mps_fire.py:355
TrapezoidalStripTopology::stripLength
float stripLength() const override
det heigth (strip length in the middle)
Definition: TrapezoidalStripTopology.h:63
RPCDetId::region
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
edm::DetSet::clear
void clear()
Definition: DetSet.h:71
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
RPCDetId
Definition: RPCDetId.h:16
RPCSynchronizer
Definition: RPCSynchronizer.h:36
RPCSynchronizer::getSimHitBx
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
Definition: RPCSynchronizer.cc:58
RPCRoll.h
DDAxes::x
RPCSim::strips
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:55
RPCSimSimple::~RPCSimSimple
~RPCSimSimple() override
Definition: RPCSimSimple.cc:28
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
config
Definition: config.py:1
RPCRoll::id
RPCDetId id() const
Definition: RPCRoll.cc:16
RectangularStripTopology
Definition: RectangularStripTopology.h:11
RPCSim::theDetectorHitMap
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:68
RPCSimSimple::simulate
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
Definition: RPCSimSimple.cc:30
ecaldqm::topology
const CaloTopology * topology(nullptr)
TrapezoidalStripTopology
Definition: TrapezoidalStripTopology.h:21
RPCSim::theRpcDigiSimLinks
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:70
RPCRollSpecs::topology
const Topology & topology() const override
Definition: RPCRollSpecs.cc:36
RPCSimSimple::nbxing
int nbxing
Definition: RPCSimSimple.h:33
Point3DBase< float, LocalTag >
RectangularStripTopology::stripLength
float stripLength() const override
Definition: RectangularStripTopology.h:44
RPCRollSpecs.h
edm::ParameterSet
Definition: ParameterSet.h:36
RPCSimSimple::_rpcSync
RPCSynchronizer * _rpcSync
Definition: RPCSimSimple.h:29
RPCRoll::nstrips
int nstrips() const
Definition: RPCRoll.cc:24
RPCSimSimple::N_hits
int N_hits
Definition: RPCSimSimple.h:32
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition: JetExtendedAssociation.h:30
RPCSim
Definition: RPCSim.h:30
RPCSimSimple.h
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
RPCRoll::specs
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:14
RPCSimSimple::rate
double rate
Definition: RPCSimSimple.h:34
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
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
RPCSim::RPCDigiSimLinks
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:33
RPCSimSimple::gate
double gate
Definition: RPCSimSimple.h:35
custom_jme_cff.area
area
Definition: custom_jme_cff.py:169
RPCSimSimple::simulateNoise
void simulateNoise(const RPCRoll *, CLHEP::HepRandomEngine *) override
Definition: RPCSimSimple.cc:50