CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DPFIsolation Class Reference
Inheritance diagram for DPFIsolation:
deep_tau::DeepTauBase edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > > edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DPFIsolation (const edm::ParameterSet &cfg, const deep_tau::DeepTauCache *cache)
 
- Public Member Functions inherited from deep_tau::DeepTauBase
 DeepTauBase (const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
 
void produce (edm::Event &event, const edm::EventSetup &es) override
 
 ~DeepTauBase () override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static unsigned GetNumberOfFeatures (unsigned graphVersion)
 
static unsigned getNumberOfParticles (unsigned graphVersion)
 
static const OutputCollectionGetOutputs ()
 
- Static Public Member Functions inherited from deep_tau::DeepTauBase
static void globalEndJob (const DeepTauCache *cache)
 
static std::unique_ptr< DeepTauCacheinitializeGlobalCache (const edm::ParameterSet &cfg)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

tensorflow::Tensor getPredictions (edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus) override
 

Private Attributes

unsigned graphVersion
 
edm::EDGetTokenT< pat::PackedCandidateCollectionpfcand_token
 
edm::EDGetTokenT< reco::VertexCollectionvtx_token
 

Additional Inherited Members

- Public Types inherited from deep_tau::DeepTauBase
using Cutter = TauWPThreshold
 
using CutterPtr = std::unique_ptr< Cutter >
 
using ElectronCollection = pat::ElectronCollection
 
using LorentzVectorXYZ = ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double >>
 
using MuonCollection = pat::MuonCollection
 
using OutputCollection = std::map< std::string, Output >
 
using TauCollection = std::vector< TauType >
 
using TauDiscriminator = pat::PATTauDiscriminator
 
using TauRef = edm::Ref< TauCollection >
 
using TauRefProd = edm::RefProd< TauCollection >
 
using TauType = pat::Tau
 
using WPMap = std::map< std::string, CutterPtr >
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DeepTauCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected Attributes inherited from deep_tau::DeepTauBase
const DeepTauCachecache_
 
OutputCollection outputs_
 
edm::EDGetTokenT< TauCollectiontausToken_
 
std::map< std::string, WPMapworkingPoints_
 

Detailed Description

Definition at line 34 of file DPFIsolation.cc.

Constructor & Destructor Documentation

DPFIsolation::DPFIsolation ( const edm::ParameterSet cfg,
const deep_tau::DeepTauCache cache 
)
inlineexplicit

Definition at line 79 of file DPFIsolation.cc.

References Exception.

79  :
80  DeepTauBase(cfg, GetOutputs(), cache),
81  pfcand_token(consumes<pat::PackedCandidateCollection>(cfg.getParameter<edm::InputTag>("pfcands"))),
82  vtx_token(consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertices"))),
83  graphVersion(cfg.getParameter<unsigned>("version"))
84  {
85  const auto& shape = cache_->getGraph().node(0).attr().at("shape").shape();
86 
87  if(!(graphVersion == 1 || graphVersion == 0 ))
88  throw cms::Exception("DPFIsolation") << "unknown version of the graph_ file.";
89 
90  if(!(shape.dim(1).size() == getNumberOfParticles(graphVersion) && shape.dim(2).size() == GetNumberOfFeatures(graphVersion)))
91  throw cms::Exception("DPFIsolation") << "number of inputs does not match the expected inputs for the given version";
92 
93  }
T getParameter(std::string const &) const
edm::EDGetTokenT< pat::PackedCandidateCollection > pfcand_token
static unsigned getNumberOfParticles(unsigned graphVersion)
Definition: DPFIsolation.cc:43
const tensorflow::GraphDef & getGraph() const
Definition: DeepTauBase.h:50
const DeepTauCache * cache_
Definition: DeepTauBase.h:101
static unsigned GetNumberOfFeatures(unsigned graphVersion)
Definition: DPFIsolation.cc:49
DeepTauBase(const edm::ParameterSet &cfg, const OutputCollection &outputs, const DeepTauCache *cache)
Definition: DeepTauBase.cc:79
edm::EDGetTokenT< reco::VertexCollection > vtx_token
unsigned graphVersion
static const OutputCollection & GetOutputs()
Definition: DPFIsolation.cc:36

Member Function Documentation

static void DPFIsolation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 55 of file DPFIsolation.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

56  {
58  desc.add<edm::InputTag>("pfcands", edm::InputTag("packedPFCandidates"));
59  desc.add<edm::InputTag>("taus", edm::InputTag("slimmedTaus"));
60  desc.add<edm::InputTag>("vertices", edm::InputTag("offlineSlimmedPrimaryVertices"));
61  desc.add<std::string>("graph_file", "RecoTauTag/TrainingFiles/data/DPFTauId/DPFIsolation_2017v0_quantized.pb");
62  desc.add<unsigned>("version", 0);
63  desc.add<bool>("mem_mapped", false);
64 
66  descWP.add<std::string>("VVVLoose", "0");
67  descWP.add<std::string>("VVLoose", "0");
68  descWP.add<std::string>("VLoose", "0");
69  descWP.add<std::string>("Loose", "0");
70  descWP.add<std::string>("Medium", "0");
71  descWP.add<std::string>("Tight", "0");
72  descWP.add<std::string>("VTight", "0");
73  descWP.add<std::string>("VVTight", "0");
74  descWP.add<std::string>("VVVTight", "0");
75  desc.add<edm::ParameterSetDescription>("VSallWP", descWP);
76  descriptions.add("DPFTau2016v0", desc);
77  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static unsigned DPFIsolation::GetNumberOfFeatures ( unsigned  graphVersion)
inlinestatic

Definition at line 49 of file DPFIsolation.cc.

50  {
51  static const std::map<unsigned, unsigned> nfeatures { { 0, 47 }, { 1, 51 } };
52  return nfeatures.at(graphVersion);
53  }
unsigned graphVersion
static unsigned DPFIsolation::getNumberOfParticles ( unsigned  graphVersion)
inlinestatic

Definition at line 43 of file DPFIsolation.cc.

44  {
45  static const std::map<unsigned, unsigned> nparticles { { 0, 60 }, { 1, 36 } };
46  return nparticles.at(graphVersion);
47  }
unsigned graphVersion
static const OutputCollection& DPFIsolation::GetOutputs ( )
inlinestatic

Definition at line 36 of file DPFIsolation.cc.

References Output.

37  {
38  const size_t tau_index = 0;
39  static const OutputCollection outputs_ = { { "VSall", Output({tau_index}, {}) } };
40  return outputs_;
41  };
std::map< std::string, Output > OutputCollection
Definition: DeepTauBase.h:82
OutputCollection outputs_
Definition: DeepTauBase.h:100
#define Output(cl)
Definition: vmac.h:192
tensorflow::Tensor DPFIsolation::getPredictions ( edm::Event event,
const edm::EventSetup es,
edm::Handle< TauCollection taus 
)
inlineoverrideprivatevirtual

Implements deep_tau::DeepTauBase.

Definition at line 96 of file DPFIsolation.cc.

References funct::abs(), begin, EnergyCorrector::c, pat::PackedCandidate::charge(), std::clamp(), constexpr, hiPixelPairStep_cff::deltaPhi, deltaR(), pat::PackedCandidate::dxy(), pat::PackedCandidate::dxyError(), pat::PackedCandidate::dz(), pat::PackedCandidate::dzError(), end, reco::LeafCandidate::eta(), pat::PackedCandidate::eta(), objects.autophobj::float, pat::PackedCandidate::fromPV(), models::generate(), pat::PackedCandidate::hasTrackDetails(), mps_fire::i, pat::Tau::isTauIDAvailable(), pat::PackedCandidate::lostInnerHits(), min(), gen::n, pat::PackedCandidate::numberOfHits(), pat::PackedCandidate::numberOfPixelHits(), AlCaHLTBitMon_ParallelJobs::p, reco::LeafCandidate::p4(), pat::PackedCandidate::p4(), pat::PackedCandidate::pdgId(), reco::LeafCandidate::phi(), pat::PackedCandidate::phi(), reco::LeafCandidate::pt(), pat::PackedCandidate::pt(), pat::PackedCandidate::puppiWeight(), pat::PackedCandidate::pvAssociationQuality(), reco::LeafCandidate::pz(), tensorflow::run(), pat::Tau::signalCands(), mathSSE::sqrt(), metsig::tau, pat::Tau::tauID(), pat::PackedCandidate::trackHighPurity(), electrons_cff::vertices, pat::PackedCandidate::vx(), pat::PackedCandidate::vy(), and pat::PackedCandidate::vz().

98  {
100  event.getByToken(pfcand_token, pfcands);
101 
103  event.getByToken(vtx_token, vertices);
104 
105  tensorflow::Tensor tensor(tensorflow::DT_FLOAT, {1,
106  static_cast<int>(getNumberOfParticles(graphVersion)), static_cast<int>(GetNumberOfFeatures(graphVersion))});
107 
108  tensorflow::Tensor predictions(tensorflow::DT_FLOAT, { static_cast<int>(taus->size()), 1});
109 
110  std::vector<tensorflow::Tensor> outputs_;
111 
112  float pfCandPt, pfCandPz, pfCandPtRel, pfCandPzRel, pfCandDr, pfCandDEta, pfCandDPhi, pfCandEta, pfCandDz,
113  pfCandDzErr, pfCandD0, pfCandD0D0, pfCandD0Dz, pfCandD0Dphi, pfCandPuppiWeight,
114  pfCandPixHits, pfCandHits, pfCandLostInnerHits, pfCandPdgID, pfCandCharge, pfCandFromPV,
115  pfCandVtxQuality, pfCandHighPurityTrk, pfCandTauIndMatch, pfCandDzSig, pfCandD0Sig, pfCandD0Err,
116  pfCandPtRelPtRel, pfCandDzDz, pfCandDVx_1, pfCandDVy_1, pfCandDVz_1, pfCandD_1;
117  float pvx = !vertices->empty() ? (*vertices)[0].x() : -1;
118  float pvy = !vertices->empty() ? (*vertices)[0].y() : -1;
119  float pvz = !vertices->empty() ? (*vertices)[0].z() : -1;
120 
121  bool pfCandIsBarrel;
122 
123  // These variables define ranges further used for standardization
124  static constexpr float pfCandPt_max = 500.f;
125  static constexpr float pfCandPz_max = 1000.f;
126  static constexpr float pfCandPtRel_max = 1.f;
127  static constexpr float pfCandPzRel_max = 100.f;
128  static constexpr float pfCandPtRelPtRel_max = 1.f;
129  static constexpr float pfCandD0_max = 5.f;
130  static constexpr float pfCandDz_max = 5.f;
131  static constexpr float pfCandDVx_y_z_1_max = 0.05f;
132  static constexpr float pfCandD_1_max = 0.1f;
133  static constexpr float pfCandD0_z_Err_max = 1.f;
134  static constexpr float pfCandDzSig_max = 3.f;
135  static constexpr float pfCandD0Sig_max = 1.f;
136  static constexpr float pfCandDr_max = 0.5f;
137  static constexpr float pfCandEta_max = 2.75f;
138  static constexpr float pfCandDEta_max = 0.5f;
139  static constexpr float pfCandDPhi_max = 0.5f;
140  static constexpr float pfCandPixHits_max = 7.f;
141  static constexpr float pfCandHits_max = 30.f;
142 
143  for(size_t tau_index = 0; tau_index < taus->size(); tau_index++) {
144  pat::Tau tau = taus->at(tau_index);
145  bool isGoodTau = false;
146  const float lepRecoPt = tau.pt();
147  const float lepRecoPz = std::abs(tau.pz());
148  const float lepRecoEta = tau.eta();
149  const float lepRecoPhi = tau.phi();
150 
151  if(lepRecoPt >= 30 && std::abs(lepRecoEta) < 2.3 && tau.isTauIDAvailable("againstMuonLoose3") &&
152  tau.isTauIDAvailable("againstElectronVLooseMVA6")) {
153  isGoodTau = (tau.tauID("againstElectronVLooseMVA6") && tau.tauID("againstMuonLoose3") );
154  }
155 
156  if (!isGoodTau) {
157  predictions.matrix<float>()(tau_index, 0) = -1;
158  continue;
159  }
160 
161  std::vector<unsigned int> signalCandidateInds;
162 
163  for(const auto c : tau.signalCands())
164  signalCandidateInds.push_back(getPFCandidateIndex(pfcands,c));
165 
166  // Use of setZero results in warnings in eigen library during compilation.
167  //tensor.flat<float>().setZero();
169  for(unsigned input_idx = 0; input_idx < n_inputs; ++input_idx)
170  tensor.flat<float>()(input_idx) = 0;
171 
172  unsigned int iPF = 0;
173  const unsigned max_iPF = getNumberOfParticles(graphVersion);
174 
175  std::vector<unsigned int> sorted_inds(pfcands->size());
176  std::size_t n = 0;
177  std::generate(std::begin(sorted_inds), std::end(sorted_inds), [&]{ return n++; });
178 
179  std::sort(std::begin(sorted_inds), std::end(sorted_inds),
180  [&](int i1, int i2) { return pfcands->at(i1).pt() > pfcands->at(i2).pt(); } );
181 
182  for(size_t pf_index = 0; pf_index < pfcands->size() && iPF < max_iPF; pf_index++) {
183  pat::PackedCandidate p = pfcands->at(sorted_inds.at(pf_index));
184  float deltaR_tau_p = deltaR(p.p4(),tau.p4());
185 
186  if (p.pt() < 0.5) continue;
187  if (p.fromPV() < 0) continue;
188  if (deltaR_tau_p > 0.5) continue;
189  if (p.fromPV() < 1 && p.charge() != 0) continue;
190  pfCandPt = p.pt();
191  pfCandPtRel = p.pt()/lepRecoPt;
192 
193  pfCandDr = deltaR_tau_p;
194  pfCandDEta = std::abs(lepRecoEta - p.eta());
195  pfCandDPhi = std::abs(deltaPhi(lepRecoPhi, p.phi()));
196  pfCandEta = p.eta();
197  pfCandIsBarrel = (std::abs(pfCandEta) < 1.4);
198  pfCandPz = std::abs(std::sinh(pfCandEta)*pfCandPt);
199  pfCandPzRel = pfCandPz/lepRecoPz;
200  pfCandPdgID = std::abs(p.pdgId());
201  pfCandCharge = p.charge();
202  pfCandDVx_1 = p.vx() - pvx;
203  pfCandDVy_1 = p.vy() - pvy;
204  pfCandDVz_1 = p.vz() - pvz;
205 
206  pfCandD_1 = std::sqrt(pfCandDVx_1*pfCandDVx_1 + pfCandDVy_1*pfCandDVy_1 + pfCandDVz_1*pfCandDVz_1);
207 
208  if (pfCandCharge != 0 and p.hasTrackDetails()){
209  pfCandDz = p.dz();
210  pfCandDzErr = p.dzError();
211  pfCandDzSig = (std::abs(p.dz()) + 0.000001)/(p.dzError() + 0.00001);
212  pfCandD0 = p.dxy();
213  pfCandD0Err = p.dxyError();
214  pfCandD0Sig = (std::abs(p.dxy()) + 0.000001)/ (p.dxyError() + 0.00001);
215  pfCandPixHits = p.numberOfPixelHits();
216  pfCandHits = p.numberOfHits();
217  pfCandLostInnerHits = p.lostInnerHits();
218  } else {
219  float disp = 1;
220  int psudorand = p.pt()*1000000;
221  if (psudorand%2 == 0) disp = -1;
222  pfCandDz = 5*disp;
223  pfCandDzErr = 0;
224  pfCandDzSig = 0;
225  pfCandD0 = 5*disp;
226  pfCandD0Err = 0;
227  pfCandD0Sig = 0;
228  pfCandPixHits = 0;
229  pfCandHits = 0;
230  pfCandLostInnerHits = 2.;
231  pfCandDVx_1 = 1;
232  pfCandDVy_1 = 1;
233  pfCandDVz_1 = 1;
234  pfCandD_1 = 1;
235  }
236 
237  pfCandPuppiWeight = p.puppiWeight();
238  pfCandFromPV = p.fromPV();
239  pfCandVtxQuality = p.pvAssociationQuality();
240  pfCandHighPurityTrk = p.trackHighPurity();
241  float pfCandTauIndMatch_temp = 0;
242 
243  for (auto i : signalCandidateInds) {
244  if (i == sorted_inds.at(pf_index)) pfCandTauIndMatch_temp = 1;
245  }
246 
247  pfCandTauIndMatch = pfCandTauIndMatch_temp;
248  pfCandPtRelPtRel = pfCandPtRel*pfCandPtRel;
249  pfCandPt = std::min(pfCandPt, pfCandPt_max);
250  pfCandPt = pfCandPt/pfCandPt_max;
251 
252  pfCandPz = std::min(pfCandPz, pfCandPz_max);
253  pfCandPz = pfCandPz/pfCandPz_max;
254 
255  pfCandPtRel = std::min(pfCandPtRel, pfCandPtRel_max);
256  pfCandPzRel = std::min(pfCandPzRel, pfCandPzRel_max);
257  pfCandPzRel = pfCandPzRel/pfCandPzRel_max;
258  pfCandDr = pfCandDr/pfCandDr_max;
259  pfCandEta = pfCandEta/pfCandEta_max;
260  pfCandDEta = pfCandDEta/pfCandDEta_max;
261  pfCandDPhi = pfCandDPhi/pfCandDPhi_max;
262  pfCandPixHits = pfCandPixHits/pfCandPixHits_max;
263  pfCandHits = pfCandHits/pfCandHits_max;
264 
265  pfCandPtRelPtRel = std::min(pfCandPtRelPtRel, pfCandPtRelPtRel_max);
266 
267  pfCandD0 = std::clamp(pfCandD0, -pfCandD0_max, pfCandD0_max);
268  pfCandD0 = pfCandD0/pfCandD0_max;
269 
270  pfCandDz = std::clamp(pfCandDz, -pfCandDz_max, pfCandDz_max);
271  pfCandDz = pfCandDz/pfCandDz_max;
272 
273  pfCandD0Err = std::min(pfCandD0Err, pfCandD0_z_Err_max);
274  pfCandDzErr = std::min(pfCandDzErr, pfCandD0_z_Err_max);
275  pfCandDzSig = std::min(pfCandDzSig, pfCandDzSig_max);
276  pfCandDzSig = pfCandDzSig/pfCandDzSig_max;
277 
278  pfCandD0Sig = std::min(pfCandD0Sig, pfCandD0Sig_max);
279  pfCandD0D0 = pfCandD0*pfCandD0;
280  pfCandDzDz = pfCandDz*pfCandDz;
281  pfCandD0Dz = pfCandD0*pfCandDz;
282  pfCandD0Dphi = pfCandD0*pfCandDPhi;
283 
284  pfCandDVx_1 = std::clamp(pfCandDVx_1, -pfCandDVx_y_z_1_max, pfCandDVx_y_z_1_max);
285  pfCandDVx_1 = pfCandDVx_1/pfCandDVx_y_z_1_max;
286 
287  pfCandDVy_1 = std::clamp(pfCandDVy_1, -pfCandDVx_y_z_1_max, pfCandDVx_y_z_1_max);
288  pfCandDVy_1 = pfCandDVy_1/pfCandDVx_y_z_1_max;
289 
290  pfCandDVz_1 = std::clamp(pfCandDVz_1, -pfCandDVx_y_z_1_max, pfCandDVx_y_z_1_max);
291  pfCandDVz_1 = pfCandDVz_1/pfCandDVx_y_z_1_max;
292 
293  pfCandD_1 = std::clamp(pfCandD_1, -pfCandD_1_max, pfCandD_1_max);
294  pfCandD_1 = pfCandD_1/ pfCandD_1_max;
295 
296  if (graphVersion == 0) {
297  tensor.tensor<float,3>()( 0, 60-1-iPF, 0) = pfCandPt;
298  tensor.tensor<float,3>()( 0, 60-1-iPF, 1) = pfCandPz;
299  tensor.tensor<float,3>()( 0, 60-1-iPF, 2) = pfCandPtRel;
300  tensor.tensor<float,3>()( 0, 60-1-iPF, 3) = pfCandPzRel;
301  tensor.tensor<float,3>()( 0, 60-1-iPF, 4) = pfCandDr;
302  tensor.tensor<float,3>()( 0, 60-1-iPF, 5) = pfCandDEta;
303  tensor.tensor<float,3>()( 0, 60-1-iPF, 6) = pfCandDPhi;
304  tensor.tensor<float,3>()( 0, 60-1-iPF, 7) = pfCandEta;
305  tensor.tensor<float,3>()( 0, 60-1-iPF, 8) = pfCandDz;
306  tensor.tensor<float,3>()( 0, 60-1-iPF, 9) = pfCandDzSig;
307  tensor.tensor<float,3>()( 0, 60-1-iPF, 10) = pfCandD0;
308  tensor.tensor<float,3>()( 0, 60-1-iPF, 11) = pfCandD0Sig;
309  tensor.tensor<float,3>()( 0, 60-1-iPF, 12) = pfCandDzErr;
310  tensor.tensor<float,3>()( 0, 60-1-iPF, 13) = pfCandD0Err;
311  tensor.tensor<float,3>()( 0, 60-1-iPF, 14) = pfCandD0D0;
312  tensor.tensor<float,3>()( 0, 60-1-iPF, 15) = pfCandCharge==0;
313  tensor.tensor<float,3>()( 0, 60-1-iPF, 16) = pfCandCharge==1;
314  tensor.tensor<float,3>()( 0, 60-1-iPF, 17) = pfCandCharge==-1;
315  tensor.tensor<float,3>()( 0, 60-1-iPF, 18) = pfCandPdgID>22;
316  tensor.tensor<float,3>()( 0, 60-1-iPF, 19) = pfCandPdgID==22;
317  tensor.tensor<float,3>()( 0, 60-1-iPF, 20) = pfCandDzDz;
318  tensor.tensor<float,3>()( 0, 60-1-iPF, 21) = pfCandD0Dz;
319  tensor.tensor<float,3>()( 0, 60-1-iPF, 22) = pfCandD0Dphi;
320  tensor.tensor<float,3>()( 0, 60-1-iPF, 23) = pfCandPtRelPtRel;
321  tensor.tensor<float,3>()( 0, 60-1-iPF, 24) = pfCandPixHits;
322  tensor.tensor<float,3>()( 0, 60-1-iPF, 25) = pfCandHits;
323  tensor.tensor<float,3>()( 0, 60-1-iPF, 26) = pfCandLostInnerHits==-1;
324  tensor.tensor<float,3>()( 0, 60-1-iPF, 27) = pfCandLostInnerHits==0;
325  tensor.tensor<float,3>()( 0, 60-1-iPF, 28) = pfCandLostInnerHits==1;
326  tensor.tensor<float,3>()( 0, 60-1-iPF, 29) = pfCandLostInnerHits==2;
327  tensor.tensor<float,3>()( 0, 60-1-iPF, 30) = pfCandPuppiWeight;
328  tensor.tensor<float,3>()( 0, 60-1-iPF, 31) = (pfCandVtxQuality == 1);
329  tensor.tensor<float,3>()( 0, 60-1-iPF, 32) = (pfCandVtxQuality == 5);
330  tensor.tensor<float,3>()( 0, 60-1-iPF, 33) = (pfCandVtxQuality == 6);
331  tensor.tensor<float,3>()( 0, 60-1-iPF, 34) = (pfCandVtxQuality == 7);
332  tensor.tensor<float,3>()( 0, 60-1-iPF, 35) = (pfCandFromPV == 1);
333  tensor.tensor<float,3>()( 0, 60-1-iPF, 36) = (pfCandFromPV == 2);
334  tensor.tensor<float,3>()( 0, 60-1-iPF, 37) = (pfCandFromPV == 3);
335  tensor.tensor<float,3>()( 0, 60-1-iPF, 38) = pfCandIsBarrel;
336  tensor.tensor<float,3>()( 0, 60-1-iPF, 39) = pfCandHighPurityTrk;
337  tensor.tensor<float,3>()( 0, 60-1-iPF, 40) = pfCandPdgID==1;
338  tensor.tensor<float,3>()( 0, 60-1-iPF, 41) = pfCandPdgID==2;
339  tensor.tensor<float,3>()( 0, 60-1-iPF, 42) = pfCandPdgID==11;
340  tensor.tensor<float,3>()( 0, 60-1-iPF, 43) = pfCandPdgID==13;
341  tensor.tensor<float,3>()( 0, 60-1-iPF, 44) = pfCandPdgID==130;
342  tensor.tensor<float,3>()( 0, 60-1-iPF, 45) = pfCandPdgID==211;
343  tensor.tensor<float,3>()( 0, 60-1-iPF, 46) = pfCandTauIndMatch;
344  }
345 
346  if (graphVersion == 1) {
347  tensor.tensor<float,3>()( 0, 36-1-iPF, 0) = pfCandPt;
348  tensor.tensor<float,3>()( 0, 36-1-iPF, 1) = pfCandPz;
349  tensor.tensor<float,3>()( 0, 36-1-iPF, 2) = pfCandPtRel;
350  tensor.tensor<float,3>()( 0, 36-1-iPF, 3) = pfCandPzRel;
351  tensor.tensor<float,3>()( 0, 36-1-iPF, 4) = pfCandDr;
352  tensor.tensor<float,3>()( 0, 36-1-iPF, 5) = pfCandDEta;
353  tensor.tensor<float,3>()( 0, 36-1-iPF, 6) = pfCandDPhi;
354  tensor.tensor<float,3>()( 0, 36-1-iPF, 7) = pfCandEta;
355  tensor.tensor<float,3>()( 0, 36-1-iPF, 8) = pfCandDz;
356  tensor.tensor<float,3>()( 0, 36-1-iPF, 9) = pfCandDzSig;
357  tensor.tensor<float,3>()( 0, 36-1-iPF, 10) = pfCandD0;
358  tensor.tensor<float,3>()( 0, 36-1-iPF, 11) = pfCandD0Sig;
359  tensor.tensor<float,3>()( 0, 36-1-iPF, 12) = pfCandDzErr;
360  tensor.tensor<float,3>()( 0, 36-1-iPF, 13) = pfCandD0Err;
361  tensor.tensor<float,3>()( 0, 36-1-iPF, 14) = pfCandD0D0;
362  tensor.tensor<float,3>()( 0, 36-1-iPF, 15) = pfCandCharge==0;
363  tensor.tensor<float,3>()( 0, 36-1-iPF, 16) = pfCandCharge==1;
364  tensor.tensor<float,3>()( 0, 36-1-iPF, 17) = pfCandCharge==-1;
365  tensor.tensor<float,3>()( 0, 36-1-iPF, 18) = pfCandPdgID>22;
366  tensor.tensor<float,3>()( 0, 36-1-iPF, 19) = pfCandPdgID==22;
367  tensor.tensor<float,3>()( 0, 36-1-iPF, 20) = pfCandDVx_1;
368  tensor.tensor<float,3>()( 0, 36-1-iPF, 21) = pfCandDVy_1;
369  tensor.tensor<float,3>()( 0, 36-1-iPF, 22) = pfCandDVz_1;
370  tensor.tensor<float,3>()( 0, 36-1-iPF, 23) = pfCandD_1;
371  tensor.tensor<float,3>()( 0, 36-1-iPF, 24) = pfCandDzDz;
372  tensor.tensor<float,3>()( 0, 36-1-iPF, 25) = pfCandD0Dz;
373  tensor.tensor<float,3>()( 0, 36-1-iPF, 26) = pfCandD0Dphi;
374  tensor.tensor<float,3>()( 0, 36-1-iPF, 27) = pfCandPtRelPtRel;
375  tensor.tensor<float,3>()( 0, 36-1-iPF, 28) = pfCandPixHits;
376  tensor.tensor<float,3>()( 0, 36-1-iPF, 29) = pfCandHits;
377  tensor.tensor<float,3>()( 0, 36-1-iPF, 30) = pfCandLostInnerHits==-1;
378  tensor.tensor<float,3>()( 0, 36-1-iPF, 31) = pfCandLostInnerHits==0;
379  tensor.tensor<float,3>()( 0, 36-1-iPF, 32) = pfCandLostInnerHits==1;
380  tensor.tensor<float,3>()( 0, 36-1-iPF, 33) = pfCandLostInnerHits==2;
381  tensor.tensor<float,3>()( 0, 36-1-iPF, 34) = pfCandPuppiWeight;
382  tensor.tensor<float,3>()( 0, 36-1-iPF, 35) = (pfCandVtxQuality == 1);
383  tensor.tensor<float,3>()( 0, 36-1-iPF, 36) = (pfCandVtxQuality == 5);
384  tensor.tensor<float,3>()( 0, 36-1-iPF, 37) = (pfCandVtxQuality == 6);
385  tensor.tensor<float,3>()( 0, 36-1-iPF, 38) = (pfCandVtxQuality == 7);
386  tensor.tensor<float,3>()( 0, 36-1-iPF, 39) = (pfCandFromPV == 1);
387  tensor.tensor<float,3>()( 0, 36-1-iPF, 40) = (pfCandFromPV == 2);
388  tensor.tensor<float,3>()( 0, 36-1-iPF, 41) = (pfCandFromPV == 3);
389  tensor.tensor<float,3>()( 0, 36-1-iPF, 42) = pfCandIsBarrel;
390  tensor.tensor<float,3>()( 0, 36-1-iPF, 43) = pfCandHighPurityTrk;
391  tensor.tensor<float,3>()( 0, 36-1-iPF, 44) = pfCandPdgID==1;
392  tensor.tensor<float,3>()( 0, 36-1-iPF, 45) = pfCandPdgID==2;
393  tensor.tensor<float,3>()( 0, 36-1-iPF, 46) = pfCandPdgID==11;
394  tensor.tensor<float,3>()( 0, 36-1-iPF, 47) = pfCandPdgID==13;
395  tensor.tensor<float,3>()( 0, 36-1-iPF, 48) = pfCandPdgID==130;
396  tensor.tensor<float,3>()( 0, 36-1-iPF, 49) = pfCandPdgID==211;
397  tensor.tensor<float,3>()( 0, 36-1-iPF, 50) = pfCandTauIndMatch;
398  }
399  iPF++;
400  }
401  tensorflow::run(&(cache_->getSession()), { { "input_1", tensor } }, { "output_node0" }, {}, &outputs_);
402  predictions.matrix<float>()(tau_index, 0) = outputs_[0].flat<float>()(0);
403  }
404  return predictions;
405  }
float puppiWeight() const
Set both weights at once (with option for only full PUPPI)
virtual float dz(size_t ipv=0) const
dz with respect to the PV[ipv]
edm::EDGetTokenT< pat::PackedCandidateCollection > pfcand_token
float dxyError() const override
uncertainty on dxy
double eta() const final
momentum pseudorapidity
int numberOfHits() const
int pdgId() const override
PDG identifier.
static unsigned getNumberOfParticles(unsigned graphVersion)
Definition: DPFIsolation.cc:43
tensorflow::Session & getSession() const
Definition: DeepTauBase.h:49
const DeepTauCache * cache_
Definition: DeepTauBase.h:101
const LorentzVector & p4() const override
four-momentum Lorentz vecto r
float dzError() const override
uncertainty on dz
double pt() const final
transverse momentum
float tauID(const std::string &name) const
reco::CandidatePtrVector signalCands() const
double vz() const override
z coordinate of vertex position
#define constexpr
def generate(map_blobs=False, class_name=None)
Definition: models.py:187
OutputCollection outputs_
Definition: DeepTauBase.h:100
int charge() const override
electric charge
double vy() const override
y coordinate of vertex position
static unsigned GetNumberOfFeatures(unsigned graphVersion)
Definition: DPFIsolation.cc:49
const PVAssociationQuality pvAssociationQuality() const
double pz() const final
z coordinate of momentum vector
const PVAssoc fromPV(size_t ipv=0) const
T sqrt(T t)
Definition: SSEVec.h:18
bool trackHighPurity() const
true if the track had the highPurity quality bit
LostInnerHits lostInnerHits() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
double pt() const override
transverse momentum
#define end
Definition: vmac.h:37
T min(T a, T b)
Definition: MathUtil.h:58
int numberOfPixelHits() const
Analysis-level tau class.
Definition: Tau.h:55
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
bool isTauIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Tau.
double eta() const override
momentum pseudorapidity
double phi() const override
momentum azimuthal angle
edm::EDGetTokenT< reco::VertexCollection > vtx_token
const T & clamp(const T &v, const T &lo, const T &hi)
Definition: DPFIsolation.cc:27
#define begin
Definition: vmac.h:30
unsigned graphVersion
void run(Session *session, const NamedTensorList &inputs, const std::vector< std::string > &outputNames, const std::vector< std::string > &targetNodes, std::vector< Tensor > *outputs)
Definition: TensorFlow.cc:210
virtual float dxy() const
dxy with respect to the PV ref
double phi() const final
momentum azimuthal angle
double vx() const override
x coordinate of vertex position

Member Data Documentation

unsigned DPFIsolation::graphVersion
private

Definition at line 410 of file DPFIsolation.cc.

edm::EDGetTokenT<pat::PackedCandidateCollection> DPFIsolation::pfcand_token
private

Definition at line 408 of file DPFIsolation.cc.

edm::EDGetTokenT<reco::VertexCollection> DPFIsolation::vtx_token
private

Definition at line 409 of file DPFIsolation.cc.