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