Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:01

0001 #ifndef CalibCalorimetry_EcalTPGTools_EcalTPGParamBuilder_h
0002 #define CalibCalorimetry_EcalTPGTools_EcalTPGParamBuilder_h
0003 
0004 //Author: Pascal Paganini - LLR
0005 //Date: 2006/07/10 15:58:06 $
0006 
0007 // system include files
0008 #include <memory>
0009 
0010 // user include files
0011 #include "FWCore/Framework/interface/Frameworkfwd.h"
0012 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/MakerMacros.h"
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/Framework/interface/EventSetup.h"
0017 #include "FWCore/Utilities/interface/ESGetToken.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 
0020 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0021 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
0022 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0023 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0024 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0025 
0026 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
0027 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
0028 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0029 #include "CondFormats/DataRecord/interface/EcalLaserAlphasRcd.h"
0030 #include "CondFormats/DataRecord/interface/EcalLaserAPDPNRatiosRcd.h"
0031 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0032 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
0033 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0034 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0035 #include "CondFormats/EcalObjects/interface/EcalLaserAPDPNRatios.h"
0036 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0037 #include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
0038 #include "OnlineDB/EcalCondDB/interface/all_fe_config_types.h"
0039 
0040 //modif-alex-27-july-2015
0041 #include "CondFormats/EcalObjects/interface/EcalLaserAlphas.h"
0042 
0043 #include "SimCalorimetry/EcalSimAlgos/interface/EcalShapeBase.h"
0044 #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h"
0045 #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h"
0046 
0047 #include <TH1F.h>
0048 
0049 #include <vector>
0050 #include <string>
0051 #include <map>
0052 #include <iostream>
0053 
0054 class EcalTPGDBApp;
0055 
0056 class coeffStruc {
0057 public:
0058   coeffStruc() {}
0059   double calibCoeff_;
0060   double gainRatio_[3];
0061   int pedestals_[3];
0062 };
0063 
0064 class linStruc {
0065 public:
0066   linStruc() {}
0067   int pedestal_[3];
0068   int mult_[3];
0069   int shift_[3];
0070 };
0071 
0072 class EcalTPGParamBuilder : public edm::one::EDAnalyzer<> {
0073 public:
0074   explicit EcalTPGParamBuilder(edm::ParameterSet const& pSet);
0075   ~EcalTPGParamBuilder() override;
0076   void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) override;
0077   void beginJob() override;
0078 
0079 private:
0080   bool checkIfOK(EcalPedestals::Item item);
0081   bool computeLinearizerParam(
0082       double theta, double gainRatio, double calibCoeff, std::string subdet, int& mult, int& shift);
0083   void create_header();
0084   int uncodeWeight(double weight, int complement2 = 7);
0085   double uncodeWeight(int iweight, int complement2 = 7);
0086   std::vector<unsigned int> computeWeights(EcalShapeBase& shape, TH1F* histo);
0087   void computeLUT(int* lut, std::string det = "EB");
0088   //void getCoeff(coeffStruc & coeff, const EcalIntercalibConstantMap & calibMap, uint rawId) ; //modif-alex-27-july-2015 uncomment to go back
0089   void getCoeff(coeffStruc& coeff, const EcalGainRatioMap& gainMap, uint rawId);
0090   void getCoeff(coeffStruc& coeff, const EcalPedestalsMap& pedMap, uint rawId);
0091   void getCoeff(coeffStruc& coeff, const std::map<EcalLogicID, MonPedestalsDat>& pedMap, const EcalLogicID& logicId);
0092 
0093   //modif-alex-27-july-2015
0094   void getCoeff(coeffStruc& coeff,
0095                 const EcalIntercalibConstantMap& calibMap,
0096                 const EcalLaserAlphaMap& laserAlphaMap,
0097                 uint rawId,
0098                 std::string& ss);
0099 
0100   void computeFineGrainEBParameters(uint& lowRatio, uint& highRatio, uint& lowThreshold, uint& highThreshold, uint& lut);
0101   void computeFineGrainEEParameters(uint& threshold, uint& lut_strip, uint& lut_tower);
0102   int getEtaSlice(int tccId, int towerInTCC);
0103   bool realignBaseline(linStruc& lin, float forceBase12, int cmsswid);
0104   int getGCTRegionPhi(int ttphi);
0105   int getGCTRegionEta(int tteta);
0106   std::string getDet(int tcc);
0107   std::pair<std::string, int> getCrate(int tcc);
0108 
0109   edm::ESGetToken<CaloSubdetectorGeometry, EcalEndcapGeometryRecord> theEndcapGeometryToken_;
0110   edm::ESGetToken<CaloSubdetectorGeometry, EcalBarrelGeometryRecord> theBarrelGeometryToken_;
0111   const CaloSubdetectorGeometry* theEndcapGeometry_;
0112   const CaloSubdetectorGeometry* theBarrelGeometry_;
0113   edm::ESGetToken<EcalTrigTowerConstituentsMap, IdealGeometryRecord> eTTmapToken_;
0114   const EcalTrigTowerConstituentsMap* eTTmap_;
0115   edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> ecalmappingToken_;
0116   const EcalElectronicsMapping* theMapping_;
0117 
0118   edm::ESGetToken<EcalLaserAlphas, EcalLaserAlphasRcd> ecalLaserAlphasToken_;
0119   edm::ESGetToken<EcalLaserAPDPNRatios, EcalLaserAPDPNRatiosRcd> ecalLaserAPDPNRatiosToken_;
0120   edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> ecalPedestalsToken_;
0121   edm::ESGetToken<EcalIntercalibConstants, EcalIntercalibConstantsRcd> ecalIntercalibConstantsToken_;
0122   edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> ecalGainRatiosToken_;
0123   edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> ecalADCToGeVConstantToken_;
0124 
0125   bool useTransverseEnergy_;
0126   double xtal_LSB_EB_, xtal_LSB_EE_;
0127   double Et_sat_EB_, Et_sat_EE_;
0128   unsigned int sliding_;
0129   unsigned int sampleMax_;
0130   double weight_timeShift_;
0131   bool weight_unbias_recovery_;
0132   bool weight_even_computeFromShape_;
0133   std::string weight_even_idMapFile_;
0134   std::string weight_even_weightGroupFile_;
0135   std::string weight_odd_idMapFile_;
0136   std::string weight_odd_weightGroupFile_;
0137   static constexpr uint NWEIGHTS = 5;  // It can be up to 6, but in Run 1,2,3 only 5 weights have been used
0138 
0139   bool weight_useDoubleWeights_;
0140   bool TPmode_EnableEBOddFilter_;
0141   bool TPmode_EnableEEOddFilter_;
0142   bool TPmode_EnableEBOddPeakFinder_;
0143   bool TPmode_EnableEEOddPeakFinder_;
0144   bool TPmode_DisableEBEvenPeakFinder_;
0145   bool TPmode_DisableEEEvenPeakFinder_;
0146   unsigned int TPmode_FenixEBStripOutput_;
0147   unsigned int TPmode_FenixEEStripOutput_;
0148   unsigned int TPmode_FenixEBStripInfobit2_;
0149   unsigned int TPmode_FenixEEStripInfobit2_;
0150   unsigned int TPmode_FenixEBTcpOutput_;
0151   unsigned int TPmode_FenixEBTcpInfobit1_;
0152   unsigned int TPmode_FenixEETcpOutput_;
0153   unsigned int TPmode_FenixEETcpInfobit1_;
0154 
0155   unsigned int nSample_;
0156   unsigned int complement2_;
0157   std::string LUT_option_;
0158   double LUT_threshold_EB_, LUT_threshold_EE_;
0159   double LUT_stochastic_EB_, LUT_noise_EB_, LUT_constant_EB_;
0160   double LUT_stochastic_EE_, LUT_noise_EE_, LUT_constant_EE_;
0161   double TTF_lowThreshold_EB_, TTF_highThreshold_EB_;
0162   double TTF_lowThreshold_EE_, TTF_highThreshold_EE_;
0163   double FG_lowThreshold_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_highRatio_EB_;
0164   unsigned int FG_lut_EB_;
0165   double FG_Threshold_EE_;
0166   unsigned int FG_lut_strip_EE_, FG_lut_tower_EE_;
0167   int forcedPedestalValue_;
0168   bool forceEtaSlice_;
0169   unsigned int SFGVB_Threshold_, SFGVB_lut_, pedestal_offset_;
0170   int SFGVB_SpikeKillingThreshold_;  //modif-alex 01/21/11
0171   bool useInterCalibration_, H2_;
0172 
0173   //modif-alex-30/01/2012
0174   std::string Transparency_Corr_;
0175   bool useTransparencyCorr_;
0176 
0177   //modif-alex-02/02/11
0178   std::string TimingDelays_EB_;
0179   std::string TimingDelays_EE_;
0180   std::string TimingPhases_EB_;
0181   std::string TimingPhases_EE_;
0182   std::map<int, std::vector<int> > delays_EB_;
0183   std::map<int, std::vector<int> > phases_EB_;
0184   std::map<int, std::vector<int> > delays_EE_;
0185   std::map<int, std::vector<int> > phases_EE_;
0186 
0187   //modif-alex 30/01/2012
0188   std::map<int, double> Transparency_Correction_;
0189 
0190   EBShape shapeEB_;
0191   EEShape shapeEE_;
0192 
0193   std::ofstream* out_file_;
0194   std::ofstream* geomFile_;
0195   EcalTPGDBApp* db_;
0196   bool writeToDB_;
0197   bool writeToFiles_;
0198   unsigned int DBrunNb_;
0199   bool DBEE_;
0200 
0201   int ped_conf_id_;
0202   int lin_conf_id_;
0203   int lut_conf_id_;
0204   int fgr_conf_id_;
0205   int sli_conf_id_;
0206   int wei_conf_id_;
0207   int wei2_conf_id_;
0208   int spi_conf_id_;  //modif-alex 21/01.11
0209   int del_conf_id_;  //modif-alex 21/01.11
0210   int bxt_conf_id_;
0211   int btt_conf_id_;
0212   int bst_conf_id_;
0213   int coke_conf_id_;
0214   std::string tag_;
0215   int version_;
0216   int m_write_ped;
0217   int m_write_lin;
0218   int m_write_lut;
0219   int m_write_wei;
0220   int m_write_wei2;
0221   int m_write_fgr;
0222   int m_write_sli;
0223   int m_write_spi;  //modif-alex 21/01/11
0224   int m_write_del;  //modif-alex 21/01/11
0225   int m_write_bxt;
0226   int m_write_btt;
0227   int m_write_bst;
0228 
0229   Int_t* ntupleInts_;
0230   Char_t ntupleDet_[10];
0231   Char_t ntupleCrate_[10];
0232 };
0233 #endif