CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronConversionRejectionVars.cc
Go to the documentation of this file.
1 //
2 
17 
20 
31 
32 
34  public:
35  explicit ElectronConversionRejectionVars(const edm::ParameterSet & iConfig);
37 
38  virtual void produce(edm::Event & iEvent, const edm::EventSetup & iSetup);
39 
40  private:
42 };
43 
45  probes_(iConfig.getParameter<edm::InputTag>("probes"))
46 {
47  produces<edm::ValueMap<float> >("dist");
48  produces<edm::ValueMap<float> >("dcot");
49  produces<edm::ValueMap<float> >("convradius");
50  produces<edm::ValueMap<float> >("passConvRej");
51 }
52 
53 
55 {
56 }
57 
58 void
60  using namespace edm;
61 
62  // read input
66 
67  iEvent.getByLabel(probes_, probes);
68  iEvent.getByLabel("generalTracks", tracks_h );
69  iEvent.getByLabel("gsfElectrons", elHandle);
70 
71  float evt_bField = 3.8;
72 
73 
74  // prepare vector for output
75  std::vector<float> values;
76  std::vector<float> values2;
77  std::vector<float> values3;
78  std::vector<float> values4;
79 
80  // fill: use brute force
81  double dist = 0.0;
82  double dcot = 0.0;
83  double convradius = 0.0;
84  double passConvRej = 0.0;
85  ConversionFinder convFinder;
86 
87  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
88  const reco::GsfElectronCollection* electronCollection = elHandle.product();
89  reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin();
90 
91  for (probe = probes->begin(); probe != endprobes; ++probe) {
92  for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
93  if( fabs(eleIt->et() - probe->et() ) < 0.05 && fabs(eleIt->eta() - probe->eta() ) < 0.01
94  && fabs(eleIt->phi() - probe->phi() ) < 0.01 ){
95  //we have a match
96  ConversionInfo convInfo = convFinder.getConversionInfo(*eleIt, tracks_h, evt_bField);
97  dist = convInfo.dist();
98  dcot = convInfo.dcot();
99  convradius = convInfo.radiusOfConversion();
100  if( fabs(dist)>0.02 && fabs(dcot)>0.02) passConvRej = 1.0;
101  break; //got our guy, so break
102  }
103  }
104  values.push_back(dist);
105  values2.push_back(dcot);
106  values3.push_back(convradius);
107  values4.push_back(passConvRej);
108  }
109 
110 
111  // convert into ValueMap and store
112  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
113  ValueMap<float>::Filler filler(*valMap);
114  filler.insert(probes, values.begin(), values.end());
115  filler.fill();
116  iEvent.put(valMap, "dist");
117 
118 
119  // ---> same for dcot
120  std::auto_ptr<ValueMap<float> > valMap2(new ValueMap<float>());
121  ValueMap<float>::Filler filler2(*valMap2);
122  filler2.insert(probes, values2.begin(), values2.end());
123  filler2.fill();
124  iEvent.put(valMap2, "dcot");
125 
126  // ---> same for convradius
127  std::auto_ptr<ValueMap<float> > valMap3(new ValueMap<float>());
128  ValueMap<float>::Filler filler3(*valMap3);
129  filler3.insert(probes, values3.begin(), values3.end());
130  filler3.fill();
131  iEvent.put(valMap3, "convradius");
132 
133 
134  // ---> same for passConvRej
135  std::auto_ptr<ValueMap<float> > valMap4(new ValueMap<float>());
136  ValueMap<float>::Filler filler4(*valMap4);
137  filler4.insert(probes, values4.begin(), values4.end());
138  filler4.fill();
139  iEvent.put(valMap4, "passConvRej");
140 }
141 
142 
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
double radiusOfConversion() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double dist() const
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
Store electron partner track conversion-rejection quantities (&quot;dist&quot; and &quot;dcot&quot;) in the TP tree...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
ElectronConversionRejectionVars(const edm::ParameterSet &iConfig)
double dcot() const