ATLAS Offline Software
Loading...
Searching...
No Matches
Tool_DecayModeDeterminator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
8
9
13
14
16
17
19
20 m_init=true;
21
26
27 //get the discri tools
31
32 //get the variable prefix
33 ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Prefix_Basic) );
34
35 //get the BDT cut values
36 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R10X_CellBased", m_BDTCutValue_R10X_CellBased) );
37 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R11X_CellBased", m_BDTCutValue_R11X_CellBased) );
38 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R110_CellBased", m_BDTCutValue_R110_CellBased) );
39 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R1XX_CellBased", m_BDTCutValue_R1XX_CellBased) );
40 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R30X_CellBased", m_BDTCutValue_R30X_CellBased) );
41 ATH_CHECK( m_Tool_InformationStore->getInfo_Double("DecayModeDeterminator_BDTCutValue_R3XX_CellBased", m_BDTCutValue_R3XX_CellBased) );
42
43 return StatusCode::SUCCESS;
44}
45
46
48
49 PanTau::TauFeature* features = inSeed->getFeatures();
50
51 //check for invalid input seed
56 bool invalidForDecayMode = (noValidInput || noAnyConstituents || noSelConstituents || badPt);
57
58 int decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtModeNotSet;
59 xAOD::TauJet* tauJet = inSeed->getTauJet();
60
61 if(invalidForDecayMode) {
62 ATH_MSG_DEBUG("Seed has no constituents assigned and/or input seed has no substructure info - use NotSet mode for this");
63 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::Mode_NotSet);
64 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", PanTau::PanTauSeed::t_ExtModeNotSet);
66 return StatusCode::SUCCESS;
67 }
68
69 //get the mode as it was determined by the subalgorithm
70 int decayMode_SubAlg = inSeed->getDecayModeBySubAlg();
71 int decayMode_PanTau = xAOD::TauJetParameters::Mode_NotSet;
72
73 //and calc the number of additional neutrals, not tagged as pi0
76 int AdditionalNeutrals = nNeutrals_SubAlg - nPi0Neut_SubAlg;
77
78 //based on the subAlg decay mode, pass to corresponding PanTau BDT...
79 double bdtResponse = -5;
81 // 1p0n mode
82 if(decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p0n) {
83
84 //1 prong, and no other objects at all -> use 1p0n
85 if(AdditionalNeutrals == 0) {
86 decayMode_PanTau = xAOD::TauJetParameters::Mode_1p0n;
87 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode100;
88 bdtResponse = -3.;
89
90 //if there are neutrals which are not pi0-tagged, check BDT to maybe set 1p1n
91 }
92 else {
93 bool isOK = false;
94 bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK);
95 bdtTest = t_1p0n_vs_1p1n;
96 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode10X;
97 if(!isOK) {
98 ATH_MSG_WARNING("WARNING: problems getting bdt response for 1p0n + X-neutrals. use subAlg mode");
99 decayMode_PanTau = decayMode_SubAlg;
100 }
101 else {
103 }
104 }
105 }//end 1p0n
106
107 //1p1n mode
108 else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1p1n) {
109 //1prong, 1pi0 and no other neutrals. check 1p0n-vs-1p1n
110 if(AdditionalNeutrals == 0) {
111 bool isOK = false;
112 bdtResponse = m_Tool_ModeDiscriminator_1p0n_vs_1p1n->getResponse(inSeed, isOK);
113 bdtTest = t_1p0n_vs_1p1n;
114 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode110;
115 if(!isOK) {
116 ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + 0-neutrals. use subAlg mode");
117 decayMode_PanTau = decayMode_SubAlg;
118 }
119 else {
121 }
122 //1prong, 1pi0 and additional neutrals. check 1p1n vs 1pXn
123 }
124 else {
125 //NOTE: May investigate chain of decisions here: first check 1p0n-1p1n, and then (in case of 1p1n) 1p1n-1pXn
126 bool isOK = false;
127 bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK);
128 bdtTest = t_1p1n_vs_1pXn;
129 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode11X;
130 if(!isOK) {
131 ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode");
132 decayMode_PanTau = decayMode_SubAlg;
133 }
134 else {
136 }
137 }
138 }//end 1p1n
139
140 //1pXn mode
141 else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_1pXn) {
142 //1prong, Xpi0. check 1p1n-vs-1pXn
143 bool isOK = false;
144 bdtResponse = m_Tool_ModeDiscriminator_1p1n_vs_1pXn->getResponse(inSeed, isOK);
145 bdtTest = t_1p1n_vs_1pXn;
146 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode1XX;
147 if(!isOK) {
148 ATH_MSG_WARNING("WARNING problems getting bdt response for 1p1n + X-neutrals. use subAlg mode");
149 decayMode_PanTau = decayMode_SubAlg;
150 } else {
152 }
153 }//end 1pXn
154
155 //3p0n mode
156 else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3p0n) {
157 //no additional neutrals.
158 if(AdditionalNeutrals == 0) {
159 decayMode_PanTau = xAOD::TauJetParameters::Mode_3p0n;
160 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode300;
161 bdtResponse = -2.5;
162 //additional neutrals
163 }
164 else {
165 bool isOK = false;
166 bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK);
167 bdtTest = t_3p0n_vs_3pXn;
168 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode30X;
169 if(!isOK) {
170 ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode");
171 decayMode_PanTau = decayMode_SubAlg;
172 }
173 else {
175 }
176 }
177 }//end 3p0n
178
179 //3pXn mode
180 else if (decayMode_SubAlg == xAOD::TauJetParameters::Mode_3pXn) {
181 //3prong, Xpi0. check 3p0n-vs-3pXn
182 bool isOK = false;
183 bdtResponse = m_Tool_ModeDiscriminator_3p0n_vs_3pXn->getResponse(inSeed, isOK);
184 bdtTest = t_3p0n_vs_3pXn;
185 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode3XX;
186 if(!isOK) {
187 ATH_MSG_WARNING("WARNING problems getting bdt response for 3p0n + X-neutrals. use subAlg mode");
188 decayMode_PanTau = decayMode_SubAlg;
189 }
190 else {
192 }
193 } //end 3pXn
194
195 //it's none of 1p0n, 1p1n, 1pXn, 3p0n, 3pXn -> set other mode
196 else {
197 decayMode_PanTau = xAOD::TauJetParameters::Mode_Other;
198 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtModeOther;
199 bdtResponse = -4;
200 bdtTest = t_UnknownTest;
201 }
202
203 // this overrides Pantau BDT 1p1n decision in the following case:
204 // if cell based counted 1 charged, 1 pi0neut, and number of hits in EM1 for the pi0neut is 3 or larger, set 1pXn;
205 if(inSeed->getNumberOfConstituentsOfType(PanTau::TauConstituent::t_Charged) == 1 && nPi0Neut_SubAlg == 1) {
206 //check for shots in EM1
207 bool isOK = false;
209 if(isOK) {
210 double nPhotons = 0.;
211 std::vector<PanTau::TauConstituent*> shots = pi0Neut->getShots();
212
213 for(unsigned int iShot=0; iShot<shots.size(); iShot++) {
214 nPhotons = nPhotons + static_cast<double>(shots.at(iShot)->getNPhotonsInShot());
215 }
216
217 if(nPhotons > 2.) {
218 decayMode_SubAlg = xAOD::TauJetParameters::Mode_1pXn;
219 decayMode_PanTau = xAOD::TauJetParameters::Mode_1pXn;
220 decayMode_PanTauExtended = PanTau::PanTauSeed::t_ExtMode11shots;
221 inSeed->setModeHackedByCellBased(true);
222 bdtResponse = -2.;
223 }
224 //end check for pi0 neutrals were found
225 }
226 else {
227 ATH_MSG_WARNING("Could not find expected CellBased neutral -> don't check for photons in cluster");
228 }
229 } //end hack check for 1p1n
230
231 //update mode of seed and store in features
232 inSeed->setDecayModeByPanTau(decayMode_PanTau);
233 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_RecoMode", static_cast<double>(decayMode_SubAlg));
234 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTau", static_cast<double>(decayMode_PanTau));
235 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_RecoMode_PanTauExtended", static_cast<double>(decayMode_PanTauExtended));
236
238
239 if(bdtTest == t_1p0n_vs_1p1n) {
240 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", bdtResponse);
241 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.);
242 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.);
243 }
244 if(bdtTest == t_1p1n_vs_1pXn) {
245 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.);
246 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", bdtResponse);
247 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.);
248 }
249 if(bdtTest == t_3p0n_vs_3pXn) {
250 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.);
251 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.);
252 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", bdtResponse);
253 }
254 if(bdtTest == t_UnknownTest) {
255 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p0n_vs_1p1n", -5.);
256 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_1p1n_vs_1pXn", -5.);
257 features->addFeature("CellBased_" + m_varTypeName_Prefix_Basic + "_BDTValue_3p0n_vs_3pXn", -5.);
258 }
259
260 return StatusCode::SUCCESS;
261}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static StatusCode bindToolHandle(ToolHandle< T > &, std::string)
void setDecayModeByPanTau(int decayModePanTau)
Definition PanTauSeed.h:230
std::vector< PanTau::TauConstituent * > getConstituentsOfType(int tauConstituent_Type, bool &foundit)
int getNumberOfConstituentsOfType(int tauConstituent_Type)
bool isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const
const xAOD::TauJet * getTauJet() const
Definition PanTauSeed.h:215
int getDecayModeBySubAlg() const
Definition PanTauSeed.h:224
void setModeHackedByCellBased(bool f)
Definition PanTauSeed.h:153
const PanTau::TauFeature * getFeatures() const
Definition PanTauSeed.h:217
Input object for PanTau.
const std::vector< TauConstituent * > & getShots() const
Class containing features of a tau seed.
Definition TauFeature.h:19
bool addFeature(const std::string &name, const double value)
adds a new feature
Gaudi::Property< std::string > m_Tool_ModeDiscriminator_1p1n_vs_1pXnName
Gaudi::Property< std::string > m_Tool_InformationStoreName
ToolHandle< PanTau::ITool_ModeDiscriminator > m_Tool_ModeDiscriminator_3p0n_vs_3pXn
Gaudi::Property< std::string > m_Tool_ModeDiscriminator_1p0n_vs_1p1nName
ToolHandle< PanTau::ITool_ModeDiscriminator > m_Tool_ModeDiscriminator_1p1n_vs_1pXn
ToolHandle< PanTau::ITool_ModeDiscriminator > m_Tool_ModeDiscriminator_1p0n_vs_1p1n
Gaudi::Property< std::string > m_Tool_ModeDiscriminator_3p0n_vs_3pXnName
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
ToolHandle< PanTau::ITool_InformationStore > m_Tool_InformationStore
virtual StatusCode execute(PanTau::PanTauSeed *inSeed) const
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
void setPanTauDetail(TauJetParameters::PanTauDetails panTauDetail, int value)
TauJet_v3 TauJet
Definition of the current "tau version".