CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCSimSimple.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 
19 
20 #include<cstring>
21 #include<iostream>
22 #include<string>
23 #include<vector>
24 #include<stdlib.h>
25 #include <utility>
26 #include <map>
27 
29 
30  rate=config.getParameter<double>("Rate");
31  nbxing=config.getParameter<int>("Nbxing");
32  gate=config.getParameter<double>("Gate");
33 
34  _rpcSync = new RPCSynchronizer(config);
35 }
36 
37 void RPCSimSimple::setRandomEngine(CLHEP::HepRandomEngine& eng){
38  flatDistribution1 = new CLHEP::RandFlat(eng);
39  flatDistribution2 = new CLHEP::RandFlat(eng);
40  poissonDistribution = new CLHEP::RandPoissonQ(eng);
42 }
43 
44 
46  delete flatDistribution1;
47  delete flatDistribution2;
48  delete poissonDistribution;
49  delete _rpcSync;
50 }
51 
52 
53 void
55  const edm::PSimHitContainer& rpcHits)
56 {
59  theDetectorHitMap.clear();
61 
62  const Topology& topology=roll->specs()->topology();
63  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
64  _hit != rpcHits.end(); ++_hit){
65 
66 
67  // Here I hould check if the RPC are up side down;
68  const LocalPoint& entr=_hit->entryPoint();
69  int time_hit = _rpcSync->getSimHitBx(&(*_hit));
70  // const LocalPoint& exit=_hit->exitPoint();
71 
72  std::pair<int, int> digi(topology.channel(entr)+1,
73  time_hit);
74 
75  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
76  strips.insert(digi);
77  }
78 }
79 
80 
82 {
83 
84  RPCDetId rpcId = roll->id();
85  int nstrips = roll->nstrips();
86  double area = 0.0;
87 
88  if ( rpcId.region() == 0 )
89  {
90  const RectangularStripTopology* top_ = dynamic_cast<const
91  RectangularStripTopology*>(&(roll->topology()));
92  float xmin = (top_->localPosition(0.)).x();
93  float xmax = (top_->localPosition((float)roll->nstrips())).x();
94  float striplength = (top_->stripLength());
95  area = striplength*(xmax-xmin);
96  }
97  else
98  {
99  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
100  float xmin = (top_->localPosition(0.)).x();
101  float xmax = (top_->localPosition((float)roll->nstrips())).x();
102  float striplength = (top_->stripLength());
103  area = striplength*(xmax-xmin);
104  }
105 
106  double ave = rate*nbxing*gate*area*1.0e-9;
107 
108  N_hits = poissonDistribution->fire(ave);
109 
110  for (int i = 0; i < N_hits; i++ ){
111  int strip = static_cast<int>(flatDistribution1->fire(1, nstrips));
112  int time_hit;
113  time_hit = (static_cast<int>(flatDistribution2->fire((nbxing*gate)/gate))) - nbxing/2;
114  std::pair<int, int> digi(strip,time_hit);
115  strips.insert(digi);
116  }
117 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
CLHEP::RandFlat * flatDistribution2
Definition: RPCSimSimple.h:44
const Topology & topology() const
Definition: RPCRoll.cc:30
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
void setRandomEngine(CLHEP::HepRandomEngine &eng)
Definition: RPCSimSimple.cc:37
RPCSynchronizer * _rpcSync
Definition: RPCSimSimple.h:35
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:68
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:46
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:47
void simulateNoise(const RPCRoll *)
Definition: RPCSimSimple.cc:81
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:18
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
CLHEP::RandPoissonQ * poissonDistribution
Definition: RPCSimSimple.h:45
RPCSimSimple(const edm::ParameterSet &config)
Definition: RPCSimSimple.cc:28
Definition: RPCSim.h:27
Container::value_type value_type
int getSimHitBx(const PSimHit *)
void setRandomEngine(CLHEP::HepRandomEngine &eng)
string const
Definition: compareJSON.py:14
void simulate(const RPCRoll *roll, const edm::PSimHitContainer &rpcHits)
Definition: RPCSimSimple.cc:54
void clear()
Definition: DetSet.h:70
std::vector< PSimHit > PSimHitContainer
Definition: DDAxes.h:10
CLHEP::RandFlat * flatDistribution1
Definition: RPCSimSimple.h:43
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:70
const Topology & topology() const
Definition: RPCRollSpecs.cc:43
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67