CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronSeedTrackRefUpdater.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ElectronSeedTrackRefUpdater
4 // Class: ElectronSeedTrackRefUpdater
5 //
13 //
14 // Original Author: Tomasz Maciej Frueboes
15 // Created: Fri Apr 9 12:15:56 CEST 2010
16 // $Id: ElectronSeedTrackRefUpdater.cc,v 1.1 2012/03/01 17:03:28 fruboes Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
34 
39 
41 //
42 // class decleration
43 //
44 using namespace reco;
45 
46 
48  public:
51 
52  private:
53  virtual void beginJob() ;
54  virtual void produce(edm::Event&, const edm::EventSetup&);
55  virtual void endJob() ;
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  _inSeeds(iConfig.getParameter< edm::InputTag > ("inSeeds")),
79  _inPreId(iConfig.getParameter< edm::InputTag > ("inPreId")),
80  _targetTracks(iConfig.getParameter< edm::InputTag > ("targetTracks"))
81 {
82  preidgsf_ = iConfig.getParameter<std::string>("PreGsfLabel");
83  preidname_= iConfig.getParameter<std::string>("PreIdLabel");
84 
85  produces<ElectronSeedCollection>(preidgsf_);
86  produces<PreIdCollection>(preidname_);
87  //produces<edm::ValueMap<reco::PreIdRef> >(preidname_);
88 
89 }
90 
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called to produce the data ------------
106 void
108 {
109  using namespace edm;
110  using namespace std;
111  using namespace reco;
112 
113  auto_ptr<ElectronSeedCollection> output_preid(new ElectronSeedCollection);
114  auto_ptr<PreIdCollection> output_preidinfo(new PreIdCollection);
115 
117  iEvent.getByLabel( _targetTracks, hTargetTracks);
118 
120  iEvent.getByLabel( _inSeeds, hElectronSeeds);
121 
123  iEvent.getByLabel( _inPreId, hPreId);
124 
125  for (PreIdCollection::const_iterator it = hPreId->begin(); it!=hPreId->end(); ++ it){
126  PreId newPreId(*it);
127  TrackRef currentTrRef = it->trackRef();
128  if ( currentTrRef.isNull() || !currentTrRef.isAvailable() ) {
129  std::cout << "XXXX whoops! Org track ref empty!!" << std::endl;
130  // keep things as they are;
131  output_preidinfo->push_back(newPreId);
132  continue;
133  }
134  size_t newIndex = -1;
135  bool found = false;
136  for (size_t i=0; i<hTargetTracks->size();++i){
137 
138  if ( deltaR( currentTrRef->momentum(), hTargetTracks->at(i).momentum()) < 0.001){
139  newIndex = i;
140  found = true;
141  break;
142  }
143  }
144  if (found) {
145  TrackRef trackRef(hTargetTracks, newIndex);
146  newPreId.setTrack(trackRef);
147  output_preidinfo->push_back(newPreId); // temp hack for mumu filtering
148  } else {
149  std::cout << "XXXX whoops! Cannot set track ref!!" << std::endl;
150  }
151  }
152 
153 
154 
155  for (ElectronSeedCollection::const_iterator it = hElectronSeeds->begin(); it!=hElectronSeeds->end(); ++ it){
156  ElectronSeed newSeed(*it);
157  TrackRef currentTrRef = it->ctfTrack ();
158  if ( currentTrRef.isNull() || !currentTrRef.isAvailable() ) {
159  std::cout << "XXXX whoops! Org track ref empty!!" << std::endl;
160  // keep things as they are;
161  output_preid->push_back(newSeed);
162  continue;
163  }
164  size_t newIndex = -1;
165  bool found = false;
166  for (size_t i=0; i<hTargetTracks->size();++i){
167 
168  if ( deltaR( currentTrRef->momentum(), hTargetTracks->at(i).momentum()) < 0.001){
169  newIndex = i;
170  found = true;
171  break;
172  }
173  }
174  if (found) {
175  TrackRef trackRef(hTargetTracks, newIndex);
176  newSeed.setCtfTrack(trackRef);
177  output_preid->push_back(newSeed); // temporary hack for Zmumu filtering
178  } else {
179  std::cout << "XXXX whoops! Cannot set track ref!!" << std::endl;
180  }
181  }
182 
183 
184 
185 
186  iEvent.put(output_preid,preidgsf_);
187  iEvent.put(output_preidinfo,preidname_);
188 
189  //iEvent.put(newCol);
190 
191 }
192 
193 // ------------ method called once each job just before starting event loop ------------
194 void
196 {
197 }
198 
199 // ------------ method called once each job just after ending the event loop ------------
200 void
202 }
203 
204 //define this as a plug-in
bool isAvailable() const
Definition: Ref.h:576
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< reco::PreId > PreIdCollection
Definition: PreIdFwd.h:6
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ElectronSeedTrackRefUpdater(const edm::ParameterSet &)
void beginJob()
Definition: Breakpoints.cc:15
void setCtfTrack(const CtfTrackRef &)
Set additional info.
Definition: ElectronSeed.cc:64
void setTrack(reco::TrackRef trackref)
Definition: PreId.h:34
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< ElectronSeed > ElectronSeedCollection
collection of ElectronSeed objects
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:418
bool isNull() const
Checks for null.
Definition: Ref.h:249
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
tuple cout
Definition: gather_cfg.py:145