CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfTrackMixer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: GsfTrackMixer
4 // Class: GsfTrackMixer
5 //
13 //
14 // Original Author: Tomasz Maciej Frueboes
15 // Created: Fri Apr 9 12:15:56 CEST 2010
16 // $Id: GsfTrackMixer.cc,v 1.2 2013/03/29 15:55:19 veelken Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
36 
41 //
42 // class decleration
43 //
44 using namespace reco;
45 
46 
48  public:
49  explicit GsfTrackMixer(const edm::ParameterSet&);
50  ~GsfTrackMixer();
51 
52  private:
53  virtual void beginJob() ;
54  virtual void produce(edm::Event&, const edm::EventSetup&);
55  virtual void endJob() ;
58 
59 
62  // ----------member data ---------------------------
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 
70 //
71 // static data member definitions
72 //
73 
74 //
75 // constructors and destructor
76 //
78  _col1(iConfig.getParameter< edm::InputTag > ("collection1")),
79  _col2(iConfig.getParameter< edm::InputTag > ("collection2"))
80 {
81 
82  // ?setBranchAlias?
83  produces<reco::GsfTrackCollection>();
84  produces<reco::TrackExtraCollection>();
85  produces<reco::GsfTrackExtraCollection>();
86  //produces<reco::GsfTrackCollection>().setBranchAlias( alias_ + "GsfTracks" );
87  //produces<reco::TrackExtraCollection>().setBranchAlias( alias_ + "TrackExtras" );
88  //produces<reco::GsfTrackExtraCollection>().setBranchAlias( alias_ + "GsfTrackExtras" );
89  //produces<TrackingRecHitCollection>().setBranchAlias( alias_ + "RecHits" );
90  //produces<std::vector<Trajectory> >() ;
91  //produces<TrajGsfTrackAssociationCollection>();
92 
93 
94 }
95 
96 
98 {
99 
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 
103 }
104 
105 
106 //
107 // member functions
108 //
109 
110 // ------------ method called to produce the data ------------
111 void
113 {
114  using namespace edm;
115  using namespace std;
116  using namespace reco;
117 
118  // see RecoTracker/TrackProducer/plugins/GsfTrackProducer.cc
119  // and RecoTracker/TrackProducer/src/GsfTrackProducerBase.cc
120  //std::auto_ptr<TrackingRecHitCollection> outputRHColl (new TrackingRecHitCollection);
121  std::auto_ptr<reco::GsfTrackCollection> outputTColl(new reco::GsfTrackCollection);
122  std::auto_ptr<reco::TrackExtraCollection> outputTEColl(new reco::TrackExtraCollection);
123  std::auto_ptr<reco::GsfTrackExtraCollection> outputGsfTEColl(new reco::GsfTrackExtraCollection);
124  //std::auto_ptr<std::vector<Trajectory> > outputTrajectoryColl(new std::vector<Trajectory>);
125 
129 
130 
133 
135  iEvent.getByLabel( _col1, hcol1);
136  iEvent.getByLabel( _col2, hcol2);
137 
138  std::vector< edm::Handle< reco::GsfTrackCollection > > cols;
139  cols.push_back(hcol1);
140  cols.push_back(hcol2);
141 
142  for ( std::vector< edm::Handle< reco::GsfTrackCollection > >::iterator itCols=cols.begin();
143  itCols!=cols.end();
144  ++itCols )
145  {
146  for (GsfTrackCollection::const_iterator it = (*itCols)->begin(); it!=(*itCols)->end(); ++ it){
147  GsfTrack gsfTrack = *it;
148  TrackExtra te = *(it->extra());
149  GsfTrackExtra ge = *(it->gsfExtra());
150 
151  reco::GsfTrackExtraRef terefGsf = reco::GsfTrackExtraRef ( rGsfTrackExtras, idxGsf ++ );
152  reco::TrackExtraRef teref= reco::TrackExtraRef ( rTrackExtras, idx ++ );
153 
154  gsfTrack.setExtra( teref );
155  gsfTrack.setGsfExtra( terefGsf );
156 
157  outputTColl->push_back(gsfTrack);
158  outputTEColl->push_back(te);
159  outputGsfTEColl->push_back(ge);
160  }
161  }
162 
163 
164 
165  iEvent.put(outputTColl);
166  iEvent.put(outputTEColl);
167  iEvent.put(outputGsfTEColl);
168 
169 }
170 
171 // ------------ method called once each job just before starting event loop ------------
172 void
174 {
175 }
176 
177 // ------------ method called once each job just after ending the event loop ------------
178 void
180 }
181 
182 //define this as a plug-in
virtual void produce(edm::Event &, const edm::EventSetup &)
std::string preidname_
void setGsfExtra(const GsfTrackExtraRef &ref)
set reference to GSF &quot;extra&quot; object
Definition: GsfTrack.h:30
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:17
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:230
edm::InputTag _col2
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
std::string preidgsf_
GsfTrackMixer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
edm::Ref< GsfTrackExtraCollection > GsfTrackExtraRef
persistent reference to a GsfTrackExtra
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:11
void setExtra(const TrackExtraRef &ref)
set reference to &quot;extra&quot; object
Definition: Track.h:184
virtual void beginJob()
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::InputTag _col1
virtual void endJob()
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:168