Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:18

0001 
0002 
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/MakerMacros.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009 
0010 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0011 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
0012 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTiming.h"
0013 #include "TBDataFormats/HcalTBObjects/interface/HcalTBBeamCounters.h"
0014 #include "TBDataFormats/HcalTBObjects/interface/HcalTBEventPosition.h"
0015 #include "RecoTBCalo/ZDCTBAnalysis/interface/ZdcTBAnalysis.h"
0016 #include "TFile.h"
0017 #include "TTree.h"
0018 #include "TH1.h"
0019 #include <iostream>
0020 #include <memory>
0021 
0022 class ZdcTBAnalyzer : public edm::EDAnalyzer {
0023 public:
0024   explicit ZdcTBAnalyzer(const edm::ParameterSet&);
0025   ~ZdcTBAnalyzer() override;
0026   void analyze(const edm::Event&, const edm::EventSetup&) override;
0027   void endJob() override;
0028 
0029 private:
0030   std::string outputFileName;
0031   std::string inputFileName;
0032   bool beamDetectorsADCInfo;
0033   bool beamDetectorsTDCInfo;
0034   bool wireChambersInfo;
0035   bool triggerInfo;
0036   ZdcTBAnalysis zdcTBAnalysis;
0037 
0038   edm::EDGetTokenT<ZDCRecHitCollection> tok_zdc_;
0039   edm::EDGetTokenT<HcalTBTriggerData> tok_tb_;
0040   edm::EDGetTokenT<HcalTBTiming> tok_timing_;
0041   edm::EDGetTokenT<HcalTBBeamCounters> tok_bc_;
0042   edm::EDGetTokenT<HcalTBEventPosition> tok_pos_;
0043 };
0044 
0045 ZdcTBAnalyzer::ZdcTBAnalyzer(const edm::ParameterSet& iConfig) {
0046   tok_zdc_ = consumes<ZDCRecHitCollection>(iConfig.getParameter<edm::InputTag>("zdcRecHitCollectionTag"));
0047   tok_tb_ = consumes<HcalTBTriggerData>(iConfig.getParameter<edm::InputTag>("hcalTBTriggerDataTag"));
0048   tok_timing_ = consumes<HcalTBTiming>(iConfig.getParameter<edm::InputTag>("hcalTBTimingTag"));
0049   tok_bc_ = consumes<HcalTBBeamCounters>(iConfig.getParameter<edm::InputTag>("hcalTBBeamCountersTag"));
0050   tok_pos_ = consumes<HcalTBEventPosition>(iConfig.getParameter<edm::InputTag>("hcalTBEventPositionTag"));
0051 
0052   std::cout << "**************** ZdcTBAnalizer Start**************************" << std::endl;
0053   edm::ParameterSet para = iConfig.getParameter<edm::ParameterSet>("ZdcTBAnalyzer");
0054 
0055   beamDetectorsADCInfo = para.getParameter<bool>("beamDetectorsADCInfoFlag");
0056   beamDetectorsTDCInfo = para.getParameter<bool>("beamDetectorsTDCInfoFlag");
0057   wireChambersInfo = para.getParameter<bool>("wireChambersInfoFlag");
0058   triggerInfo = para.getParameter<bool>("triggerInfoFlag");
0059   outputFileName = para.getParameter<std::string>("ntupleOutputFileName");
0060   zdcTBAnalysis.setup(outputFileName);
0061 }
0062 
0063 ZdcTBAnalyzer::~ZdcTBAnalyzer() { ; }
0064 
0065 void ZdcTBAnalyzer::analyze(const edm::Event& e, const edm::EventSetup&) {
0066   using namespace edm;
0067   edm::Handle<ZDCRecHitCollection> zdcRecHits;
0068   edm::Handle<HcalTBTriggerData> triggers;
0069   edm::Handle<HcalTBTiming> times;
0070   edm::Handle<HcalTBBeamCounters> bc;
0071   edm::Handle<HcalTBEventPosition> chpos;
0072 
0073   e.getByToken(tok_zdc_, zdcRecHits);
0074   if (triggerInfo) {
0075     e.getByToken(tok_tb_, triggers);
0076     zdcTBAnalysis.analyze(*triggers);
0077   }
0078   if (beamDetectorsTDCInfo) {
0079     e.getByToken(tok_timing_, times);  // e.getByLabel("tbunpacker2",times);
0080     zdcTBAnalysis.analyze(*times);
0081   }
0082   if (beamDetectorsADCInfo) {
0083     e.getByToken(tok_bc_, bc);
0084     zdcTBAnalysis.analyze(*bc);
0085   }
0086   if (wireChambersInfo) {
0087     e.getByToken(tok_pos_, chpos);
0088     zdcTBAnalysis.analyze(*chpos);
0089   }
0090   zdcTBAnalysis.analyze(*zdcRecHits);
0091   zdcTBAnalysis.fillTree();
0092 }
0093 
0094 void ZdcTBAnalyzer::endJob() {
0095   zdcTBAnalysis.done();
0096   std::cout << "****************ZdcTBAnalizer End**************************" << std::endl;
0097 }
0098 
0099 //define this as a plug-in
0100 DEFINE_FWK_MODULE(ZdcTBAnalyzer);