CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
 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 18 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),
15  minFCToDelay_(minFCToDelay)
16 {
17 }
const CaloVSimParameterMap * theParameterMap

Member Function Documentation

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

Definition at line 21 of file HcalTimeSlewSim.cc.

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

22 {
23  double totalCharge = 0.;
24  for(int i = 0; i < 4; ++i) {
25  int bin = i + samples.presamples();
26  if(bin < samples.size()) {
27  totalCharge += samples[bin];
28  }
29  }
30  return totalCharge;
31 }
int i
Definition: DBlmapReader.cc:9
int presamples() const
access presample information
Definition: CaloSamples.h:36
int size() const
get the size
Definition: CaloSamples.h:24
void HcalTimeSlewSim::delay ( CaloSamples samples,
CLHEP::HepRandomEngine *  engine 
) const

Definition at line 34 of file HcalTimeSlewSim.cc.

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

Referenced by HcalAmplifier::amplify().

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

Member Data Documentation

double HcalTimeSlewSim::minFCToDelay_
private

Definition at line 29 of file HcalTimeSlewSim.h.

Referenced by delay().

const CaloVSimParameterMap* HcalTimeSlewSim::theParameterMap
private

Definition at line 28 of file HcalTimeSlewSim.h.

Referenced by delay().