CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CalibCalorimetry/EcalTPGTools/plugins/EcalTPGParamBuilder.h

Go to the documentation of this file.
00001 #ifndef ECALTPGPARAMBUILDER_H
00002 #define ECALTPGPARAMBUILDER_H
00003 
00004 //Author: Pascal Paganini - LLR
00005 //Date: 2006/07/10 15:58:06 $
00006 
00007 #define CMSSW_VERSION 340
00008 
00009 
00010 // system include files
00011 #include <memory>
00012 
00013 // user include files
00014 #include "FWCore/Framework/interface/Frameworkfwd.h"
00015 #include "FWCore/Framework/interface/EDAnalyzer.h"
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 #include "FWCore/Framework/interface/EventSetup.h"
00020 #include "FWCore/Framework/interface/ESHandle.h"
00021 
00022 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00023 
00024 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00025 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00026 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
00027 #include "OnlineDB/EcalCondDB/interface/all_monitoring_types.h"
00028 #include "OnlineDB/EcalCondDB/interface/all_fe_config_types.h"
00029 
00030 #if (CMSSW_VERSION>=340)
00031 #include "SimCalorimetry/EcalSimAlgos/interface/EcalShapeBase.h"
00032 #else
00033 #include "SimCalorimetry/EcalSimAlgos/interface/EcalShape.h"
00034 #endif
00035 
00036 
00037 #include <TH1F.h>
00038 
00039 #include <vector>
00040 #include <string>
00041 #include <map>
00042 #include <iostream>
00043 
00044 class CaloSubdetectorGeometry ;
00045 class EcalElectronicsMapping ;
00046 class EcalTPGDBApp ;
00047 
00048 class coeffStruc {
00049  public:
00050   coeffStruc() { }
00051   double calibCoeff_ ;
00052   double gainRatio_[3] ;
00053   int pedestals_[3] ;
00054 };
00055 
00056 class linStruc {
00057  public:
00058   linStruc() { }
00059   int pedestal_[3] ;
00060   int mult_[3] ;
00061   int shift_[3] ;
00062 };
00063 
00064 class EcalTPGParamBuilder : public edm::EDAnalyzer {
00065 
00066  public:
00067   explicit EcalTPGParamBuilder(edm::ParameterSet const& pSet) ;
00068   ~EcalTPGParamBuilder() ;
00069   virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) ;
00070   virtual void beginJob() ;
00071   bool checkIfOK (EcalPedestals::Item item) ;
00072 
00073  private:
00074   bool computeLinearizerParam(double theta, double gainRatio, double calibCoeff, std::string subdet, int & mult , int & shift) ;
00075   void create_header() ;
00076   int uncodeWeight(double weight, int complement2 = 7) ;
00077   double uncodeWeight(int iweight, int complement2 = 7) ;
00078 #if (CMSSW_VERSION>=340)
00079   std::vector<unsigned int> computeWeights(EcalShapeBase & shape, TH1F * histo) ;
00080 #else
00081   std::vector<unsigned int> computeWeights(EcalShape & shape, TH1F * histo) ;
00082 #endif
00083   void computeLUT(int * lut, std::string det="EB")  ;
00084   void getCoeff(coeffStruc & coeff, const EcalIntercalibConstantMap & calibMap, uint rawId) ;
00085   void getCoeff(coeffStruc & coeff, const EcalGainRatioMap & gainMap, uint rawId) ;
00086   void getCoeff(coeffStruc & coeff, const EcalPedestalsMap & pedMap, uint rawId) ;
00087   void getCoeff(coeffStruc & coeff, const std::map<EcalLogicID, MonPedestalsDat> & pedMap, const EcalLogicID & logicId) ;
00088 
00089   void computeFineGrainEBParameters(uint & lowRatio, uint & highRatio,
00090                                     uint & lowThreshold, uint & highThreshold, uint & lut) ;
00091   void computeFineGrainEEParameters(uint & threshold, uint & lut_strip, uint & lut_tower) ;
00092   int getEtaSlice(int tccId, int towerInTCC) ;
00093   bool realignBaseline(linStruc & lin, float forceBase12) ;
00094   int getGCTRegionPhi(int ttphi) ;
00095   int getGCTRegionEta(int tteta) ;
00096   std::string getDet(int tcc) ;
00097   std::pair < std::string, int > getCrate(int tcc) ;
00098 
00099   const CaloSubdetectorGeometry * theEndcapGeometry_ ;
00100   const CaloSubdetectorGeometry * theBarrelGeometry_ ;
00101   edm::ESHandle<EcalTrigTowerConstituentsMap> eTTmap_;
00102   const EcalElectronicsMapping * theMapping_ ;
00103 
00104   bool useTransverseEnergy_ ;
00105   double xtal_LSB_EB_ , xtal_LSB_EE_ ;
00106   double Et_sat_EB_,  Et_sat_EE_ ;
00107   unsigned int sliding_ ;
00108   unsigned int sampleMax_ ;
00109   double weight_timeShift_ ;
00110   bool weight_unbias_recovery_ ;
00111   unsigned int nSample_ ;
00112   unsigned int complement2_ ;
00113   std::string LUT_option_ ;
00114   double LUT_threshold_EB_, LUT_threshold_EE_ ;
00115   double LUT_stochastic_EB_, LUT_noise_EB_, LUT_constant_EB_ ;
00116   double LUT_stochastic_EE_, LUT_noise_EE_, LUT_constant_EE_ ;
00117   double TTF_lowThreshold_EB_, TTF_highThreshold_EB_ ;
00118   double TTF_lowThreshold_EE_, TTF_highThreshold_EE_ ;
00119   double FG_lowThreshold_EB_, FG_highThreshold_EB_, FG_lowRatio_EB_, FG_highRatio_EB_ ; 
00120   unsigned int FG_lut_EB_ ;
00121   double FG_Threshold_EE_ ;
00122   unsigned int FG_lut_strip_EE_, FG_lut_tower_EE_ ;
00123   int forcedPedestalValue_ ;
00124   bool forceEtaSlice_ ;
00125   unsigned int SFGVB_Threshold_, SFGVB_lut_, pedestal_offset_ ;
00126   int SFGVB_SpikeKillingThreshold_; //modif-alex 01/21/11
00127   bool useInterCalibration_, H2_ ;
00128 
00129   //modif-alex-02/02/11
00130   std::string TimingDelays_EB_;
00131   std::string TimingDelays_EE_;
00132   std::string TimingPhases_EB_;
00133   std::string TimingPhases_EE_;
00134   std::map<int, std::vector<int> > delays_EB_ ; 
00135   std::map<int, std::vector<int> > phases_EB_ ; 
00136   std::map<int, std::vector<int> > delays_EE_ ; 
00137   std::map<int, std::vector<int> > phases_EE_ ; 
00138 
00139   std::ofstream * out_file_ ;
00140   std::ofstream * geomFile_ ;
00141   EcalTPGDBApp * db_ ;
00142   bool writeToDB_ ;
00143   bool writeToFiles_ ;
00144   unsigned int DBrunNb_ ;
00145   bool DBEE_ ;
00146 
00147   int ped_conf_id_;
00148   int lin_conf_id_;
00149   int lut_conf_id_;
00150   int fgr_conf_id_;
00151   int sli_conf_id_;
00152   int wei_conf_id_;
00153   int spi_conf_id_; //modif-alex 21/01.11
00154   int del_conf_id_; //modif-alex 21/01.11
00155   int bxt_conf_id_;
00156   int btt_conf_id_;
00157   int bst_conf_id_;
00158   std::string tag_;
00159   int version_;
00160   int m_write_ped;
00161   int m_write_lin;
00162   int m_write_lut;
00163   int m_write_wei;
00164   int m_write_fgr;
00165   int m_write_sli;
00166   int m_write_spi; //modif-alex 21/01/11
00167   int m_write_del; //modif-alex 21/01/11
00168   int m_write_bxt;
00169   int m_write_btt;
00170   int m_write_bst;
00171 
00172   Int_t * ntupleInts_ ;
00173   Char_t ntupleDet_[10] ;
00174   Char_t ntupleCrate_[10] ;
00175 
00176 };
00177 #endif