CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalTimeSlewSim Class Reference

#include <HcalTimeSlewSim.h>

Public Member Functions

void delay (CaloSamples &samples, CLHEP::HepRandomEngine *, const HcalTimeSlew *hcalTimeSlew_delay) const
 
 HcalTimeSlewSim (const CaloVSimParameterMap *parameterMap, double minFCToDelay)
 

Private Member Functions

double charge (const CaloSamples &samples) const
 

Private Attributes

double minFCToDelay_
 
const CaloVSimParameterMaptheParameterMap
 

Detailed Description

Definition at line 19 of file HcalTimeSlewSim.h.

Constructor & Destructor Documentation

◆ HcalTimeSlewSim()

HcalTimeSlewSim::HcalTimeSlewSim ( const CaloVSimParameterMap parameterMap,
double  minFCToDelay 
)

Definition at line 13 of file HcalTimeSlewSim.cc.

14  : theParameterMap(parameterMap), minFCToDelay_(minFCToDelay) {}
const CaloVSimParameterMap * theParameterMap

Member Function Documentation

◆ charge()

double HcalTimeSlewSim::charge ( const CaloSamples samples) const
private

Definition at line 17 of file HcalTimeSlewSim.cc.

References newFWLiteAna::bin, mps_fire::i, and EgammaValidation_cff::samples.

17  {
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 }

◆ delay()

void HcalTimeSlewSim::delay ( CaloSamples samples,
CLHEP::HepRandomEngine *  engine,
const HcalTimeSlew hcalTimeSlew_delay 
) const

Definition at line 28 of file HcalTimeSlewSim.cc.

References DetId::Calo, callgraph::cs, DMR_cfg::cut, data, HcalTimeSlew::delay(), HLT_2023v12_cff::eps, f, HcalBarrel, HcalEndcap, HcalOuter, dqmiolumiharvest::j, LogDebug, HcalTimeSlew::Medium, minFCToDelay_, submitPVValidationJobs::params, SiStripPI::rms, L1EGammaClusterEmuProducer_cfi::scale, CaloVSimParameterMap::simParameters(), HcalTimeSlew::Slow, HcalDetId::subdet(), HcalZDCDetId::SubdetectorId, submitPVValidationJobs::t, and theParameterMap.

Referenced by HcalAmplifier::amplify().

30  {
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 =
41  (hcalDetId.subdet() == HcalOuter) ? HcalTimeSlew::Slow : HcalTimeSlew::Medium;
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 }
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
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
double f[11][100]
const CaloVSimParameterMap * theParameterMap
Definition: DetId.h:17
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
#define LogDebug(id)

Member Data Documentation

◆ minFCToDelay_

double HcalTimeSlewSim::minFCToDelay_
private

Definition at line 29 of file HcalTimeSlewSim.h.

Referenced by delay().

◆ theParameterMap

const CaloVSimParameterMap* HcalTimeSlewSim::theParameterMap
private

Definition at line 28 of file HcalTimeSlewSim.h.

Referenced by delay().