CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibCalorimetry/CaloTPG/plugins/CaloTPGTranscoderULUTs.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CaloTPGTranscoderULUTs
00004 // Class:      CaloTPGTranscoderULUTs
00005 // 
00013 //
00014 // Original Author:  Jeremiah Mans
00015 //         Created:  Fri Sep 15 11:49:44 CDT 2006
00016 // $Id: CaloTPGTranscoderULUTs.cc,v 1.5 2009/10/27 12:08:49 kvtsang Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 
00026 #include "FWCore/Framework/interface/SourceFactory.h"
00027 #include "FWCore/Framework/interface/ESProducer.h"
00028 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00029 
00030 #include "CalibCalorimetry/CaloTPG/src/CaloTPGTranscoderULUT.h"
00031 #include "CalibFormats/CaloTPG/interface/CaloTPGRecord.h"
00032 #include "FWCore/Framework/interface/ValidityInterval.h"
00033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00034 
00035 
00036 //
00037 // class decleration
00038 //
00039 
00040 class CaloTPGTranscoderULUTs : public edm::ESProducer,
00041                          public edm::EventSetupRecordIntervalFinder {
00042 public:
00043   CaloTPGTranscoderULUTs(const edm::ParameterSet&);
00044   ~CaloTPGTranscoderULUTs();
00045   
00046   typedef std::auto_ptr<CaloTPGTranscoder> ReturnType;
00047   
00048   ReturnType produce(const CaloTPGRecord&);
00049 
00050   void setIntervalFor(const edm::eventsetup::EventSetupRecordKey& iKey, const edm::IOVSyncValue& iTime, edm::ValidityInterval& oInterval ) {
00051     oInterval = edm::ValidityInterval (edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime()); //infinite
00052   }
00053 private:
00054   // ----------member data ---------------------------
00055   edm::FileInPath hfilename1_;
00056   edm::FileInPath hfilename2_;
00057   bool read_Ascii_Compression;
00058   bool read_Ascii_RCT;
00059   std::vector<int> ietal;
00060   std::vector<int> ietah;
00061   std::vector<int> ZS;
00062   std::vector<int> LUTfactor;
00063   double nominal_gain;
00064   double RCTLSB;
00065 };
00066 
00067 //
00068 // constants, enums and typedefs
00069 //
00070 
00071 //
00072 // static data member definitions
00073 //
00074 
00075 //
00076 // constructors and destructor
00077 //
00078 CaloTPGTranscoderULUTs::CaloTPGTranscoderULUTs(const edm::ParameterSet& iConfig) :
00079   hfilename1_(iConfig.getParameter<edm::FileInPath>("hcalLUT1")),
00080   hfilename2_(iConfig.getParameter<edm::FileInPath>("hcalLUT2"))
00081 {
00082    //the following line is needed to tell the framework what
00083    // data is being produced
00084    setWhatProduced(this);
00085    findingRecord<CaloTPGRecord>();
00086 
00087    //now do what ever other initialization is needed
00088    read_Ascii_Compression = false;
00089    read_Ascii_RCT = false;
00090    read_Ascii_Compression=iConfig.getParameter<bool>("read_Ascii_Compression_LUTs");
00091    read_Ascii_RCT=iConfig.getParameter<bool>("read_Ascii_RCT_LUTs");
00092 
00093    ietal = iConfig.getParameter< std::vector<int> >("ietaLowerBound");
00094    ietah = iConfig.getParameter< std::vector<int> >("ietaUpperBound");
00095    ZS = iConfig.getParameter< std::vector<int> >("ZS");
00096    LUTfactor = iConfig.getParameter< std::vector<int> >("LUTfactor");
00097    nominal_gain = iConfig.getParameter<double>("nominal_gain");
00098    RCTLSB = iConfig.getParameter<double>("RCTLSB");
00099 
00100 }
00101 
00102 
00103 CaloTPGTranscoderULUTs::~CaloTPGTranscoderULUTs()
00104 {
00105  
00106    // do anything here that needs to be done at desctruction time
00107    // (e.g. close files, deallocate resources etc.)
00108 
00109 }
00110 
00111 
00112 //
00113 // member functions
00114 //
00115 
00116 // ------------ method called to produce the data  ------------
00117 CaloTPGTranscoderULUTs::ReturnType
00118 CaloTPGTranscoderULUTs::produce(const CaloTPGRecord& iRecord)
00119 {
00120    using namespace edm::es;
00121    std::string file1="";
00122    std::string file2="";
00123    if (read_Ascii_RCT && read_Ascii_Compression) {
00124          edm::LogInfo("Level1") << "Using " << hfilename1_.fullPath() << " & " << hfilename2_.fullPath()
00125                           << " for CaloTPGTranscoderULUTs HCAL initialization";
00126          //std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(hfilename1_.fullPath(), hfilename2_.fullPath()));
00127          //return pTCoder;
00128        file1 = hfilename1_.fullPath();
00129        file2 = hfilename2_.fullPath();
00130    } else if (read_Ascii_RCT && !read_Ascii_Compression) {
00131          edm::LogInfo("Level1") << "Using analytical compression and " << hfilename2_.fullPath()
00132                           << " RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
00133          //std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT("", hfilename2_.fullPath()));
00134          //return pTCoder;
00135        file2 = hfilename2_.fullPath();
00136    } else if (read_Ascii_Compression && !read_Ascii_RCT) {
00137          edm::LogInfo("Level1") << "Using ASCII compression tables " << hfilename1_.fullPath()
00138                           << " and automatic RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
00139          //std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(hfilename1_.fullPath(),""));
00140      //return pTCoder;
00141        file1 = hfilename1_.fullPath();
00142    } else {
00143          edm::LogInfo("Level1") << "Using analytical compression and RCT decompression for CaloTPGTranscoderULUTs HCAL initialization";
00144          //std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT());
00145          //return pTCoder;
00146    }
00147    //std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(ietal, ietah, ZS, LUTfactor, RCTLSB, nominal_gain, file1, file2));
00148    std::auto_ptr<CaloTPGTranscoder> pTCoder(new CaloTPGTranscoderULUT(file1, file2));
00149    return pTCoder;
00150 }
00151 
00152 //define this as a plug-in
00153 DEFINE_FWK_EVENTSETUP_SOURCE(CaloTPGTranscoderULUTs);