CMS 3D CMS Logo

ElectronIDValueMapProducer.cc
Go to the documentation of this file.
15 
16 #include <vector>
17 
19 
20  public:
21 
24 
25  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
26 
27  private:
28 
29  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
30 
31  // for AOD and MiniAOD case
36 
37 };
38 
40  // Declare consummables, handle both AOD and miniAOD case
41  : src_ ( consumesCollector(), iConfig, "src", "srcMiniAOD")
42  , ebRecHits_(src_, consumesCollector(), iConfig, "ebReducedRecHitCollection", "ebReducedRecHitCollectionMiniAOD")
43  , eeRecHits_(src_, consumesCollector(), iConfig, "eeReducedRecHitCollection", "eeReducedRecHitCollectionMiniAOD")
44  , esRecHits_(src_, consumesCollector(), iConfig, "esReducedRecHitCollection", "esReducedRecHitCollectionMiniAOD")
45 {
46 
47  produces<edm::ValueMap<float> >("eleFull5x5SigmaIEtaIEta");
48  produces<edm::ValueMap<float> >("eleFull5x5SigmaIEtaIPhi");
49  produces<edm::ValueMap<float> >("eleFull5x5E1x5" );
50  produces<edm::ValueMap<float> >("eleFull5x5E2x5" );
51  produces<edm::ValueMap<float> >("eleFull5x5E5x5" );
52  produces<edm::ValueMap<float> >("eleFull5x5R9" );
53  produces<edm::ValueMap<float> >("eleFull5x5Circularity" );
54 
55 }
56 
58 {
59  // Get handle on electrons
60  auto src = src_.getValidHandle(iEvent);
61 
62  noZS::EcalClusterLazyTools lazyToolnoZS(iEvent, iSetup,
63  ebRecHits_.get(iEvent),
64  eeRecHits_.get(iEvent),
65  esRecHits_.get(iEvent));
66 
67  // size_t n = src->size();
68  std::vector<float> eleFull5x5SigmaIEtaIEta, eleFull5x5SigmaIEtaIPhi;
69  std::vector<float> eleFull5x5R9, eleFull5x5Circularity;
70  std::vector<float> eleFull5x5E1x5,eleFull5x5E2x5,eleFull5x5E5x5;
71 
72  // reco::GsfElectron::superCluster() is virtual so we can exploit polymorphism
73  for (const auto &ele : *src) {
74  const auto& theseed = *(ele.superCluster()->seed());
75 
76  std::vector<float> vCov = lazyToolnoZS.localCovariances( theseed );
77  const float see = (edm::isNotFinite(vCov[0]) ? 0. : sqrt(vCov[0]));
78  const float sep = vCov[1];
79  eleFull5x5SigmaIEtaIEta.push_back(see);
80  eleFull5x5SigmaIEtaIPhi.push_back(sep);
81  eleFull5x5R9.push_back(lazyToolnoZS.e3x3( theseed ) / ele.superCluster()->rawEnergy() );
82 
83  const float e1x5 = lazyToolnoZS.e1x5( theseed );
84  const float e2x5 = lazyToolnoZS.e2x5Max( theseed );
85  const float e5x5 = lazyToolnoZS.e5x5( theseed );
86  const float circularity = (e5x5 != 0.) ? 1.-e1x5/e5x5 : -1;
87 
88  eleFull5x5E1x5.push_back(e1x5);
89  eleFull5x5E2x5.push_back(e2x5);
90  eleFull5x5E5x5.push_back(e5x5);
91  eleFull5x5Circularity.push_back(circularity);
92  }
93 
94  writeValueMap(iEvent, src, eleFull5x5SigmaIEtaIEta, "eleFull5x5SigmaIEtaIEta");
95  writeValueMap(iEvent, src, eleFull5x5SigmaIEtaIPhi, "eleFull5x5SigmaIEtaIPhi");
96  writeValueMap(iEvent, src, eleFull5x5R9, "eleFull5x5R9");
97  writeValueMap(iEvent, src, eleFull5x5E1x5, "eleFull5x5E1x5");
98  writeValueMap(iEvent, src, eleFull5x5E2x5, "eleFull5x5E2x5");
99  writeValueMap(iEvent, src, eleFull5x5E5x5, "eleFull5x5E5x5");
100  writeValueMap(iEvent, src, eleFull5x5Circularity, "eleFull5x5Circularity");
101 }
102 
104  // electronIDValueMapProducer
106  desc.add<edm::InputTag>("src", edm::InputTag("gedGsfElectrons"));
107  desc.add<edm::InputTag>("srcMiniAOD", edm::InputTag("slimmedElectrons","","@skipCurrentProcess"));
108  desc.add<edm::InputTag>("ebReducedRecHitCollection", edm::InputTag("reducedEcalRecHitsEB"));
109  desc.add<edm::InputTag>("eeReducedRecHitCollection", edm::InputTag("reducedEcalRecHitsEE"));
110  desc.add<edm::InputTag>("esReducedRecHitCollection", edm::InputTag("reducedEcalRecHitsES"));
111  desc.add<edm::InputTag>("ebReducedRecHitCollectionMiniAOD", edm::InputTag("reducedEgamma","reducedEBRecHits"));
112  desc.add<edm::InputTag>("eeReducedRecHitCollectionMiniAOD", edm::InputTag("reducedEgamma","reducedEERecHits"));
113  desc.add<edm::InputTag>("esReducedRecHitCollectionMiniAOD", edm::InputTag("reducedEgamma","reducedESRecHits"));
114  descriptions.add("electronIDValueMapProducer", desc);
115 }
116 
117 
const MultiTokenT< edm::View< reco::GsfElectron > > src_
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
void writeValueMap(edm::Event &iEvent, const edm::Handle< HandleType > &handle, const std::vector< ValueType > &values, const std::string &label)
Definition: Utils.h:13
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
T sqrt(T t)
Definition: SSEVec.h:18
const MultiTokenT< EcalRecHitCollection > eeRecHits_
edm::Handle< T > getValidHandle(const edm::Event &iEvent) const
Definition: MultiToken.h:95
ParameterDescriptionBase * add(U const &iLabel, T const &value)
ElectronIDValueMapProducer(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< float > localCovariances(const reco::BasicCluster &cluster, float w0=4.7)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const MultiTokenT< EcalRecHitCollection > esRecHits_
const MultiTokenT< EcalRecHitCollection > ebRecHits_