Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:38:08

0001 #ifndef simcalorimetry_hgcalsimalgos_hgcalsinoisemap
0002 #define simcalorimetry_hgcalsimalgos_hgcalsinoisemap
0003 
0004 #include "SimCalorimetry/HGCalSimAlgos/interface/HGCalRadiationMap.h"
0005 #include "SimCalorimetry/HGCalSimProducers/interface/HGCFEElectronics.h"
0006 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0007 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0008 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0009 #include <string>
0010 #include <array>
0011 #include <unordered_map>
0012 
0013 /**
0014    @class HGCalSiNoiseMap
0015    @short derives from HGCalRadiation map to parse fluence parameters, provides Si-specific functions; see DN-19-045
0016 */
0017 template <typename T>
0018 class HGCalSiNoiseMap : public HGCalRadiationMap {
0019 public:
0020   enum GainRange_t { q80fC, q160fC, q320fC, AUTO };
0021   enum NoiseMapAlgoBits_t { FLUENCE, CCE, NOISE, PULSEPERGAIN, CACHEDOP };
0022 
0023   struct SiCellOpCharacteristicsCore {
0024     SiCellOpCharacteristicsCore() : cce(0.), noise(0.), gain(0), thrADC(0) {}
0025     float cce, noise;
0026     unsigned short gain, thrADC;
0027   };
0028 
0029   struct SiCellOpCharacteristics {
0030     SiCellOpCharacteristics() : lnfluence(0.), fluence(0.), ileak(0.), enc_s(0.), enc_p(0.), mipfC(0), mipADC(0) {}
0031     SiCellOpCharacteristicsCore core;
0032     double lnfluence, fluence, ileak, enc_s, enc_p, mipfC;
0033     unsigned int mipADC;
0034   };
0035 
0036   HGCalSiNoiseMap();
0037   ~HGCalSiNoiseMap() {}
0038 
0039   /**
0040      @short set the ileak parameters to use
0041   */
0042   void setIleakParam(const std::vector<double> &pars) { ileakParam_ = pars; }
0043 
0044   /**
0045      @short set the cce parameters to use
0046   */
0047   void setCceParam(const std::vector<double> &parsFine,
0048                    const std::vector<double> &parsThin,
0049                    const std::vector<double> &parsThick) {
0050     cceParam_.push_back(parsFine);   //120
0051     cceParam_.push_back(parsThin);   //200
0052     cceParam_.push_back(parsThick);  //300
0053   }
0054 
0055   /**
0056      @short overrides base class method with specifics for the configuration of the algo
0057   */
0058   void setDoseMap(const std::string &, const unsigned int &);
0059 
0060   /**
0061      @short specialization of the base class method which sets the geometry so that it can instantiate an operation
0062      cache the first time it is called - intrinsically related to the valid detIds in the geometry
0063      the filling of the cache is ignored by configuration or if it has already been filled
0064    */
0065   void setGeometry(const CaloSubdetectorGeometry *, GainRange_t gain = GainRange_t::AUTO, int aimMIPtoADC = 10);
0066 
0067   /**
0068      @short returns the charge collection efficiency and noise
0069      if gain range is set to auto, it will find the most appropriate gain to put the mip peak close to 10 ADC counts
0070   */
0071   const SiCellOpCharacteristicsCore getSiCellOpCharacteristicsCore(const T &did, GainRange_t gain, int aimMIPtoADC);
0072   const SiCellOpCharacteristicsCore getSiCellOpCharacteristicsCore(const T &did) {
0073     return getSiCellOpCharacteristicsCore(did, defaultGain_, defaultAimMIPtoADC_);
0074   }
0075 
0076   SiCellOpCharacteristics getSiCellOpCharacteristics(const T &did,
0077                                                      GainRange_t gain = GainRange_t::AUTO,
0078                                                      int aimMIPtoADC = 10);
0079   SiCellOpCharacteristics getSiCellOpCharacteristics(double &cellCap,
0080                                                      double &cellVol,
0081                                                      double &mipEqfC,
0082                                                      std::vector<double> &cceParam,
0083                                                      int &subdet,
0084                                                      int &layer,
0085                                                      double &radius,
0086                                                      GainRange_t &gain,
0087                                                      int &aimMIPtoADC);
0088 
0089   std::array<double, 3> &getMipEqfC() { return mipEqfC_; }
0090   std::array<double, 3> &getCellCapacitance() { return cellCapacitance_; }
0091   std::array<double, 3> &getCellVolume() { return cellVolume_; }
0092   std::vector<std::vector<double> > &getCCEParam() { return cceParam_; }
0093   std::vector<double> &getIleakParam() { return ileakParam_; }
0094   std::vector<std::vector<double> > &getENCsParam() { return encsParam_; }
0095   std::vector<double> &getLSBPerGain() { return lsbPerGain_; }
0096   void setDefaultADCPulseShape(const hgc_digi::FEADCPulseShape &adcPulse) { defaultADCPulse_ = adcPulse; };
0097   const hgc_digi::FEADCPulseShape &adcPulseForGain(GainRange_t gain) {
0098     if (ignoreGainDependentPulse_)
0099       return defaultADCPulse_;
0100     return adcPulses_[gain];
0101   };
0102   std::vector<double> &getMaxADCPerGain() { return chargeAtFullScaleADCPerGain_; }
0103   double getENCpad(double ileak);
0104   void setCachedOp(bool flag) { activateCachedOp_ = flag; }
0105   double getTDCOnsetAuto(uint32_t gainIdx);
0106 
0107   inline void setENCCommonNoiseSubScale(double val) { encCommonNoiseSub_ = val; }
0108 
0109 private:
0110   GainRange_t defaultGain_;
0111   int defaultAimMIPtoADC_;
0112 
0113   //cache of SiCellOpCharacteristics
0114   std::map<uint32_t, SiCellOpCharacteristicsCore> siopCache_;
0115 
0116   //vector of three params, per sensor type: 0:120 [mum], 1:200, 2:300
0117   std::array<double, 3> mipEqfC_, cellCapacitance_, cellVolume_;
0118   std::vector<std::vector<double> > cceParam_;
0119 
0120   //leakage current/volume vs fluence
0121   std::vector<double> ileakParam_;
0122 
0123   //common noise subtraction noise (final scaling value)
0124   double encCommonNoiseSub_;
0125 
0126   //electron charge in fC
0127   const double qe2fc_;
0128 
0129   //electronics noise (series+parallel) polynomial coeffs and ADC pulses;
0130   std::vector<std::vector<double> > encsParam_;
0131   hgc_digi::FEADCPulseShape defaultADCPulse_;
0132   std::vector<hgc_digi::FEADCPulseShape> adcPulses_;
0133 
0134   //lsb
0135   std::vector<double> lsbPerGain_, chargeAtFullScaleADCPerGain_;
0136 
0137   //conversions
0138   const double unitToMicro_ = 1.e6;
0139   const double unitToMicroLog_ = log(unitToMicro_);
0140 
0141   //flags used to disable specific components of the Si operation parameters or usage of operation cache
0142   bool ignoreFluence_, ignoreCCE_, ignoreNoise_, ignoreGainDependentPulse_, activateCachedOp_;
0143 };
0144 
0145 #include "HGCalSiNoiseMap.icc"
0146 
0147 template class HGCalSiNoiseMap<HGCSiliconDetId>;
0148 template class HGCalSiNoiseMap<HFNoseDetId>;
0149 
0150 #endif