CMS 3D CMS Logo

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