File indexing completed on 2024-09-07 04:37:37
0001 #ifndef RecoLocalCalo_HGCalRecAlgos_HGCalRecHitSimpleAlgo_HH
0002 #define RecoLocalCalo_HGCalRecAlgos_HGCalRecHitSimpleAlgo_HH
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "FWCore/Utilities/interface/Exception.h"
0012 #include "RecoLocalCalo/HGCalRecAlgos/interface/HGCalRecHitAbsAlgo.h"
0013 #include "DataFormats/HGCDigi/interface/HGCDataFrame.h"
0014 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0015 #include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
0016 #include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h"
0017 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0018 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
0019 #include <iostream>
0020
0021 class HGCalRecHitSimpleAlgo : public HGCalRecHitAbsAlgo {
0022 public:
0023
0024 HGCalRecHitSimpleAlgo() {
0025 adcToGeVConstant_ = -1;
0026 adcToGeVConstantIsSet_ = false;
0027 }
0028
0029 void setLayerWeights(const std::vector<float>& weights) override { weights_ = weights; }
0030
0031 void setNoseLayerWeights(const std::vector<float>& weights) { weightsNose_ = weights; }
0032
0033 void setADCToGeVConstant(const float value) override {
0034 adcToGeVConstant_ = value;
0035 adcToGeVConstantIsSet_ = true;
0036 }
0037
0038
0039 ~HGCalRecHitSimpleAlgo() override {}
0040
0041
0042 HGCRecHit makeRecHit(const HGCUncalibratedRecHit& uncalibRH, const uint32_t& flags = 0) const override {
0043 if (!adcToGeVConstantIsSet_) {
0044 throw cms::Exception("HGCalRecHitSimpleAlgoBadConfig")
0045 << "makeRecHit: adcToGeVConstant_ not set before calling this method!";
0046 }
0047
0048 DetId baseid = uncalibRH.id();
0049 unsigned layer = rhtools_.getLayerWithOffset(baseid);
0050 bool hfnose = DetId::Forward == baseid.det() && HFNose == baseid.subdetId();
0051
0052
0053 float energy = (hfnose ? (uncalibRH.amplitude() * weightsNose_[layer] * 0.001f)
0054 : (uncalibRH.amplitude() * weights_[layer] * 0.001f));
0055 float time = uncalibRH.jitter();
0056
0057
0058
0059 HGCRecHit rh(uncalibRH.id(), energy, time);
0060
0061
0062
0063 rh.setFlag(HGCRecHit::kGood);
0064
0065 return rh;
0066 }
0067
0068 private:
0069 float adcToGeVConstant_;
0070 bool adcToGeVConstantIsSet_;
0071 std::vector<float> weights_, weightsNose_;
0072 };
0073 #endif