CMS 3D CMS Logo

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:
37  explicit EGMSeedGainProducer(const edm::ParameterSet& iConfig)
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
edm::StreamID
Definition: StreamID.h:30
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
mps_fire.i
i
Definition: mps_fire.py:428
EGMSeedGainProducer::~EGMSeedGainProducer
~EGMSeedGainProducer() override
Definition: EGMSeedGainProducer.cc:43
EcalRecHit::kHasSwitchToGain6
Definition: EcalRecHit.h:37
sistrip::View
View
Definition: ConstantsForView.h:26
EGMSeedGainProducer::recHitsEE_
edm::EDGetTokenT< EcalRecHitCollection > recHitsEE_
Definition: EGMSeedGainProducer.cc:54
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Photon.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EGMSeedGainProducer::src_
edm::EDGetTokenT< edm::View< T > > src_
Definition: EGMSeedGainProducer.cc:52
edm::SortedCollection< EcalRecHit >
PhotonSeedGainProducer
EGMSeedGainProducer< pat::Photon > PhotonSeedGainProducer
Definition: EGMSeedGainProducer.cc:116
ElectronSeedGainProducer
EGMSeedGainProducer< pat::Electron > ElectronSeedGainProducer
Definition: EGMSeedGainProducer.cc:115
edm::Handle
Definition: AssociativeIterator.h:50
fileCollector.seed
seed
Definition: fileCollector.py:127
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
EGMSeedGainProducer
Definition: EGMSeedGainProducer.cc:35
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
Event.h
EGMSeedGainProducer::recHitsEB_
edm::EDGetTokenT< EcalRecHitCollection > recHitsEB_
Definition: EGMSeedGainProducer.cc:53
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
EGMSeedGainProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EGMSeedGainProducer.cc:105
EcalRecHit::kHasSwitchToGain1
Definition: EcalRecHit.h:38
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
EcalDeadCellBoundaryEnergyFilter_cfi.recHitsEE
recHitsEE
Definition: EcalDeadCellBoundaryEnergyFilter_cfi.py:18
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ValueMap< int >
EGMSeedGainProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: EGMSeedGainProducer.cc:71
Electron.h
EGMSeedGainProducer::EGMSeedGainProducer
EGMSeedGainProducer(const edm::ParameterSet &iConfig)
Definition: EGMSeedGainProducer.cc:37
EcalDeadCellBoundaryEnergyFilter_cfi.recHitsEB
recHitsEB
Definition: EcalDeadCellBoundaryEnergyFilter_cfi.py:17
edm::helper::Filler
Definition: ValueMap.h:22
View.h
ParameterSet.h
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
EDProducer.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
StreamID.h
edm::InputTag
Definition: InputTag.h:15