CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/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.2 2012/11/12 20:49:45 dlange 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 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00041 
00042 //
00043 // class decleration
00044 //
00045 
00046 class WriteL1TriggerObjetsXml : public edm::EDAnalyzer {
00047    public:
00048       explicit WriteL1TriggerObjetsXml(const edm::ParameterSet&);
00049       ~WriteL1TriggerObjetsXml();
00050 
00051 
00052    private:
00053       virtual void beginJob() ;
00054       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00055       virtual void endJob() ;
00056 
00057       // ----------member data ---------------------------
00058       std::string tagname_;
00059 };
00060 
00061 //
00062 // constants, enums and typedefs
00063 //
00064 
00065 //
00066 // static data member definitions
00067 //
00068 
00069 //
00070 // constructors and destructor
00071 //
00072 WriteL1TriggerObjetsXml::WriteL1TriggerObjetsXml(const edm::ParameterSet& iConfig) : tagname_(iConfig.getParameter<std::string>("TagName"))
00073 {
00074    //now do what ever initialization is needed
00075 
00076 }
00077 
00078 
00079 WriteL1TriggerObjetsXml::~WriteL1TriggerObjetsXml()
00080 {
00081  
00082    // do anything here that needs to be done at desctruction time
00083    // (e.g. close files, deallocate resources etc.)
00084 
00085 }
00086 
00087 
00088 //
00089 // member functions
00090 //
00091 
00092 // ------------ method called to for each event  ------------
00093 void
00094 WriteL1TriggerObjetsXml::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00095 {
00096    using namespace edm;
00097    edm::ESHandle<HcalDbService> conditions;
00098    iSetup.get<HcalDbRecord>().get(conditions);
00099    const HcalTopology* topo=conditions->getTopologyUsed();
00100 
00101    HcalSubdetector subDet[3] = {HcalBarrel, HcalEndcap, HcalForward};
00102    std::string subDetName[3] = {"HB", "HE", "HF"};
00103 
00104    HcalL1TriggerObjectsXml xml(tagname_);
00105    for (int isub = 0; isub < 3; ++isub){
00106       for (int ieta = -41; ieta <= 41; ++ieta){
00107          for (int iphi = 1; iphi <=72; ++iphi){
00108             for (int depth = 1; depth <= 3; ++depth){
00109                HcalDetId id(subDet[isub], ieta, iphi, depth);
00110 
00111                if (!topo->valid(id)) continue;
00112                HcalCalibrations calibrations = conditions->getHcalCalibrations(id);
00113                const HcalChannelStatus* channelStatus = conditions->getHcalChannelStatus(id);
00114                uint32_t status = channelStatus->getValue();
00115 
00116                double gain = 0.0;
00117                double ped = 0.0;
00118 
00119                for (int i=0; i<4; ++i) {
00120                   gain += calibrations.LUTrespcorrgain(i);
00121                   ped += calibrations.pedestal(i);
00122                }
00123                gain /= 4.;
00124                ped /= 4.;
00125 
00126                xml.add_hcal_channel_dataset(ieta, iphi, depth, subDetName[isub], ped, gain, status);
00127             }// for depth
00128          }// for iphi
00129       }// for ieta
00130    }// for subdet
00131 
00132    std::string xmlOutputFileName(tagname_);
00133    xmlOutputFileName += ".xml";
00134    xml.write(xmlOutputFileName);
00135 }
00136 
00137 // ------------ method called once each job just before starting event loop  ------------
00138 void 
00139 WriteL1TriggerObjetsXml::beginJob()
00140 {
00141 }
00142 
00143 // ------------ method called once each job just after ending the event loop  ------------
00144 void 
00145 WriteL1TriggerObjetsXml::endJob() {
00146 }
00147 
00148 //define this as a plug-in
00149 DEFINE_FWK_MODULE(WriteL1TriggerObjetsXml);