CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/TauAnalysis/MCEmbeddingTools/plugins/RecoTracksMixer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    RecoTracksMixer
00004 // Class:      RecoTracksMixer
00005 //
00013 //
00014 // Original Author:  Tomasz Maciej Frueboes
00015 //         Created:  Fri Apr  9 12:15:56 CEST 2010
00016 // $Id: RecoTracksMixer.cc,v 1.3 2010/11/08 16:03:27 friis 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 //
00036 // class decleration
00037 //
00038 
00039 class RecoTracksMixer : public edm::EDProducer {
00040    public:
00041       explicit RecoTracksMixer(const edm::ParameterSet&);
00042       ~RecoTracksMixer();
00043 
00044    private:
00045       virtual void beginJob() ;
00046       virtual void produce(edm::Event&, const edm::EventSetup&);
00047       virtual void endJob() ;
00048       edm::InputTag _tracks1;
00049       edm::InputTag _tracks2;
00050 
00051       // ----------member data ---------------------------
00052 };
00053 
00054 //
00055 // constants, enums and typedefs
00056 //
00057 
00058 
00059 //
00060 // static data member definitions
00061 //
00062 
00063 //
00064 // constructors and destructor
00065 //
00066 RecoTracksMixer::RecoTracksMixer(const edm::ParameterSet& iConfig) :
00067   _tracks1(iConfig.getParameter< edm::InputTag > ("trackCol1")),
00068   _tracks2(iConfig.getParameter< edm::InputTag > ("trackCol2"))
00069 {
00070 
00071    produces<reco::TrackCollection>();
00072 }
00073 
00074 
00075 RecoTracksMixer::~RecoTracksMixer()
00076 {
00077 
00078    // do anything here that needs to be done at desctruction time
00079    // (e.g. close files, deallocate resources etc.)
00080 
00081 }
00082 
00083 
00084 //
00085 // member functions
00086 //
00087 
00088 // ------------ method called to produce the data  ------------
00089 void
00090 RecoTracksMixer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00091 {
00092    using namespace edm;
00093 
00094    std::vector< edm::Handle<reco::TrackCollection> > cols;
00095    edm::Handle<reco::TrackCollection> tks1;
00096    iEvent.getByLabel( _tracks1, tks1);
00097 
00098    edm::Handle<reco::TrackCollection> tks2;
00099    iEvent.getByLabel( _tracks2, tks2);
00100 
00101    cols.push_back(tks1);
00102    cols.push_back(tks2);
00103 
00104    std::auto_ptr< reco::TrackCollection  > newCol(new reco::TrackCollection );
00105 
00106    //std::cout << "##########################################\n";
00107    //int i  = 0;
00108    std::vector< edm::Handle<reco::TrackCollection> >::iterator it = cols.begin();
00109    for(;it != cols.end(); ++it)
00110    {
00111      //std::cout << " col " << i++ << std::endl;
00112      for ( reco::TrackCollection::const_iterator itT = (*it)->begin() ; itT != (*it)->end(); ++itT)
00113      {
00114        /*
00115        std::cout << " " << itT->vx()
00116            << " " << itT->vy()
00117            << " " << itT->vz()
00118            << " " << itT->pt()
00119            << std::endl;*/
00120 
00121        newCol->push_back(*itT);
00122      }
00123 
00124    }
00125 
00126    iEvent.put(newCol);
00127 
00128 }
00129 
00130 // ------------ method called once each job just before starting event loop  ------------
00131 void
00132 RecoTracksMixer::beginJob()
00133 {
00134 }
00135 
00136 // ------------ method called once each job just after ending the event loop  ------------
00137 void
00138 RecoTracksMixer::endJob() {
00139 }
00140 
00141 //define this as a plug-in
00142 DEFINE_FWK_MODULE(RecoTracksMixer);