CMS 3D CMS Logo

HcalTimeSlewSim.cc
Go to the documentation of this file.
10 
11 #include "CLHEP/Random/RandGaussQ.h"
12 
14  : theParameterMap(parameterMap), minFCToDelay_(minFCToDelay) {}
15 
16 // not quite adequate to 25ns high-PU regime
18  double totalCharge = 0.;
19  for (int i = 0; i < 4; ++i) {
20  int bin = i + samples.presamples();
21  if (bin < samples.size()) {
22  totalCharge += samples[bin];
23  }
24  }
25  return totalCharge;
26 }
27 
29  CLHEP::HepRandomEngine* engine,
30  const HcalTimeSlew* hcalTimeSlew_delay) const {
31  // HO goes slow, HF shouldn't be used at all
32  //ZDC not used for the moment
33 
34  DetId detId(cs.id());
35  if (detId.det() == DetId::Calo && detId.subdetId() == HcalZDCDetId::SubdetectorId)
36  return;
37  HcalDetId hcalDetId(detId);
38 
39  if (hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter) {
40  HcalTimeSlew::BiasSetting biasSetting =
42 
43  // double totalCharge = charge(cs); // old TS...
44 
45  int maxbin = cs.size();
46  CaloSamples data(detId, maxbin); // for a temporary copy
47  data = cs;
48 
49  // smearing
50  int soi = cs.presamples();
51  double eps = 1.e-6;
52  double scale_factor = 0.6;
53  double scale = cs[soi] / scale_factor;
54  double smearns = 0.;
55  double cut = minFCToDelay_; //5. fC (above mean) for signal to be delayed
56 
57  const HcalSimParameters& params = static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
58  if (params.doTimeSmear()) {
59  double rms = params.timeSmearRMS(scale);
60  smearns = CLHEP::RandGaussQ::shoot(engine) * rms;
61  LogDebug("HcalTimeSlewSim") << "TimeSmear charge " << scale << " rms " << rms << " smearns " << smearns;
62  }
63 
64  // cycle over TS', it - current TS index
65  for (int it = 0; it < maxbin - 1;) {
66  double datai = cs[it];
67  int nts = 0;
68  double tshift = smearns;
69  double totalCharge = datai / scale_factor;
70 
71  // until we get more precise/reliable QIE8 simulation...
72  if (totalCharge <= 0.)
73  totalCharge = eps; // protecion against negaive v.
74  tshift += hcalTimeSlew_delay->delay(totalCharge, biasSetting);
75  if (tshift <= 0.)
76  tshift = eps;
77 
78  if (cut > -999.) { //preserve compatibility
79  if ((datai > cut) && (it == 0 || (datai > cs[it - 1]))) {
80  // number of TS affected by current move depends on the signal shape:
81  // rising or peaking
82  nts = 2; // rising
83  if (datai > cs[it + 1])
84  nts = 3; // peaking
85 
86  // 1 or 2 TS to move from here,
87  // 2d or 3d TS gets leftovers to preserve the sum
88  for (int j = it; j < it + nts && j < maxbin; ++j) {
89  // snippet borrowed from CaloSamples::offsetTime(offset)
90  // CalibFormats/CaloObjects/src/CaloSamples.cc
91  double t = j * 25. - tshift;
92  int firstbin = floor(t / 25.);
93  double f = t / 25. - firstbin;
94  int nextbin = firstbin + 1;
95  double v1 = (firstbin < 0 || firstbin >= maxbin) ? 0. : cs[firstbin];
96  double v2 = (nextbin < 0 || nextbin >= maxbin) ? 0. : cs[nextbin];
97 
98  // Keeping the overal sum intact
99  if (nts == 2) {
100  if (j == it)
101  data[j] = v2 * f;
102  else
103  data[j] = v1 * (1. - f) + v2;
104  } else { // nts = 3
105  if (j == it)
106  data[j] = v2 * f;
107  if (j == it + 1)
108  data[j] = v1 * (1. - f) + v2 * f;
109  if (j == it + nts - 1)
110  data[j] = v1 * (1. - f) + v2;
111  }
112 
113  } // end of local move of TS', now update...
114  cs = data;
115 
116  } // end of rising edge or peak finding
117  } else {
118  double t = it * 25. - tshift;
119  int firstbin = floor(t / 25.);
120  double f = t / 25. - firstbin;
121  int nextbin = firstbin + 1;
122  double v2 = (nextbin < 0 || nextbin >= maxbin) ? 0. : data[nextbin];
123  data[it] = v2 * f;
124  data[it + 1] += (v2 - data[it]);
125  cs = data;
126  }
127 
128  if (nts < 3)
129  it++;
130  else
131  it += 2;
132  }
133 
134  // final update of the shifted TS array
135  cs = data;
136  }
137 }
mps_fire.i
i
Definition: mps_fire.py:428
HcalSimParameters.h
MessageLogger.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
HcalTimeSlewSim::HcalTimeSlewSim
HcalTimeSlewSim(const CaloVSimParameterMap *parameterMap, double minFCToDelay)
Definition: HcalTimeSlewSim.cc:13
CaloVSimParameterMap
Definition: CaloVSimParameterMap.h:7
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
HcalTimeSlew::Medium
Definition: HcalTimeSlew.h:71
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
HcalTimeSlewSim::delay
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *, const HcalTimeSlew *hcalTimeSlew_delay) const
Definition: HcalTimeSlewSim.cc:28
gpuVertexFinder::eps
WorkSpace int float eps
Definition: gpuClusterTracksDBSCAN.h:18
HcalTimeSlew.h
CaloSimParameters.h
HcalBarrel
Definition: HcalAssistant.h:33
HcalZDCDetId.h
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
DetId::Calo
Definition: DetId.h:29
HcalTimeSlew::BiasSetting
BiasSetting
Definition: HcalTimeSlew.h:71
HcalTimeSlew
Definition: HcalTimeSlew.h:19
HcalTimeSlew::delay
float delay(float fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:20
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
DetId
Definition: DetId.h:17
CaloVSimParameterMap::simParameters
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
HcalOuter
Definition: HcalAssistant.h:35
HcalZDCDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
HcalTimeSlew::Slow
Definition: HcalTimeSlew.h:71
HcalTimeSlewSim::minFCToDelay_
double minFCToDelay_
Definition: HcalTimeSlewSim.h:29
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
HcalDetId.h
HcalDetId::subdet
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
HcalDetId
Definition: HcalDetId.h:12
CaloSamples
Definition: CaloSamples.h:14
HcalTimeSlewSim::theParameterMap
const CaloVSimParameterMap * theParameterMap
Definition: HcalTimeSlewSim.h:28
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
HcalSimParameters
Definition: HcalSimParameters.h:10
HcalEndcap
Definition: HcalAssistant.h:34
DetId.h
HcalTimeSlewSim::charge
double charge(const CaloSamples &samples) const
Definition: HcalTimeSlewSim.cc:17
Exception.h
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
hcalUnsuppressedDigis_cfi.minFCToDelay
minFCToDelay
Definition: hcalUnsuppressedDigis_cfi.py:29
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HcalTimeSlewSim.h