test
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 
6 
11 //
12 // class declaration
13 //
14 
15 
16 
17 
18 //
19 // constructors and destructor
20 //
21 
22 using namespace std;
23 using namespace reco;
24 using namespace edm;
25 
27 {
28  // read parameters
29  preidgsfLabel = iConfig.getParameter<string>("PreGsfLabel");
30  preidLabel= iConfig.getParameter<string>("PreIdLabel");
31  oldTracksTag = iConfig.getParameter<InputTag>("oldTrackCollection");
32  newTracksTag = iConfig.getParameter<InputTag>("newTrackCollection");
33  seedsTag = iConfig.getParameter<InputTag>("seedCollection");
34  idsTag = iConfig.getParameter<InputTag>("idCollection");
35 
36  //register your products
37  produces<reco::ElectronSeedCollection>(preidgsfLabel);
38  produces<reco::PreIdCollection>(preidLabel);
39  produces<ValueMap<reco::PreIdRef> >(preidLabel);
40 
41  //create tokens
42  oldTracksToken = consumes<reco::TrackCollection>(oldTracksTag);
43  newTracksToken = consumes<reco::TrackCollection>(newTracksTag);
44  seedsToken = consumes<reco::ElectronSeedCollection>(seedsTag);
45  idsToken = consumes<reco::PreIdCollection >(idsTag);
46  idMapToken = consumes<ValueMap<reco::PreIdRef> >(idsTag) ;
47 }
48 
49 
51 {
52 
53  // do anything here that needs to be done at desctruction time
54  // (e.g. close files, deallocate resources etc.)
55 
56 }
57 
58 
59 //
60 // member functions
61 //
62 
63 // ------------ method called to produce the data ------------
64 void
66 {
67  using namespace edm;
68 
69  Handle<TrackCollection> oldTracks;
70  iEvent.getByToken(oldTracksToken,oldTracks);
71 
72  Handle<TrackCollection> newTracks;
73  iEvent.getByToken(newTracksToken,newTracks);
74 
76  iEvent.getByToken(seedsToken,iSeeds);
77 
79  iEvent.getByToken(idsToken,iIds);
80 
82  iEvent.getByToken(idMapToken,iIdMap);
83 
84  auto_ptr<ElectronSeedCollection> oSeeds(new ElectronSeedCollection);
85  auto_ptr<PreIdCollection> oIds(new PreIdCollection);
86  auto_ptr<ValueMap<PreIdRef> > oIdMap(new ValueMap<PreIdRef>);
87 
88  ValueMap<PreIdRef>::Filler mapFiller(*oIdMap);
89 
90  for(unsigned int s = 0;s<iSeeds->size();++s){
91  oSeeds->push_back(iSeeds->at(s));
92  TrackRef newTrackRef(newTracks,oSeeds->back().ctfTrack().index());
93  oSeeds->back().setCtfTrack(newTrackRef);
94  }
95 
96  for(unsigned int i = 0;i<iIds->size();++i){
97  oIds->push_back(iIds->at(i));
98  TrackRef newTrackRef(newTracks,oIds->back().trackRef().index());
99  oIds->back().setTrack(newTrackRef);
100  }
101 
102  iEvent.put(oSeeds,preidgsfLabel);
103  const edm::OrphanHandle<reco::PreIdCollection> preIdProd = iEvent.put(oIds,preidLabel);
104 
105  vector<PreIdRef> values;
106  for(unsigned int t = 0;t<newTracks->size();++t){
107  if(t < oldTracks->size()){
108  TrackRef oldTrackRef(oldTracks,t);
109  values.push_back(PreIdRef(preIdProd,(*(iIdMap.product()))[oldTrackRef].index()));
110  }
111  else{
112  values.push_back(PreIdRef());
113  }
114  }
115  mapFiller.insert(newTracks,values.begin(),values.end());
116  mapFiller.fill();
117 
118  iEvent.put(oIdMap,preidLabel);
119 }
120 
121 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
122 void
124  //The following says we do not know what parameters are allowed so do no validation
125  // Please change this to state exactly what you do use, even if it is no parameters
127  desc.setUnknown();
128  descriptions.addDefault(desc);
129 }
130 
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:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
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:121
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
edm::Ref< reco::PreIdCollection > PreIdRef
Definition: PreIdFwd.h:8
tuple size
Write out results.