CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTracksMixer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoTracksMixer
4 // Class: RecoTracksMixer
5 //
13 //
14 // Original Author: Tomasz Maciej Frueboes
15 // Created: Fri Apr 9 12:15:56 CEST 2010
16 // $Id: RecoTracksMixer.cc,v 1.3 2010/11/08 16:03:27 friis Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
34 
35 //
36 // class decleration
37 //
38 
40  public:
41  explicit RecoTracksMixer(const edm::ParameterSet&);
43 
44  private:
45  virtual void beginJob() ;
46  virtual void produce(edm::Event&, const edm::EventSetup&);
47  virtual void endJob() ;
50 
51  // ----------member data ---------------------------
52 };
53 
54 //
55 // constants, enums and typedefs
56 //
57 
58 
59 //
60 // static data member definitions
61 //
62 
63 //
64 // constructors and destructor
65 //
67  _tracks1(iConfig.getParameter< edm::InputTag > ("trackCol1")),
68  _tracks2(iConfig.getParameter< edm::InputTag > ("trackCol2"))
69 {
70 
71  produces<reco::TrackCollection>();
72 }
73 
74 
76 {
77 
78  // do anything here that needs to be done at desctruction time
79  // (e.g. close files, deallocate resources etc.)
80 
81 }
82 
83 
84 //
85 // member functions
86 //
87 
88 // ------------ method called to produce the data ------------
89 void
91 {
92  using namespace edm;
93 
94  std::vector< edm::Handle<reco::TrackCollection> > cols;
96  iEvent.getByLabel( _tracks1, tks1);
97 
99  iEvent.getByLabel( _tracks2, tks2);
100 
101  cols.push_back(tks1);
102  cols.push_back(tks2);
103 
104  std::auto_ptr< reco::TrackCollection > newCol(new reco::TrackCollection );
105 
106  //std::cout << "##########################################\n";
107  //int i = 0;
108  std::vector< edm::Handle<reco::TrackCollection> >::iterator it = cols.begin();
109  for(;it != cols.end(); ++it)
110  {
111  //std::cout << " col " << i++ << std::endl;
112  for ( reco::TrackCollection::const_iterator itT = (*it)->begin() ; itT != (*it)->end(); ++itT)
113  {
114  /*
115  std::cout << " " << itT->vx()
116  << " " << itT->vy()
117  << " " << itT->vz()
118  << " " << itT->pt()
119  << std::endl;*/
120 
121  newCol->push_back(*itT);
122  }
123 
124  }
125 
126  iEvent.put(newCol);
127 
128 }
129 
130 // ------------ method called once each job just before starting event loop ------------
131 void
133 {
134 }
135 
136 // ------------ method called once each job just after ending the event loop ------------
137 void
139 }
140 
141 //define this as a plug-in
edm::InputTag _tracks2
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual void beginJob()
edm::InputTag _tracks1
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void endJob()
RecoTracksMixer(const edm::ParameterSet &)