CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHitCorrection.cc
Go to the documentation of this file.
10 
11 #include "CLHEP/Random/RandGaussQ.h"
12 
14  : theParameterMap(parameterMap)
15 {
16 }
17 
18 
20 {
21  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
22  hitItr != hits.end(); ++hitItr)
23  {
24  HcalDetId hcalDetId(hitItr->id());
25  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter )
26  {
27  LogDebug("HcalHitCorrection") << "HcalHitCorrection::Hit 0x" << std::hex
28  << hitItr->id() << std::dec;
29  int tbin = timeBin(*hitItr);
30  LogDebug("HcalHitCorrection") << "HcalHitCorrection::Hit tbin" << tbin;
31  if(tbin >= 0 && tbin < 10)
32  {
33  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
34  }
35  }
36  }
37 }
38 
39 
40 void HcalHitCorrection::fillChargeSums(std::vector<PCaloHit> & hits) {
41 
42  for(std::vector<PCaloHit>::const_iterator hitItr = hits.begin();
43  hitItr != hits.end(); ++hitItr)
44  {
45  HcalDetId hcalDetId(hitItr->id());
46  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter )
47  {
48  LogDebug("HcalHitCorrection") << "HcalHitCorrection::Hit 0x" << std::hex
49  << hitItr->id() << std::dec;
50  int tbin = timeBin(*hitItr);
51  LogDebug("HcalHitCorrection") << "HcalHitCorrection::Hit tbin" << tbin;
52  if(tbin >= 0 && tbin < 10)
53  {
54  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
55  }
56  }
57  }
58 }
59 
60 
62 {
63  for(int i = 0; i < 10; ++i)
64  {
65  theChargeSumsForTimeBin[i].clear();
66  }
67 }
68 
69 double HcalHitCorrection::charge(const PCaloHit & hit) const
70 {
71  HcalDetId detId(hit.id());
73  double simHitToCharge = parameters.simHitToPhotoelectrons(detId)
74  * parameters.photoelectronsToAnalog(detId);
75  return hit.energy() * simHitToCharge;
76 }
77 
78 
79 double HcalHitCorrection::delay(const PCaloHit & hit, CLHEP::HepRandomEngine* engine) const
80 {
81  // HO goes slow, HF shouldn't be used at all
82  //ZDC not used for the moment
83 
84  DetId detId(hit.id());
85  if(detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId) return 0.0;
86  HcalDetId hcalDetId(hit.id());
87  double delay = 0.;
88 
89  if(hcalDetId.subdet() == HcalBarrel || hcalDetId.subdet() == HcalEndcap || hcalDetId.subdet() == HcalOuter ) {
90 
91  HcalTimeSlew::BiasSetting biasSetting = (hcalDetId.subdet() == HcalOuter) ?
94 
95  int tbin = timeBin(hit);
96  double totalCharge=0;
97  if(tbin >= 0 && tbin < 10)
98  {
99  ChargeSumsByChannel::const_iterator totalChargeItr = theChargeSumsForTimeBin[tbin].find(detId);
100  if(totalChargeItr == theChargeSumsForTimeBin[tbin].end())
101  {
102  throw cms::Exception("HcalHitCorrection") << "Cannot find HCAL charge sum for hit " << hit;
103  }
104  totalCharge = totalChargeItr->second;
105  delay = HcalTimeSlew::delay(totalCharge, biasSetting);
106  LogDebug("HcalHitCorrection") << "TIMESLEWcharge " << charge(hit)
107  << " totalcharge " << totalCharge
108  << " olddelay " << HcalTimeSlew::delay(charge(hit), biasSetting)
109  << " newdelay " << delay;
110  }
111  // now, the smearing
112  const HcalSimParameters& params=static_cast<const HcalSimParameters&>(theParameterMap->simParameters(detId));
113  if (params.doTimeSmear()) {
114  double rms=params.timeSmearRMS(charge(hit));
115 
116  double smearns = CLHEP::RandGaussQ::shoot(engine) * rms;
117 
118  LogDebug("HcalHitCorrection") << "TimeSmear charge " << charge(hit) << " rms " << rms << " delay " << delay << " smearns " << smearns;
119  delay+=smearns;
120  }
121  }
122 
123  return delay;
124 }
125 
127 {
129  double t = hit.time() - timeOfFlight(DetId(hit.id())) + parameters.timePhase();
130  return static_cast<int> (t / 25) + parameters.binOfMaximum() - 1;
131 }
132 
133 
134 double HcalHitCorrection::timeOfFlight(const DetId & detId) const
135 {
136  if(detId.det()==DetId::Calo && detId.subdetId()==HcalZDCDetId::SubdetectorId)
137  return 37.666;
138  switch(detId.subdetId())
139  {
140  case HcalBarrel:
141  return 8.4;
142  break;
143  case HcalEndcap:
144  return 13.;
145  break;
146  case HcalOuter:
147  return 18.7;
148  break;
149  case HcalForward:
150  return 37.;
151  break;
152  default:
153  throw cms::Exception("HcalHitCorrection") << "Bad Hcal subdetector " << detId.subdetId();
154  break;
155  }
156 }
#define LogDebug(id)
HcalHitCorrection(const CaloVSimParameterMap *parameterMap)
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
double time() const
Definition: PCaloHit.h:36
double energy() const
Definition: PCaloHit.h:29
int timeBin(const PCaloHit &hit) const
which time bin the peak of the signal will fall in
Main class for Parameters in different subdetectors.
iterator end()
double timePhase() const
the adjustment you need to apply to get the signal where you want it
bool doTimeSmear() const
double timeSmearRMS(double ampl) const
void fillChargeSums(MixCollection< PCaloHit > &hits)
ChargeSumsByChannel theChargeSumsForTimeBin[10]
double simHitToPhotoelectrons() const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
#define end
Definition: vmac.h:37
unsigned int id() const
Definition: PCaloHit.h:43
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
iterator begin()
static const int SubdetectorId
Definition: HcalZDCDetId.h:20
double timeOfFlight(const DetId &id) const
simple average approximation
double charge(const PCaloHit &hit) const
how much charge we expect from this hit
virtual double delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const
how much delay this hit will get
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int binOfMaximum() const
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
const CaloVSimParameterMap * theParameterMap