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 // not quite adequate to 25ns high-PU regime
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 
50  int maxbin = samples.size();
51  CaloSamples data(detId, maxbin); // for a temporary copy
52  data = samples;
53 
54  // smearing
55  double eps = 1.e-6;
56  double scale_factor = 0.6;
57  double scale = data[4] / scale_factor;
58  double smearns = 0.;
59 
60  const HcalSimParameters& params =
61  static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
62  if (params.doTimeSmear()) {
63  double rms = params.timeSmearRMS(scale);
64  smearns = CLHEP::RandGaussQ::shoot(engine)*rms;
65  LogDebug("HcalTimeSlewSim") << "TimeSmear charge "
66  << scale << " rms " << rms
67  << " smearns " << smearns;
68  }
69 
70  for(int i = 0; i < samples.size()-1; ++i) {
71  double totalCharge = data[i]/scale_factor;
72  // until we get more precise/reliable QIE8 simulation...
73 
74  double delay = smearns;
75  if(totalCharge <= 0.) totalCharge = eps; // protecion against negaive v.
76  delay += HcalTimeSlew::delay(totalCharge, biasSetting);
77  if(delay <= 0.) delay = eps;
78 
79  double t = i*25. - delay;
80  int firstbin = floor(t/25.);
81  double f = t/25. - firstbin;
82  int nextbin = firstbin + 1;
83  double v2 = (nextbin < 0 || nextbin >= maxbin) ? 0. : data[nextbin];
84  data[i] = v2*f;
85  data[i+1] = data[i+1] + (v2 - data[i]);
86  }
87 
88  samples = data;
89  }
90 }
#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
double f[11][100]
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
double charge(const CaloSamples &samples) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
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