CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EGMSeedGainProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PhysicsTools/NanoAOD
4 // Class: EGMSeedGainProducer
5 //
12 // system include files
13 #include <memory>
14 
15 // user include files
18 
21 
24 
27 
29 
30 //
31 // class declaration
32 //
33 
34 template <typename T>
36 public:
38  : src_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("src"))),
39  recHitsEB_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEB"))),
40  recHitsEE_(consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsEE"))) {
41  produces<edm::ValueMap<int>>();
42  }
43  ~EGMSeedGainProducer() override{};
44 
45  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
46 
47 private:
48  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
49 
50  // ----------member data ---------------------------
51 
55 };
56 
57 //
58 // constants, enums and typedefs
59 //
60 
61 //
62 // static data member definitions
63 //
64 
65 //
66 // member functions
67 //
68 
69 // ------------ method called to produce the data ------------
70 template <typename T>
73  iEvent.getByToken(src_, src);
75  iEvent.getByToken(recHitsEB_, recHitsEB);
77  iEvent.getByToken(recHitsEE_, recHitsEE);
78 
79  unsigned nSrc = src->size();
80  std::vector<int> gainSeed(nSrc, 12);
81 
82  // determine gain of seed crystal as in RecoEgamma/EgammaTools/src/PhotonEnergyCalibrator.cc
83  for (unsigned i = 0; i < nSrc; i++) {
84  auto obj = src->ptrAt(i);
85  auto detid = obj->superCluster()->seed()->seed();
86  auto coll = obj->isEB() ? recHitsEB.product() : recHitsEE.product();
87  auto seed = coll->find(detid);
88  if (seed != coll->end()) {
89  if (seed->checkFlag(EcalRecHit::kHasSwitchToGain6))
90  gainSeed[i] = 6;
91  if (seed->checkFlag(EcalRecHit::kHasSwitchToGain1))
92  gainSeed[i] = 1;
93  }
94  }
95 
96  std::unique_ptr<edm::ValueMap<int>> gainSeedV(new edm::ValueMap<int>());
97  edm::ValueMap<int>::Filler fillerCorr(*gainSeedV);
98  fillerCorr.insert(src, gainSeed.begin(), gainSeed.end());
99  fillerCorr.fill();
100  iEvent.put(std::move(gainSeedV));
101 }
102 
103 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
104 template <typename T>
107  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
108  desc.add<edm::InputTag>("recHitsEB", edm::InputTag("reducedEgamma", "reducedEBRecHits"))
109  ->setComment("EB rechit collection");
110  desc.add<edm::InputTag>("recHitsEE", edm::InputTag("reducedEgamma", "reducedEERecHits"))
111  ->setComment("EE rechit collection");
112  descriptions.addDefault(desc);
113 }
114 
117 
118 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< EcalRecHitCollection > recHitsEE_
edm::EDGetTokenT< edm::View< T > > src_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
def move
Definition: eostools.py:511
edm::EDGetTokenT< EcalRecHitCollection > recHitsEB_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T const * product() const
Definition: Handle.h:70
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
EGMSeedGainProducer< pat::Electron > ElectronSeedGainProducer
long double T
EGMSeedGainProducer(const edm::ParameterSet &iConfig)
EGMSeedGainProducer< pat::Photon > PhotonSeedGainProducer