47 bool tryAOD()
const{
return data_==AUTO || data_==AOD;}
48 bool tryMiniAOD()
const{
return data_==AUTO || data_==MINIAOD;}
63 const std::vector<T> &
values,
74 const std::vector<EleTkIsolFromCands::PIDVeto>& pidVetos,
81 for(
auto&
tag : tags) {
84 tokens.push_back(token);
92 auto tagsAOD =iPara.
getParameter<std::vector<edm::InputTag> >(tagAOD);
93 auto tagsMiniAOD =iPara.
getParameter<std::vector<edm::InputTag> >(tagMiniAOD);
96 tokens.resize(maxSize);
98 for(
size_t tagNr=0;tagNr<tagsAOD.size();tagNr++) {
103 for(
size_t tagNr=0;tagNr<tagsMiniAOD.size();tagNr++) {
126 static std::vector<edm::Handle<T> >
128 std::vector<edm::Handle<T> > handles(tokens.size());
129 if(tokens.empty())
return handles;
130 if(!tokens[0].
aod.isUninitialized()) iEvent.
getByToken(tokens[0].aod,handles[0]);
131 bool isAOD = handles[0].isValid();
132 if(!isAOD && !tokens[0].
miniAOD.isUninitialized() ) iEvent.
getByToken(tokens[0].miniAOD,handles[0]);
134 for(
size_t tokenNr=1;tokenNr<tokens.size();tokenNr++){
135 auto token = isAOD ? tokens[tokenNr].aod : tokens[tokenNr].miniAOD;
136 if(!token.isUninitialized()) iEvent.
getByToken(token,handles[tokenNr]);
145 if(handle.
isValid())
return true;
154 std::vector<DualToken<pat::PackedCandidateCollection> >
candTokens_;
187 auto fillVetos=[](
const auto&
in,
auto&
out){
193 throw cms::Exception(
"ConfigError") <<
" Error candVetosAOD should be the same size as candsAOD "<<std::endl;
198 throw cms::Exception(
"ConfigError") <<
" Error candVetosMiniAOD should be the same size as candsMiniAOD "<<std::endl;
225 std::vector<float> eleTrkPtIso;
226 std::vector<float> eleTrkPtIso04;
227 std::vector<int> eleNrSaturateIn5x5;
228 for(
auto const& ele : *eleHandle) {
233 eleNrSaturateIn5x5.push_back(
nrSaturatedCrysIn5x5(ele,ebRecHitHandle,eeRecHitHandle,caloTopoHandle));
256 const std::vector<EleTkIsolFromCands::PIDVeto>& pidVetos,
262 for(
size_t handleNr=0;handleNr<handles.size();handleNr++){
263 auto&
handle = handles[handleNr];
265 if(handleNr<pidVetos.size()){
268 throw cms::Exception(
"LogicError") <<
" somehow the pidVetos and handles do not much, given this is checked at construction time, something has gone wrong in the code handle nr "<<handleNr<<
" size of vetos "<<pidVetos.size();
279 const std::vector<T> &
values,
295 desc.
add<std::vector<edm::InputTag> >(
"candsAOD",{
edm::InputTag(
"packedCandidates")});
296 desc.
add<std::vector<std::string> >(
"candVetosAOD",{
"none"});
301 desc.
add<std::vector<edm::InputTag> >(
"candsMiniAOD",{
edm::InputTag(
"packedCandidates")});
302 desc.
add<std::vector<std::string> >(
"candVetosMiniAOD",{
"none"});
304 desc.
add<
int>(
"dataFormat",0);
305 desc.
add<
bool>(
"makeTrkIso04",
false);
T getParameter(std::string const &) const
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
EleTkIsolFromCands trkIsoCalc_
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
static void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::GsfElectron > > &handle, const std::vector< T > &values, const std::string &label)
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< DualToken< pat::PackedCandidateCollection > > candTokens_
static edm::Handle< T > getHandle(const edm::Event &iEvent, const DualToken< T > &token)
void setToken(edm::EDGetTokenT< T > &token, const edm::ParameterSet &iPara, const std::string &tag)
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< EleTkIsolFromCands::PIDVeto > candVetosMiniAOD_
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_
double calIsolPt(Args &&...args) const
static const std::string eleNrSaturateIn5x5Label_
EleTkIsolFromCands trkIso04Calc_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
static const std::string eleTrkPtIsoLabel_
static edm::Handle< T > getHandle(const edm::Event &iEvent, const edm::EDGetTokenT< T > &token)
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)
static std::vector< edm::Handle< T > > getHandles(const edm::Event &iEvent, const std::vector< DualToken< T > > &tokens)
std::vector< EleTkIsolFromCands::PIDVeto > candVetosAOD_
void setToken(std::vector< edm::EDGetTokenT< T > > &tokens, const edm::ParameterSet &iPara, const std::string &tagName)
ElectronHEEPIDValueMapProducer(const edm::ParameterSet &)
edm::EDGetTokenT< T > aod
SuperClusterRef superCluster() const override
reference to a SuperCluster
static float calTrkIso(const reco::GsfElectron &ele, const edm::View< reco::GsfElectron > &eles, const std::vector< edm::Handle< pat::PackedCandidateCollection > > &handles, const std::vector< EleTkIsolFromCands::PIDVeto > &pidVetos, const EleTkIsolFromCands &trkIsoCalc)
void setToken(edm::EDGetTokenT< T > &token, edm::InputTag tag)
T const * product() const
static bool isEventAOD(const edm::Event &iEvent, const DualToken< T > &token)
~ElectronHEEPIDValueMapProducer() override