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
RPCSimAsymmetricCls Class Reference

#include <RPCSimAsymmetricCls.h>

Inheritance diagram for RPCSimAsymmetricCls:
RPCSim

Public Member Functions

int getClSize (float posX, CLHEP::HepRandomEngine *)
 
int getClSize (uint32_t id, float posX, CLHEP::HepRandomEngine *)
 
 RPCSimAsymmetricCls (const edm::ParameterSet &config)
 
void simulate (const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
 
void simulateNoise (const RPCRoll *, CLHEP::HepRandomEngine *) override
 
unsigned int slice (float posX)
 
 ~RPCSimAsymmetricCls ()
 
- 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::vector< double > clsForDetId
 
std::map< int, std::vector
< double > > 
clsMap
 
double dtimCs
 
double frate
 
double gate
 
std::ifstream * infile
 
double lbGate
 
int N_hits
 
int nbxing
 
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 29 of file RPCSimAsymmetricCls.h.

Constructor & Destructor Documentation

RPCSimAsymmetricCls::RPCSimAsymmetricCls ( const edm::ParameterSet config)

Definition at line 41 of file RPCSimAsymmetricCls.cc.

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

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

Definition at line 75 of file RPCSimAsymmetricCls.cc.

References _rpcSync.

76 {
77  delete _rpcSync;
78 }
RPCSynchronizer * _rpcSync

Member Function Documentation

int RPCSimAsymmetricCls::getClSize ( float  posX,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 100 of file RPCSimAsymmetricCls.cc.

References clsMap, RPCSimSetUp::getClsMap(), RPCSim::getRPCSimSetUp(), getDQMSummary::iter, bookConverter::min, and sum_clsize.

Referenced by simulate().

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

Definition at line 80 of file RPCSimAsymmetricCls.cc.

References clsForDetId, RPCSimSetUp::getAsymmetricClsDistribution(), RPCSim::getRPCSimSetUp(), i, bookConverter::min, and slice().

81 {
82  std::vector<double> clsForDetId = getRPCSimSetUp()->getAsymmetricClsDistribution(id,slice(posX));
83 
84  int cnt = 1;
85  int min = 1;
86 
87  double rr_cl = CLHEP::RandFlat::shoot(engine);
88  for(unsigned int i = 0 ; i < clsForDetId.size(); i++){
89  cnt++;
90  if(rr_cl > clsForDetId[i]){
91  min = cnt;
92  }
93  else if(rr_cl < clsForDetId[i]){
94  break;
95  }
96  }
97  return min;
98 }
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & getAsymmetricClsDistribution(uint32_t id, uint32_t slice)
Definition: RPCSimSetUp.cc:231
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
std::vector< double > clsForDetId
unsigned int slice(float posX)
void RPCSimAsymmetricCls::init ( void  )
inlineprivatevirtual

Implements RPCSim.

Definition at line 47 of file RPCSimAsymmetricCls.h.

47 {};
void RPCSimAsymmetricCls::simulate ( const RPCRoll roll,
const edm::PSimHitContainer rpcHits,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Implements RPCSim.

Definition at line 145 of file RPCSimAsymmetricCls.cc.

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

148 {
151  theDetectorHitMap.clear();
153 
154  RPCDetId rpcId = roll->id();
155  RPCGeomServ RPCname(rpcId);
156  std::string nameRoll = RPCname.name();
157 
158  const Topology& topology=roll->specs()->topology();
159  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
160  _hit != rpcHits.end(); ++_hit){
161  if(_hit-> particleType() == 11) continue;
162  // Here I hould check if the RPC are up side down;
163  const LocalPoint& entr=_hit->entryPoint();
164 
165  int time_hit = _rpcSync->getSimHitBx(&(*_hit),engine);
166  float posX = roll->strip(_hit->localPosition())
167  - static_cast<int>(roll->strip(_hit->localPosition()));
168 
169  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
170 
171  // Effinciecy
172  int centralStrip = topology.channel(entr)+1;
173  float fire = CLHEP::RandFlat::shoot(engine);
174 
175  if (fire < veff[centralStrip-1]) {
176 
177  int fstrip=centralStrip;
178  int lstrip=centralStrip;
179 
180  // Compute the cluster size
181  double w = CLHEP::RandFlat::shoot(engine);
182  if (w < 1.e-10) w=1.e-10;
183 
184  int clsize = this->getClSize(rpcId.rawId(),posX, engine); // This is for cluster size chamber by chamber
185 
186  std::vector<int> cls;
187 
188  std::vector<double> TMPclsAsymmForDetId
189  = getRPCSimSetUp()->getAsymmetryForCls(rpcId,slice(posX),clsize);
190 
191  cls.push_back(centralStrip);
192  if (clsize > 1){
193  for (int cl = 0; cl < (clsize-1)/2; cl++){
194  if (centralStrip - cl -1 >= 1 ){
195  fstrip = centralStrip-cl-1;
196  cls.push_back(fstrip);
197  }
198  if (centralStrip + cl + 1 <= roll->nstrips() ){
199  lstrip = centralStrip+cl+1;
200  cls.push_back(lstrip);
201  }
202  }
203  if (clsize%2 == 0 ){
204  // insert the last strip according to the
205  // simhit position in the central strip
206  double deltaw=roll->centreOfStrip(centralStrip).x()-entr.x();
207  if (deltaw<0.) {
208  if (lstrip < roll->nstrips() ){
209  lstrip++;
210  cls.push_back(lstrip);
211  }
212  }else{
213  if (fstrip > 1 ){
214  fstrip--;
215  cls.push_back(fstrip);
216  }
217  }
218  }
219 
220  }
221 
222  //Now calculate the shift according to the distribution
223  float fire1 = CLHEP::RandFlat::shoot(engine);
224  int strip_shift=0;
225 
226  int offset;
227 
228  if(clsize%2==0){
229  offset = 2;
230  }
231  else {
232  offset = 1;
233  }
234 
235  for(unsigned int i = 0; i < TMPclsAsymmForDetId.size(); i ++){
236  if(fire1 < TMPclsAsymmForDetId[i]){
237  strip_shift = i - offset;
238  break;
239  }
240  }
241 
242  vector<int> shifted_cls;
243  shifted_cls.clear();
244 
245  int min_strip=100;
246  int max_strip=0;
247 
248  //correction for the edges
249  for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
250  if(*i+strip_shift < min_strip){
251  min_strip = *i+strip_shift;
252  }
253  if(*i+strip_shift > max_strip){
254  max_strip = *i+strip_shift;
255  }
256  }
257 
258  if(min_strip<1 || max_strip-roll->nstrips()>0){
259  strip_shift = 0;
260  }
261  // if(min_strip<1){
262  // strip_shift = 0;
263  // }
264  // if(max_strip-roll->nstrips()>0){
265  // if(max_strip-roll->nstrips()==1){
266  // strip_shift--;
267  // }
268  // else{
269  // strip_shift = 0;
270  // }
271  // }
272 
273  //Now shift the cluster
274  for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
275  shifted_cls.push_back(*i+strip_shift);
276  }
277  for (std::vector<int>::iterator i=shifted_cls.begin(); i!=shifted_cls.end();i++){
278  // Check the timing of the adjacent strip
279  if(*i != centralStrip){
280  if(CLHEP::RandFlat::shoot(engine) < veff[*i-1]){
281  std::pair<int, int> digi(*i,time_hit);
282  strips.insert(digi);
283 
284  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
285  }
286  }
287  else {
288  std::pair<int, int> digi(*i,time_hit);
289  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
290 
291  strips.insert(digi);
292  }
293  }
294  }
295  }
296 }
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
CaloTopology const * topology(0)
DetectorHitMap theDetectorHitMap
Definition: RPCSim.h:71
void setRPCSimSetUp(RPCSimSetUp *simsetup)
int nstrips() const
Definition: RPCRoll.cc:46
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
const RPCRollSpecs * specs() const
Definition: RPCRoll.cc:18
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::DetSet< RPCDigiSimLink > RPCDigiSimLinks
Definition: RPCSim.h:35
RPCDetId id() const
Definition: RPCRoll.cc:24
virtual int channel(const LocalPoint &p) const =0
unsigned int offset(bool)
Container::value_type value_type
const std::vector< double > & getAsymmetryForCls(uint32_t id, uint32_t slice, uint32_t cls)
Definition: RPCSimSetUp.cc:295
int getClSize(float posX, CLHEP::HepRandomEngine *)
RPCSynchronizer * _rpcSync
void clear()
Definition: DetSet.h:69
T w() const
T x() const
Definition: PV3DBase.h:62
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:73
unsigned int slice(float posX)
const Topology & topology() const
Definition: RPCRollSpecs.cc:43
void RPCSimAsymmetricCls::simulateNoise ( const RPCRoll roll,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Implements RPCSim.

Definition at line 298 of file RPCSimAsymmetricCls.cc.

References compareJSON::const, frate, gate, RPCSim::getRPCSimSetUp(), i, RPCRoll::id(), j, N_hits, RPCGeomServ::name(), nbxing, RPCRoll::nstrips(), DetId::rawId(), RPCDetId::region(), AlCaHLTBitMon_QueryRunRegistry::string, RPCSim::strips, RPCRoll::topology(), x, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::xmin.

300 {
301 
302  RPCDetId rpcId = roll->id();
303 
304  RPCGeomServ RPCname(rpcId);
305  std::string nameRoll = RPCname.name();
306 
307  std::vector<float> vnoise = (getRPCSimSetUp())->getNoise(rpcId.rawId());
308  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
309 
310  unsigned int nstrips = roll->nstrips();
311  double area = 0.0;
312 
313  if ( rpcId.region() == 0 )
314  {
315  const RectangularStripTopology* top_ = dynamic_cast<const
316  RectangularStripTopology*>(&(roll->topology()));
317  float xmin = (top_->localPosition(0.)).x();
318  float xmax = (top_->localPosition((float)roll->nstrips())).x();
319  float striplength = (top_->stripLength());
320  area = striplength*(xmax-xmin);
321  }
322  else
323  {
324  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
325  float xmin = (top_->localPosition(0.)).x();
326  float xmax = (top_->localPosition((float)roll->nstrips())).x();
327  float striplength = (top_->stripLength());
328  area = striplength*(xmax-xmin);
329  }
330 
331  for(unsigned int j = 0; j < vnoise.size(); ++j){
332 
333  if(j >= nstrips) break;
334 
335  // The efficiency of 0% does not imply on the noise rate.
336  // If the strip is masked the noise rate should be 0 Hz/cm^2
337  // if(veff[j] == 0) continue;
338 
339  // double ave = vnoise[j]*nbxing*gate*area*1.0e-9*frate;
340  // The vnoise is the noise rate per strip, so we shout multiply not
341  // by the chamber area,
342  // but the strip area which is area/((float)roll->nstrips()));
343  double ave =
344  vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips());
345 
346  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
347  N_hits = randPoissonQ.fire();
348 
349  for (int i = 0; i < N_hits; i++ ){
350  int time_hit = (static_cast<int>(CLHEP::RandFlat::shoot((nbxing*gate)/gate))) - nbxing/2;
351  std::pair<int, int> digi(j+1,time_hit);
352  strips.insert(digi);
353  }
354  }
355 }
int i
Definition: DBlmapReader.cc:9
const Topology & topology() const
Definition: RPCRoll.cc:30
int nstrips() const
Definition: RPCRoll.cc:46
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
std::set< std::pair< int, int > > strips
Definition: RPCSim.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
RPCDetId id() const
Definition: RPCRoll.cc:24
int j
Definition: DBlmapReader.cc:9
string const
Definition: compareJSON.py:14
Definition: DDAxes.h:10
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:63
unsigned int RPCSimAsymmetricCls::slice ( float  posX)

Definition at line 357 of file RPCSimAsymmetricCls.cc.

Referenced by getClSize(), and simulate().

357  {
358 
359  if(0.0 <= posX && posX < 0.2) {
360  return 0;
361  }
362  else if(0.2 <= posX && posX < 0.4) {
363  return 1;
364  }
365  else if(0.4 <= posX && posX < 0.6) {
366  return 2;
367  }
368  else if(0.6 <= posX && posX < 0.8) {
369  return 3;
370  }
371  else if(0.8 <= posX && posX < 1.0) {
372  return 4;
373  }
374  else return 2;
375 }

Member Data Documentation

RPCSynchronizer* RPCSimAsymmetricCls::_rpcSync
private

Definition at line 70 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls(), simulate(), and ~RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::aveCls
private

Definition at line 50 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::aveEff
private

Definition at line 47 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

std::vector<double> RPCSimAsymmetricCls::clsForDetId
private

Definition at line 67 of file RPCSimAsymmetricCls.h.

Referenced by getClSize().

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

Definition at line 65 of file RPCSimAsymmetricCls.h.

Referenced by getClSize().

double RPCSimAsymmetricCls::dtimCs
private

Definition at line 53 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::frate
private

Definition at line 63 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls(), and simulateNoise().

double RPCSimAsymmetricCls::gate
private

Definition at line 62 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls(), and simulateNoise().

std::ifstream* RPCSimAsymmetricCls::infile
private

Definition at line 68 of file RPCSimAsymmetricCls.h.

double RPCSimAsymmetricCls::lbGate
private

Definition at line 56 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

int RPCSimAsymmetricCls::N_hits
private

Definition at line 59 of file RPCSimAsymmetricCls.h.

Referenced by simulateNoise().

int RPCSimAsymmetricCls::nbxing
private

Definition at line 60 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls(), and simulateNoise().

double RPCSimAsymmetricCls::rate
private

Definition at line 61 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::resEle
private

Definition at line 54 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::resRPC
private

Definition at line 51 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

bool RPCSimAsymmetricCls::rpcdigiprint
private

Definition at line 57 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

double RPCSimAsymmetricCls::sspeed
private

Definition at line 55 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().

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

Definition at line 66 of file RPCSimAsymmetricCls.h.

Referenced by getClSize().

double RPCSimAsymmetricCls::timOff
private

Definition at line 52 of file RPCSimAsymmetricCls.h.

Referenced by RPCSimAsymmetricCls().