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 
11 #include "CLHEP/Random/RandGaussQ.h"
12 
14  : theParameterMap(parameterMap)
15 {
16 }
17 
18 
19 
20 double HcalTimeSlewSim::charge(const CaloSamples & samples) const
21 {
22  double totalCharge = 0.;
23  for(int i = 0; i < 4; ++i) {
24  int bin = i + samples.presamples();
25  if(bin < samples.size()) {
26  totalCharge += samples[bin];
27  }
28  }
29  return totalCharge;
30 }
31 
32 
33 void HcalTimeSlewSim::delay(CaloSamples & samples, CLHEP::HepRandomEngine* engine) const
34 {
35  // HO goes slow, HF shouldn't be used at all
36  //ZDC not used for the moment
37 
38  DetId detId(samples.id());
39  if(detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId) return;
40  HcalDetId hcalDetId(detId);
41 
42  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter ) {
43 
44  HcalTimeSlew::BiasSetting biasSetting = (hcalDetId.subdet() == HcalOuter) ?
47 
48  double totalCharge = charge(samples);
49  if(totalCharge <= 0.) totalCharge = 1.e-6; // protecion against negaive v.
50  double delay = HcalTimeSlew::delay(totalCharge, biasSetting);
51  // now, the smearing
52  const HcalSimParameters& params=static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
53  if (params.doTimeSmear()) {
54  double rms=params.timeSmearRMS(totalCharge);
55  double smearns=CLHEP::RandGaussQ::shoot(engine)*rms;
56 
57  LogDebug("HcalTimeSlewSim") << "TimeSmear charge " << totalCharge << " rms " << rms << " delay " << delay << " smearns " << smearns;
58  delay+=smearns;
59  }
60 
61  samples.offsetTime(delay);
62  }
63 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:30
int presamples() const
access presample information
Definition: CaloSamples.h:36
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *) const
bool doTimeSmear() const
double timeSmearRMS(double ampl) const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
const CaloVSimParameterMap * theParameterMap
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:20
int size() const
get the size
Definition: CaloSamples.h:24
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:67
double charge(const CaloSamples &samples) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
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