CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronSeedTrackRefFix.cc
Go to the documentation of this file.
2 
7 
12 //
13 // class declaration
14 //
15 
16 
17 
18 
19 //
20 // constructors and destructor
21 //
22 
23 using namespace std;
24 using namespace reco;
25 using namespace edm;
26 
28 {
29  // read parameters
30  preidgsfLabel = iConfig.getParameter<string>("PreGsfLabel");
31  preidLabel= iConfig.getParameter<string>("PreIdLabel");
32  oldTracksTag = iConfig.getParameter<InputTag>("oldTrackCollection");
33  newTracksTag = iConfig.getParameter<InputTag>("newTrackCollection");
34  seedsTag = iConfig.getParameter<InputTag>("seedCollection");
35  idsTag = iConfig.getParameter<InputTag>("idCollection");
36 
37  //register your products
38  produces<reco::ElectronSeedCollection>(preidgsfLabel);
39  produces<reco::PreIdCollection>(preidLabel);
40  produces<ValueMap<reco::PreIdRef> >(preidLabel);
41 
42  //create tokens
43  oldTracksToken = consumes<reco::TrackCollection>(oldTracksTag);
44  newTracksToken = consumes<reco::TrackCollection>(newTracksTag);
45  seedsToken = consumes<reco::ElectronSeedCollection>(seedsTag);
46  idsToken = consumes<reco::PreIdCollection >(idsTag);
47  idMapToken = consumes<ValueMap<reco::PreIdRef> >(idsTag) ;
48 }
49 
50 
52 {
53 
54  // do anything here that needs to be done at desctruction time
55  // (e.g. close files, deallocate resources etc.)
56 
57 }
58 
59 
60 //
61 // member functions
62 //
63 
64 // ------------ method called to produce the data ------------
65 void
67 {
68  using namespace edm;
69 
70  Handle<TrackCollection> oldTracks;
71  iEvent.getByToken(oldTracksToken,oldTracks);
72 
73  Handle<TrackCollection> newTracks;
74  iEvent.getByToken(newTracksToken,newTracks);
75 
77  iEvent.getByToken(seedsToken,iSeeds);
78 
80  iEvent.getByToken(idsToken,iIds);
81 
83  iEvent.getByToken(idMapToken,iIdMap);
84 
85  auto_ptr<ElectronSeedCollection> oSeeds(new ElectronSeedCollection);
86  auto_ptr<PreIdCollection> oIds(new PreIdCollection);
87  auto_ptr<ValueMap<PreIdRef> > oIdMap(new ValueMap<PreIdRef>);
88 
89  ValueMap<PreIdRef>::Filler mapFiller(*oIdMap);
90 
91  for(unsigned int s = 0;s<iSeeds->size();++s){
92  oSeeds->push_back(iSeeds->at(s));
93  TrackRef newTrackRef(newTracks,oSeeds->back().ctfTrack().index());
94  oSeeds->back().setCtfTrack(newTrackRef);
95  }
96 
97  for(unsigned int i = 0;i<iIds->size();++i){
98  oIds->push_back(iIds->at(i));
99  TrackRef newTrackRef(newTracks,oIds->back().trackRef().index());
100  oIds->back().setTrack(newTrackRef);
101  }
102 
103  iEvent.put(oSeeds,preidgsfLabel);
104  const edm::OrphanHandle<reco::PreIdCollection> preIdProd = iEvent.put(oIds,preidLabel);
105 
106  vector<PreIdRef> values;
107  for(unsigned int t = 0;t<newTracks->size();++t){
108  if(t < oldTracks->size()){
109  TrackRef oldTrackRef(oldTracks,t);
110  values.push_back(PreIdRef(preIdProd,(*(iIdMap.product()))[oldTrackRef].index()));
111  }
112  else{
113  values.push_back(PreIdRef());
114  }
115  }
116  mapFiller.insert(newTracks,values.begin(),values.end());
117  mapFiller.fill();
118 
119  iEvent.put(oIdMap,preidLabel);
120 }
121 
122 // ------------ method called once each job just before starting event loop ------------
123 void
125 {
126 }
127 
128 // ------------ method called once each job just after ending the event loop ------------
129 void
131 }
132 
133 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
134 void
136  //The following says we do not know what parameters are allowed so do no validation
137  // Please change this to state exactly what you do use, even if it is no parameters
139  desc.setUnknown();
140  descriptions.addDefault(desc);
141 }
142 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
virtual void beginJob() override
virtual void endJob() override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ElectronSeedTrackRefFix(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
edm::Ref< reco::PreIdCollection > PreIdRef
Definition: PreIdFwd.h:8
tuple size
Write out results.