CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/RecoHI/HiCentralityAlgos/src/CentralityBinProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CentralityBinProducer
00004 // Class:      CentralityBinProducer
00005 // 
00013 //
00014 // Original Author:  Yetkin Yilmaz
00015 //         Created:  Thu Aug 12 05:34:11 EDT 2010
00016 // $Id: CentralityBinProducer.cc,v 1.4 2010/11/02 16:15:59 yilmaz 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/EDProducer.h"
00028 
00029 #include "FWCore/Framework/interface/Event.h"
00030 #include "FWCore/Framework/interface/MakerMacros.h"
00031 
00032 #include "FWCore/Utilities/interface/InputTag.h"
00033 
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 #include "DataFormats/HeavyIonEvent/interface/CentralityProvider.h"
00036 
00037 
00038 //
00039 // class declaration
00040 //
00041 
00042 class CentralityBinProducer : public edm::EDProducer {
00043    public:
00044       explicit CentralityBinProducer(const edm::ParameterSet&);
00045       ~CentralityBinProducer();
00046 
00047    private:
00048       virtual void beginJob() ;
00049       virtual void produce(edm::Event&, const edm::EventSetup&);
00050       virtual void endJob() ;
00051       
00052       // ----------member data ---------------------------
00053 
00054    CentralityProvider * centrality_;
00055 
00056 };
00057 
00058 //
00059 // constants, enums and typedefs
00060 //
00061 
00062 
00063 //
00064 // static data member definitions
00065 //
00066 
00067 //
00068 // constructors and destructor
00069 //
00070 CentralityBinProducer::CentralityBinProducer(const edm::ParameterSet& iConfig) :
00071   centrality_(0)
00072 {
00073    produces<int>();  
00074 }
00075 
00076 
00077 CentralityBinProducer::~CentralityBinProducer()
00078 {
00079  
00080    // do anything here that needs to be done at desctruction time
00081    // (e.g. close files, deallocate resources etc.)
00082 
00083 }
00084 
00085 
00086 //
00087 // member functions
00088 //
00089 
00090 // ------------ method called to produce the data  ------------
00091 void
00092 CentralityBinProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00093 {
00094    using namespace edm;
00095    if(!centrality_) centrality_ = new CentralityProvider(iSetup);
00096    centrality_->newEvent(iEvent,iSetup);
00097 
00098    int bin = centrality_->getBin();
00099    std::auto_ptr<int> binp(new int(bin));
00100 
00101    iEvent.put(binp);
00102  
00103 }
00104 
00105 // ------------ method called once each job just before starting event loop  ------------
00106 void 
00107 CentralityBinProducer::beginJob()
00108 {
00109 }
00110 
00111 // ------------ method called once each job just after ending the event loop  ------------
00112 void 
00113 CentralityBinProducer::endJob() {
00114 }
00115 
00116 //define this as a plug-in
00117 DEFINE_FWK_MODULE(CentralityBinProducer);