67 const std::vector<T>&
values,
91 tokens.push_back(
token);
105 template <
typename T>
111 auto tagsAOD = iPara.
getParameter<std::vector<edm::InputTag>>(tagAOD);
112 auto tagsMiniAOD = iPara.
getParameter<std::vector<edm::InputTag>>(tagMiniAOD);
117 for (
size_t tagNr = 0; tagNr < tagsAOD.size(); tagNr++) {
118 setToken(tokens[tagNr].aod, tagsAOD[tagNr]);
121 if (
format.tryMiniAOD()) {
122 for (
size_t tagNr = 0; tagNr < tagsMiniAOD.size(); tagNr++) {
128 template <
typename T>
131 if (!
token.aod.isUninitialized())
133 if (!
handle.isValid() && !
token.miniAOD.isUninitialized())
138 template <
typename T>
140 std::vector<edm::Handle<T>>
handles(tokens.size());
143 if (!tokens[0].aod.isUninitialized())
149 for (
size_t tokenNr = 1; tokenNr < tokens.size(); tokenNr++) {
150 auto token =
isAOD ? tokens[tokenNr].aod : tokens[tokenNr].miniAOD;
151 if (!
token.isUninitialized())
157 template <
typename T>
160 if (!
token.aod.isUninitialized())
171 std::vector<DualToken<pat::PackedCandidateCollection>>
candTokens_;
192 : trkIsoCalcCfg_(iConfig.getParameter<
edm::
ParameterSet>(
"trkIsoConfig")),
193 trkIso04CalcCfg_(iConfig.getParameter<
edm::
ParameterSet>(
"trkIso04Config")),
194 makeTrkIso04_(iConfig.getParameter<
bool>(
"makeTrkIso04")),
195 dataFormat_(iConfig.getParameter<
int>(
"dataFormat")) {
203 auto fillVetos = [](
const auto&
in,
auto&
out) {
209 throw cms::Exception(
"ConfigError") <<
" Error candVetosAOD should be the same size as candsAOD " << std::endl;
214 throw cms::Exception(
"ConfigError") <<
" Error candVetosMiniAOD should be the same size as candsMiniAOD " 244 trkIso04Calcs.emplace_back(
254 std::vector<float> eleTrkPtIso;
255 std::vector<float> eleTrkPtIso04;
256 std::vector<int> eleNrSaturateIn5x5;
257 for (
auto const& ele : *eleHandle) {
258 eleTrkPtIso.push_back(
calTrkIso(ele, trkIsoCalcs));
260 eleTrkPtIso04.push_back(
calTrkIso(ele, trkIso04Calcs));
262 eleNrSaturateIn5x5.push_back(
nrSaturatedCrysIn5x5(ele, ebRecHitHandle, eeRecHitHandle, caloTopoHandle));
287 for (
auto& calculator : isolationCalculators) {
293 template <
typename T>
296 const std::vector<T>&
values,
310 desc.add<std::vector<edm::InputTag>>(
"candsAOD", {
edm::InputTag(
"packedCandidates")});
311 desc.add<std::vector<std::string>>(
"candVetosAOD", {
"none"});
316 desc.add<std::vector<edm::InputTag>>(
"candsMiniAOD", {
edm::InputTag(
"packedCandidates")});
317 desc.add<std::vector<std::string>>(
"candVetosMiniAOD", {
"none"});
319 desc.add<
int>(
"dataFormat", 0);
320 desc.add<
bool>(
"makeTrkIso04",
false);
DualToken< EcalRecHitCollection > ebRecHitToken_
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
edm::EDGetTokenT< T > miniAOD
void produce(edm::Event &, const edm::EventSetup &) override
static int nrSaturatedCrysIn5x5(const reco::GsfElectron &ele, edm::Handle< EcalRecHitCollection > &ebHits, edm::Handle< EcalRecHitCollection > &eeHits, edm::ESHandle< CaloTopology > &caloTopo)
T const * product() const
std::vector< DualToken< pat::PackedCandidateCollection > > candTokens_
void setToken(std::vector< edm::EDGetTokenT< T >> &tokens, const edm::ParameterSet &iPara, const std::string &tagName)
static edm::Handle< T > getHandle(const edm::Event &iEvent, const DualToken< T > &token)
std::vector< std::unique_ptr< EleTkIsolFromCands > > IsolationCalculators
static float calTrkIso(const reco::GsfElectron &ele, IsolationCalculators const &isolationCalculators)
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
void setToken(edm::EDGetTokenT< T > &token, const edm::ParameterSet &iPara, const std::string &tag)
T const * product() const
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< EleTkIsolFromCands::PIDVeto > candVetosMiniAOD_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
std::vector< BaseVolumeHandle * > handles
static std::vector< edm::Handle< T > > getHandles(const edm::Event &iEvent, const std::vector< DualToken< T >> &tokens)
DualToken< edm::View< reco::GsfElectron > > eleToken_
void setToken(DualToken< T > &token, const edm::ParameterSet &iPara, const std::string &tagAOD, const std::string &tagMiniAOD, DataFormat format)
#define DEFINE_FWK_MODULE(type)
static edm::ParameterSetDescription pSetDescript()
DualToken< EcalRecHitCollection > eeRecHitToken_
static const std::string eleTrkPtIso04Label_
static void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::GsfElectron >> &handle, const std::vector< T > &values, const std::string &label)
static const std::string eleNrSaturateIn5x5Label_
bool isNull() const
Checks for null.
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
static const std::string eleTrkPtIsoLabel_
void setToken(std::vector< DualToken< T >> &tokens, const edm::ParameterSet &iPara, const std::string &tagAOD, const std::string &tagMiniAOD, DataFormat format)
static PIDVeto pidVetoFromStr(const std::string &vetoStr)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< EleTkIsolFromCands::PIDVeto > candVetosAOD_
EleTkIsolFromCands::Configuration trkIso04CalcCfg_
ElectronHEEPIDValueMapProducer(const edm::ParameterSet &)
edm::EDGetTokenT< T > aod
void setToken(edm::EDGetTokenT< T > &token, edm::InputTag tag)
static bool isEventAOD(const edm::Event &iEvent, const DualToken< T > &token)
~ElectronHEEPIDValueMapProducer() override
SuperClusterRef superCluster() const override
reference to a SuperCluster
EleTkIsolFromCands::Configuration trkIsoCalcCfg_