CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/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, unsigned int rawId) ;
00085   void getCoeff(coeffStruc & coeff, const EcalGainRatioMap & gainMap, unsigned int rawId) ;
00086   void getCoeff(coeffStruc & coeff, const EcalPedestalsMap & pedMap, unsigned int rawId) ;
00087   void getCoeff(coeffStruc & coeff, const std::map<EcalLogicID, MonPedestalsDat> & pedMap, const EcalLogicID & logicId) ;
00088 
00089   void computeFineGrainEBParameters(unsigned int & lowRatio, unsigned int & highRatio,
00090                                     unsigned int & lowThreshold, unsigned int & highThreshold, unsigned int & lut) ;
00091   void computeFineGrainEEParameters(unsigned int & threshold, unsigned int & lut_strip, unsigned int & 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   bool useInterCalibration_ ;
00127 
00128 
00129   std::ofstream * out_file_ ;
00130   std::ofstream * geomFile_ ;
00131   EcalTPGDBApp * db_ ;
00132   bool writeToDB_ ;
00133   bool writeToFiles_ ;
00134   unsigned int DBrunNb_ ;
00135   bool DBEE_ ;
00136 
00137   int ped_conf_id_;
00138   int lin_conf_id_;
00139   int lut_conf_id_;
00140   int fgr_conf_id_;
00141   int sli_conf_id_;
00142   int wei_conf_id_;
00143   int bxt_conf_id_;
00144   int btt_conf_id_;
00145   std::string tag_;
00146   int version_;
00147   int m_write_ped;
00148   int m_write_lin;
00149   int m_write_lut;
00150   int m_write_wei;
00151   int m_write_fgr;
00152   int m_write_sli;
00153   int m_write_bxt;
00154   int m_write_btt;
00155 
00156   Float_t * ntupleFloats_ ;
00157   Char_t ntupleDet_[10] ;
00158   Char_t ntupleCrate_[10] ;
00159 
00160 };
00161 #endif