CMS 3D CMS Logo

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

#include <RPCSynchronizer.h>

Public Member Functions

double getExactTime () const
 
RPCSimSetUpgetRPCSimSetUp ()
 
int getSimHitBx (const PSimHit *, CLHEP::HepRandomEngine *)
 
int getSimHitBxAndTimingForIRPC (const PSimHit *, CLHEP::HepRandomEngine *)
 
double getSmearedTime () const
 
 RPCSynchronizer (const edm::ParameterSet &config)
 
void setRPCSimSetUp (RPCSimSetUp *simsetup)
 
 ~RPCSynchronizer ()
 

Private Attributes

double cosmicPar
 
bool cosmics
 
double cspeed
 
double dtimCs
 
double irpc_electronics_jitter
 
double irpc_timing_res
 
double lbGate
 
double lbGateNew
 
double LHCGate
 
int N_BX
 
double resEle
 
double resRPC
 
double sspeed
 
double the_exact_time
 
double the_smeared_time
 
RPCSimSetUptheSimSetUp
 
double timOff
 

Detailed Description

Class for the RPC strip response simulation based on a parametrized model (ORCA-based)

Author
Raffaello Trentadue – INFN Bari

Definition at line 36 of file RPCSynchronizer.h.

Constructor & Destructor Documentation

RPCSynchronizer::RPCSynchronizer ( const edm::ParameterSet config)

Definition at line 33 of file RPCSynchronizer.cc.

References c, ecal_dqm_sourceclient-live_cfg::cosmics, alignCSCRings::e, edm::ParameterSet::getParameter(), and lumi::N_BX.

33  {
34  resRPC = config.getParameter<double>("timeResolution");
35  timOff = config.getParameter<double>("timingRPCOffset");
36  dtimCs = config.getParameter<double>("deltatimeAdjacentStrip");
37  resEle = config.getParameter<double>("timeJitter");
38  sspeed = config.getParameter<double>("signalPropagationSpeed");
39  lbGate = config.getParameter<double>("linkGateWidth");
40  LHCGate = config.getParameter<double>("Gate");
41  cosmics = config.getParameter<bool>("cosmics");
42  irpc_timing_res = config.getParameter<double>("IRPC_time_resolution");
43  irpc_electronics_jitter = config.getParameter<double>("IRPC_electronics_jitter");
44  N_BX = config.getParameter<int>("BX_range");
45  //"magic" parameter for cosmics
46  cosmicPar = 37.62;
47 
48  double c = 299792458; // [m/s]
49  //light speed in [cm/ns]
50  cspeed = c * 1e+2 * 1e-9;
51  //signal propagation speed [cm/ns]
52  sspeed = sspeed * cspeed;
53 }
const edm::EventSetup & c
double irpc_electronics_jitter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
RPCSynchronizer::~RPCSynchronizer ( )

Definition at line 55 of file RPCSynchronizer.cc.

55 {}

Member Function Documentation

double RPCSynchronizer::getExactTime ( ) const
inline

Definition at line 45 of file RPCSynchronizer.h.

References the_exact_time.

45 { return the_exact_time; }
RPCSimSetUp* RPCSynchronizer::getRPCSimSetUp ( )
inline

Definition at line 44 of file RPCSynchronizer.h.

References theSimSetUp.

44 { return theSimSetUp; }
RPCSimSetUp * theSimSetUp
int RPCSynchronizer::getSimHitBx ( const PSimHit simhit,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 57 of file RPCSynchronizer.cc.

References makePileupJSON::bx, ecal_dqm_sourceclient-live_cfg::cosmics, RPCGeometry::dets(), PSimHit::detUnitId(), relativeConstraints::geometry, RPCSimSetUp::getGeometry(), RPCSimSetUp::getTime(), PSimHit::localPosition(), dqmiodumpmetadata::n, lumi::N_BX, alignCSCRings::r, RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), PSimHit::timeOfFlight(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by RPCSimSimple::simulate(), RPCSimParam::simulate(), RPCSimAverageNoise::simulate(), RPCSimAverage::simulate(), RPCSimAverageNoiseEff::simulate(), RPCSimAverageNoiseEffCls::simulate(), and RPCSimAsymmetricCls::simulate().

57  {
58  RPCSimSetUp* simsetup = this->getRPCSimSetUp();
59  const RPCGeometry* geometry = simsetup->getGeometry();
60  float timeref = simsetup->getTime(simhit->detUnitId());
61 
62  int bx = -999;
63  LocalPoint simHitPos = simhit->localPosition();
64  float tof = simhit->timeOfFlight();
65 
66  //automatic variable to prevent memory leak
67 
68  float rr_el = CLHEP::RandGaussQ::shoot(engine, 0., resEle);
69 
70  RPCDetId SimDetId(simhit->detUnitId());
71 
72  const RPCRoll* SimRoll = nullptr;
73 
74  for (TrackingGeometry::DetContainer::const_iterator it = geometry->dets().begin(); it != geometry->dets().end();
75  it++) {
76  if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
77  auto ch = dynamic_cast<const RPCChamber*>(*it);
78 
79  std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
80  for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
81  if ((*r)->id() == SimDetId) {
82  SimRoll = &(*(*r));
83  break;
84  }
85  }
86  }
87  }
88 
89  if (SimRoll != nullptr) {
90  float distanceFromEdge = 0;
91  float half_stripL = 0.;
92 
93  if (SimRoll->id().region() == 0) {
94  const RectangularStripTopology* top_ = dynamic_cast<const RectangularStripTopology*>(&(SimRoll->topology()));
95  half_stripL = top_->stripLength() / 2;
96  distanceFromEdge = half_stripL + simHitPos.y();
97  } else {
98  const TrapezoidalStripTopology* top_ = dynamic_cast<const TrapezoidalStripTopology*>(&(SimRoll->topology()));
99  half_stripL = top_->stripLength() / 2;
100  distanceFromEdge = half_stripL - simHitPos.y();
101  }
102 
103  float prop_time = distanceFromEdge / sspeed;
104 
105  double rr_tim1 = CLHEP::RandGaussQ::shoot(engine, 0., resRPC);
106  double total_time = tof + prop_time + timOff + rr_tim1 + rr_el;
107 
108  // Bunch crossing assignment
109  double time_differ = 0.;
110 
111  if (cosmics) {
112  time_differ = (total_time - (timeref + ((half_stripL / sspeed) + timOff))) / cosmicPar;
113  } else if (!cosmics) {
114  time_differ = total_time - (timeref + (half_stripL / sspeed) + timOff);
115  }
116 
117  double inf_time = 0;
118  double sup_time = 0;
119 
120  for (int n = -N_BX; n <= N_BX; ++n) {
121  if (cosmics) {
122  inf_time = (-lbGate / 2 + n * LHCGate) / cosmicPar;
123  sup_time = (lbGate / 2 + n * LHCGate) / cosmicPar;
124  } else if (!cosmics) {
125  inf_time = -lbGate / 2 + n * LHCGate;
126  sup_time = lbGate / 2 + n * LHCGate;
127  }
128 
129  if (inf_time < time_differ && time_differ < sup_time) {
130  bx = n;
131  break;
132  }
133  }
134  }
135 
136  return bx;
137 }
float getTime(uint32_t id)
Definition: RPCSimSetUp.cc:440
T y() const
Definition: PV3DBase.h:60
float stripLength() const override
const RPCGeometry * getGeometry()
Definition: RPCSimSetUp.h:49
float timeOfFlight() const
Definition: PSimHit.h:73
Local3DPoint localPosition() const
Definition: PSimHit.h:52
RPCSimSetUp * getRPCSimSetUp()
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: RPCGeometry.cc:24
float stripLength() const override
det heigth (strip length in the middle)
unsigned int detUnitId() const
Definition: PSimHit.h:97
int RPCSynchronizer::getSimHitBxAndTimingForIRPC ( const PSimHit simhit,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 139 of file RPCSynchronizer.cc.

References makePileupJSON::bx, ecal_dqm_sourceclient-live_cfg::cosmics, RPCGeometry::dets(), PSimHit::detUnitId(), relativeConstraints::geometry, RPCSimSetUp::getGeometry(), RPCSimSetUp::getTime(), PSimHit::localPosition(), dqmiodumpmetadata::n, lumi::N_BX, alignCSCRings::r, RectangularStripTopology::stripLength(), TrapezoidalStripTopology::stripLength(), PSimHit::timeOfFlight(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by RPCSimModelTiming::simulate().

139  {
140  RPCSimSetUp* simsetup = this->getRPCSimSetUp();
141  const RPCGeometry* geometry = simsetup->getGeometry();
142  float timeref = simsetup->getTime(simhit->detUnitId());
143 
144  int bx = -999;
145  LocalPoint simHitPos = simhit->localPosition();
146  float tof = simhit->timeOfFlight();
147 
148  //automatic variable to prevent memory leak
149 
150  // float rr_el = CLHEP::RandGaussQ::shoot(engine, 0.,resEle);
151  float rr_el = CLHEP::RandGaussQ::shoot(engine, 0., irpc_electronics_jitter);
152 
153  RPCDetId SimDetId(simhit->detUnitId());
154 
155  const RPCRoll* SimRoll = nullptr;
156 
157  for (TrackingGeometry::DetContainer::const_iterator it = geometry->dets().begin(); it != geometry->dets().end();
158  it++) {
159  if (dynamic_cast<const RPCChamber*>(*it) != nullptr) {
160  auto ch = dynamic_cast<const RPCChamber*>(*it);
161 
162  std::vector<const RPCRoll*> rollsRaf = (ch->rolls());
163  for (std::vector<const RPCRoll*>::iterator r = rollsRaf.begin(); r != rollsRaf.end(); ++r) {
164  if ((*r)->id() == SimDetId) {
165  SimRoll = &(*(*r));
166  break;
167  }
168  }
169  }
170  }
171 
172  if (SimRoll != nullptr) {
173  float distanceFromEdge = 0;
174  float half_stripL = 0.;
175 
176  if (SimRoll->id().region() == 0) {
177  const RectangularStripTopology* top_ = dynamic_cast<const RectangularStripTopology*>(&(SimRoll->topology()));
178  half_stripL = top_->stripLength() / 2;
179  distanceFromEdge = half_stripL + simHitPos.y();
180  } else {
181  const TrapezoidalStripTopology* top_ = dynamic_cast<const TrapezoidalStripTopology*>(&(SimRoll->topology()));
182  half_stripL = top_->stripLength() / 2;
183  distanceFromEdge = half_stripL - simHitPos.y();
184  }
185 
186  float prop_time = distanceFromEdge / sspeed;
187 
188  // double rr_tim1 = CLHEP::RandGaussQ::shoot(engine, 0.,resRPC);
189  double rr_tim1 = CLHEP::RandGaussQ::shoot(engine, 0., irpc_timing_res);
190 
191  double total_time = tof + prop_time + timOff + rr_tim1 + rr_el;
192 
193  // Bunch crossing assignment
194  double time_differ = 0.;
195 
196  if (cosmics) {
197  time_differ = (total_time - (timeref + ((half_stripL / sspeed) + timOff))) / cosmicPar;
198  } else if (!cosmics) {
199  time_differ = total_time - (timeref + (half_stripL / sspeed) + timOff);
200  }
201 
202  double exact_total_time = tof + prop_time + timOff;
203  double exact_time_differ = 0.;
204 
205  if (cosmics) {
206  exact_time_differ = (exact_total_time - (timeref + ((half_stripL / sspeed) + timOff))) / cosmicPar;
207  } else if (!cosmics) {
208  exact_time_differ = exact_total_time - (timeref + (half_stripL / sspeed) + timOff);
209  }
210 
211  double inf_time = 0;
212  double sup_time = 0;
213 
214  for (int n = -N_BX; n <= N_BX; ++n) {
215  if (cosmics) {
216  inf_time = (-lbGate / 2 + n * LHCGate) / cosmicPar;
217  sup_time = (lbGate / 2 + n * LHCGate) / cosmicPar;
218  } else if (!cosmics) {
219  inf_time = -lbGate / 2 + n * LHCGate;
220  sup_time = lbGate / 2 + n * LHCGate;
221  }
222 
223  if (inf_time < time_differ && time_differ < sup_time) {
224  bx = n;
225  the_exact_time = exact_time_differ;
226  the_smeared_time = time_differ;
227 
228  //cout<<"Debug\t"<<inf_time<<'\t'<<sup_time<<endl;
230  // cout<<"Bingo\t"<<time_differ<<'\t'<<bx<<'\t'<<exact_time_differ<<'\t'<<exact_time_differ-time_differ<<'\t'<<exact_time_differ-bx*25.<<endl;
231  break;
232  }
233  }
234  }
235  return bx;
236 }
float getTime(uint32_t id)
Definition: RPCSimSetUp.cc:440
T y() const
Definition: PV3DBase.h:60
float stripLength() const override
const RPCGeometry * getGeometry()
Definition: RPCSimSetUp.h:49
float timeOfFlight() const
Definition: PSimHit.h:73
Local3DPoint localPosition() const
Definition: PSimHit.h:52
RPCSimSetUp * getRPCSimSetUp()
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Definition: RPCGeometry.cc:24
double irpc_electronics_jitter
float stripLength() const override
det heigth (strip length in the middle)
unsigned int detUnitId() const
Definition: PSimHit.h:97
double RPCSynchronizer::getSmearedTime ( ) const
inline

Definition at line 46 of file RPCSynchronizer.h.

References the_smeared_time.

Referenced by RPCSimModelTiming::simulate().

46 { return the_smeared_time; }
void RPCSynchronizer::setRPCSimSetUp ( RPCSimSetUp simsetup)
inline

Member Data Documentation

double RPCSynchronizer::cosmicPar
private

Definition at line 57 of file RPCSynchronizer.h.

bool RPCSynchronizer::cosmics
private

Definition at line 59 of file RPCSynchronizer.h.

double RPCSynchronizer::cspeed
private

Definition at line 54 of file RPCSynchronizer.h.

double RPCSynchronizer::dtimCs
private

Definition at line 51 of file RPCSynchronizer.h.

double RPCSynchronizer::irpc_electronics_jitter
private

Definition at line 61 of file RPCSynchronizer.h.

double RPCSynchronizer::irpc_timing_res
private

Definition at line 60 of file RPCSynchronizer.h.

double RPCSynchronizer::lbGate
private

Definition at line 55 of file RPCSynchronizer.h.

double RPCSynchronizer::lbGateNew
private

Definition at line 56 of file RPCSynchronizer.h.

double RPCSynchronizer::LHCGate
private

Definition at line 58 of file RPCSynchronizer.h.

int RPCSynchronizer::N_BX
private

Definition at line 65 of file RPCSynchronizer.h.

double RPCSynchronizer::resEle
private

Definition at line 52 of file RPCSynchronizer.h.

double RPCSynchronizer::resRPC
private

Definition at line 49 of file RPCSynchronizer.h.

double RPCSynchronizer::sspeed
private

Definition at line 53 of file RPCSynchronizer.h.

double RPCSynchronizer::the_exact_time
private

Definition at line 62 of file RPCSynchronizer.h.

Referenced by getExactTime().

double RPCSynchronizer::the_smeared_time
private

Definition at line 63 of file RPCSynchronizer.h.

Referenced by getSmearedTime().

RPCSimSetUp* RPCSynchronizer::theSimSetUp
private

Definition at line 64 of file RPCSynchronizer.h.

Referenced by getRPCSimSetUp(), and setRPCSimSetUp().

double RPCSynchronizer::timOff
private

Definition at line 50 of file RPCSynchronizer.h.