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)
const;
80 for(
auto&
tag : tags) {
83 tokens.push_back(token);
91 auto tagsAOD =iPara.
getParameter<std::vector<edm::InputTag> >(tagAOD);
92 auto tagsMiniAOD =iPara.
getParameter<std::vector<edm::InputTag> >(tagMiniAOD);
95 tokens.resize(maxSize);
97 for(
size_t tagNr=0;tagNr<tagsAOD.size();tagNr++) {
102 for(
size_t tagNr=0;tagNr<tagsMiniAOD.size();tagNr++) {
125 static std::vector<edm::Handle<T> >
127 std::vector<edm::Handle<T> > handles(tokens.size());
128 if(tokens.empty())
return handles;
129 if(!tokens[0].
aod.isUninitialized()) iEvent.
getByToken(tokens[0].aod,handles[0]);
130 bool isAOD = handles[0].isValid();
131 if(!isAOD && !tokens[0].
miniAOD.isUninitialized() ) iEvent.
getByToken(tokens[0].miniAOD,handles[0]);
133 for(
size_t tokenNr=1;tokenNr<tokens.size();tokenNr++){
134 auto token = isAOD ? tokens[tokenNr].aod : tokens[tokenNr].miniAOD;
135 if(!token.isUninitialized()) iEvent.
getByToken(token,handles[tokenNr]);
144 if(handle.
isValid())
return true;
153 std::vector<DualToken<pat::PackedCandidateCollection> >
candTokens_;
180 auto fillVetos=[](
const auto&
in,
auto&
out){
186 throw cms::Exception(
"ConfigError") <<
" Error candVetosAOD should be the same size as candsAOD "<<std::endl;
191 throw cms::Exception(
"ConfigError") <<
" Error candVetosMiniAOD should be the same size as candsMiniAOD "<<std::endl;
217 std::vector<float> eleTrkPtIso;
218 std::vector<int> eleNrSaturateIn5x5;
219 for(
size_t eleNr=0;eleNr<eleHandle->size();eleNr++){
220 auto elePtr = eleHandle->ptrAt(eleNr);
221 eleTrkPtIso.push_back(
calTrkIso(*elePtr,*eleHandle,candHandles,candVetos));
222 eleNrSaturateIn5x5.push_back(
nrSaturatedCrysIn5x5(*elePtr,ebRecHitHandle,eeRecHitHandle,caloTopoHandle));
244 const std::vector<EleTkIsolFromCands::PIDVeto>& pidVetos)
const 249 for(
size_t handleNr=0;handleNr<handles.size();handleNr++){
250 auto&
handle = handles[handleNr];
252 if(handleNr<pidVetos.size()){
255 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();
266 const std::vector<T> &
values,
282 desc.
add<std::vector<edm::InputTag> >(
"candsAOD",{
edm::InputTag(
"packedCandidates")});
283 desc.
add<std::vector<std::string> >(
"candVetosAOD",{
"none"});
288 desc.
add<std::vector<edm::InputTag> >(
"candsMiniAOD",{
edm::InputTag(
"packedCandidates")});
289 desc.
add<std::vector<std::string> >(
"candVetosMiniAOD",{
"none"});
291 desc.
add<
int>(
"dataFormat",0);
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
#define DEFINE_FWK_MODULE(type)
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)
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_
double calIsolPt(Args &&...args) const
static const std::string eleNrSaturateIn5x5Label_
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)
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
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
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