CMS 3D CMS Logo

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