Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:52

0001 #ifndef RecoLocalCalo_HGCalRecAlgos_HGCalRecHitSimpleAlgo_HH
0002 #define RecoLocalCalo_HGCalRecAlgos_HGCalRecHitSimpleAlgo_HH
0003 
0004 /** \class HGCalRecHitSimpleAlgo
0005   *  Simple algoritm to make HGCAL rechits from HGCAL uncalibrated rechits
0006   *  , following Ecal sceleton
0007   *
0008   *  \author Valeri Andreev
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   // default ctor
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   // destructor
0039   ~HGCalRecHitSimpleAlgo() override{};
0040 
0041   /// Compute parameters
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     //    float clockToNsConstant = 25;
0053     float energy = (hfnose ? (uncalibRH.amplitude() * weightsNose_[layer] * 0.001f)
0054                            : (uncalibRH.amplitude() * weights_[layer] * 0.001f));
0055     float time = uncalibRH.jitter();
0056 
0057     //if(time<0) time   = 0; // fast-track digi conversion
0058 
0059     HGCRecHit rh(uncalibRH.id(), energy, time);
0060 
0061     // Now fill flags
0062     // all rechits from the digitizer are "good" at present
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