9 #include "TLorentzVector.h"
25 return u->getBDTValue() >
v->getBDTValue();
30 return u->p4().Et() >
v->p4().Et();
46 ATH_CHECK( m_Tool_InformationStore.retrieve() );
48 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) );
49 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) );
50 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) );
51 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) );
52 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) );
53 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) );
54 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) );
55 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) );
56 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) );
57 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) );
58 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) );
59 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) );
60 ATH_CHECK( m_Tool_InformationStore->getInfo_String(
"FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) );
62 ATH_CHECK( m_Tool_InformationStore->getInfo_Int(
"FeatureExtractor_UseEmptySeeds", m_Config_UseEmptySeeds) );
64 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(
"CellBased_BinEdges_Eta", m_Config_CellBased_BinEdges_Eta) );
65 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(
"CellBased_EtaBinned_Pi0MVACut_1prong", m_Config_CellBased_EtaBinned_Pi0MVACut_1prong) );
66 ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble(
"CellBased_EtaBinned_Pi0MVACut_3prong", m_Config_CellBased_EtaBinned_Pi0MVACut_3prong) );
68 return StatusCode::SUCCESS;
73 std::map<std::string, double>& variants_SeedEt) {
76 variants_SeedEt[
"EtAllConsts"] = 0.0;
79 for (
unsigned int iConst = 0; iConst < tauConstituents.size(); iConst++) {
83 double curEt = curConstituent->
p4().Et();
88 variants_SeedEt[
"EtAllConsts"] += curEt;
95 const std::string& featName,
97 const std::map<std::string, double>& denominatorMap) {
98 std::map<std::string, double>::const_iterator
it = denominatorMap.begin();
99 for(;
it!=denominatorMap.end(); ++
it) {
101 float value =
static_cast<float>(
it->second);
113 bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau);
114 if(
static_cast<bool>(m_Config_UseEmptySeeds)) isBadSeed = noValidInputTau;
117 ATH_MSG_DEBUG(
"Seed is not valid for feature extraction (no constituents or no valid input tau) - just fill isPanTauCandidate feature");
119 return StatusCode::SUCCESS;
124 ATH_CHECK( calculateBasicFeatures(inSeed) );
126 ATH_CHECK( addConstituentMomenta(inSeed) );
129 std::map<std::string, double> variants_SeedEt;
141 ATH_CHECK( addCombinedFeatures(inSeed, variants_SeedEt) );
143 return StatusCode::SUCCESS;
151 std::string featurePrefix = m_varTypeName_Basic;
152 std::string
name =
"CellBased_" + featurePrefix;
154 double SumCharge = 0;
155 double AbsCharge = 0;
162 bool foundIt =
false;
164 if(!foundIt)
continue;
168 unsigned int nConstituents = curList.size();
173 for(
unsigned int iConst=0; iConst<nConstituents; iConst++) {
175 SumCharge += curConstituent->
getCharge();
176 AbsCharge += std::abs(
static_cast<double>(curConstituent->
getCharge()));
188 featureMap->
addFeature(
name +
"_ProtoMomentumCore_pt", tlv_ProtoMomentumCore.Perp());
189 featureMap->
addFeature(
name +
"_ProtoMomentumCore_eta", tlv_ProtoMomentumCore.Eta());
190 featureMap->
addFeature(
name +
"_ProtoMomentumCore_phi", tlv_ProtoMomentumCore.Phi());
191 featureMap->
addFeature(
name +
"_ProtoMomentumCore_m", tlv_ProtoMomentumCore.M());
193 return StatusCode::SUCCESS;
199 std::string prefixVARType = m_varTypeName_HLV;
202 std::vector<PanTau::TauConstituent*> list_TypeConstituents = inSeed->
getConstituentsOfType(iType, isOK);
203 unsigned int n_Constituents_Type = list_TypeConstituents.size();
204 TLorentzVector tlv_TypeConstituents = inSeed->
getSubsystemHLV(iType, isOK);
206 std::string
name =
"CellBased_" + curTypeName +
"_" + prefixVARType;
208 std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = inSeed->
getConstituentsOfType(iType, isOK);
209 std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(),
sortTauConstituentMVA);
211 if(!list_TypeConstituents.empty()) {
212 tauFeatureMap->
addFeature(
name +
"_SumPt", tlv_TypeConstituents.Perp());
213 tauFeatureMap->
addFeature(
name +
"_SumEta", tlv_TypeConstituents.Eta());
214 tauFeatureMap->
addFeature(
name +
"_SumPhi", tlv_TypeConstituents.Phi());
215 tauFeatureMap->
addFeature(
name +
"_SumM", tlv_TypeConstituents.M());
219 std::vector<double> curConstsBDT_pt = std::vector<double>(0);
220 std::vector<double> curConstsBDT_eta = std::vector<double>(0);
221 std::vector<double> curConstsBDT_phi = std::vector<double>(0);
222 std::vector<double> curConstsBDT_m = std::vector<double>(0);
223 for(
unsigned int iConst=0; iConst<n_Constituents_Type; iConst++) {
224 TLorentzVector tlv_curConstBDT = list_TypeConstituents_SortBDT[iConst]->p4();
225 curConstsBDT_pt.push_back(tlv_curConstBDT.Perp());
226 curConstsBDT_eta.push_back(tlv_curConstBDT.Eta());
227 curConstsBDT_phi.push_back(tlv_curConstBDT.Phi());
228 curConstsBDT_m.push_back(tlv_curConstBDT.M());
230 tauFeatureMap->
addVecFeature(
name +
"_BDTSort_Constituents_pt", curConstsBDT_pt);
231 tauFeatureMap->
addVecFeature(
name +
"_BDTSort_Constituents_eta", curConstsBDT_eta);
232 tauFeatureMap->
addVecFeature(
name +
"_BDTSort_Constituents_phi", curConstsBDT_phi);
237 return StatusCode::SUCCESS;
242 int tauConstituentType,
243 const std::map<std::string, double>& variants_SeedEt)
const {
252 bool foundIt =
false;
253 std::vector<PanTau::TauConstituent*> list_TypeConstituents;
256 if (!foundIt)
return StatusCode::SUCCESS;
258 unsigned int n_Constituents_Type = list_TypeConstituents.size();
265 std::vector<PanTau::TauConstituent*> list_TypeConstituents_SortBDT = list_TypeConstituents;
266 std::sort(list_TypeConstituents_SortBDT.begin(), list_TypeConstituents_SortBDT.end(),
sortTauConstituentMVA);
268 TLorentzVector tlv_1st_BDT;
270 if(!list_TypeConstituents_SortBDT.empty()) tlv_1st_BDT = list_TypeConstituents_SortBDT[0]->p4();
277 TLorentzVector tlv_TypeConstituents;
282 double sum_EtxDR = 0;
284 unsigned int num_EFOs = 0;
289 for(
unsigned int iTypeConst=0; iTypeConst<list_TypeConstituents.size(); iTypeConst++) {
292 TLorentzVector tlv_curConst = list_TypeConstituents.at(iTypeConst)->p4();
295 if (std::isnan(tlv_curConst.Pt()) || std::isinf(tlv_curConst.Pt()))
continue;
300 tlv_TypeConstituents += tlv_curConst;
303 double hlp_Et = tlv_curConst.Et();
304 double hlp_Et2 = hlp_Et * hlp_Et;
305 double hlp_DeltaR = tlv_Reference.DeltaR(tlv_curConst);
311 sum_EtxDR += hlp_Et * hlp_DeltaR;
323 std::string prefixVARType =
"";
327 if( num_EFOs == 0 ) {
328 return StatusCode::SUCCESS;
332 prefixVARType = m_varTypeName_PID;
335 for(
unsigned int iTypeConst=0; iTypeConst<n_Constituents_Type; iTypeConst++) {
337 double value_BDT = list_TypeConstituents_SortBDT[iTypeConst]->getBDTValue();
338 if( std::isnan(value_BDT) || std::isinf(value_BDT) )
continue;
342 double mvaCorrection = 0.0;
343 double etaCurConst = list_TypeConstituents_SortBDT[iTypeConst]->p4().Eta();
344 int etaBinIndex = m_HelperFunctions.getBinIndex(m_Config_CellBased_BinEdges_Eta, std::abs(etaCurConst));
346 if(numTrack == 1) { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_1prong.at(etaBinIndex); }
347 else { mvaCorrection = m_Config_CellBased_EtaBinned_Pi0MVACut_3prong.at(etaBinIndex); }
349 value_BDT = value_BDT - mvaCorrection;
352 std::string iConst = m_HelperFunctions.convertNumberToString(
static_cast<double>(iTypeConst+1));
353 tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_BDTValues_BDTSort_" + iConst, value_BDT);
362 TLorentzVector totalTLV_SumShots = TLorentzVector(0., 0., 0., 0.);
363 unsigned int totalPhotonsInSeed = 0;
365 std::vector<TLorentzVector> allShotTLVs = std::vector<TLorentzVector>(0);
367 for(
unsigned int iConst=0; iConst<list_TypeConstituents_SortBDT.size(); iConst++) {
370 TLorentzVector tlv_CurConst = curConst->
p4();
371 std::vector<PanTau::TauConstituent*> shotConstituents = curConst->
getShots();
372 unsigned int nShots = shotConstituents.size();
374 unsigned int totalPhotonsInNeutral = 0;
375 TLorentzVector tlv_SumShots = TLorentzVector(0., 0., 0., 0.);
377 for(
unsigned int iShot=0; iShot<nShots; iShot++) {
380 tlv_SumShots += curShot->
p4();
381 allShotTLVs.push_back(curShot->
p4());
383 totalTLV_SumShots += tlv_SumShots;
384 totalPhotonsInSeed += totalPhotonsInNeutral;
386 std::string iConstStr = m_HelperFunctions.convertNumberToString(
static_cast<double>(iConst+1));
388 tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_nPhotons_BDTSort_" + iConstStr, totalPhotonsInNeutral);
390 if(tlv_CurConst.Et() > 0.) tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_EtSumShotsOverConstEt_BDTSort_" + iConstStr, tlv_SumShots.Et() / tlv_CurConst.Et());
395 tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_NPhotonsInSeed", totalPhotonsInSeed);
401 prefixVARType = m_varTypeName_Ratio;
403 if(curTypeName != curTypeName_All) addFeatureWrtSeedEnergy(tauFeatureMap,
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_EtOver", sum_Et, variants_SeedEt);
405 if(tlv_1st_BDT.Pt() != 0) addFeatureWrtSeedEnergy(tauFeatureMap,
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_1stBDTEtOver", tlv_1st_BDT.Et(), variants_SeedEt);
407 if(tlv_1st_BDT.Pt() != 0 && sum_Et > 0.) tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_1stBDTEtOverTypeEt", tlv_1st_BDT.Et() / sum_Et);
410 prefixVARType = m_varTypeName_StdDev;
412 double stddev_Et = m_HelperFunctions.stddev(sum_Et2, sum_Et, num_EFOs);
414 if(stddev_Et > 0.) addFeatureWrtSeedEnergy(tauFeatureMap,
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_Et_Wrt", stddev_Et, variants_SeedEt);
420 prefixVARType = m_varTypeName_JetMoment;
424 tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_EtDR", sum_EtxDR / sum_Et);
425 tauFeatureMap->
addFeature(
"CellBased_" + curTypeName +
"_" + prefixVARType +
"_EtDRxTotalEt", (sum_EtxDR / sum_Et) * variants_SeedEt.at(
"EtAllConsts"));
428 return StatusCode::SUCCESS;
433 const std::map<std::string, double>& variants_SeedEt)
const {
444 std::vector<PanTau::TauConstituent*> list_NeutralConstituents = inSeed->
getConstituentsOfType(et_Neutral, foundIt);
461 name_EFOType[iType] =
"";
462 num_EFOs[iType] = 0.;
463 tlv_System[iType] = TLorentzVector();
464 tlv_1stEFO[iType] = TLorentzVector();
465 tlv_2ndEFO[iType] = TLorentzVector();
466 tlv_Sys_OK[iType] =
false;
467 tlv_1st_OK[iType] =
false;
474 if (!tlv_Sys_OK[iType])
continue;
476 std::vector<TauConstituent*> typeConstituents = inSeed->
getConstituentsOfType(iType, tlv_Sys_OK[iType]);
477 if (typeConstituents.empty()) tlv_Sys_OK[iType] =
false;
478 if (!tlv_Sys_OK[iType])
continue;
480 num_EFOs[iType] = typeConstituents.size();
482 if (!typeConstituents.empty()) {
483 tlv_1stEFO[iType] = typeConstituents.at(0)->p4();
484 tlv_1st_OK[iType] =
true;
486 tlv_1st_OK[iType] =
false;
489 if (typeConstituents.size() > 1) {
490 tlv_2ndEFO[iType] = typeConstituents.at(1)->p4();
495 std::string prefixVARType = m_varTypeName_Combined;
505 int type_Denom = iType;
510 int type_Nom = jType;
512 if(jType == iType)
continue;
517 double sum_Et_Nom = 0.0;
518 double sum_Et_Denom = 0.0;
519 if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) {
520 sum_Et_Nom = tlv_System[type_Nom].Et();
521 sum_Et_Denom = tlv_System[type_Denom].Et();
526 if(tlv_1st_OK[type_Nom]) {
527 if(tlv_1stEFO[type_Nom].Et() > 0. && sum_Et_Denom > 0.) {
528 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_Log1st" + typeName_Nom +
"EtOver" + typeName_Denom +
"Et", std::log10(tlv_1stEFO[type_Nom].Et() / sum_Et_Denom) );
533 if(jType <= iType)
continue;
536 if(sum_Et_Denom > 0. && sum_Et_Nom > 0.) {
537 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_Log" + typeName_Nom +
"EtOver" + typeName_Denom +
"Et", std::log10(sum_Et_Nom / sum_Et_Denom) );
541 if(tlv_Sys_OK[type_Nom] && tlv_Sys_OK[type_Denom]) {
542 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_Angle" + typeName_Nom +
"To" + typeName_Denom, tlv_System[type_Nom].
Angle( tlv_System[type_Denom].Vect()) );
545 if(tlv_1st_OK[type_Nom] && tlv_1st_OK[type_Denom]) {
547 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_DeltaR1st" + typeName_Nom +
"To1st" + typeName_Denom, tlv_1stEFO[type_Nom].
DeltaR( tlv_1stEFO[type_Denom] ) );
550 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_Angle1st" + typeName_Nom +
"To1st" + typeName_Denom, tlv_1stEFO[type_Nom].
Angle( tlv_1stEFO[type_Denom].Vect() ) );
560 const int cTypes = 1;
561 const int nTypes = 2;
562 int index_charged[cTypes] = {et_Charged};
563 int index_neutral[nTypes] = {et_Pi0Neut, et_Neutral};
565 for(
int cType=0; cType<cTypes; cType++) {
566 for(
int nType=0; nType<nTypes; nType++) {
568 int et_c = index_charged[cType];
569 int et_n = index_neutral[nType];
574 if(!tlv_Sys_OK[et_c] || !tlv_Sys_OK[et_n])
continue;
577 if(num_EFOs[et_c] + num_EFOs[et_n] > 0.) {
578 double mean_cTypenTypeEt = ( tlv_System[et_c].Et() + tlv_System[et_n].Et() ) / (num_EFOs[et_c] + num_EFOs[et_n]);
579 addFeatureWrtSeedEnergy(tauFeatures,
"CellBased_" + prefixVARType +
"_Mean" + name_cType + name_nType +
"Et_Wrt", mean_cTypenTypeEt, variants_SeedEt);
583 tauFeatures->
addFeature(
"CellBased_" + prefixVARType +
"_InvMass" + name_cType + name_nType, ( tlv_System[et_c] + tlv_System[et_n] ).M() );
588 return StatusCode::SUCCESS;