CMS 3D CMS Logo

HGCalUncalibRecHitRecWeightsAlgo.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HGCalRecAlgos_HGCalUncalibRecHitRecWeightsAlgo_HH
2 #define RecoLocalCalo_HGCalRecAlgos_HGCalUncalibRecHitRecWeightsAlgo_HH
3 
14 #include <vector>
15 #include <cmath>
16 
19 
20 template <class C>
22 public:
23  // destructor
25 
26  void set_isSiFESim(const bool isSiFE) { isSiFESim_ = isSiFE; }
27  bool isSiFESim() const { return isSiFESim_; }
28 
29  void set_ADCLSB(const double adclsb) { adcLSB_ = adclsb; }
30  void set_TDCLSB(const double tdclsb) { tdcLSB_ = tdclsb; }
31 
32  void set_toaLSBToNS(const double lsb2ns) { toaLSBToNS_ = lsb2ns; }
33 
34  void set_tdcOnsetfC(const double tdcOnset) { tdcOnsetfC_ = tdcOnset; }
35 
36  void set_fCPerMIP(const std::vector<double>& fCPerMIP) {
37  if (std::any_of(fCPerMIP.cbegin(), fCPerMIP.cend(), [](double conv) { return conv <= 0.0; })) {
38  throw cms::Exception("BadConversionFactor") << "At least one of fCPerMIP is zero!" << std::endl;
39  }
41  }
42 
44  if (geom)
45  ddd_ = &(geom->topology().dddConstants());
46  else
47  ddd_ = nullptr;
48  }
49 
51  virtual HGCUncalibratedRecHit makeRecHit(const C& dataFrame) {
52  double amplitude_(-1.), pedestal_(-1.), jitter_(-1.), chi2_(-1.);
53  uint32_t flag = 0;
54 
55  constexpr int iSample = 2; //only in-time sample
56  const auto& sample = dataFrame.sample(iSample);
57 
58  // Were digis done w/ the complete digitization and using signal shape?
59  // (originally done only for the silicon, while for scitillator it was trivial. Fomr 11_ also scinti uses shape)
60  if (isSiFESim_) {
61  // mode == true: TDC readout was activated and amplitude comes from TimeOverThreshold
62  if (sample.mode()) {
63  flag = !sample.threshold(); // raise flag if busy cell
64  // LG (23/06/2015):
65  // to get a continuous energy spectrum we must add here the maximum value in fC ever
66  // reported by the ADC. Namely: floor(tdcOnset/adcLSB_) * adcLSB_
67  // need to increment by one so TDC doesn't overlap with ADC last bin
68  // LG (11/04/2016):
69  // offset the TDC upwards to reflect the bin center
70  amplitude_ = (std::floor(tdcOnsetfC_ / adcLSB_) + 1.0) * adcLSB_ + (double(sample.data()) + 0.5) * tdcLSB_;
71 
72  if (sample.getToAValid()) {
73  jitter_ = double(sample.toa()) * toaLSBToNS_;
74  }
75  } else {
76  amplitude_ = double(sample.data()) * adcLSB_; // why do we not have +0.5 here ?
77  if (sample.getToAValid()) {
78  jitter_ = double(sample.toa()) * toaLSBToNS_;
79  }
80  } //isSiFESim_
81  } //mode()
82 
83  // trivial digitization, i.e. no signal shape
84  else {
85  amplitude_ = double(sample.data()) * adcLSB_;
86  }
87 
88  int thickness = (ddd_ != nullptr) ? ddd_->waferType(dataFrame.id()) : 0;
89  amplitude_ = amplitude_ / fCPerMIP_[thickness];
90 
91  LogDebug("HGCUncalibratedRecHit") << "isSiFESim_: " << isSiFESim_ << " ADC+: set the charge to: " << amplitude_
92  << ' ' << sample.data() << ' ' << adcLSB_ << ' '
93  << " TDC+: set the ToA to: " << jitter_ << ' ' << sample.toa()
94  << ' ' << toaLSBToNS_ << ' ' << tdcLSB_
95  << " getToAValid(): " << sample.getToAValid()
96  << " mode(): " << sample.mode() << std::endl;
97  LogDebug("HGCUncalibratedRecHit") << "Final uncalibrated amplitude : " << amplitude_ << std::endl;
98 
99  return HGCUncalibratedRecHit(dataFrame.id(), amplitude_, pedestal_, jitter_, chi2_, flag);
100  }
101 
102 private:
105  std::vector<double> fCPerMIP_;
107 };
108 #endif
HGCalUncalibRecHitRecWeightsAlgo::tdcOnsetfC_
double tdcOnsetfC_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:103
HGCalUncalibRecHitRecWeightsAlgo::set_toaLSBToNS
void set_toaLSBToNS(const double lsb2ns)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:32
HGCalUncalibRecHitRecWeightsAlgo::setGeometry
void setGeometry(const HGCalGeometry *geom)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:43
MessageLogger.h
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
conv
static HepMC::IO_HEPEVT conv
Definition: BeamHaloProducer.cc:48
HGCalUncalibRecHitRecWeightsAlgo::fCPerMIP_
std::vector< double > fCPerMIP_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:105
HGCalUncalibRecHitRecWeightsAlgo::set_ADCLSB
void set_ADCLSB(const double adclsb)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:29
HGCalUncalibRecHitRecWeightsAlgo::toaLSBToNS_
double toaLSBToNS_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:103
HGCUncalibratedRecHit
Definition: HGCUncalibratedRecHit.h:7
HGCalDDDConstants
Definition: HGCalDDDConstants.h:25
HGCalUncalibRecHit_cfi.tdcOnset
tdcOnset
Definition: HGCalUncalibRecHit_cfi.py:10
HGCalDDDConstants::waferType
int waferType(DetId const &id, bool fromFile=false) const
Definition: HGCalDDDConstants.cc:1228
HGCalUncalibRecHitRecWeightsAlgo::ddd_
const HGCalDDDConstants * ddd_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:106
HGCalUncalibRecHitRecWeightsAlgo::set_tdcOnsetfC
void set_tdcOnsetfC(const double tdcOnset)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:34
Calorimetry_cff.thickness
thickness
Definition: Calorimetry_cff.py:114
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
HGCalGeometry
Definition: HGCalGeometry.h:30
HGCalGeometry.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
HGCalUncalibRecHitRecWeightsAlgo::set_TDCLSB
void set_TDCLSB(const double tdclsb)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:30
HGCalUncalibRecHitRecWeightsAlgo::isSiFESim_
bool isSiFESim_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:104
HGCalUncalibRecHit_cfi.isSiFE
isSiFE
Definition: HGCalUncalibRecHit_cfi.py:8
HGCalUncalibRecHitRecWeightsAlgo
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:21
HGCalUncalibRecHitRecWeightsAlgo::adcLSB_
double adcLSB_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:103
HGCalUncalibRecHitRecWeightsAlgo::tdcLSB_
double tdcLSB_
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:103
HGCalUncalibRecHit_cfi.fCPerMIP
fCPerMIP
Definition: HGCalUncalibRecHit_cfi.py:7
HGCalUncalibRecHitRecWeightsAlgo::set_isSiFESim
void set_isSiFESim(const bool isSiFE)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:26
gen::C
C
Definition: PomwigHadronizer.cc:76
Exception
Definition: hltDiff.cc:246
HGCalUncalibRecHitRecWeightsAlgo::makeRecHit
virtual HGCUncalibratedRecHit makeRecHit(const C &dataFrame)
Compute HGCUncalibratedRecHit from DataFrame.
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:51
HGCalUncalibRecHitRecWeightsAlgo::isSiFESim
bool isSiFESim() const
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:27
HGCalUncalibRecHitRecAbsAlgo.h
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
HGCalUncalibRecHitRecWeightsAlgo::set_fCPerMIP
void set_fCPerMIP(const std::vector< double > &fCPerMIP)
Definition: HGCalUncalibRecHitRecWeightsAlgo.h:36