CMS 3D CMS Logo

DPFIsolation.cc
Go to the documentation of this file.
1 /*
2  * \class DPFIsolation
3  *
4  * Deep ParticleFlow tau isolation using Deep NN.
5  *
6  * \author Owen Colegrove, UCSB
7  */
8 
10 
11 namespace {
12 
13 inline int getPFCandidateIndex(const edm::Handle<pat::PackedCandidateCollection>& pfcands,
14  const reco::CandidatePtr& cptr)
15 {
16  for(unsigned int i = 0; i < pfcands->size(); ++i) {
17  if(reco::CandidatePtr(pfcands,i) == cptr)
18  return i;
19  }
20  return -1;
21 }
22 } // anonymous namespace
23 
24 #if __cplusplus < 201703L
25 namespace std {
26  template<class T>
27  inline constexpr const T& clamp( const T& v, const T& lo, const T& hi )
28  {
29  return (v < lo) ? lo : (v > hi)? hi : v;
30  }
31 }
32 #endif
33 
35 public:
36  static const OutputCollection& GetOutputs()
37  {
38  const size_t tau_index = 0;
39  static const OutputCollection outputs_ = { { "VSall", Output({tau_index}, {}) } };
40  return outputs_;
41  };
42 
43  static unsigned getNumberOfParticles(unsigned graphVersion)
44  {
45  static const std::map<unsigned, unsigned> nparticles { { 0, 60 }, { 1, 36 } };
46  return nparticles.at(graphVersion);
47  }
48 
49  static unsigned GetNumberOfFeatures(unsigned graphVersion)
50  {
51  static const std::map<unsigned, unsigned> nfeatures { { 0, 47 }, { 1, 51 } };
52  return nfeatures.at(graphVersion);
53  }
54 
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  }
78 
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  }
94 
95 private:
96  tensorflow::Tensor getPredictions(edm::Event& event, const edm::EventSetup& es,
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();
168  const unsigned n_inputs = getNumberOfParticles(graphVersion) * GetNumberOfFeatures(graphVersion);
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  }
406 
407 private:
410  unsigned graphVersion;
411 };
412 
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: DPFIsolation.cc:55
int numberOfHits() const
int pdgId() const override
PDG identifier.
static unsigned getNumberOfParticles(unsigned graphVersion)
Definition: DPFIsolation.cc:43
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< pat::PackedCandidate > PackedCandidateCollection
const LorentzVector & p4() const override
four-momentum Lorentz vecto r
float dzError() const override
uncertainty on dz
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float tauID(const std::string &name) const
reco::CandidatePtrVector signalCands() const
double vz() const override
z coordinate of vertex position
std::map< std::string, Output > OutputCollection
Definition: DeepTauBase.h:82
#define constexpr
Definition: HeavyIon.h:7
def generate(map_blobs=False, class_name=None)
Definition: models.py:187
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int numberOfPixelHits() const
Analysis-level tau class.
Definition: Tau.h:55
tensorflow::Tensor getPredictions(edm::Event &event, const edm::EventSetup &es, edm::Handle< TauCollection > taus) override
Definition: DPFIsolation.cc:96
def cache(function)
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
DPFIsolation(const edm::ParameterSet &cfg, const deep_tau::DeepTauCache *cache)
Definition: DPFIsolation.cc:79
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
#define begin
Definition: vmac.h:30
HLT enums.
#define Output(cl)
Definition: vmac.h:192
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
static const OutputCollection & GetOutputs()
Definition: DPFIsolation.cc:36
virtual float dxy() const
dxy with respect to the PV ref
long double T
double phi() const final
momentum azimuthal angle
double vx() const override
x coordinate of vertex position
Definition: event.py:1