CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CalibCalorimetry/EcalSRTools/interface/EcalDccWeightBuilder.h

Go to the documentation of this file.
00001 /*
00002  * $Id: EcalDccWeightBuilder.h,v 1.6 2009/10/09 15:55:35 pgras Exp $
00003  */
00004 
00005 #ifndef ECALDCCWEIGHTBUILDER_CC
00006 #define ECALDCCWEIGHTBUILDER_CC
00007 
00008 
00009 #include "FWCore/Framework/interface/EDAnalyzer.h"
00010 #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h"
00011 #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h"
00012 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00013 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00014 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00018 
00019 #include <vector>
00020 #include <map>
00021 #include <inttypes.h>
00022 
00023 // Forward declarations:
00024 class EcalElectronicsMapping;
00025 
00028 class EcalDccWeightBuilder: public edm::EDAnalyzer {
00029 private:
00030   enum mode_t { WEIGHTS_FROM_CONFIG, COMPUTE_WEIGHTS};
00031   
00032   //constructor(s) and destructor(s)
00033 public:
00037   EcalDccWeightBuilder(edm::ParameterSet const& ps);
00038   
00041   virtual ~EcalDccWeightBuilder(){};
00042 
00043   //method(s)
00044 public:
00045 
00050   void analyze(const edm::Event& event, const edm::EventSetup& es);
00051 
00052 private:
00053 
00067   void
00068   computeWeights(const EcalShapeBase& shape,
00069                  int binOfMax, double timePhase, 
00070                  int iFirst0, int nWeights, int iSkip0,
00071                  std::vector<double>& result);
00072 
00073   void computeAllWeights(bool withIntercalib);
00074   
00075   int encodeWeight(double w);
00076 
00077   double decodeWeight(int W);
00078 
00079   void unbiasWeights(std::vector<double>& weights,
00080                      std::vector<int32_t>* encodedWeigths);
00081 
00086   double intercalib(const DetId& detId);
00087   
00088   void writeWeightToAsciiFile();
00089   void writeWeightToRootFile();   
00090   void writeWeightToDB();
00091 
00092   //converts DetId to IDs used by DB:
00093   void dbId(const DetId& detId, int& fedId, int& smId, int& ruId,
00094            int& xtalId) const;
00095 
00102   template<class T>
00103   void sort(const std::vector<T>& a,
00104             std::vector<int>& s,
00105             bool decreasingOrder = false);
00106 
00107   
00108   //attribute(s)
00109 protected:
00110 private:
00111   int dcc1stSample_;
00112   int sampleToSkip_;
00113   int nDccWeights_;
00116   std::vector<double> inputWeights_;
00117   std::string mode_;
00118   mode_t imode_;
00119   bool dccWeightsWithIntercalib_;
00120   bool writeToDB_;
00121   bool writeToAsciiFile_;
00122   bool writeToRootFile_;
00123   std::string asciiOutputFileName_;
00124   std::string rootOutputFileName_;
00125   std::string dbSid_;
00126   std::string dbUser_;
00127   std::string dbPassword_;
00128   std::string dbTag_;
00129   int dbVersion_;
00130   bool sqlMode_;
00131   
00132   edm::ESHandle<CaloGeometry> geom_;
00133   
00134   EcalIntercalibConstantMap& calibMap_;
00135   EcalIntercalibConstantMap emptyCalibMap_;
00136   std::map<DetId, std::vector<int> > encodedWeights_;
00137 
00138   static const double weightScale_;
00139   const EcalElectronicsMapping* ecalElectronicsMap_;
00140 
00141   static const int ecalDccFedIdMin = 601;
00142   static const int ecalDccFedIdMax = 654;
00143   static const int nDccs = ecalDccFedIdMax-ecalDccFedIdMin+1;
00144 };
00145 
00146 #endif //ECALDCCWEIGHTBUILDER_CC not defined