CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/TauAnalysis/MCEmbeddingTools/plugins/GSFElectronsMixer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    GSFElectronsMixer
00004 // Class:      GSFElectronsMixer
00005 //
00013 //
00014 // Original Author:  Tomasz Maciej Frueboes
00015 //         Created:  Fri Apr  9 12:15:56 CEST 2010
00016 // $Id: GSFElectronsMixer.cc,v 1.1 2011/10/13 08:29:03 fruboes Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDProducer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 #include "DataFormats/TrackReco/interface/Track.h"
00033 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00034 
00035 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00036 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00037 
00038 //
00039 // class decleration
00040 //
00041 
00042 class GSFElectronsMixer : public edm::EDProducer {
00043    public:
00044       explicit GSFElectronsMixer(const edm::ParameterSet&);
00045       ~GSFElectronsMixer();
00046 
00047    private:
00048       virtual void beginJob() ;
00049       virtual void produce(edm::Event&, const edm::EventSetup&);
00050       virtual void endJob() ;
00051       edm::InputTag _electrons1;
00052       edm::InputTag _electrons2;
00053 
00054       // ----------member data ---------------------------
00055 };
00056 
00057 //
00058 // constants, enums and typedefs
00059 //
00060 
00061 
00062 //
00063 // static data member definitions
00064 //
00065 
00066 //
00067 // constructors and destructor
00068 //
00069 GSFElectronsMixer::GSFElectronsMixer(const edm::ParameterSet& iConfig) :
00070   _electrons1(iConfig.getParameter< edm::InputTag > ("col1")),
00071   _electrons2(iConfig.getParameter< edm::InputTag > ("col2"))
00072 {
00073 
00074    produces<reco::GsfElectronCollection>();
00075 }
00076 
00077 
00078 GSFElectronsMixer::~GSFElectronsMixer()
00079 {
00080 
00081    // do anything here that needs to be done at desctruction time
00082    // (e.g. close files, deallocate resources etc.)
00083 
00084 }
00085 
00086 
00087 //
00088 // member functions
00089 //
00090 
00091 // ------------ method called to produce the data  ------------
00092 void
00093 GSFElectronsMixer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00094 {
00095    using namespace edm;
00096 
00097    std::vector< edm::Handle<reco::GsfElectronCollection> > cols;
00098    edm::Handle<reco::GsfElectronCollection> tks1;
00099    iEvent.getByLabel( _electrons1, tks1);
00100 
00101    edm::Handle<reco::GsfElectronCollection> tks2;
00102    iEvent.getByLabel( _electrons2, tks2);
00103 
00104    cols.push_back(tks1);
00105    cols.push_back(tks2);
00106 
00107    std::auto_ptr<reco::GsfElectronCollection> finalCollection( new reco::GsfElectronCollection ) ;
00108 
00109    //std::cout << "##########################################\n";
00110    //int i  = 0;
00111    std::vector< edm::Handle< reco::GsfElectronCollection > >::iterator it = cols.begin();
00112    for(;it != cols.end(); ++it)
00113    {
00114      //std::cout << " col " << i++ << std::endl;
00115      for ( reco::GsfElectronCollection::const_iterator itT = (*it)->begin() ; itT != (*it)->end(); ++itT)
00116      {
00117        /*
00118        std::cout << " " << itT->vx()
00119            << " " << itT->vy()
00120            << " " << itT->vz()
00121            << " " << itT->pt()
00122            << std::endl;*/
00123 
00124        finalCollection->push_back(*itT);
00125      }
00126 
00127    }
00128 
00129    iEvent.put(finalCollection);
00130 
00131 }
00132 
00133 // ------------ method called once each job just before starting event loop  ------------
00134 void
00135 GSFElectronsMixer::beginJob()
00136 {
00137 }
00138 
00139 // ------------ method called once each job just after ending the event loop  ------------
00140 void
00141 GSFElectronsMixer::endJob() {
00142 }
00143 
00144 //define this as a plug-in
00145 DEFINE_FWK_MODULE(GSFElectronsMixer);