67 const std::vector<T>&
values,
79 token = consumes<T>(
tag);
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);
115 tokens.resize(maxSize);
117 for (
size_t tagNr = 0; tagNr < tagsAOD.size(); tagNr++) {
118 setToken(tokens[tagNr].aod, tagsAOD[tagNr]);
122 for (
size_t tagNr = 0; tagNr < tagsMiniAOD.size(); tagNr++) {
128 template <
typename T>
131 if (!token.
aod.isUninitialized())
138 template <
typename T>
140 std::vector<edm::Handle<T>>
handles(tokens.size());
143 if (!tokens[0].aod.isUninitialized())
145 bool isAOD =
handles[0].isValid();
146 if (!isAOD && !tokens[0].
miniAOD.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 "
242 trkIsoCalcs.emplace_back(std::make_unique<EleTkIsolFromCands>(
trkIsoCalcCfg_, *
handle, candVetos[handleNr]));
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) {
288 trkIso += (*calculator)(*ele.
gsfTrack()).ptSum;
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_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< T > miniAOD
#define DEFINE_FWK_MODULE(type)
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)
void insert(const H &h, I begin, I end)
std::vector< std::unique_ptr< EleTkIsolFromCands >> IsolationCalculators
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)
static float calTrkIso(const reco::GsfElectron &ele, IsolationCalculators const &isolationCalculators)
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
void setToken(edm::EDGetTokenT< T > &token, const edm::ParameterSet &iPara, const std::string &tag)
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< EleTkIsolFromCands::PIDVeto > candVetosMiniAOD_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopoToken_
std::vector< BaseVolumeHandle * > handles
tuple maxSize
'/store/data/Commissioning08/BeamHalo/RECO/StuffAlmostToP5_v1/000/061/642/10A0FE34-A67D-DD11-AD05-000...
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)
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_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
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)
T const * product() const
static PIDVeto pidVetoFromStr(const std::string &vetoStr)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T const * product() const
T getParameter(std::string const &) const
std::vector< EleTkIsolFromCands::PIDVeto > candVetosAOD_
EleTkIsolFromCands::Configuration trkIso04CalcCfg_
ElectronHEEPIDValueMapProducer(const edm::ParameterSet &)
edm::EDGetTokenT< T > aod
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
void setToken(edm::EDGetTokenT< T > &token, edm::InputTag tag)
static bool isEventAOD(const edm::Event &iEvent, const DualToken< T > &token)
tuple size
Write out results.
~ElectronHEEPIDValueMapProducer() override
SuperClusterRef superCluster() const override
reference to a SuperCluster
EleTkIsolFromCands::Configuration trkIsoCalcCfg_