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 ( const CaloVSimParameterMap parameterMap,
double  minFCToDelay 
)

Definition at line 13 of file HcalTimeSlewSim.cc.

14  : theParameterMap(parameterMap),
16 {
17 }
const CaloVSimParameterMap * theParameterMap

Member Function Documentation

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

Definition at line 20 of file HcalTimeSlewSim.cc.

References stringResolutionProvider_cfi::bin, mps_fire::i, CaloSamples::presamples(), and CaloSamples::size().

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 }
int presamples() const
access presample information
Definition: CaloSamples.h:36
bin
set the eta bin as selection string.
int size() const
get the size
Definition: CaloSamples.h:24
void HcalTimeSlewSim::delay ( CaloSamples samples,
CLHEP::HepRandomEngine *  engine,
const HcalTimeSlew hcalTimeSlew_delay 
) const

Definition at line 32 of file HcalTimeSlewSim.cc.

References DetId::Calo, fwrapper::cs, TkAlMuonSelectors_cfi::cut, data, HcalTimeSlew::delay(), HcalSimParameters::doTimeSmear(), f, HcalBarrel, HcalEndcap, HcalOuter, CaloSamples::id(), LogDebug, HcalTimeSlew::Medium, minFCToDelay_, CaloSamples::presamples(), SiStripPI::rms, Scenarios_cff::scale, CaloVSimParameterMap::simParameters(), CaloSamples::size(), HcalTimeSlew::Slow, HcalDetId::subdet(), HcalZDCDetId::SubdetectorId, lumiQTWidget::t, theParameterMap, and HcalSimParameters::timeSmearRMS().

Referenced by HcalAmplifier::amplify().

33 {
34  // HO goes slow, HF shouldn't be used at all
35  //ZDC not used for the moment
36 
37  DetId detId(cs.id());
38  if(detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId) return;
39  HcalDetId hcalDetId(detId);
40 
41  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter ) {
42 
43  HcalTimeSlew::BiasSetting biasSetting = (hcalDetId.subdet() == HcalOuter) ?
46 
47  // double totalCharge = charge(cs); // old TS...
48 
49  int maxbin = cs.size();
50  CaloSamples data(detId, maxbin); // for a temporary copy
51  data = cs;
52 
53  // smearing
54  int soi = cs.presamples();
55  double eps = 1.e-6;
56  double scale_factor = 0.6;
57  double scale = cs[soi] / scale_factor;
58  double smearns = 0.;
59  double cut = minFCToDelay_; //5. fC (above mean) for signal to be delayed
60 
61  const HcalSimParameters& params =
62  static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
63  if (params.doTimeSmear()) {
64  double rms = params.timeSmearRMS(scale);
65  smearns = CLHEP::RandGaussQ::shoot(engine)*rms;
66  LogDebug("HcalTimeSlewSim") << "TimeSmear charge "
67  << scale << " rms " << rms
68  << " smearns " << smearns;
69  }
70 
71  // cycle over TS', it - current TS index
72  for(int it = 0; it < maxbin-1; ) {
73 
74  double datai = cs[it];
75  int nts = 0;
76  double tshift = smearns;
77  double totalCharge = datai/scale_factor;
78 
79  // until we get more precise/reliable QIE8 simulation...
80  if(totalCharge <= 0.) totalCharge = eps; // protecion against negaive v.
81  tshift += hcalTimeSlew_delay->delay(totalCharge, biasSetting);
82  if(tshift <= 0.) tshift = eps;
83 
84  if ( cut > -999. ) { //preserve compatibility
85  if ((datai > cut) && ( it == 0 || (datai > cs[it-1]))) {
86  // number of TS affected by current move depends on the signal shape:
87  // rising or peaking
88  nts = 2; // rising
89  if(datai > cs[it+1]) nts = 3; // peaking
90 
91  // 1 or 2 TS to move from here,
92  // 2d or 3d TS gets leftovers to preserve the sum
93  for (int j = it; j < it+nts && j < maxbin; ++j) {
94 
95  // snippet borrowed from CaloSamples::offsetTime(offset)
96  // CalibFormats/CaloObjects/src/CaloSamples.cc
97  double t = j*25. - tshift;
98  int firstbin = floor(t/25.);
99  double f = t/25. - firstbin;
100  int nextbin = firstbin + 1;
101  double v1 = (firstbin < 0 || firstbin >= maxbin) ? 0. : cs[firstbin];
102  double v2 = (nextbin < 0 || nextbin >= maxbin) ? 0. : cs[nextbin];
103 
104  // Keeping the overal sum intact
105  if(nts == 2) {
106  if(j == it) data[j] = v2*f;
107  else data[j] = v1*(1.-f) + v2;
108  }
109  else { // nts = 3
110  if(j == it) data[j] = v2*f;
111  if(j == it+1) data[j] = v1*(1.-f) + v2*f;
112  if(j == it+nts-1) data[j] = v1*(1.-f) + v2;
113  }
114 
115  } // end of local move of TS', now update...
116  cs = data;
117 
118  } // end of rising edge or peak finding
119  }
120  else{
121  double t=it*25.- tshift;
122  int firstbin=floor(t/25.);
123  double f=t/25. - firstbin;
124  int nextbin = firstbin +1;
125  double v2= (nextbin<0 || nextbin >= maxbin) ? 0. : data[nextbin];
126  data[it]=v2*f;
127  data[it+1]+= (v2-data[it]);
128  cs=data;
129  }
130 
131  if(nts < 3) it++;
132  else it +=2;
133  }
134 
135  // final update of the shifted TS array
136  cs = data;
137  }
138 }
#define LogDebug(id)
unique_ptr< ClusterSequence > cs
double delay(double 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:14
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:25
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82

Member Data Documentation

double HcalTimeSlewSim::minFCToDelay_
private

Definition at line 30 of file HcalTimeSlewSim.h.

Referenced by delay().

const CaloVSimParameterMap* HcalTimeSlewSim::theParameterMap
private

Definition at line 29 of file HcalTimeSlewSim.h.

Referenced by delay().