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  double delay = HcalTimeSlew::delay(totalCharge, biasSetting);
48  // now, the smearing
49  const HcalSimParameters& params=static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
50  if (params.doTimeSmear() && theRandGaussQ!=0) {
51  double rms=params.timeSmearRMS(totalCharge);
52  double smearns=theRandGaussQ->fire()*rms;
53 
54  LogDebug("HcalTimeSlewSim") << "TimeSmear charge " << totalCharge << " rms " << rms << " delay " << delay << " smearns " << smearns;
55  delay+=smearns;
56  }
57 
58  samples.offsetTime(delay);
59  }
60 }
61 
62 
63 void HcalTimeSlewSim::setRandomEngine(CLHEP::HepRandomEngine & engine) {
64  if (theRandGaussQ==0) {
65  theRandGaussQ=new CLHEP::RandGaussQ(engine);
66  }
67 }
#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:31
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:24
CLHEP::RandGaussQ * theRandGaussQ
CaloSamples & offsetTime(double offset)
shift all the samples by a time, in ns, interpolating
Definition: CaloSamples.cc:35
void delay(CaloSamples &samples) const
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