CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoTBCalo/EcalTBTDCReconstructor/src/EcalTBTDCRawInfoDumper.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/EcalTBTDCReconstructor/interface/EcalTBTDCRawInfoDumper.h"
00002 #include "TBDataFormats/EcalTBObjects/interface/EcalTBTDCRawInfo.h"
00003 #include "DataFormats/Common/interface/EDCollection.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005 #include "FWCore/Framework/interface/Selector.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/EventSetup.h"
00008 
00009 #include <TFile.h>
00010 #include <FWCore/Framework/interface/MakerMacros.h>
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012     
00013 EcalTBTDCRawInfoDumper::EcalTBTDCRawInfoDumper(edm::ParameterSet const& ps)
00014 {
00015   rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
00016   rawInfoProducer_   = ps.getParameter<std::string>("rawInfoProducer");
00017   rootfile_          = ps.getUntrackedParameter<std::string>("rootfile","ecalTDCRawInfoPlots.root");
00018 }
00019 
00020 EcalTBTDCRawInfoDumper::~EcalTBTDCRawInfoDumper() {
00021 }
00022 
00023 //========================================================================
00024 void
00025 EcalTBTDCRawInfoDumper::beginJob() 
00026 {
00027   //========================================================================
00028   h_TDCrawValue_ = new TH1F("h_TDCrawValue","TDC raw value",2048,-0.5,2047.5);
00029 }
00030 
00031 //========================================================================
00032 void
00033 EcalTBTDCRawInfoDumper::endJob() {
00034 //========================================================================
00035   TFile f(rootfile_.c_str(),"RECREATE");
00036   h_TDCrawValue_->Write();
00037   f.Close();
00038 }
00039 
00040 void EcalTBTDCRawInfoDumper::analyze(const edm::Event& e, const edm::EventSetup& es)
00041 {
00042   // Get input
00043   edm::Handle<EcalTBTDCRawInfo> ecalRawTDC;  
00044   const EcalTBTDCRawInfo* tdcRawInfo = 0;
00045   //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00046   e.getByLabel( rawInfoProducer_, ecalRawTDC);
00047   if (!ecalRawTDC.isValid()) {
00048     edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
00049   } else {
00050     tdcRawInfo = ecalRawTDC.product();
00051   }
00052 
00053   
00054   if (tdcRawInfo)
00055     {
00056       int tdcd = (*tdcRawInfo)[0].tdcValue();
00057       h_TDCrawValue_->Fill(tdcd);
00058     }
00059   // Create empty output
00060 } 
00061 
00062