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

#include <RPCSimAverageNoiseEffCls.h>

Inheritance diagram for RPCSimAverageNoiseEffCls:
RPCSim

Public Member Functions

int getClSize (float posX, CLHEP::HepRandomEngine *)
 
int getClSize (uint32_t id, float posX, CLHEP::HepRandomEngine *)
 
 RPCSimAverageNoiseEffCls (const edm::ParameterSet &config)
 
void simulate (const RPCRoll *roll, const edm::PSimHitContainer &rpcHits, CLHEP::HepRandomEngine *) override
 
void simulateNoise (const RPCRoll *, CLHEP::HepRandomEngine *) override
 
 ~RPCSimAverageNoiseEffCls ()
 
- 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 RPCSimAverageNoiseEffCls.h.

Constructor & Destructor Documentation

RPCSimAverageNoiseEffCls::RPCSimAverageNoiseEffCls ( const edm::ParameterSet config)

Definition at line 41 of file RPCSimAverageNoiseEffCls.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
tuple cout
Definition: gather_cfg.py:121
RPCSimAverageNoiseEffCls::~RPCSimAverageNoiseEffCls ( )

Definition at line 75 of file RPCSimAverageNoiseEffCls.cc.

References _rpcSync.

76 {
77  delete _rpcSync;
78 }

Member Function Documentation

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

Definition at line 130 of file RPCSimAverageNoiseEffCls.cc.

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

Referenced by simulate().

131 {
132 
133  std::map< int, std::vector<double> > clsMap = getRPCSimSetUp()->getClsMap();
134 
135  int cnt = 1;
136  int min = 1;
137  double func=0.0;
138  std::vector<double> sum_clsize;
139 
140  double rr_cl = CLHEP::RandFlat::shoot(engine);
141  if(0.0 <= posX && posX < 0.2) {
142  func = (clsMap[1])[(clsMap[1]).size()-1]*(rr_cl);
143  sum_clsize = clsMap[1];
144  }
145  if(0.2 <= posX && posX < 0.4) {
146  func = (clsMap[2])[(clsMap[2]).size()-1]*(rr_cl);
147  sum_clsize = clsMap[2];
148  }
149  if(0.4 <= posX && posX < 0.6) {
150  func = (clsMap[3])[(clsMap[3]).size()-1]*(rr_cl);
151  sum_clsize = clsMap[3];
152  }
153  if(0.6 <= posX && posX < 0.8) {
154  func = (clsMap[4])[(clsMap[4]).size()-1]*(rr_cl);
155  sum_clsize = clsMap[4];
156  }
157  if(0.8 <= posX && posX < 1.0) {
158  func = (clsMap[5])[(clsMap[5]).size()-1]*(rr_cl);
159  sum_clsize = clsMap[5];
160  }
161 
162  for(vector<double>::iterator iter = sum_clsize.begin();
163  iter != sum_clsize.end(); ++iter){
164  cnt++;
165  if(func > (*iter)){
166  min = cnt;
167  }
168  else if(func < (*iter)){
169  break;
170  }
171  }
172  return min;
173 }
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
std::vector< double > sum_clsize
const std::map< int, std::vector< double > > & getClsMap()
Definition: RPCSimSetUp.cc:397
T min(T a, T b)
Definition: MathUtil.h:58
std::map< int, std::vector< double > > clsMap
int RPCSimAverageNoiseEffCls::getClSize ( uint32_t  id,
float  posX,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 81 of file RPCSimAverageNoiseEffCls.cc.

References clsForDetId, RPCSimSetUp::getCls(), RPCSim::getRPCSimSetUp(), i, min(), and sum_clsize.

82 {
83  std::vector<double> clsForDetId = getRPCSimSetUp()->getCls(id);
84 
85  int cnt = 1;
86  int min = 1;
87  double func=0.0;
88  std::vector<double> sum_clsize;
89 
90  sum_clsize.clear();
91  sum_clsize = clsForDetId;
92  int vectOffset(0);
93 
94  double rr_cl = CLHEP::RandFlat::shoot(engine);
95 
96  if(0.0 <= posX && posX < 0.2) {
97  func = clsForDetId[19]*(rr_cl);
98  vectOffset = 0;
99  }
100  if(0.2 <= posX && posX < 0.4) {
101  func = clsForDetId[39]*(rr_cl);
102  vectOffset = 20;
103  }
104  if(0.4 <= posX && posX < 0.6) {
105  func = clsForDetId[59]*(rr_cl);
106  vectOffset = 40;
107  }
108  if(0.6 <= posX && posX < 0.8) {
109  func = clsForDetId[79]*(rr_cl);
110  vectOffset = 60;
111  }
112  if(0.8 <= posX && posX < 1.0) {
113  func = clsForDetId[89]*(rr_cl);
114  vectOffset = 80;
115  }
116 
117 
118  for(int i = vectOffset; i<(vectOffset+20); i++){
119  cnt++;
120  if(func > clsForDetId[i]){
121  min = cnt;
122  }
123  else if(func < clsForDetId[i]){
124  break;
125  }
126  }
127  return min;
128 }
int i
Definition: DBlmapReader.cc:9
RPCSimSetUp * getRPCSimSetUp()
Definition: RPCSim.h:50
std::vector< double > clsForDetId
std::vector< double > sum_clsize
const std::vector< double > & getCls(uint32_t id)
Definition: RPCSimSetUp.cc:408
T min(T a, T b)
Definition: MathUtil.h:58
void RPCSimAverageNoiseEffCls::init ( void  )
inlineprivatevirtual

Implements RPCSim.

Definition at line 46 of file RPCSimAverageNoiseEffCls.h.

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

Implements RPCSim.

Definition at line 176 of file RPCSimAverageNoiseEffCls.cc.

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

179 {
180 
183  theDetectorHitMap.clear();
185 
186  RPCDetId rpcId = roll->id();
187  RPCGeomServ RPCname(rpcId);
188  //std::string nameRoll = RPCname.name();
189 
190  const Topology& topology=roll->specs()->topology();
191 
192  for (edm::PSimHitContainer::const_iterator _hit = rpcHits.begin();
193  _hit != rpcHits.end(); ++_hit){
194 
195  if(_hit-> particleType() == 11) continue;
196 
197  // Here I hould check if the RPC are up side down;
198  const LocalPoint& entr=_hit->entryPoint();
199 
200  int time_hit = _rpcSync->getSimHitBx(&(*_hit), engine);
201  float posX = roll->strip(_hit->localPosition()) - static_cast<int>(roll->strip(_hit->localPosition()));
202 
203  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
204 
205  // Effinciecy
206  int centralStrip = topology.channel(entr)+1;;
207  float fire = CLHEP::RandFlat::shoot(engine);
208 
209  if (fire < veff[centralStrip-1]) {
210 
211  int fstrip=centralStrip;
212  int lstrip=centralStrip;
213 
214  // Compute the cluster size
215  double w = CLHEP::RandFlat::shoot(engine);
216  if (w < 1.e-10) w=1.e-10;
217 // int clsize = this->getClSize(posX, engine); // This is for one and the same cls for all the chambers
218  int clsize = this->getClSize(rpcId.rawId(),posX, engine); // This is for cluster size chamber by chamber
219  std::vector<int> cls;
220  cls.push_back(centralStrip);
221  if (clsize > 1){
222  for (int cl = 0; cl < (clsize-1)/2; cl++){
223  if (centralStrip - cl -1 >= 1 ){
224  fstrip = centralStrip-cl-1;
225  cls.push_back(fstrip);
226  }
227  if (centralStrip + cl + 1 <= roll->nstrips() ){
228  lstrip = centralStrip+cl+1;
229  cls.push_back(lstrip);
230  }
231  }
232  if (clsize%2 == 0 ){
233  // insert the last strip according to the
234  // simhit position in the central strip
235  double deltaw=roll->centreOfStrip(centralStrip).x()-entr.x();
236  if (deltaw<0.) {
237  if (lstrip < roll->nstrips() ){
238  lstrip++;
239  cls.push_back(lstrip);
240  }
241  }else{
242  if (fstrip > 1 ){
243  fstrip--;
244  cls.push_back(fstrip);
245  }
246  }
247  }
248  }
249 
250  for (std::vector<int>::iterator i=cls.begin(); i!=cls.end();i++){
251  // Check the timing of the adjacent strip
252  if(*i != centralStrip){
253  if(CLHEP::RandFlat::shoot(engine) < veff[*i-1]){
254  std::pair<int, int> digi(*i,time_hit);
255  strips.insert(digi);
256 
257  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
258  }
259  }
260  else {
261  std::pair<int, int> digi(*i,time_hit);
262  theDetectorHitMap.insert(DetectorHitMap::value_type(digi,&(*_hit)));
263 
264  strips.insert(digi);
265  }
266  }
267  }
268  }
269 }
float strip(const LocalPoint &lp) const
Definition: RPCRoll.cc:71
int getClSize(float posX, CLHEP::HepRandomEngine *)
int i
Definition: DBlmapReader.cc:9
LocalPoint centreOfStrip(int strip) const
Definition: RPCRoll.cc:52
const double w
Definition: UKUtility.cc:23
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
Container::value_type value_type
void clear()
Definition: DetSet.h:69
T x() const
Definition: PV3DBase.h:62
RPCDigiSimLinks theRpcDigiSimLinks
Definition: RPCSim.h:73
const Topology & topology() const
Definition: RPCRollSpecs.cc:43
void RPCSimAverageNoiseEffCls::simulateNoise ( const RPCRoll roll,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Implements RPCSim.

Definition at line 271 of file RPCSimAverageNoiseEffCls.cc.

References compareJSON::const, frate, gate, RPCSim::getRPCSimSetUp(), i, RPCRoll::id(), j, RectangularStripTopology::localPosition(), TrapezoidalStripTopology::localPosition(), N_hits, nbxing, RPCRoll::nstrips(), DetId::rawId(), RPCDetId::region(), RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), RPCSim::strips, RPCRoll::topology(), x, SiStripMonitorClusterAlca_cfi::xmax, and SiStripMonitorClusterAlca_cfi::xmin.

273 {
274 
275  RPCDetId rpcId = roll->id();
276 
277  RPCGeomServ RPCname(rpcId);
278  //std::string nameRoll = RPCname.name();
279 
280  std::vector<float> vnoise = (getRPCSimSetUp())->getNoise(rpcId.rawId());
281  std::vector<float> veff = (getRPCSimSetUp())->getEff(rpcId.rawId());
282 
283  unsigned int nstrips = roll->nstrips();
284  double area = 0.0;
285 
286  if ( rpcId.region() == 0 )
287  {
288  const RectangularStripTopology* top_ = dynamic_cast<const
289  RectangularStripTopology*>(&(roll->topology()));
290  float xmin = (top_->localPosition(0.)).x();
291  float xmax = (top_->localPosition((float)roll->nstrips())).x();
292  float striplength = (top_->stripLength());
293  area = striplength*(xmax-xmin);
294  }
295  else
296  {
297  const TrapezoidalStripTopology* top_=dynamic_cast<const TrapezoidalStripTopology*>(&(roll->topology()));
298  float xmin = (top_->localPosition(0.)).x();
299  float xmax = (top_->localPosition((float)roll->nstrips())).x();
300  float striplength = (top_->stripLength());
301  area = striplength*(xmax-xmin);
302  }
303 
304  for(unsigned int j = 0; j < vnoise.size(); ++j){
305 
306  if(j >= nstrips) break;
307 
308  // The efficiency of 0% does not imply on the noise rate.
309  // If the strip is masked the noise rate should be 0 Hz/cm^2
310  // if(veff[j] == 0) continue;
311 
312  // double ave = vnoise[j]*nbxing*gate*area*1.0e-9*frate;
313  // The vnoise is the noise rate per strip, so we shout multiply not
314  // by the chamber area,
315  // but the strip area which is area/((float)roll->nstrips()));
316  double ave =
317  vnoise[j]*nbxing*gate*area*1.0e-9*frate/((float)roll->nstrips());
318 
319  CLHEP::RandPoissonQ randPoissonQ(*engine, ave);
320  N_hits = randPoissonQ.fire();
321 
322  for (int i = 0; i < N_hits; i++ ){
323 
324  int time_hit = (static_cast<int>(CLHEP::RandFlat::shoot(engine, (nbxing*gate)/gate))) - nbxing/2;
325  std::pair<int, int> digi(j+1,time_hit);
326  strips.insert(digi);
327  }
328  }
329 }
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: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
virtual LocalPoint localPosition(float strip) const
virtual LocalPoint localPosition(float strip) const
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:63

Member Data Documentation

RPCSynchronizer* RPCSimAverageNoiseEffCls::_rpcSync
private
double RPCSimAverageNoiseEffCls::aveCls
private

Definition at line 49 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

double RPCSimAverageNoiseEffCls::aveEff
private

Definition at line 46 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

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

Definition at line 66 of file RPCSimAverageNoiseEffCls.h.

Referenced by getClSize().

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

Definition at line 64 of file RPCSimAverageNoiseEffCls.h.

Referenced by getClSize().

double RPCSimAverageNoiseEffCls::dtimCs
private

Definition at line 52 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

double RPCSimAverageNoiseEffCls::frate
private

Definition at line 62 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls(), and simulateNoise().

double RPCSimAverageNoiseEffCls::gate
private

Definition at line 61 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls(), and simulateNoise().

std::ifstream* RPCSimAverageNoiseEffCls::infile
private

Definition at line 67 of file RPCSimAverageNoiseEffCls.h.

double RPCSimAverageNoiseEffCls::lbGate
private

Definition at line 55 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

int RPCSimAverageNoiseEffCls::N_hits
private

Definition at line 58 of file RPCSimAverageNoiseEffCls.h.

Referenced by simulateNoise().

int RPCSimAverageNoiseEffCls::nbxing
private

Definition at line 59 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls(), and simulateNoise().

double RPCSimAverageNoiseEffCls::rate
private

Definition at line 60 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

double RPCSimAverageNoiseEffCls::resEle
private

Definition at line 53 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

double RPCSimAverageNoiseEffCls::resRPC
private

Definition at line 50 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

bool RPCSimAverageNoiseEffCls::rpcdigiprint
private

Definition at line 56 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

double RPCSimAverageNoiseEffCls::sspeed
private

Definition at line 54 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().

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

Definition at line 65 of file RPCSimAverageNoiseEffCls.h.

Referenced by getClSize().

double RPCSimAverageNoiseEffCls::timOff
private

Definition at line 51 of file RPCSimAverageNoiseEffCls.h.

Referenced by RPCSimAverageNoiseEffCls().