CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorHitCorrection.cc
Go to the documentation of this file.
9 
11 : theParameterMap(parameterMap)
12 {
13 }
14 
15 
17 {
18  // clear();
19  for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin();
20  hitItr != hits.end(); ++hitItr)
21  {
22  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit 0x" << std::hex << hitItr->id() << std::dec;
23  int tbin = timeBin(*hitItr);
24  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit tbin" << tbin;
25  if(tbin >= 0 && tbin < 10)
26  {
27  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
28  }
29  }
30 }
31 
32 void CastorHitCorrection::fillChargeSums(const std::vector<PCaloHit> & hits)
33 {
34  // clear();
35  for(std::vector<PCaloHit>::const_iterator hitItr = hits.begin();
36  hitItr != hits.end(); ++hitItr)
37  {
38  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit 0x" << std::hex << hitItr->id() << std::dec;
39  int tbin = timeBin(*hitItr);
40  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit tbin" << tbin;
41  if(tbin >= 0 && tbin < 10)
42  {
43  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
44  }
45  }
46 }
47 
48 
50 {
51  for(int i = 0; i < 10; ++i)
52  {
53  theChargeSumsForTimeBin[i].clear();
54  }
55 }
56 
58 {
59  DetId detId(hit.id());
61  double simHitToCharge = parameters.simHitToPhotoelectrons()
62  * parameters.photoelectronsToAnalog();
63  return hit.energy() * simHitToCharge;
64 }
65 
66 double CastorHitCorrection::delay(const PCaloHit & hit, CLHEP::HepRandomEngine*) const
67 {
68  // HO goes slow, HF shouldn't be used at all
69  //Castor not used for the moment
70 
71  DetId detId(hit.id());
72  if(detId.det()==DetId::Calo && (detId.subdetId()==HcalCastorDetId::SubdetectorId)) return 0;
73 
74  HcalDetId hcalDetId(hit.id());
75  if(hcalDetId.subdet() == HcalForward) return 0;
76  CastorTimeSlew::BiasSetting biasSetting = (hcalDetId.subdet() == HcalOuter) ?
79  double delay = 0.;
80  int tbin = timeBin(hit);
81  if(tbin >= 0 && tbin < 10)
82  {
83  ChargeSumsByChannel::const_iterator totalChargeItr = theChargeSumsForTimeBin[tbin].find(detId);
84  if(totalChargeItr == theChargeSumsForTimeBin[tbin].end())
85  {
86  throw cms::Exception("CastorHitCorrection") << "Cannot find HCAL/CASTOR charge sum for hit " << hit;
87  }
88  double totalCharge = totalChargeItr->second;
89  delay = CastorTimeSlew::delay(totalCharge, biasSetting);
90  LogDebug("CastorHitCorrection") << "TIMESLEWcharge " << charge(hit)
91  << " totalcharge " << totalCharge
92  << " olddelay " << CastorTimeSlew::delay(charge(hit), biasSetting)
93  << " newdelay " << delay;
94  }
95 
96  return delay;
97 }
98 
99 
101 {
103  double t = hit.time() - timeOfFlight(DetId(hit.id())) + parameters.timePhase();
104  return static_cast<int> (t / 25) + parameters.binOfMaximum() - 1;
105 }
106 
107 
108 double CastorHitCorrection::timeOfFlight(const DetId & detId) const
109 {
110  if(detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId)
111  return 37.666;
112  else
113  throw cms::Exception("not HcalCastorDetId");
114 }
115 
#define LogDebug(id)
double timeOfFlight(const DetId &id) const
simple average approximation
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...
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
double time() const
Definition: PCaloHit.h:36
virtual double delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const
how much delay this hit will get
int timeBin(const PCaloHit &hit) const
which time bin the peak of the signal will fall in
void fillChargeSums(MixCollection< PCaloHit > &hits)
double energy() const
Definition: PCaloHit.h:29
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 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
static const int SubdetectorId
CastorHitCorrection(const CaloVSimParameterMap *parameterMap)
Definition: DetId.h:18
iterator begin()
const CaloVSimParameterMap * theParameterMap
double charge(const PCaloHit &hit) const
how much charge we expect from this hit
ChargeSumsByChannel theChargeSumsForTimeBin[10]
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
int binOfMaximum() const