CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CaloOnlineTools/HcalOnlineDb/src/WriteL1TriggerObjetsXml.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    WriteL1TriggerObjetsXml
00004 // Class:      WriteL1TriggerObjetsXml
00005 // 
00013 //
00014 // Original Author:  Ka Vang TSANG
00015 //         Created:  Fri Jul 31 15:18:53 CEST 2009
00016 // $Id: WriteL1TriggerObjetsXml.cc,v 1.1 2009/09/23 22:06:28 kukartse Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 #include <string>
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/Frameworkfwd.h"
00027 #include "FWCore/Framework/interface/EDAnalyzer.h"
00028 
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00033 
00034 #include "CaloOnlineTools/HcalOnlineDb/interface/HcalL1TriggerObjectsXml.h"
00035 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00036 #include "CalibFormats/HcalObjects/interface/HcalCalibrations.h"
00037 #include "CalibFormats/HcalObjects/interface/HcalDbService.h"
00038 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
00039 #include "FWCore/Framework/interface/ESHandle.h"
00040 
00041 //
00042 // class decleration
00043 //
00044 
00045 class WriteL1TriggerObjetsXml : public edm::EDAnalyzer {
00046    public:
00047       explicit WriteL1TriggerObjetsXml(const edm::ParameterSet&);
00048       ~WriteL1TriggerObjetsXml();
00049 
00050 
00051    private:
00052       virtual void beginJob() ;
00053       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00054       virtual void endJob() ;
00055 
00056       // ----------member data ---------------------------
00057       std::string tagname_;
00058 };
00059 
00060 //
00061 // constants, enums and typedefs
00062 //
00063 
00064 //
00065 // static data member definitions
00066 //
00067 
00068 //
00069 // constructors and destructor
00070 //
00071 WriteL1TriggerObjetsXml::WriteL1TriggerObjetsXml(const edm::ParameterSet& iConfig) : tagname_(iConfig.getParameter<std::string>("TagName"))
00072 {
00073    //now do what ever initialization is needed
00074 
00075 }
00076 
00077 
00078 WriteL1TriggerObjetsXml::~WriteL1TriggerObjetsXml()
00079 {
00080  
00081    // do anything here that needs to be done at desctruction time
00082    // (e.g. close files, deallocate resources etc.)
00083 
00084 }
00085 
00086 
00087 //
00088 // member functions
00089 //
00090 
00091 // ------------ method called to for each event  ------------
00092 void
00093 WriteL1TriggerObjetsXml::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00094 {
00095    using namespace edm;
00096    edm::ESHandle<HcalDbService> conditions;
00097    iSetup.get<HcalDbRecord>().get(conditions);
00098 
00099    HcalSubdetector subDet[3] = {HcalBarrel, HcalEndcap, HcalForward};
00100    std::string subDetName[3] = {"HB", "HE", "HF"};
00101 
00102    HcalL1TriggerObjectsXml xml(tagname_);
00103    for (int isub = 0; isub < 3; ++isub){
00104       for (int ieta = -41; ieta <= 41; ++ieta){
00105          for (int iphi = 1; iphi <=72; ++iphi){
00106             for (int depth = 1; depth <= 3; ++depth){
00107                if (!HcalDetId::validDetId(subDet[isub], ieta, iphi, depth)) continue;
00108                HcalDetId id(subDet[isub], ieta, iphi, depth);
00109                HcalCalibrations calibrations = conditions->getHcalCalibrations(id);
00110                const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(id);
00111                uint32_t status = channelStatus->getValue();
00112 
00113                double gain = 0.0;
00114                double ped = 0.0;
00115 
00116                for (int i=0; i<4; ++i) {
00117                   gain += calibrations.LUTrespcorrgain(i);
00118                   ped += calibrations.pedestal(i);
00119                }
00120                gain /= 4.;
00121                ped /= 4.;
00122 
00123                xml.add_hcal_channel_dataset(ieta, iphi, depth, subDetName[isub], ped, gain, status);
00124             }// for depth
00125          }// for iphi
00126       }// for ieta
00127    }// for subdet
00128 
00129    std::string xmlOutputFileName(tagname_);
00130    xmlOutputFileName += ".xml";
00131    xml.write(xmlOutputFileName);
00132 }
00133 
00134 // ------------ method called once each job just before starting event loop  ------------
00135 void 
00136 WriteL1TriggerObjetsXml::beginJob()
00137 {
00138 }
00139 
00140 // ------------ method called once each job just after ending the event loop  ------------
00141 void 
00142 WriteL1TriggerObjetsXml::endJob() {
00143 }
00144 
00145 //define this as a plug-in
00146 DEFINE_FWK_MODULE(WriteL1TriggerObjetsXml);