CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
RPCSimAverageNoiseEff Class Reference

#include <RPCSimAverageNoiseEff.h>

Inheritance diagram for RPCSimAverageNoiseEff:
RPCSim

Public Member Functions

int getClSize (float posX)
 
 RPCSimAverageNoiseEff (const edm::ParameterSet &config)
 
void setRandomEngine (CLHEP::HepRandomEngine &eng)
 
void simulate (const RPCRoll *roll, const edm::PSimHitContainer &rpcHits)
 
void simulateNoise (const RPCRoll *)
 
 ~RPCSimAverageNoiseEff ()
 
- Public Member Functions inherited from RPCSim
const DigiSimLinksdigiSimLinks () const
 
virtual void fillDigis (int rollDetId, RPCDigiCollection &digis)
 
RPCSimSetUpgetRPCSimSetUp ()
 
const RPCDigiSimLinksrpcDigiSimLinks () const
 
void setRPCSimSetUp (RPCSimSetUp *setup)
 
virtual ~RPCSim ()
 

Private Member Functions

void init ()
 

Private Attributes

RPCSynchronizer_rpcSync
 
double aveCls
 
double aveEff
 
std::map< int, std::vector
< double > > 
clsMap
 
double dtimCs
 
CLHEP::RandFlat * flatDistribution
 
CLHEP::RandFlat * flatDistribution2
 
double frate
 
double gate
 
std::ifstream * infile
 
double lbGate
 
int N_hits
 
int nbxing
 
CLHEP::RandPoissonQ * poissonDistribution_
 
double rate
 
double resEle
 
double resRPC
 
bool rpcdigiprint
 
double sspeed
 
std::vector< double > sum_clsize
 
double timOff
 

Additional Inherited Members

- Public Types inherited from RPCSim
typedef edm::DetSet
< StripDigiSimLink
DigiSimLinks
 
typedef edm::DetSet
< RPCDigiSimLink
RPCDigiSimLinks
 
- Protected Types inherited from RPCSim
typedef std::multimap
< std::pair< unsigned int, int >
, const PSimHit *, std::less
< std::pair< unsigned int, int > > > 
DetectorHitMap
 
- Protected Member Functions inherited from RPCSim
virtual void addLinks (unsigned int strip, int bx)
 
 RPCSim (const edm::ParameterSet &config)
 
- Protected Attributes inherited from RPCSim
std::set< std::pair< int, int > > strips
 
DetectorHitMap theDetectorHitMap
 
DigiSimLinks theDigiSimLinks
 
RPCDigiSimLinks theRpcDigiSimLinks
 
RPCSimSetUptheSimSetUp
 

Detailed Description

Definition at line 31 of file RPCSimAverageNoiseEff.h.

Constructor & Destructor Documentation

RPCSimAverageNoiseEff::RPCSimAverageNoiseEff ( const edm::ParameterSet config)

Definition at line 50 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, aveCls, aveEff, gather_cfg::cout, dtimCs, frate, gate, edm::ParameterSet::getParameter(), lbGate, nbxing, rate, resEle, resRPC, rpcdigiprint, sspeed, and timOff.

50  :
51  RPCSim(config)
52 {
53 
54  aveEff = config.getParameter<double>("averageEfficiency");
55  aveCls = config.getParameter<double>("averageClusterSize");
56  resRPC = config.getParameter<double>("timeResolution");
57  timOff = config.getParameter<double>("timingRPCOffset");
58  dtimCs = config.getParameter<double>("deltatimeAdjacentStrip");
59  resEle = config.getParameter<double>("timeJitter");
60  sspeed = config.getParameter<double>("signalPropagationSpeed");
61  lbGate = config.getParameter<double>("linkGateWidth");
62  rpcdigiprint = config.getParameter<bool>("printOutDigitizer");
63 
64  rate=config.getParameter<double>("Rate");
65  nbxing=config.getParameter<int>("Nbxing");
66  gate=config.getParameter<double>("Gate");
67  frate=config.getParameter<double>("Frate");
68 
69  if (rpcdigiprint) {
70  std::cout <<"Average Efficiency = "<<aveEff<<std::endl;
71  std::cout <<"Average Cluster Size = "<<aveCls<<" strips"<<std::endl;
72  std::cout <<"RPC Time Resolution = "<<resRPC<<" ns"<<std::endl;
73  std::cout <<"RPC Signal formation time = "<<timOff<<" ns"<<std::endl;
74  std::cout <<"RPC adjacent strip delay = "<<dtimCs<<" ns"<<std::endl;
75  std::cout <<"Electronic Jitter = "<<resEle<<" ns"<<std::endl;
76  std::cout <<"Signal propagation time = "<<sspeed<<" x c"<<std::endl;
77  std::cout <<"Link Board Gate Width = "<<lbGate<<" ns"<<std::endl;
78  }
79 
80  _rpcSync = new RPCSynchronizer(config);
81 
82 }
T getParameter(std::string const &) const
RPCSim(const edm::ParameterSet &config)
Definition: RPCSim.cc:5
RPCSynchronizer * _rpcSync
tuple cout
Definition: gather_cfg.py:121
RPCSimAverageNoiseEff::~RPCSimAverageNoiseEff ( )

Definition at line 91 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, flatDistribution, flatDistribution2, and poissonDistribution_.

92 {
93  //Deleting the distribution defined in the constructor
94  delete flatDistribution;
95  delete flatDistribution2;
96  delete poissonDistribution_;
97  delete _rpcSync;
98 }
CLHEP::RandFlat * flatDistribution
RPCSynchronizer * _rpcSync
CLHEP::RandFlat * flatDistribution2
CLHEP::RandPoissonQ * poissonDistribution_

Member Function Documentation

int RPCSimAverageNoiseEff::getClSize ( float  posX)

Definition at line 100 of file RPCSimAverageNoiseEff.cc.

References clsMap, flatDistribution, RPCSimSetUp::getClsMap(), RPCSim::getRPCSimSetUp(), min, and sum_clsize.

Referenced by simulate().

101 {
102 
103  std::map< int, std::vector<double> > clsMap = getRPCSimSetUp()->getClsMap();
104 
105  int cnt = 1;
106  int min = 1;
107  double func=0.0;
108  std::vector<double> sum_clsize;
109 
110  double rr_cl = flatDistribution->fire(1);
111  if(0.0 <= posX && posX < 0.2) {
112  func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
113  sum_clsize = clsMap[1];
114  }
115  if(0.2 <= posX && posX < 0.4) {
116  func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
117  sum_clsize = clsMap[2];
118  }
119  if(0.4 <= posX && posX < 0.6) {
120  func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
121  sum_clsize = clsMap[3];
122  }
123  if(0.6 <= posX && posX < 0.8) {
124  func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
125  sum_clsize = clsMap[4];
126  }
127  if(0.8 <= posX && posX < 1.0) {
128  func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
129  sum_clsize = clsMap[5];
130  }
131 
132  for(vector<double>::iterator iter = sum_clsize.begin();
133  iter != sum_clsize.end(); ++iter){
134  cnt++;
135  if(func > (*iter)){
136  min = cnt;
137  }
138  else if(func < (*iter)){
139  break;
140  }
141  }
142  return min;
143 }
std::vector< double > sum_clsize
CLHEP::RandFlat * flatDistribution
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:47
#define min(a, b)
Definition: mlp_lapack.h:161
const std::map< int, std::vector< double > > & getClsMap()
Definition: RPCSimSetUp.cc:195
std::map< int, std::vector< double > > clsMap
void RPCSimAverageNoiseEff::init ( void  )
inlineprivatevirtual

Implements RPCSim.

Definition at line 47 of file RPCSimAverageNoiseEff.h.

47 {};
void RPCSimAverageNoiseEff::setRandomEngine ( CLHEP::HepRandomEngine &  eng)
virtual

Implements RPCSim.

Definition at line 84 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, flatDistribution, flatDistribution2, poissonDistribution_, and RPCSynchronizer::setRandomEngine().

84  {
85  flatDistribution = new CLHEP::RandFlat(eng);
86  flatDistribution2 = new CLHEP::RandFlat(eng);
87  poissonDistribution_ = new CLHEP::RandPoissonQ(eng);
89 }
CLHEP::RandFlat * flatDistribution
void setRandomEngine(CLHEP::HepRandomEngine &eng)
RPCSynchronizer * _rpcSync
CLHEP::RandFlat * flatDistribution2
CLHEP::RandPoissonQ * poissonDistribution_
void RPCSimAverageNoiseEff::simulate ( const RPCRoll roll,
const edm::PSimHitContainer rpcHits 
)
virtual

Implements RPCSim.

Definition at line 146 of file RPCSimAverageNoiseEff.cc.

References _rpcSync, RPCRoll::centreOfStrip(), Topology::channel(), cl, edm::DetSet< T >::clear(), alignCSCRings::e, flatDistribution, getClSize(), RPCSim::getRPCSimSetUp(), RPCSynchronizer::getSimHitBx(), i, RPCRoll::id(), RPCGeomServ::name(), RPCRoll::nstrips(), DetId::rawId(), RPCSynchronizer::setRPCSimSetUp(), RPCRoll::specs(), RPCRoll::strip(), RPCSim::strips, RPCSim::theDetectorHitMap, RPCSim::theRpcDigiSimLinks, RPCRollSpecs::topology(), w(), and PV3DBase< T, PVType, FrameType >::x().

148 {
149 
152  theDetectorHitMap.clear();
154 
155  RPCDetId rpcId = roll->id();
156  RPCGeomServ RPCname(rpcId);
157  std::string nameRoll = RPCname.name();
158 
159  const Topology& topology=roll->specs()->topology();
160 
161  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
162  _hit != rpcHits.end(); ++_hit){
163 
164  if(_hit-> particleType() == 11) continue;
165 
166  // Here I hould check if the RPC are up side down;
167  const LocalPoint& entr=_hit->entryPoint();
168 
169  int time_hit = _rpcSync->getSimHitBx(&(*_hit));
170  float posX = roll->strip(_hit->localPosition()) - static_cast<int>(roll->strip(_hit->localPosition()));
171 
172  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
173 
174  // Effinciecy
175  int centralStrip = topology.channel(entr)+1;;
176  float fire = flatDistribution->fire(1);
177 
178  if (fire < veff[centralStrip-1]) {
179 
180  int fstrip=centralStrip;
181  int lstrip=centralStrip;
182 
183  // Compute the cluster size
184  double w = flatDistribution->fire(1);
185  if (w < 1.e-10) w=1.e-10;
186  int clsize = this->getClSize(posX);
187 
188  std::vector<int> cls;
189  cls.push_back(centralStrip);
190  if (clsize > 1){
191  for (int cl = 0; cl < (clsize-1)/2; cl++){
192  if (centralStrip - cl -1 >= 1 ){
193  fstrip = centralStrip-cl-1;
194  cls.push_back(fstrip);
195  }
196  if (centralStrip + cl + 1 <= roll->nstrips() ){
197  lstrip = centralStrip+cl+1;
198  cls.push_back(lstrip);
199  }
200  }
201  if (clsize%2 == 0 ){
202  // insert the last strip according to the
203  // simhit position in the central strip
204  double deltaw=roll->centreOfStrip(centralStrip).x()-entr.x();
205  if (deltaw<0.) {
206  if (lstrip < roll->nstrips() ){
207  lstrip++;
208  cls.push_back(lstrip);
209  }
210  }else{
211  if (fstrip > 1 ){
212  fstrip--;
213  cls.push_back(fstrip);
214  }
215  }
216  }
217  }
218 
219  for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
220  // Check the timing of the adjacent strip
221  if(*i != centralStrip){
222  if(flatDistribution->fire(1) < veff[*i-1]){
223  std::pair<int, int> digi(*i,time_hit);
224  strips.insert(digi);
225 
226  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
227  }
228  }
229  else {
230  std::pair<int, int> digi(*i,time_hit);
231  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
232 
233  strips.insert(digi);
234  }
235  }
236  }
237  }
238 }
float strip(const LocalPoint &lp) const
Definition: RPCRoll.cc:71
int i
Definition: DBlmapReader.cc:9
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
CLHEP::RandFlat * flatDistribution
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:68
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:46
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:47
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
virtual int channel(const LocalPoint &p) const =0
Container::value_type value_type
float cl
Definition: Combine.cc:71
int getSimHitBx(const PSimHit *)
RPCSynchronizer * _rpcSync
void clear()
Definition: DetSet.h:70
T x() const
Definition: PV3DBase.h:61
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:70
T w() const
const Topology & topology() const
Definition: RPCRollSpecs.cc:43
void RPCSimAverageNoiseEff::simulateNoise ( const RPCRoll roll)
virtual

Implements RPCSim.

Definition at line 240 of file RPCSimAverageNoiseEff.cc.

References compareJSON::const, flatDistribution2, frate, gate, RPCSim::getRPCSimSetUp(), i, RPCRoll::id(), j, RectangularStripTopology::localPosition(), TrapezoidalStripTopology::localPosition(), N_hits, RPCGeomServ::name(), nbxing, RPCRoll::nstrips(), poissonDistribution_, DetId::rawId(), RPCDetId::region(), RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), RPCSim::strips, RPCRoll::topology(), and vdt::x.

241 {
242 
243  RPCDetId rpcId = roll->id();
244 
245  RPCGeomServ RPCname(rpcId);
246  std::string nameRoll = RPCname.name();
247 
248  std::vector<float> vnoise = (getRPCSimSetUp())->getNoise(rpcId.rawId());
249  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
250 
251  unsigned int nstrips = roll->nstrips();
252  double area = 0.0;
253 
254  if ( rpcId.region() == 0 )
255  {
256  const RectangularStripTopology* top_ = dynamic_cast<const
257  RectangularStripTopology*>(&(roll->topology()));
258  float xmin = (top_->localPosition(0.)).x();
259  float xmax = (top_->localPosition((float)roll->nstrips())).x();
260  float striplength = (top_->stripLength());
261  area = striplength*(xmax-xmin);
262  }
263  else
264  {
265  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
266  float xmin = (top_->localPosition(0.)).x();
267  float xmax = (top_->localPosition((float)roll->nstrips())).x();
268  float striplength = (top_->stripLength());
269  area = striplength*(xmax-xmin);
270  }
271 
272  for(unsigned int j = 0; j < vnoise.size(); ++j){
273 
274  if(j >= nstrips) break;
275 
276  // The efficiency of 0% does not imply on the noise rate.
277  // If the strip is masked the noise rate should be 0 Hz/cm^2
278  // if(veff[j] == 0) continue;
279 
280 
281  // double ave = vnoise[j]*nbxing*gate*area*1.0e-9*frate;
282  // The vnoise is the noise rate per strip, so we shout multiply not
283  // by the chamber area,
284  // but the strip area which is area/((float)roll->nstrips()));
285  double ave =
286  vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips());
287 
288  N_hits = poissonDistribution_->fire(ave);
289 
290  for (int i = 0; i < N_hits; i++ ){
291 
292  int time_hit = (static_cast<int>(flatDistribution2->fire((nbxing*gate)/gate))) - nbxing/2;
293  std::pair<int, int> digi(j+1,time_hit);
294  strips.insert(digi);
295  }
296  }
297 }
int i
Definition: DBlmapReader.cc:9
const Topology & topology() const
Definition: RPCRoll.cc:30
virtual float stripLength() const
int nstrips() const
Definition: RPCRoll.cc:46
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:47
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:57
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
RPCDetId id() const
Definition: RPCRoll.cc:24
int j
Definition: DBlmapReader.cc:9
string const
Definition: compareJSON.py:14
virtual LocalPoint localPosition(float strip) const
CLHEP::RandFlat * flatDistribution2
CLHEP::RandPoissonQ * poissonDistribution_
virtual LocalPoint localPosition(float strip) const
x
Definition: VDTMath.h:216
virtual float stripLength() const
det heigth (strip length in the middle)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67

Member Data Documentation

RPCSynchronizer* RPCSimAverageNoiseEff::_rpcSync
private
double RPCSimAverageNoiseEff::aveCls
private

Definition at line 50 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::aveEff
private

Definition at line 47 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

std::map< int, std::vector<double> > RPCSimAverageNoiseEff::clsMap
private

Definition at line 65 of file RPCSimAverageNoiseEff.h.

Referenced by getClSize().

double RPCSimAverageNoiseEff::dtimCs
private

Definition at line 53 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

CLHEP::RandFlat* RPCSimAverageNoiseEff::flatDistribution
private
CLHEP::RandFlat* RPCSimAverageNoiseEff::flatDistribution2
private

Definition at line 76 of file RPCSimAverageNoiseEff.h.

Referenced by setRandomEngine(), simulateNoise(), and ~RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::frate
private

Definition at line 63 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

double RPCSimAverageNoiseEff::gate
private

Definition at line 62 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

std::ifstream* RPCSimAverageNoiseEff::infile
private

Definition at line 67 of file RPCSimAverageNoiseEff.h.

double RPCSimAverageNoiseEff::lbGate
private

Definition at line 56 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

int RPCSimAverageNoiseEff::N_hits
private

Definition at line 59 of file RPCSimAverageNoiseEff.h.

Referenced by simulateNoise().

int RPCSimAverageNoiseEff::nbxing
private

Definition at line 60 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff(), and simulateNoise().

CLHEP::RandPoissonQ* RPCSimAverageNoiseEff::poissonDistribution_
private

Definition at line 77 of file RPCSimAverageNoiseEff.h.

Referenced by setRandomEngine(), simulateNoise(), and ~RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::rate
private

Definition at line 61 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::resEle
private

Definition at line 54 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::resRPC
private

Definition at line 51 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

bool RPCSimAverageNoiseEff::rpcdigiprint
private

Definition at line 57 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

double RPCSimAverageNoiseEff::sspeed
private

Definition at line 55 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().

std::vector<double> RPCSimAverageNoiseEff::sum_clsize
private

Definition at line 66 of file RPCSimAverageNoiseEff.h.

Referenced by getClSize().

double RPCSimAverageNoiseEff::timOff
private

Definition at line 52 of file RPCSimAverageNoiseEff.h.

Referenced by RPCSimAverageNoiseEff().