65 template <
typename HandleType,
typename ValType>
68 const std::vector<ValType>& vals,
70 auto valMap = std::make_unique<edm::ValueMap<ValType>>();
72 filler.insert(objHandle, vals.begin(), vals.end());
80 : photonToken_(consumes(conf.getParameter<
edm::
InputTag>(
"src"))),
81 energyCorrector_(conf.getParameter<
std::
string>(
"correctionFile")),
82 recHitCollectionEBToken_(consumes(conf.getParameter<
edm::
InputTag>(
"recHitCollectionEB"))),
83 recHitCollectionEEToken_(consumes(conf.getParameter<
edm::
InputTag>(
"recHitCollectionEE"))),
84 produceCalibratedObjs_(conf.getParameter<
bool>(
"produceCalibratedObjs")) {
93 produces<std::vector<T>>();
100 template <
typename T>
107 desc.add<
double>(
"minEtToCalibrate", 5.0);
108 desc.add<
bool>(
"produceCalibratedObjs",
true);
109 desc.add<
bool>(
"semiDeterministic",
true);
110 std::vector<std::string> valMapsProduced;
111 valMapsProduced.reserve(valMapsToStore_.size());
112 for (
auto varToStore : valMapsToStore_)
114 desc.add<std::vector<std::string>>(
"valueMapsStored", valMapsProduced)
116 "provides to python configs the list of valuemaps stored, can not be overriden in the python config");
120 template <
typename T>
122 auto inHandle =
iEvent.getHandle(photonToken_);
124 auto recHitCollectionEBHandle =
iEvent.getHandle(recHitCollectionEBToken_);
125 auto recHitCollectionEEHandle =
iEvent.getHandle(recHitCollectionEEToken_);
127 std::unique_ptr<std::vector<T>>
out = std::make_unique<std::vector<T>>();
129 size_t nrObj = inHandle->size();
137 for (
const auto& pho : *inHandle) {
138 out->emplace_back(pho);
140 if (semiDeterministicRng_)
141 setSemiDetRandomSeed(
iEvent, pho, nrObj,
out->size());
144 (pho.isEB()) ? recHitCollectionEBHandle.product() : recHitCollectionEEHandle.product();
145 std::array<float, EGEnergySysIndex::kNrSysErrs> uncertainties =
153 auto fillAndStore = [&](
auto handle) {
154 for (
const auto& mapToStore : valMapsToStore_) {
159 if (produceCalibratedObjs_) {
162 fillAndStore(inHandle);
167 template <
typename T>
172 if (
obj.superCluster().isNonnull()) {
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
std::unique_ptr< TRandom > semiDeterministicRng_
void initPrivateRng(TRandom *rnd)
static const std::string & name(size_t index)
#define DEFINE_FWK_MODULE(type)
void produce(edm::Event &, const edm::EventSetup &) override
PhotonEnergyCalibrator energyCorrector_
void setSemiDetRandomSeed(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
CalibratedPhotonProducerT(const edm::ParameterSet &)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
static constexpr size_t kNrSysErrs
uint32_t getRandomSeedFromObj(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
~CalibratedPhotonProducerT() override
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::View< T > > photonToken_
uint32_t getRandomSeedFromSC(const edm::Event &iEvent, const reco::SuperClusterRef scRef)
static const std::vector< int > valMapsToStore_
bool produceCalibratedObjs_