CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTimeSlewSim.cc
Go to the documentation of this file.
10 
12  : theParameterMap(parameterMap),theRandGaussQ(0)
13 {
14 }
15 
16 
17 
18 double HcalTimeSlewSim::charge(const CaloSamples & samples) const
19 {
20  double totalCharge = 0.;
21  for(int i = 0; i < 4; ++i) {
22  int bin = i + samples.presamples();
23  if(bin < samples.size()) {
24  totalCharge += samples[bin];
25  }
26  }
27  return totalCharge;
28 }
29 
30 
31 void HcalTimeSlewSim::delay(CaloSamples & samples) const
32 {
33  // HO goes slow, HF shouldn't be used at all
34  //ZDC not used for the moment
35 
36  DetId detId(samples.id());
37  if(detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId) return;
38  HcalDetId hcalDetId(detId);
39 
40  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter ) {
41 
42  HcalTimeSlew::BiasSetting biasSetting = (hcalDetId.subdet() == HcalOuter) ?
45 
46  double totalCharge = charge(samples);
47  if(totalCharge <= 0.) totalCharge = 1.e-6; // protecion against negaive v.
48  double delay = HcalTimeSlew::delay(totalCharge, biasSetting);
49  // now, the smearing
50  const HcalSimParameters& params=static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
51  if (params.doTimeSmear() && theRandGaussQ!=0) {
52  double rms=params.timeSmearRMS(totalCharge);
53  double smearns=theRandGaussQ->fire()*rms;
54 
55  LogDebug("HcalTimeSlewSim") << "TimeSmear charge " << totalCharge << " rms " << rms << " delay " << delay << " smearns " << smearns;
56  delay+=smearns;
57  }
58 
59  samples.offsetTime(delay);
60  }
61 }
62 
63 
64 void HcalTimeSlewSim::setRandomEngine(CLHEP::HepRandomEngine & engine) {
65  if (theRandGaussQ==0) {
66  theRandGaussQ=new CLHEP::RandGaussQ(engine);
67  }
68 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
int presamples() const
access presample information
Definition: CaloSamples.h:38
bool doTimeSmear() const
double timeSmearRMS(double ampl) const
void setRandomEngine(CLHEP::HepRandomEngine &engine)
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
const CaloVSimParameterMap * theParameterMap
Definition: DetId.h:20
static const int SubdetectorId
Definition: HcalZDCDetId.h:22
int size() const
get the size
Definition: CaloSamples.h:26
CLHEP::RandGaussQ * theRandGaussQ
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:67
void delay(CaloSamples &samples) const
double charge(const CaloSamples &samples) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:23
HcalTimeSlewSim(const CaloVSimParameterMap *parameterMap)
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:8