CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoTBCalo/ZDCTBAnalysis/src/ZdcTBAnalyzer.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "FWCore/Framework/interface/Frameworkfwd.h"
00004 #include "FWCore/Framework/interface/EDAnalyzer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/Framework/interface/MakerMacros.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 
00009 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00010 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00011 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTiming.h"
00012 #include "TBDataFormats/HcalTBObjects/interface/HcalTBBeamCounters.h"
00013 #include "TBDataFormats/HcalTBObjects/interface/HcalTBEventPosition.h"
00014 #include "RecoTBCalo/ZDCTBAnalysis/interface/ZdcTBAnalysis.h"
00015 #include "TFile.h"
00016 #include "TTree.h"
00017 #include "TH1.h"
00018 #include <iostream>
00019 #include <memory>
00020 
00021 
00022 class ZdcTBAnalyzer : public edm::EDAnalyzer {
00023 
00024  public:
00025   explicit ZdcTBAnalyzer(const edm::ParameterSet&);
00026   ~ZdcTBAnalyzer();
00027   virtual void analyze(const edm::Event&, const edm::EventSetup&);
00028   virtual void endJob();
00029 
00030 private:
00031   std::string outputFileName;
00032   std::string inputFileName;
00033   bool beamDetectorsADCInfo;
00034   bool beamDetectorsTDCInfo;
00035   bool wireChambersInfo;
00036   bool triggerInfo;
00037   ZdcTBAnalysis zdcTBAnalysis;
00038 };
00039 
00040 ZdcTBAnalyzer::ZdcTBAnalyzer(const edm::ParameterSet& iConfig)
00041 {
00042   std::cout<<"**************** ZdcTBAnalizer Start**************************"<<std::endl;
00043   edm::ParameterSet para = iConfig.getParameter<edm::ParameterSet>("ZdcTBAnalyzer");
00044   
00045   beamDetectorsADCInfo = para.getParameter<bool>("beamDetectorsADCInfoFlag");
00046   beamDetectorsTDCInfo = para.getParameter<bool>("beamDetectorsTDCInfoFlag");
00047   wireChambersInfo = para.getParameter<bool>("wireChambersInfoFlag");
00048   triggerInfo = para.getParameter<bool>("triggerInfoFlag");
00049   outputFileName =  para.getParameter<std::string>("ntupleOutputFileName");
00050   zdcTBAnalysis.setup(outputFileName);
00051 }
00052 
00053 ZdcTBAnalyzer::~ZdcTBAnalyzer(){;}
00054 
00055 void ZdcTBAnalyzer::analyze(const edm::Event& e, const edm::EventSetup&){
00056   using namespace edm;
00057   edm::Handle<ZDCRecHitCollection> zdcRecHits;
00058   edm::Handle<HcalTBTriggerData> triggers;
00059   edm::Handle<HcalTBTiming> times;
00060   edm::Handle<HcalTBBeamCounters> bc;
00061   edm::Handle<HcalTBEventPosition> chpos;
00062   
00063   e.getByType(zdcRecHits);
00064   if(triggerInfo){
00065     e.getByType(triggers);
00066     zdcTBAnalysis.analyze(*triggers);
00067   }
00068   if(beamDetectorsTDCInfo){
00069     e.getByType(times);  // e.getByLabel("tbunpacker2",times);
00070     zdcTBAnalysis.analyze(*times);
00071   }
00072   if(beamDetectorsADCInfo){
00073     e.getByType(bc);
00074      zdcTBAnalysis.analyze(*bc);
00075   }
00076   if(wireChambersInfo){
00077     e.getByType(chpos);
00078     zdcTBAnalysis.analyze(*chpos);
00079   }     
00080   zdcTBAnalysis.analyze(*zdcRecHits);
00081   zdcTBAnalysis.fillTree();
00082 }
00083 
00084 void ZdcTBAnalyzer::endJob(){
00085   zdcTBAnalysis.done();
00086 std::cout<<"****************ZdcTBAnalizer End**************************"<<std::endl;
00087 }
00088 
00089 //define this as a plug-in
00090 DEFINE_FWK_MODULE(ZdcTBAnalyzer);