Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-13 13:14:13

0001 // -*- C++ -*-
0002 //
0003 // Package:    FFTJetImageRecorder
0004 // Class:      FFTJetImageRecorder
0005 //
0006 /**\class FFTJetImageRecorder FFTJetImageRecorder.cc RecoJets/JetAnalyzers/src/FFTJetImageRecorder.cc
0007 
0008  Description: collects the info produced by FFTJetEFlowSmoother
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Igor Volobouev
0015 //         Created:  Thu Apr 21 15:52:11 CDT 2011
0016 //
0017 //
0018 
0019 #include <cassert>
0020 #include <sstream>
0021 #include <numeric>
0022 
0023 #include "TNtuple.h"
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/ServiceRegistry/interface/Service.h"
0032 
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 
0035 #include "DataFormats/Common/interface/Handle.h"
0036 #include <TH3F.h>
0037 
0038 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0039 
0040 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0041 
0042 #define init_param(type, varname) varname(ps.getParameter<type>(#varname))
0043 
0044 //
0045 // class declaration
0046 //
0047 class FFTJetImageRecorder : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0048 public:
0049   explicit FFTJetImageRecorder(const edm::ParameterSet&);
0050   FFTJetImageRecorder() = delete;
0051   FFTJetImageRecorder(const FFTJetImageRecorder&) = delete;
0052   FFTJetImageRecorder& operator=(const FFTJetImageRecorder&) = delete;
0053   ~FFTJetImageRecorder() override;
0054 
0055 private:
0056   void beginJob() override;
0057   void analyze(const edm::Event&, const edm::EventSetup&) override;
0058   void endJob() override;
0059 
0060   edm::InputTag histoLabel;
0061   unsigned long counter;
0062 
0063   edm::EDGetTokenT<TH3F> histoToken;
0064 };
0065 
0066 //
0067 // constructors and destructor
0068 //
0069 FFTJetImageRecorder::FFTJetImageRecorder(const edm::ParameterSet& ps)
0070     : init_param(edm::InputTag, histoLabel), counter(0) {
0071   histoToken = consumes<TH3F>(histoLabel);
0072   usesResource(TFileService::kSharedResource);
0073 }
0074 
0075 FFTJetImageRecorder::~FFTJetImageRecorder() {}
0076 
0077 //
0078 // member functions
0079 //
0080 
0081 // ------------ method called once each job just before starting event loop
0082 void FFTJetImageRecorder::beginJob() {
0083   edm::Service<TFileService> fs;
0084   fs->make<TNtuple>("dummy", "dummy", "var");
0085 }
0086 
0087 // ------------ method called to for each event  ------------
0088 void FFTJetImageRecorder::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0089   edm::RunNumber_t const runnumber = iEvent.id().run();
0090   edm::EventNumber_t const eventnumber = iEvent.id().event();
0091 
0092   edm::Handle<TH3F> input;
0093   iEvent.getByToken(histoToken, input);
0094 
0095   edm::Service<TFileService> fs;
0096   TH3F* copy = new TH3F(*input);
0097 
0098   std::ostringstream os;
0099   os << copy->GetName() << '_' << counter << '_' << runnumber << '_' << eventnumber;
0100   const std::string& newname(os.str());
0101   copy->SetNameTitle(newname.c_str(), newname.c_str());
0102 
0103   copy->SetDirectory(fs->getBareDirectory());
0104 
0105   ++counter;
0106 }
0107 
0108 // ------------ method called once each job just after ending the event loop
0109 void FFTJetImageRecorder::endJob() {}
0110 
0111 //define this as a plug-in
0112 DEFINE_FWK_MODULE(FFTJetImageRecorder);