CMS 3D CMS Logo

CastorHitCorrection.cc
Go to the documentation of this file.
9 
10 CastorHitCorrection::CastorHitCorrection(const CaloVSimParameterMap *parameterMap) : theParameterMap(parameterMap) {}
11 
13  // clear();
14  for (MixCollection<PCaloHit>::MixItr hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
15  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit 0x" << std::hex << hitItr->id() << std::dec;
16  int tbin = timeBin(*hitItr);
17  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit tbin" << tbin;
18  if (tbin >= 0 && tbin < 10) {
19  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
20  }
21  }
22 }
23 
24 void CastorHitCorrection::fillChargeSums(const std::vector<PCaloHit> &hits) {
25  // clear();
26  for (std::vector<PCaloHit>::const_iterator hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
27  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit 0x" << std::hex << hitItr->id() << std::dec;
28  int tbin = timeBin(*hitItr);
29  LogDebug("CastorHitCorrection") << "CastorHitCorrection::Hit tbin" << tbin;
30  if (tbin >= 0 && tbin < 10) {
31  theChargeSumsForTimeBin[tbin][DetId(hitItr->id())] += charge(*hitItr);
32  }
33  }
34 }
35 
37  for (int i = 0; i < 10; ++i) {
38  theChargeSumsForTimeBin[i].clear();
39  }
40 }
41 
43  DetId detId(hit.id());
45  double simHitToCharge = parameters.simHitToPhotoelectrons() * parameters.photoelectronsToAnalog();
46  return hit.energy() * simHitToCharge;
47 }
48 
49 double CastorHitCorrection::delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const {
50  // HO goes slow, HF shouldn't be used at all
51  // Castor not used for the moment
52 
53  DetId detId(hit.id());
54  if (detId.det() == DetId::Calo && (detId.subdetId() == HcalCastorDetId::SubdetectorId))
55  return 0;
56 
57  HcalDetId hcalDetId(hit.id());
58  if (hcalDetId.subdet() == HcalForward)
59  return 0;
60  CastorTimeSlew::BiasSetting biasSetting =
61  (hcalDetId.subdet() == HcalOuter) ? CastorTimeSlew::Slow : CastorTimeSlew::Medium;
62  double delay = 0.;
63  int tbin = timeBin(hit);
64  if (tbin >= 0 && tbin < 10) {
65  ChargeSumsByChannel::const_iterator totalChargeItr = theChargeSumsForTimeBin[tbin].find(detId);
66  if (totalChargeItr == theChargeSumsForTimeBin[tbin].end()) {
67  throw cms::Exception("CastorHitCorrection") << "Cannot find HCAL/CASTOR charge sum for hit " << hit;
68  }
69  double totalCharge = totalChargeItr->second;
70  delay = CastorTimeSlew::delay(totalCharge, biasSetting);
71  LogDebug("CastorHitCorrection") << "TIMESLEWcharge " << charge(hit) << " totalcharge " << totalCharge
72  << " olddelay " << CastorTimeSlew::delay(charge(hit), biasSetting) << " newdelay "
73  << delay;
74  }
75 
76  return delay;
77 }
78 
81  double t = hit.time() - timeOfFlight(DetId(hit.id())) + parameters.timePhase();
82  return static_cast<int>(t / 25) + parameters.binOfMaximum() - 1;
83 }
84 
85 double CastorHitCorrection::timeOfFlight(const DetId &detId) const {
86  if (detId.det() == DetId::Calo && detId.subdetId() == HcalCastorDetId::SubdetectorId)
87  return 37.666;
88  else
89  throw cms::Exception("not HcalCastorDetId");
90 }
#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...
double time() const
Definition: PCaloHit.h:30
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:24
Main class for Parameters in different subdetectors.
double timePhase() const
the adjustment you need to apply to get the signal where you want it
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
double simHitToPhotoelectrons() const
iterator end() const
#define end
Definition: vmac.h:39
unsigned int id() const
Definition: PCaloHit.h:37
static const int SubdetectorId
CastorHitCorrection(const CaloVSimParameterMap *parameterMap)
Definition: DetId.h:18
const CaloVSimParameterMap * theParameterMap
double delay(const PCaloHit &hit, CLHEP::HepRandomEngine *) const override
how much delay this hit will get
double charge(const PCaloHit &hit) const
how much charge we expect from this hit
ChargeSumsByChannel theChargeSumsForTimeBin[10]
iterator begin() const
int binOfMaximum() const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39