ATLAS Offline Software
Loading...
Searching...
No Matches
Tool_FeatureExtractor.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11
13 return u->getBDTValue() > v->getBDTValue();
14}
15
16
18 return u->p4().Et() > v->p4().Et();
19}
20
21
23 asg::AsgTool(name)
24{}
25
26
28
29 ATH_MSG_INFO(" initialize()");
30 m_init=true;
31
34
35 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) );
36 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) );
37 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) );
38 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) );
39 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) );
40 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) );
41 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) );
42
43 ATH_CHECK( m_Tool_InformationStore->getInfo_Int("FeatureExtractor_UseEmptySeeds", m_Config_UseEmptySeeds) );
44
45 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("Common_BinEdges_Eta", m_Config_BinEdges_Eta) );
46 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) );
47 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) );
48
49 return StatusCode::SUCCESS;
50}
51
52
53void PanTau::Tool_FeatureExtractor::fillVariantsSeedEt(const std::vector<PanTau::TauConstituent*>& tauConstituents,
54 std::map<std::string, double>& variants_SeedEt) {
55
56 //use different approaches to calculate total energy of seed:
57 variants_SeedEt["EtAllConsts"] = 0.0;
58
59 //loop over all constituents in seed
60 for (unsigned int iConst = 0; iConst < tauConstituents.size(); iConst++) {
61
62 //get current constituents
63 PanTau::TauConstituent* curConstituent = tauConstituents.at(iConst);
64 double curEt = curConstituent->p4().Et();
65
66 //update the different Et definitions
67 if (curConstituent->isOfType(PanTau::TauConstituent::t_Charged) ||
69 variants_SeedEt["EtAllConsts"] += curEt;
70 }
71 }//end loop over constituents in seed
72}
73
74
76 const std::string& featName,
77 double numerator,
78 const std::map<std::string, double>& denominatorMap) {
79 std::map<std::string, double>::const_iterator it = denominatorMap.begin();
80 for(; it!=denominatorMap.end(); ++it) {
81 std::string FullName = featName + it->first;
82 float value = static_cast<float>(it->second);
83 if(value <= 0. || std::isnan(value) || std::isinf(value) ) continue;
84 targetMap->addFeature(FullName, numerator / it->second);
85 }
86}
87
88
90
93 bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau);
94 bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau);
95 if(static_cast<bool>(m_Config_UseEmptySeeds)) isBadSeed = noValidInputTau;
96
97 if (isBadSeed) {
98 ATH_MSG_DEBUG("Seed is not valid for feature extraction (no constituents or no valid input tau) - just fill isPanTauCandidate feature");
99 inSeed->getFeatures()->addFeature("CellBased_" + m_varTypeName_Basic + "_isPanTauCandidate", 0);
100 return StatusCode::SUCCESS;
101 }
102 inSeed->getFeatures()->addFeature("CellBased_" + m_varTypeName_Basic + "_isPanTauCandidate", 1);
103
104
106
108
109 // map containing different methods to calc seed et
110 std::map<std::string, double> variants_SeedEt;
111 // calculate the Et variants for the seed
112 fillVariantsSeedEt(inSeed->getConstituentsAsList_All(), variants_SeedEt);
113
114 //loop through all types of Constituents in tau and calculate type features for them
115 //baseline
116 ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_NoType, variants_SeedEt) ); //=> all constituents
117 ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Charged, variants_SeedEt) ); //=> charged ones in core
118 ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Neutral, variants_SeedEt) ); //=> neutral ones in core
119 ATH_CHECK( calculateFeatures(inSeed, PanTau::TauConstituent::t_Pi0Neut, variants_SeedEt) ); //=> pi0 tagged ones in core
120
121 //fill the combined features
122 ATH_CHECK( addCombinedFeatures(inSeed, variants_SeedEt) );
123
124 return StatusCode::SUCCESS;
125}
126
127
129
130 PanTau::TauFeature* featureMap = inSeed->getFeatures();
131
132 std::string featurePrefix = m_varTypeName_Basic;
133 std::string name = "CellBased_" + featurePrefix;
134
135 double SumCharge = 0;
136 double AbsCharge = 0;
137
141 for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) {
142
143 bool foundIt = false;
144 std::vector<TauConstituent*> curList = inSeed->getConstituentsOfType(iType, foundIt);
145 if(!foundIt) continue;
146
147 //store multiplicity of current type
149 unsigned int nConstituents = curList.size();
150 featureMap->addFeature(name + "_N" + typeName + "Consts", nConstituents);
151
152 //count charge, i.e. skip if not charged
153 if(iType != static_cast<int>(PanTau::TauConstituent::t_Charged)) continue;
154 for(unsigned int iConst=0; iConst<nConstituents; iConst++) {
155 PanTau::TauConstituent* curConstituent = curList[iConst];
156 SumCharge += curConstituent->getCharge();
157 AbsCharge += std::abs(static_cast<double>(curConstituent->getCharge()));
158 }
159 }
160
161 //store charge
162 featureMap->addFeature(name + "_SumCharge", SumCharge);
163 featureMap->addFeature(name + "_AbsCharge", AbsCharge);
164
166 //proto 4-vector (just the sum of all constituents)
167 // will have better four momentum after mode ID
168 TLorentzVector tlv_ProtoMomentumCore = inSeed->getProtoMomentumCore();
169 featureMap->addFeature(name + "_ProtoMomentumCore_pt", tlv_ProtoMomentumCore.Perp());
170 featureMap->addFeature(name + "_ProtoMomentumCore_eta", tlv_ProtoMomentumCore.Eta());
171 featureMap->addFeature(name + "_ProtoMomentumCore_phi", tlv_ProtoMomentumCore.Phi());
172 featureMap->addFeature(name + "_ProtoMomentumCore_m", tlv_ProtoMomentumCore.M());
173
174 return StatusCode::SUCCESS;
175}
176
177
179 TauFeature* tauFeatureMap = inSeed->getFeatures();
180 std::string prefixVARType = m_varTypeName_HLV;
181 for(int iType=0; iType<static_cast<int>(PanTau::TauConstituent::t_nTypes); iType++) {
182 bool isOK;
183 std::vector<PanTau::TauConstituent*> list_TypeConstituents = inSeed->getConstituentsOfType(iType, isOK); // list of constituents of current type
184 unsigned int n_Constituents_Type = list_TypeConstituents.size(); // number of objects of current type
185 TLorentzVector tlv_TypeConstituents = inSeed->getSubsystemHLV(iType, isOK); // summed hlv of objects of current type
187 std::string name = "CellBased_" + curTypeName + "_" + prefixVARType;
188
189 std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = inSeed->getConstituentsOfType(iType, isOK);
190 std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA);
191
192 if(!list_TypeConstituents.empty()) {
193 tauFeatureMap->addFeature(name + "_SumPt", tlv_TypeConstituents.Perp());
194 tauFeatureMap->addFeature(name + "_SumEta", tlv_TypeConstituents.Eta());
195 tauFeatureMap->addFeature(name + "_SumPhi", tlv_TypeConstituents.Phi());
196 tauFeatureMap->addFeature(name + "_SumM", tlv_TypeConstituents.M());
197 }
198
199 //store 4-vectors of current type (bdt sort)
200 std::vector<double> curConstsBDT_pt = std::vector<double>(0);
201 std::vector<double> curConstsBDT_eta = std::vector<double>(0);
202 std::vector<double> curConstsBDT_phi = std::vector<double>(0);
203 std::vector<double> curConstsBDT_m = std::vector<double>(0);
204 for(unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) {
205 TLorentzVector tlv_curConstBDT = list_TypeConstituents_SortBDT[iConst]->p4();
206 curConstsBDT_pt.push_back(tlv_curConstBDT.Perp());
207 curConstsBDT_eta.push_back(tlv_curConstBDT.Eta());
208 curConstsBDT_phi.push_back(tlv_curConstBDT.Phi());
209 curConstsBDT_m.push_back(tlv_curConstBDT.M());
210 }
211 tauFeatureMap->addVecFeature(name + "_BDTSort_Constituents_pt", curConstsBDT_pt);
212 tauFeatureMap->addVecFeature(name + "_BDTSort_Constituents_eta", curConstsBDT_eta);
213 tauFeatureMap->addVecFeature(name + "_BDTSort_Constituents_phi", curConstsBDT_phi);
214 tauFeatureMap->addVecFeature(name + "_BDTSort_Constituents_m", curConstsBDT_m);
215
216 } //end loop over constituent types
217
218 return StatusCode::SUCCESS;
219}
220
221
223 int tauConstituentType,
224 const std::map<std::string, double>& variants_SeedEt) const {
225
226 std::string curTypeName = PanTau::TauConstituent::getTypeName( (PanTau::TauConstituent::Type)tauConstituentType );
227 std::string curTypeName_All = PanTau::TauConstituent::AllConstituentsName();
228 PanTau::TauFeature* tauFeatureMap = inSeed->getFeatures();
229 TLorentzVector tlv_Reference = inSeed->getProtoMomentumCore();
230
231 std::vector<PanTau::TauConstituent*> list_AllConstituents = inSeed->getConstituentsAsList_Core();
232
233 bool foundIt = false;
234 std::vector<PanTau::TauConstituent*> list_TypeConstituents;
235 if (tauConstituentType != PanTau::TauConstituent::t_NoType) list_TypeConstituents = inSeed->getConstituentsOfType(tauConstituentType, foundIt);
236 if (tauConstituentType == PanTau::TauConstituent::t_NoType) list_TypeConstituents = list_AllConstituents;
237 if (!foundIt) return StatusCode::SUCCESS;
238
239 unsigned int n_Constituents_Type = list_TypeConstituents.size();
240
241 //sort the lists by Et
242 std::sort(list_AllConstituents.begin(), list_AllConstituents.end(), sortTauConstituentEt);
243 std::sort(list_TypeConstituents.begin(), list_TypeConstituents.end(), sortTauConstituentEt);
244
245 //make an additional list of constituents, but now ordered by BDT value
246 std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = list_TypeConstituents;
247 std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(), sortTauConstituentMVA);
248
249 TLorentzVector tlv_1st_BDT;
250
251 if(!list_TypeConstituents_SortBDT.empty()) tlv_1st_BDT = list_TypeConstituents_SortBDT[0]->p4();
252
256
257 // ===> hlv for the leading EFOs and the summed HLV
258 TLorentzVector tlv_TypeConstituents;
259 // ===> Sum of Et, Et^2, E and E^2
260 double sum_Et = 0;
261 double sum_Et2 = 0;
262 // ===> Sum of Et (and E) times DeltaR, DeltaR', Angle
263 double sum_EtxDR = 0;
264 // ===> Multiplicities
265 unsigned int num_EFOs = 0;
266
270 for(unsigned int iTypeConst=0; iTypeConst<list_TypeConstituents.size(); iTypeConst++) {
271
272 //get hep lorentz vector
273 TLorentzVector tlv_curConst = list_TypeConstituents.at(iTypeConst)->p4();
274
275 //final check (nan & inf)
276 if (std::isnan(tlv_curConst.Pt()) || std::isinf(tlv_curConst.Pt())) continue;
277
278 //ready to calc stuff
279 //basically update each of the prepared sum_* and num_* variables above,
280 // the sum HLV and the pointers to 1st, 2nd, 3rd leading constituents of current type
281 tlv_TypeConstituents += tlv_curConst;
282
283 //helpers to reduce function calls
284 double hlp_Et = tlv_curConst.Et();
285 double hlp_Et2 = hlp_Et * hlp_Et;
286 double hlp_DeltaR = tlv_Reference.DeltaR(tlv_curConst);
287
288 // update Sum of Et, Et^2, E and E^2
289 sum_Et += hlp_Et;
290 sum_Et2 += hlp_Et2;
291 // update Sum of Et (and E) times DeltaR, DeltaR', Angle
292 sum_EtxDR += hlp_Et * hlp_DeltaR;
293 // update Multiplicities
294 num_EFOs++;
295 }//end loop over selected EFOs
296
297
298
302
303 // naming string
304 std::string prefixVARType = "";
305
307 //if there are no EFOs of this type in the seed, all other variables cannot be calculated to have any reasonable value
308 if( num_EFOs == 0 ) {
309 return StatusCode::SUCCESS;
310 }
311
313 prefixVARType = m_varTypeName_PID;
314
315 // Sorted by highest BDT score
316 for(unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) {
317
318 double value_BDT = list_TypeConstituents_SortBDT[iTypeConst]->getBDTValue();
319 if( std::isnan(value_BDT) || std::isinf(value_BDT) ) continue;
320
321 //correct BDT value based on BDT cut
322 if(tauConstituentType != PanTau::TauConstituent::t_Charged) {
323 double mvaCorrection = 0.0;
324 double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->p4().Eta();
325 int etaBinIndex = m_HelperFunctions.getBinIndex(m_Config_BinEdges_Eta, std::abs(etaCurConst));
326 int numTrack = inSeed->getTauJet()->nTracks();
327 if(numTrack == 1) { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); }
328 else { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); }
329
330 value_BDT = value_BDT - mvaCorrection;
331 }
332
333 std::string iConst = m_HelperFunctions.convertNumberToString(static_cast<double>(iTypeConst+1));
334 tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_BDTValues_BDTSort_" + iConst, value_BDT);
335
336 }
337
340 //only execute if the constituent type is neutral
341 if(PanTau::TauConstituent::isNeutralType(tauConstituentType)) {
342
343 TLorentzVector totalTLV_SumShots = TLorentzVector(0., 0., 0., 0.);
344 unsigned int totalPhotonsInSeed = 0;
345
346 std::vector<TLorentzVector> allShotTLVs = std::vector<TLorentzVector>(0);
347
348 for(unsigned int iConst=0; iConst<list_TypeConstituents_SortBDT.size(); iConst++) {
349
350 PanTau::TauConstituent* curConst = list_TypeConstituents_SortBDT.at(iConst);
351 TLorentzVector tlv_CurConst = curConst->p4();
352 std::vector<PanTau::TauConstituent*> shotConstituents = curConst->getShots();
353 unsigned int nShots = shotConstituents.size();
354
355 unsigned int totalPhotonsInNeutral = 0;
356 TLorentzVector tlv_SumShots = TLorentzVector(0., 0., 0., 0.);
357
358 for(unsigned int iShot=0; iShot<nShots; iShot++) {
359 PanTau::TauConstituent* curShot = shotConstituents.at(iShot);
360 totalPhotonsInNeutral += curShot->getNPhotonsInShot();
361 tlv_SumShots += curShot->p4();
362 allShotTLVs.push_back(curShot->p4());
363 }//end loop over shots
364 totalTLV_SumShots += tlv_SumShots;
365 totalPhotonsInSeed += totalPhotonsInNeutral;
366
367 std::string iConstStr = m_HelperFunctions.convertNumberToString(static_cast<double>(iConst+1));
368
369 tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_nPhotons_BDTSort_" + iConstStr, totalPhotonsInNeutral);
370
371 if(tlv_CurConst.Et() > 0.) tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_EtSumShotsOverConstEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_CurConst.Et());
372
373 }//end loop over constituents in tau
374
375 //number of shots in seed
376 tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_NPhotonsInSeed", totalPhotonsInSeed);
377
378 }//end if check for shot info dumping
379
380
382 prefixVARType = m_varTypeName_Ratio;
383
384 if(curTypeName != curTypeName_All) addFeatureWrtSeedEnergy(tauFeatureMap, "CellBased_" + curTypeName + "_" + prefixVARType + "_EtOver", sum_Et, variants_SeedEt);
385
386 if(tlv_1st_BDT.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap, "CellBased_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOver", tlv_1st_BDT.Et(), variants_SeedEt);
387
388 if(tlv_1st_BDT.Pt() != 0 && sum_Et > 0.) tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_1stBDTEtOverTypeEt", tlv_1st_BDT.Et() / sum_Et);
389
391 prefixVARType = m_varTypeName_StdDev;
392
393 double stddev_Et = m_HelperFunctions.stddev(sum_Et2, sum_Et, num_EFOs);
394
395 if(stddev_Et > 0.) addFeatureWrtSeedEnergy(tauFeatureMap, "CellBased_" + curTypeName + "_" + prefixVARType + "_Et_Wrt", stddev_Et, variants_SeedEt);
396
398 // Moment wrt X = Sum( Et * X ) / Sum(Et)
399 // ==> Named as Eflow_EFOType_JetMoment_EtX" when using Et as weight
400 // ==> Named as Eflow_EFOType_JetMoment_EX" when using E as weight
401 prefixVARType = m_varTypeName_JetMoment;
402
403 if(sum_Et > 0.) {
404 //Using transverse energy
405 tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_EtDR", sum_EtxDR / sum_Et);
406 tauFeatureMap->addFeature("CellBased_" + curTypeName + "_" + prefixVARType + "_EtDRxTotalEt", (sum_EtxDR / sum_Et) * variants_SeedEt.at("EtAllConsts"));
407 }
408
409 return StatusCode::SUCCESS;
410}
411
412
414 const std::map<std::string, double>& variants_SeedEt) const {
415
416 // Prepare some short notations for variables
417 PanTau::TauFeature* tauFeatures = inSeed->getFeatures();
418
419 //et: EFO Type
420 int et_Charged = PanTau::TauConstituent::t_Charged;
421 int et_Pi0Neut = PanTau::TauConstituent::t_Pi0Neut;
422 int et_Neutral = PanTau::TauConstituent::t_Neutral;
423
424 bool foundIt;
425 std::vector<PanTau::TauConstituent*> list_NeutralConstituents = inSeed->getConstituentsOfType(et_Neutral, foundIt);
426
427 // Prepare the list of names for EFO Types &
428 // the 4 momenta of the different sub systems
429 // (ie. charged, neutral subsystem, etc...)
430 std::string name_EFOType[PanTau::TauConstituent::t_nTypes];
431 double num_EFOs[PanTau::TauConstituent::t_nTypes];
432 TLorentzVector tlv_System[PanTau::TauConstituent::t_nTypes];
433 TLorentzVector tlv_1stEFO[PanTau::TauConstituent::t_nTypes];
434 TLorentzVector tlv_2ndEFO[PanTau::TauConstituent::t_nTypes];
435
436 // get input objects to calc combined features
437 bool tlv_Sys_OK[PanTau::TauConstituent::t_nTypes];
438 bool tlv_1st_OK[PanTau::TauConstituent::t_nTypes];
439
440 //initialize arrays with default values
441 for(unsigned int iType=0; iType<(unsigned int)PanTau::TauConstituent::t_nTypes; iType++) {
442 name_EFOType[iType] = "";
443 num_EFOs[iType] = 0.;
444 tlv_System[iType] = TLorentzVector();
445 tlv_1stEFO[iType] = TLorentzVector();
446 tlv_2ndEFO[iType] = TLorentzVector();
447 tlv_Sys_OK[iType] = false;
448 tlv_1st_OK[iType] = false;
449 }
450
451 for(int iType=0; iType<static_cast<int>(PanTau::TauConstituent::t_nTypes); iType++) {
453
454 tlv_System[iType] = inSeed->getSubsystemHLV(iType, tlv_Sys_OK[iType]);
455 if (!tlv_Sys_OK[iType]) continue;
456
457 std::vector<TauConstituent*> typeConstituents = inSeed->getConstituentsOfType(iType, tlv_Sys_OK[iType]);
458 if (typeConstituents.empty()) tlv_Sys_OK[iType] = false;
459 if (!tlv_Sys_OK[iType]) continue;
460
461 num_EFOs[iType] = typeConstituents.size();
462
463 if (!typeConstituents.empty()) {
464 tlv_1stEFO[iType] = typeConstituents.at(0)->p4();
465 tlv_1st_OK[iType] = true;
466 } else {
467 tlv_1st_OK[iType] = false;
468 }
469
470 if (typeConstituents.size() > 1) {
471 tlv_2ndEFO[iType] = typeConstituents.at(1)->p4();
472 }
473 }
474
475 // From the extracted input, calc combined features
476 std::string prefixVARType = m_varTypeName_Combined;
477
478 // Combined Type-vs-Type Features
479 // Loop over all EFO types...
480 // for every type, loop over all other types (but neglect permutations, i.e. A,B is the same as B,A)
481 // calculate ratios, angles etc...
482
483 for(int iType=0; iType<PanTau::TauConstituent::t_nTypes; iType++) {
484
485 if(iType == static_cast<int>(PanTau::TauConstituent::t_NoType)) continue;
486 int type_Denom = iType;
487
488 for(int jType=0; jType<PanTau::TauConstituent::t_nTypes; jType++) {
489
490 if(jType == static_cast<int>(PanTau::TauConstituent::t_NoType)) continue;
491 int type_Nom = jType;
492
493 if(jType == iType) continue;
494
495 std::string typeName_Nom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Nom);
496 std::string typeName_Denom = PanTau::TauConstituent::getTypeName((PanTau::TauConstituent::Type)type_Denom);
497
498 double sum_Et_Nom = 0.0;
499 double sum_Et_Denom = 0.0;
500 if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) {
501 sum_Et_Nom = tlv_System[type_Nom].Et();
502 sum_Et_Denom = tlv_System[type_Denom].Et();
503 }
504
505 // Fraction of leading EFO of system A wrt complete system B
506 // this is not symmetric wrt system A and B, hence do this for all combinations
507 if(tlv_1st_OK[type_Nom]) {
508 if(tlv_1stEFO[type_Nom].Et() > 0. && sum_Et_Denom > 0.) {
509 tauFeatures->addFeature("CellBased_" + prefixVARType + "_Log1st" + typeName_Nom + "EtOver" + typeName_Denom + "Et", std::log10(tlv_1stEFO[type_Nom].Et() / sum_Et_Denom) );
510 }
511 }
512
513 //following features symmetric in system A-B, hence skip multi calculation
514 if(jType <= iType) continue;
515
516 //Energy ratios between systems
517 if(sum_Et_Denom > 0. && sum_Et_Nom > 0.) {
518 tauFeatures->addFeature("CellBased_" + prefixVARType + "_Log" + typeName_Nom + "EtOver" + typeName_Denom + "Et", std::log10(sum_Et_Nom / sum_Et_Denom) );
519 }//end check for div by zero
520
521 //Angles between systems
522 if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) {
523 tauFeatures->addFeature("CellBased_" + prefixVARType + "_Angle" + typeName_Nom + "To" + typeName_Denom, tlv_System[type_Nom].Angle( tlv_System[type_Denom].Vect()) );
524 }//end check for valid system pointer
525
526 if(tlv_1st_OK[type_Nom] && tlv_1st_OK[type_Denom]) {
527 //Delta R between 1st and 1st EFO
528 tauFeatures->addFeature("CellBased_" + prefixVARType + "_DeltaR1st" + typeName_Nom + "To1st" + typeName_Denom, tlv_1stEFO[type_Nom].DeltaR( tlv_1stEFO[type_Denom] ) );
529
530 //Angles between 1st and 1st EFO
531 tauFeatures->addFeature("CellBased_" + prefixVARType + "_Angle1st" + typeName_Nom + "To1st" + typeName_Denom, tlv_1stEFO[type_Nom].Angle( tlv_1stEFO[type_Denom].Vect() ) );
532 } //end check for valid leading efo
533
534 }//end loop over system B
535 }//end loop over system A
536
537
538 // Combined Selected-Type Features
539
540 //setup arrays for combination of selected charged and neutral combinations
541 const int cTypes = 1;
542 const int nTypes = 2;
543 int index_charged[cTypes] = {et_Charged};
544 int index_neutral[nTypes] = {et_Pi0Neut, et_Neutral};
545
546 for(int cType=0; cType<cTypes; cType++) {
547 for(int nType=0; nType<nTypes; nType++) {
548
549 int et_c = index_charged[cType];
550 int et_n = index_neutral[nType];
551
554
555 if(!tlv_Sys_OK[et_c] || !tlv_Sys_OK[et_n]) continue;
556
557 //mean Et fraction of charged+neutral system wrt total ET
558 if(num_EFOs[et_c] + num_EFOs[et_n] > 0.) {
559 double mean_cTypenTypeEt = ( tlv_System[et_c].Et() + tlv_System[et_n].Et() ) / (num_EFOs[et_c] + num_EFOs[et_n]);
560 addFeatureWrtSeedEnergy(tauFeatures, "CellBased_" + prefixVARType + "_Mean" + name_cType + name_nType + "Et_Wrt", mean_cTypenTypeEt, variants_SeedEt);
561 }
562
563 //invariant masses
564 tauFeatures->addFeature("CellBased_" + prefixVARType + "_InvMass" + name_cType + name_nType, ( tlv_System[et_c] + tlv_System[et_n] ).M() );
565
566 }//end loop neutral types
567 }//end loop charged types
568
569 return StatusCode::SUCCESS;
570}
571
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
bool sortTauConstituentMVA(const PanTau::TauConstituent *u, const PanTau::TauConstituent *v)
bool sortTauConstituentEt(const PanTau::TauConstituent *u, const PanTau::TauConstituent *v)
static StatusCode bindToolHandle(ToolHandle< T > &, std::string)
std::vector< PanTau::TauConstituent * > getConstituentsOfType(int tauConstituent_Type, bool &foundit)
TLorentzVector getProtoMomentumCore() const
Definition PanTauSeed.h:219
const std::vector< PanTau::TauConstituent * > & getConstituentsAsList_Core() const
Definition PanTauSeed.h:221
bool isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const
const xAOD::TauJet * getTauJet() const
Definition PanTauSeed.h:215
const std::vector< PanTau::TauConstituent * > & getConstituentsAsList_All() const
Definition PanTauSeed.h:222
TLorentzVector getSubsystemHLV(int tauConstituent_Type, bool &foundit)
const PanTau::TauFeature * getFeatures() const
Definition PanTauSeed.h:217
Input object for PanTau.
std::vector< std::string > getTypeName() const
const std::vector< TauConstituent * > & getShots() const
static bool isNeutralType(int tauConstituentType)
virtual FourMom_t p4() const
The full 4-momentum of the particle as a TLorentzVector.
static std::string AllConstituentsName()
bool isOfType(TauConstituent::Type aType) const
Type
Type enumeration to specify type of this tau constituent.
Class containing features of a tau seed.
Definition TauFeature.h:19
bool addFeature(const std::string &name, const double value)
adds a new feature
bool addVecFeature(const std::string &name, const std::vector< double > &value)
adds a new vector feature
std::vector< double > m_Config_BinEdges_Eta
Helper members.
static const std::string varTypeName_Shots()
Gaudi::Property< std::string > m_Tool_InformationStoreName
Tool_FeatureExtractor(const std::string &name)
StatusCode addConstituentMomenta(PanTau::PanTauSeed *inSeed) const
ToolHandle< PanTau::ITool_InformationStore > m_Tool_InformationStore
StatusCode calculateFeatures(PanTau::PanTauSeed *inSeed, int tauConstituentType, const std::map< std::string, double > &variants_SeedEt) const
std::vector< double > m_Config_CellBased_EtaBinned_Pi0MVACut_3prong
std::vector< double > m_Config_CellBased_EtaBinned_Pi0MVACut_1prong
static void addFeatureWrtSeedEnergy(PanTau::TauFeature *targetMap, const std::string &featName, double numerator, const std::map< std::string, double > &denominatorMap)
StatusCode addCombinedFeatures(PanTau::PanTauSeed *inSeed, const std::map< std::string, double > &variants_SeedEt) const
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
PanTau::HelperFunctions m_HelperFunctions
virtual StatusCode execute(PanTau::PanTauSeed *inSeed) const override
StatusCode calculateBasicFeatures(PanTau::PanTauSeed *inSeed) const
static void fillVariantsSeedEt(const std::vector< PanTau::TauConstituent * > &tauConstituents, std::map< std::string, double > &variants_SeedEt)
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
size_t nTracks(TauJetParameters::TauTrackFlag flag=TauJetParameters::TauTrackFlag::classifiedCharged) const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.