test
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) override;
39 
40  private:
44 };
45 
47  probesToken_(consumes<edm::View<reco::Candidate> >(iConfig.getParameter<edm::InputTag>("probes"))),
48  tracksToken_(consumes<reco::TrackCollection>(edm::InputTag("generalTracks"))) ,
49  gsfElecsToken_(consumes<reco::GsfElectronCollection>(edm::InputTag("gsfElectrons")))
50 {
51  produces<edm::ValueMap<float> >("dist");
52  produces<edm::ValueMap<float> >("dcot");
53  produces<edm::ValueMap<float> >("convradius");
54  produces<edm::ValueMap<float> >("passConvRej");
55 }
56 
57 
59 {
60 }
61 
62 void
64  using namespace edm;
65 
66  // read input
70 
71  iEvent.getByToken(probesToken_, probes);
72  iEvent.getByToken(tracksToken_, tracks_h );
73  iEvent.getByToken(gsfElecsToken_, elHandle);
74 
75  float evt_bField = 3.8;
76 
77 
78  // prepare vector for output
79  std::vector<float> values;
80  std::vector<float> values2;
81  std::vector<float> values3;
82  std::vector<float> values4;
83 
84  // fill: use brute force
85  double dist = 0.0;
86  double dcot = 0.0;
87  double convradius = 0.0;
88  double passConvRej = 0.0;
89  ConversionFinder convFinder;
90 
91  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
92  const reco::GsfElectronCollection* electronCollection = elHandle.product();
93  reco::GsfElectronCollection::const_iterator eleIt = electronCollection->begin();
94 
95  for (probe = probes->begin(); probe != endprobes; ++probe) {
96  for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) {
97  if( fabs(eleIt->et() - probe->et() ) < 0.05 && fabs(eleIt->eta() - probe->eta() ) < 0.01
98  && fabs(eleIt->phi() - probe->phi() ) < 0.01 ){
99  //we have a match
100  ConversionInfo convInfo = convFinder.getConversionInfo(*eleIt, tracks_h, evt_bField);
101  dist = convInfo.dist();
102  dcot = convInfo.dcot();
103  convradius = convInfo.radiusOfConversion();
104  if( fabs(dist)>0.02 && fabs(dcot)>0.02) passConvRej = 1.0;
105  break; //got our guy, so break
106  }
107  }
108  values.push_back(dist);
109  values2.push_back(dcot);
110  values3.push_back(convradius);
111  values4.push_back(passConvRej);
112  }
113 
114 
115  // convert into ValueMap and store
116  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
117  ValueMap<float>::Filler filler(*valMap);
118  filler.insert(probes, values.begin(), values.end());
119  filler.fill();
120  iEvent.put(valMap, "dist");
121 
122 
123  // ---> same for dcot
124  std::auto_ptr<ValueMap<float> > valMap2(new ValueMap<float>());
125  ValueMap<float>::Filler filler2(*valMap2);
126  filler2.insert(probes, values2.begin(), values2.end());
127  filler2.fill();
128  iEvent.put(valMap2, "dcot");
129 
130  // ---> same for convradius
131  std::auto_ptr<ValueMap<float> > valMap3(new ValueMap<float>());
132  ValueMap<float>::Filler filler3(*valMap3);
133  filler3.insert(probes, values3.begin(), values3.end());
134  filler3.fill();
135  iEvent.put(valMap3, "convradius");
136 
137 
138  // ---> same for passConvRej
139  std::auto_ptr<ValueMap<float> > valMap4(new ValueMap<float>());
140  ValueMap<float>::Filler filler4(*valMap4);
141  filler4.insert(probes, values4.begin(), values4.end());
142  filler4.fill();
143  iEvent.put(valMap4, "passConvRej");
144 }
145 
146 
double radiusOfConversion() const
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
double dist() const
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int iEvent
Definition: GenABIO.cc:230
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
edm::EDGetTokenT< reco::GsfElectronCollection > gsfElecsToken_
Store electron partner track conversion-rejection quantities (&quot;dist&quot; and &quot;dcot&quot;) in the TP tree...
ElectronConversionRejectionVars(const edm::ParameterSet &iConfig)
const_iterator end() const
double dcot() const