ATLAS Offline Software
Tool_DetailsArranger.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "xAODTau/TauJet.h"
9 
11 #include "PanTauAlgs/PanTauSeed.h"
13 
14 
16 
17  return ( i.cachedElement()->bdtPi0Score() > j.cachedElement()->bdtPi0Score() );
18 }
19 
20 
22  asg::AsgTool(name),
23  m_Tool_InformationStore("PanTau::Tool_InformationStore/Tool_InformationStore")
24 {
25  declareProperty("Tool_InformationStore", m_Tool_InformationStore, "Tool handle to the information store tool");
26  declareProperty("Tool_InformationStoreName", m_Tool_InformationStoreName, "Tool handle to the information store tool");
27 }
28 
29 
31 
32 
34 
35  m_init=true;
36 
37  ATH_CHECK( HelperFunctions::bindToolHandle( m_Tool_InformationStore, m_Tool_InformationStoreName ) );
38 
39  ATH_CHECK( m_Tool_InformationStore->getInfo_Double("TauConstituents_Types_DeltaRCore", m_CoreCone) );
40  ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_BinEdges_Eta", m_EtaBinEdges) );
41  ATH_CHECK( m_Tool_InformationStore->getInfo_VecDouble("TauConstituents_Selection_Neutral_EtaBinned_EtCut", m_EtaBinnedEtCuts) );
42  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Sum", m_varTypeName_Sum) );
43  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Ratio", m_varTypeName_Ratio) );
44  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_EtInRing", m_varTypeName_EtInRing) );
45  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Isolation", m_varTypeName_Isolation) );
46  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Num", m_varTypeName_Num) );
47  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Mean", m_varTypeName_Mean) );
48  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_StdDev", m_varTypeName_StdDev) );
49  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_HLV", m_varTypeName_HLV) );
50  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Angle", m_varTypeName_Angle) );
51  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_DeltaR", m_varTypeName_DeltaR) );
52  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetMoment", m_varTypeName_JetMoment) );
53  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Combined", m_varTypeName_Combined) );
54  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_JetShape", m_varTypeName_JetShape) );
55  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_ImpactParams", m_varTypeName_ImpactParams) );
56  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Basic", m_varTypeName_Basic) );
57  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_PID", m_varTypeName_PID) );
58  ATH_CHECK( m_Tool_InformationStore->getInfo_String("FeatureExtractor_VarTypeName_varTypeName_Shots", m_varTypeName_Shots) );
59 
60  return StatusCode::SUCCESS;
61 }
62 
63 
65 
66  std::string inputAlg = inSeed->getNameInputAlgorithm();
67 
68  bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoConstituentsAtAll);
70  bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau);
71  bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau);
72 
73  //set the PFO link vector and pantau 4-vector to default values for every tau first (xAOD technicality)
74  //if the tau is valid, overwrite with non-default values
75  xAOD::TauJet* tauJet = inSeed->getTauJet();
76 
77  if (isBadSeed) {
78  ATH_MSG_DEBUG("This seed is not useable for detail arranging (other than validity flag)");
81  return StatusCode::SUCCESS;
82  }
83 
84  ATH_CHECK(arrangePFOLinks(inSeed, tauJet, pi0Container, neutralPFOContainer));
85 
86  //Basic variables
87  addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_isPanTauCandidate", xAOD::TauJetParameters::PanTau_isPanTauCandidate, PanTau::Tool_DetailsArranger::t_Int);
88  addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_RecoMode_PanTau", xAOD::TauJetParameters::PanTau_DecayMode, PanTau::Tool_DetailsArranger::t_Int);
89  addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p0n_vs_1p1n", xAOD::TauJetParameters::PanTau_BDTValue_1p0n_vs_1p1n, PanTau::Tool_DetailsArranger::t_Float);
90  addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_1p1n_vs_1pXn", xAOD::TauJetParameters::PanTau_BDTValue_1p1n_vs_1pXn, PanTau::Tool_DetailsArranger::t_Float);
91  addPanTauDetailToTauJet(inSeed, m_varTypeName_Basic + "_BDTValue_3p0n_vs_3pXn", xAOD::TauJetParameters::PanTau_BDTValue_3p0n_vs_3pXn, PanTau::Tool_DetailsArranger::t_Float);
92 
93  //Final 4-vector
94  tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, inSeed->getFinalMomentum().Pt(), inSeed->getFinalMomentum().Eta(), inSeed->getFinalMomentum().Phi(), inSeed->getFinalMomentum().M());
95 
96  //BDT variables
97  addPanTauDetailToTauJet(inSeed, "Basic_NNeutralConsts",
99  addPanTauDetailToTauJet(inSeed, "Charged_JetMoment_EtDRxTotalEt",
101  addPanTauDetailToTauJet(inSeed, "Charged_StdDev_Et_WrtEtAllConsts",
103  addPanTauDetailToTauJet(inSeed, "Neutral_HLV_SumM",
105  addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_1",
107  addPanTauDetailToTauJet(inSeed, "Neutral_PID_BDTValues_BDTSort_2",
109  addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_1stBDTEtOverEtAllConsts",
111  addPanTauDetailToTauJet(inSeed, "Neutral_Ratio_EtOverEtAllConsts",
113  addPanTauDetailToTauJet(inSeed, "Neutral_Shots_NPhotonsInSeed",
115  addPanTauDetailToTauJet(inSeed, "Combined_DeltaR1stNeutralTo1stCharged",
117  addPanTauDetailToTauJet(inSeed, "Charged_HLV_SumM",
119 
120  return StatusCode::SUCCESS;
121 }
122 
123 
125  const std::string& featName,
127  PanTauDetailsType detailType) const {
128 
129  bool isValid;
130  const PanTau::TauFeature* features = inSeed->getFeatures();
131  std::string fullFeatName = inSeed->getNameInputAlgorithm() + "_" + featName;
132 
133  double theValue = features->value(fullFeatName, isValid);
134  if (!isValid) {
135  bool noAnyConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoConstituentsAtAll);
136  bool noSelConstituents = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoSelectedConstituents);
137  bool noValidInputTau = inSeed->isOfTechnicalQuality(PanTau::PanTauSeed::t_NoValidInputTau);
138  bool isBadSeed = (noAnyConstituents || noSelConstituents || noValidInputTau);
139 
140  if (!isBadSeed) {
141  ATH_MSG_DEBUG("WARNING --- Problems getting value for feature " << fullFeatName << " from map! This should not happen for this seed!");
142  ATH_MSG_DEBUG("WARNING --- Did the ModeDiscriminator set features used in BDTs that were not found to their default values?");
143  ATH_MSG_DEBUG("NOTE --- This can also happen for seeds with (for example) 0 neutrals when trying to get Neutral_SumM - check seed");
144  }
145  theValue = -1111.;
146  }
147 
148  xAOD::TauJet* tauJet = inSeed->getTauJet();
149  int valueToAddInt = -1;
150  float valueToAddFloat = -1.1;
151 
152  switch(detailType) {
154  valueToAddInt = (int)theValue;
155  tauJet->setPanTauDetail(detailEnum, valueToAddInt);
156  break;
158  valueToAddFloat = (float)theValue;
159  tauJet->setPanTauDetail(detailEnum, valueToAddFloat);
160  break;
161  default:
162  ATH_MSG_WARNING("Unknown PanTauDetailType! Please use enum PanTauDetailsType from PanTauAlgs/Tool_DetailsArranger.h.");
163  ATH_MSG_WARNING("!NOT! adding detail named " << featName);
164  break;
165  }
166 
167  }
168 
169 
171 
172  std::string inputAlg = inSeed->getNameInputAlgorithm();
173 
174  //get the PFO links
175  std::vector< ElementLink< xAOD::PFOContainer > > chrgPFOLinks = tauJet->protoChargedPFOLinks();
176  std::vector< ElementLink< xAOD::PFOContainer > > neutralPFOLinks = tauJet->protoNeutralPFOLinks();
177  std::vector< ElementLink< xAOD::PFOContainer > > pi0PFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent::t_Pi0Neut );
178  std::vector< ElementLink< xAOD::PFOContainer > > preSelected_neutralPFOLinks = CollectConstituentsAsPFOLinks( inSeed, tauJet->protoNeutralPFOLinks(), PanTau::TauConstituent::t_Neutral );
179 
180  //clear the default links, just to be safe
181  tauJet->clearChargedPFOLinks();
182  tauJet->clearNeutralPFOLinks();
183  tauJet->clearPi0PFOLinks();
184 
185  std::vector< ElementLink< xAOD::PFOContainer > > preLinkPi0PFOLinks = tauJet->pi0PFOLinks();
186 
187  // sort PFO links according to pi0 BDT score:
188  std::sort (pi0PFOLinks.begin(), pi0PFOLinks.end(), sortBDTscore);
189  std::sort (preSelected_neutralPFOLinks.begin(), preSelected_neutralPFOLinks.end(), sortBDTscore);
190  std::sort (neutralPFOLinks.begin(), neutralPFOLinks.end(), sortBDTscore);
191 
192  // set the masses of all neutrals *and pi0 neutrals* to 0:
193  SetNeutralConstituentVectorMasses(neutralPFOLinks, neutralPFOContainer, 0.);
194 
195  // arrange charged & neutral PFOs: they are not changed -> copy from cellbased
196  tauJet->setChargedPFOLinks(chrgPFOLinks);
197  tauJet->setNeutralPFOLinks(neutralPFOLinks);
198 
199  tauJet->setDetail(xAOD::TauJetParameters::nCharged, (int)chrgPFOLinks.size());
200 
201  //arrange pi0 pfos: depends on decay mode classification
202  int decayModeProto = inSeed->getDecayModeBySubAlg();
203  int decayModeFinal = inSeed->getDecayModeByPanTau();
204 
205  if(decayModeFinal == xAOD::TauJetParameters::Mode_Other) {
206  tauJet->setPi0PFOLinks(pi0PFOLinks);
207  SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic);
208 
209  return StatusCode::SUCCESS;
210  }
211 
212  //if pantau sets the same decay mode as the substructure algorithm, just copy the links
213  if(decayModeProto == decayModeFinal) {
214 
215  if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && pi0PFOLinks.size() > 1 ){
216 
217  // assign all neutrals but only one pi0 neutral to Pantau:
218  preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) );
219 
220  // set all masses correctly:
221  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, MASS_PI0);
222 
223  } else {
224 
225  // assign the same constituents to Pantau:
226  preLinkPi0PFOLinks=pi0PFOLinks;
227 
228  // set all masses correctly:
229  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, MASS_PI0);
230  }
231 
232  } else {
233 
234  if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1p0n ){
235 
236  // add the highest BDT-score neutral from the sub-alg:
237  if(!preSelected_neutralPFOLinks.empty()) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) );
238  else ATH_MSG_WARNING("No neutral PFO Links although there should be!!");
239 
240  // set the mass:
241  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, MASS_PI0);
242 
243  } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p0n && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){
244 
245  // do nothing (leave the pi0 neutrals list empty)
246 
247  } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1pXn && decayModeProto == xAOD::TauJetParameters::Mode_1p1n ){
248 
249 
250  if( pi0PFOLinks.size() == 1 && HasMultPi0sInOneCluster(pi0PFOLinks.at(0).cachedElement(), decayModeProto, inputAlg) ){
251 
252  // assign twice the pi0 mass to the one pi0 PFO:
253  SetNeutralConstituentVectorMasses(pi0PFOLinks, neutralPFOContainer, 2*MASS_PI0);
254 
255  // assign the same constituents to Pantau:
256  preLinkPi0PFOLinks=pi0PFOLinks;
257 
258  } else {
259 
260  // copy all (really only one) pi0s from the sub-alg and add
261  // the highest BDT-score neutral:
262  preLinkPi0PFOLinks=pi0PFOLinks;
263  if(!preSelected_neutralPFOLinks.empty()) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) );
264  else ATH_MSG_WARNING("No neutral PFO Links although there should be!!");
265 
266  // set the mass:
267  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, MASS_PI0);
268  }
269 
270  } else if( decayModeFinal == xAOD::TauJetParameters::Mode_1p1n && decayModeProto == xAOD::TauJetParameters::Mode_1pXn ){
271 
272  // copy all (two) pi0s from the sub-alg:
273  preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(0) );
274  preLinkPi0PFOLinks.push_back( pi0PFOLinks.at(1) );
275 
276  // set both pi0neutrals to mass 0 (photon mass):
277  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, 0.);
278 
279  } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3pXn && decayModeProto == xAOD::TauJetParameters::Mode_3p0n ){
280 
281  // add the highest BDT-score neutral from the sub-alg:
282  if(!preSelected_neutralPFOLinks.empty()) preLinkPi0PFOLinks.push_back( preSelected_neutralPFOLinks.at(0) );
283  else ATH_MSG_WARNING("No neutral PFO Links although there should be!!");
284 
285  // set the mass:
286  SetNeutralConstituentVectorMasses(preLinkPi0PFOLinks, neutralPFOContainer, MASS_PI0);
287 
288  } else if( decayModeFinal == xAOD::TauJetParameters::Mode_3p0n && decayModeProto == xAOD::TauJetParameters::Mode_3pXn ){
289 
290  // do nothing (leave the pi0 neutrals list empty)
291  }
292  }
293 
294  tauJet->setPi0PFOLinks(preLinkPi0PFOLinks);
295 
296  SetHLVTau(inSeed, tauJet, inputAlg, m_varTypeName_Basic);
297 
298  std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks();
299  std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks();
300  std::vector< ElementLink< xAOD::PFOContainer > > finalNeutralPFOLinks = tauJet->neutralPFOLinks();
301 
302  // vector of 4-vectors of actual pi0s and a vector with pointers to PFOs:
303  std::vector< TLorentzVector > vec_pi04vec;
304  std::vector< std::vector< ElementLink<xAOD::PFOContainer> > > vec_pi0pfos;
305  createPi0Vectors(tauJet, vec_pi04vec, vec_pi0pfos);
306 
307  for(unsigned int itlv=0; itlv!=vec_pi04vec.size(); ++itlv) {
309  pi0Container.push_back(p);
310  p->setPxPyPzE(vec_pi04vec.at(itlv).Px(), vec_pi04vec.at(itlv).Py(), vec_pi04vec.at(itlv).Pz(), vec_pi04vec.at(itlv).E());
311  std::vector< ElementLink< xAOD::PFOContainer > > pfo_link_vector;
312  for( uint ipfo = 0; ipfo != vec_pi0pfos.at(itlv).size(); ++ipfo) {
313  pfo_link_vector.push_back(vec_pi0pfos.at(itlv).at(ipfo));
314  }
315 
316  static const SG::AuxElement::Accessor<std::vector< ElementLink< xAOD::PFOContainer > > > accPi0PFOLinks("pi0PFOLinks");
317  accPi0PFOLinks(*p) = pfo_link_vector;
318 
320  linkToPi0.toContainedElement(pi0Container, dynamic_cast<xAOD::IParticle*> (p));
321 
322  tauJet->addPi0Link(linkToPi0);
323  }
324 
325  return StatusCode::SUCCESS;
326 }
327 
328 
329 // Calculate final 4-vector:
330 void PanTau::Tool_DetailsArranger::SetHLVTau( PanTau::PanTauSeed* inSeed, xAOD::TauJet* tauJet, const std::string& inputAlg, const std::string& varTypeName_Basic) {
331 
332  std::vector< ElementLink< xAOD::PFOContainer > > finalChrgPFOLinks = tauJet->chargedPFOLinks();
333  std::vector< ElementLink< xAOD::PFOContainer > > finalPi0PFOLinks = tauJet->pi0PFOLinks();
334 
335  unsigned int NCharged = finalChrgPFOLinks.size();
336  unsigned int NPi0Neut = finalPi0PFOLinks.size();
337 
338  TLorentzVector tlv_PanTau_Final;
339  for(unsigned int iPFO=0; iPFO<NCharged; iPFO++) {
340  const xAOD::PFO* pfo = finalChrgPFOLinks.at(iPFO).cachedElement();
341  tlv_PanTau_Final += pfo->p4();
342  }
343  for(unsigned int iPFO=0; iPFO<NPi0Neut; iPFO++) {
344  const xAOD::PFO* pfo = finalPi0PFOLinks.at(iPFO).cachedElement();
345  tlv_PanTau_Final += pfo->p4();
346  }
347 
348  inSeed->setFinalMomentum(tlv_PanTau_Final);
349 
350  PanTau::TauFeature* featureMap = inSeed->getFeatures();
351  featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_pt", tlv_PanTau_Final.Pt() );
352  featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_eta", tlv_PanTau_Final.Eta() );
353  featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_phi", tlv_PanTau_Final.Phi() );
354  featureMap->addFeature(inputAlg + "_" + varTypeName_Basic + "_FinalMomentumCore_m", tlv_PanTau_Final.M() );
355 }
356 
357 
358 bool PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster(const xAOD::PFO* pfo, int decayModeProto, const std::string& inputAlg) const {
359 
360  // this is only relevant for reco 1p1n modes, hence restrict the output to these modes
361 
362  int nPi0sPerCluster = 1;
363 
364  if (inputAlg != "CellBased" ) return (nPi0sPerCluster > 1);
365 
366  // cell-based sets this to 1pXn however below this function is
367  // called with the decayModeProto as evaluated by Pantau!
368  if (decayModeProto != xAOD::TauJetParameters::Mode_1p1n ) return (nPi0sPerCluster > 1);
369 
370  if( !pfo->attribute(xAOD::PFODetails::nPi0Proto, nPi0sPerCluster) ) {
371  ATH_MSG_WARNING("Could not retrieve nPi0Proto. Will set it to 1.");
372  nPi0sPerCluster = 1;
373  }
374 
375  return (nPi0sPerCluster > 1);
376 }
377 
378 
380 
381  TLorentzVector momentum;
382  PanTau::SetP4EEtaPhiM( momentum, neutral_pfo->e(), neutral_pfo->eta(), neutral_pfo->phi(), mass);
383  neutral_pfo->setP4(momentum.Pt(), neutral_pfo->eta(), neutral_pfo->phi(), mass);
384 }
385 
386 
387 void PanTau::Tool_DetailsArranger::SetNeutralConstituentVectorMasses(const std::vector< ElementLink<xAOD::PFOContainer> >& neutralPFOLinks, xAOD::PFOContainer& neutralPFOContainer, double mass) {
388 
389  for (const auto& link : neutralPFOLinks) {
390  size_t index = link.index();
391  xAOD::PFO* curNeutralPFO = neutralPFOContainer.at(index);
392  SetNeutralConstituentMass(curNeutralPFO, mass);
393  }
394 
395  }
396 
397 
398 std::vector< ElementLink< xAOD::PFOContainer > > PanTau::Tool_DetailsArranger::CollectConstituentsAsPFOLinks( PanTau::PanTauSeed* inSeed,
399  const std::vector< ElementLink< xAOD::PFOContainer > >& cellbased_neutralPFOLinks,
401  // collect element links from tau constituents in the Pantau
402  // seed of type "type". cellbased_neutralPFOLinks is only used
403  // to obtain the ElementLinks.
404 
405  std::vector< ElementLink< xAOD::PFOContainer > > new_links;
406 
407  unsigned int nConstsOfType=0;
408  bool foundIt=false;
409  std::vector<PanTau::TauConstituent*> tauConstituents=inSeed->getConstituentsOfType(type,foundIt);
410 
412  ATH_MSG_WARNING("CollectConstituentsAsPFOLinks: Function was called with type = " << type << " , however it was only designed for types t_Pi0Neut and t_Neutral! Returning...");
413  return new_links;
414  }
415 
416  for(unsigned int iConst=0; iConst<tauConstituents.size(); iConst++) {
417  bool isOfType = tauConstituents[iConst]->isOfType(type);
418  if(!isOfType) continue;
419 
420  // if the requested type is t_Neutral then exclude any t_Pi0Neut
421  // from the list (note: tau constituents that are t_Pi0Neut are
422  // also t_Neutral at the same time):
423  if(type==PanTau::TauConstituent::t_Neutral && tauConstituents[iConst]->isOfType(PanTau::TauConstituent::t_Pi0Neut) ) continue;
424  ++nConstsOfType;
425 
426  for(unsigned int iPFO=0; iPFO<cellbased_neutralPFOLinks.size(); iPFO++) {
427  const xAOD::PFO* pfo = cellbased_neutralPFOLinks.at(iPFO).cachedElement();
428 
429  if( tauConstituents[iConst]->getPFO() != pfo ) continue;
430 
431  new_links.push_back( cellbased_neutralPFOLinks.at(iPFO) );
432  }
433  }
434 
435  if( nConstsOfType != new_links.size() ){
436  ATH_MSG_WARNING("CollectConstituentsAsPFOLinks: Couldn't find PFOLinks " << new_links.size() << " for all tau constituents (" << tauConstituents.size() << ")!");
437  }
438 
439  return new_links;
440 }
441 
442 
443 //______________________________________________________________________________
444 void PanTau::Tool_DetailsArranger::createPi0Vectors(xAOD::TauJet* tauJet, std::vector<TLorentzVector>& vPi0s, std::vector< std::vector< ElementLink< xAOD::PFOContainer > > > &vec_pi0pfos)
445 {
446  // reset the pi0s
447  vPi0s.clear();
448  vec_pi0pfos.clear();
449 
450  // Since the PFO links as they come out of reconstruction, only correspond to
451  // calorimeter clusters, whereas we want the consts_pi0 vectors to correspond
452  // to real pi0s, we need to be careful to collect the PFOs correctly to pi0s
453  // for the cases where number of pi0s does not match to the decay mode:
454  size_t iNumPi0PFO = tauJet->nPi0PFOs();
455 
456  int iDecayMode = -1;
458 
459  if (iDecayMode == xAOD::TauJetParameters::Mode_1p1n && iNumPi0PFO > 1) {
460 
461  // TODO: find out if the pi0 mass is defined elsewhere in atlas code!
462  // float fMassPi0 = 134.98;
463  float fMassPi0Squared = MASS_PI0*MASS_PI0;
464 
465  // combine both photons (with 0 mass that is already set) to one pi0 vector:
466  const xAOD::PFO* xPfo1 = tauJet->pi0PFO(0);
467  const xAOD::PFO* xPfo2 = tauJet->pi0PFO(1);
468  vPi0s.push_back(xPfo1->p4() + xPfo2->p4());
469 
470  // re-set the mass to one pi0:
471  double dNewMomentum = std::sqrt(vPi0s[0].E() * vPi0s[0].E() - fMassPi0Squared);
472  vPi0s[0].SetPxPyPzE(vPi0s[0].Vect().Unit().Px() * dNewMomentum,
473  vPi0s[0].Vect().Unit().Py() * dNewMomentum,
474  vPi0s[0].Vect().Unit().Pz() * dNewMomentum,
475  vPi0s[0].E());
476 
477  std::vector< ElementLink<xAOD::PFOContainer> > pfovec;
478  pfovec.push_back(tauJet->pi0PFOLinks()[0]);
479  pfovec.push_back(tauJet->pi0PFOLinks()[1]);
480  vec_pi0pfos.push_back( pfovec );
481 
482  } else if (iDecayMode == xAOD::TauJetParameters::DecayMode::Mode_1pXn && iNumPi0PFO == 1){
483 
484  // make a single pi0 from a PFO that contains two pi0s:
485  const xAOD::PFO* xPfo = tauJet->pi0PFO(0);
486  // add the 2-pi0 vector preliminarily to the pi0vector:
487  vPi0s.push_back(xPfo->p4());
488 
489  // re-set the mass back to one pi0:
490  double dNewMomentum = std::sqrt( (vPi0s[0].E()/2.)*(vPi0s[0].E()/2.) - MASS_PI0*MASS_PI0 );
491  vPi0s[0].SetVectM(vPi0s[0].Vect().Unit() * dNewMomentum, MASS_PI0 );
492 
493  // create another pi0 from the same vector:
494  vPi0s.push_back(vPi0s[0]);
495 
496  std::vector< ElementLink<xAOD::PFOContainer> > pfovec;
497  pfovec.push_back(tauJet->pi0PFOLinks()[0]);
498  vec_pi0pfos.push_back( pfovec );
499  vec_pi0pfos.push_back( pfovec );//fix rare crash?
500 
501  } else {
502  // if it's not any of the special cases above then just collect the PFOs:
503  for (size_t iPFO = 0; iPFO < iNumPi0PFO; iPFO++){
504  vPi0s.push_back(tauJet->pi0PFO(iPFO)->p4());
505  std::vector< ElementLink<xAOD::PFOContainer> > pfovec;
506  pfovec.push_back(tauJet->pi0PFOLinks()[iPFO]);
507  vec_pi0pfos.push_back( pfovec );
508  }
509  }
510 
511 }
PanTau::Tool_DetailsArranger::SetNeutralConstituentMass
static void SetNeutralConstituentMass(xAOD::PFO *neutral_pfo, double mass)
Definition: Tool_DetailsArranger.cxx:379
xAOD::TauJetParameters::Mode_1p0n
@ Mode_1p0n
Definition: TauDefs.h:386
PanTauSeed.h
xAOD::TauJetParameters::PanTau_DecayMode
@ PanTau_DecayMode
Definition: TauDefs.h:360
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts
@ PanTau_BDTVar_Neutral_Ratio_1stBDTEtOverEtAllConsts
Definition: TauDefs.h:372
PanTau::Tool_DetailsArranger::SetHLVTau
static void SetHLVTau(PanTau::PanTauSeed *inSeed, xAOD::TauJet *tauJet, const std::string &inputAlg, const std::string &varTypeName_Basic)
Definition: Tool_DetailsArranger.cxx:330
PanTau::Tool_DetailsArranger::t_Int
@ t_Int
Definition: Tool_DetailsArranger.h:44
xAOD::TauJetParameters::PanTau_BDTVar_Combined_DeltaR1stNeutralTo1stCharged
@ PanTau_BDTVar_Combined_DeltaR1stNeutralTo1stCharged
Definition: TauDefs.h:375
PanTau::TauConstituent::t_Neutral
@ t_Neutral
Definition: TauConstituent.h:45
xAOD::TauJetParameters::Mode_1p1n
@ Mode_1p1n
Definition: TauDefs.h:387
PanTau::TauConstituent::Type
Type
Type enumeration to specify type of this tau constituent.
Definition: TauConstituent.h:42
PanTau::PanTauSeed::getFeatures
const PanTau::TauFeature * getFeatures() const
Definition: PanTauSeed.h:230
TauAnalysisTools::createPi0Vectors
void createPi0Vectors(const xAOD::TauJet *xTau, std::vector< TLorentzVector > &vPi0s)
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:316
PanTau::PanTauSeed::getTauJet
const xAOD::TauJet * getTauJet() const
Definition: PanTauSeed.h:228
PanTau::PanTauSeed::getDecayModeBySubAlg
int getDecayModeBySubAlg() const
Definition: PanTauSeed.h:239
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Base_Fragment.mass
mass
Definition: Sherpa_i/share/common/Base_Fragment.py:59
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
xAOD::TauJetParameters::nCharged
@ nCharged
Definition: TauDefs.h:266
PanTau::PanTauSeed::getDecayModeByPanTau
int getDecayModeByPanTau() const
Definition: PanTauSeed.h:240
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
PanTau::PanTauSeed::getNameInputAlgorithm
std::string getNameInputAlgorithm() const
Definition: PanTauSeed.h:227
PanTau::PanTauSeed::getConstituentsOfType
std::vector< PanTau::TauConstituent * > getConstituentsOfType(int tauConstituent_Type, bool &foundit)
Definition: PanTauSeed.cxx:358
xAOD::TauJet_v3::setPanTauDetail
void setPanTauDetail(TauJetParameters::PanTauDetails panTauDetail, int value)
Definition: TauJet_v3.cxx:395
xAOD::TauJetParameters::PanTau_BDTValue_3p0n_vs_3pXn
@ PanTau_BDTValue_3p0n_vs_3pXn
Definition: TauDefs.h:364
xAOD::PFO_v1::attribute
bool attribute(PFODetails::PFOAttributes AttributeType, T &anAttribute) const
get a PFO Variable via enum
xAOD::PFO_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: PFO_v1.cxx:60
PanTau::PanTauSeed::t_NoValidInputTau
@ t_NoValidInputTau
Definition: PanTauSeed.h:34
HelperFunctions.h
xAOD::TauJet_v3::clearNeutralPFOLinks
void clearNeutralPFOLinks()
Remove all neutral PFOs from the tau.
Definition: TauJet_v3.cxx:859
asg
Definition: DataHandleTestTool.h:28
PanTau::TauFeature::addFeature
bool addFeature(const std::string &name, const double value)
adds a new feature
Definition: TauFeature.cxx:44
xAOD::TauJet_v3::setNeutralPFOLinks
void setNeutralPFOLinks(const PFOLinks_t &neutralPFOs)
PanTau::PanTauSeed::getFinalMomentum
TLorentzVector getFinalMomentum() const
Definition: PanTauSeed.h:238
xAOD::TauJet_v3::clearPi0PFOLinks
void clearPi0PFOLinks()
Remove all pi0 PFOs from the tau.
Definition: TauJet_v3.cxx:890
PFOContainer.h
PanTau::Tool_DetailsArranger::addPanTauDetailToTauJet
void addPanTauDetailToTauJet(PanTauSeed *inSeed, const std::string &featName, xAOD::TauJetParameters::PanTauDetails detailEnum, PanTauDetailsType detailType) const
Definition: Tool_DetailsArranger.cxx:124
xAOD::TauJet_v3::panTauDetail
bool panTauDetail(TauJetParameters::PanTauDetails panTauDetail, int &value) const
Get and set values of pantau details variables via enum.
Definition: TauJet_v3.cxx:367
PanTau::Tool_DetailsArranger::PanTauDetailsType
PanTauDetailsType
Definition: Tool_DetailsArranger.h:43
PanTau::Tool_DetailsArranger::~Tool_DetailsArranger
virtual ~Tool_DetailsArranger()
PanTau::TauFeature
Definition: TauFeature.h:19
sortBDTscore
bool sortBDTscore(const ElementLink< xAOD::PFOContainer > &i, const ElementLink< xAOD::PFOContainer > &j)
Definition: Tool_DetailsArranger.cxx:15
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:225
PanTau::Tool_DetailsArranger::HasMultPi0sInOneCluster
bool HasMultPi0sInOneCluster(const xAOD::PFO *pfo, int decayModeProto, const std::string &inputAlg) const
Definition: Tool_DetailsArranger.cxx:358
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
PanTau::Tool_DetailsArranger::m_Tool_InformationStore
ToolHandle< PanTau::ITool_InformationStore > m_Tool_InformationStore
Definition: Tool_DetailsArranger.h:58
xAOD::TauJet_v3::nPi0PFOs
size_t nPi0PFOs() const
Get the number of pi0 PFO particles associated with this tau.
Definition: TauJet_v3.cxx:880
xAOD::TauJet_v3::setP4
void setP4(double pt, double eta, double phi, double m)
Set methods for IParticle values.
Definition: TauJet_v3.cxx:172
xAOD::Particle
Particle_v1 Particle
Define the latest version of the particle class.
Definition: Event/xAOD/xAODParticleEvent/xAODParticleEvent/Particle.h:17
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_HLV_SumM
@ PanTau_BDTVar_Neutral_HLV_SumM
Definition: TauDefs.h:369
xAOD::TauJetParameters::Mode_1pXn
@ Mode_1pXn
Definition: TauDefs.h:388
xAOD::TauJet_v3::pi0PFO
const PFO * pi0PFO(size_t i) const
Get the pointer to a given pi0 PFO associated with this tau.
xAOD::PFO_v1::e
virtual double e() const
The total energy of the particle.
Definition: PFO_v1.cxx:81
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
PanTau::PanTauSeed::setFinalMomentum
void setFinalMomentum(TLorentzVector finalMom)
Definition: PanTauSeed.h:244
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
PanTau::Tool_DetailsArranger::CollectConstituentsAsPFOLinks
std::vector< ElementLink< xAOD::PFOContainer > > CollectConstituentsAsPFOLinks(PanTau::PanTauSeed *inSeed, const std::vector< ElementLink< xAOD::PFOContainer > > &cellbased_neutralPFOLinks, PanTau::TauConstituent::Type type) const
Definition: Tool_DetailsArranger.cxx:398
xAOD::TauJetParameters::PanTau_BDTValue_1p1n_vs_1pXn
@ PanTau_BDTValue_1p1n_vs_1pXn
Definition: TauDefs.h:363
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
xAOD::TauJet_v3::protoNeutralPFOLinks
const PFOLinks_t & protoNeutralPFOLinks() const
PanTau::Tool_DetailsArranger::arrangePFOLinks
StatusCode arrangePFOLinks(PanTau::PanTauSeed *inSeed, xAOD::TauJet *tauJet, xAOD::ParticleContainer &pi0Container, xAOD::PFOContainer &neutralPFOContainer) const
Definition: Tool_DetailsArranger.cxx:170
xAOD::TauJet_v3::neutralPFOLinks
const PFOLinks_t & neutralPFOLinks() const
PanTau::Tool_DetailsArranger::initialize
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: Tool_DetailsArranger.cxx:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
ParticleContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
PanTau::TauFeature::value
double value(const std::string &name, bool &isValid) const
returns the value of the feature given by its name
Definition: TauFeature.cxx:23
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
xAOD::PFO_v1::p4
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition: PFO_v1.cxx:95
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::PFO_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: PFO_v1.cxx:67
xAOD::TauJetParameters::PanTau_BDTValue_1p0n_vs_1p1n
@ PanTau_BDTValue_1p0n_vs_1p1n
Definition: TauDefs.h:362
xAOD::TauJetParameters::PanTauCellBased
@ PanTauCellBased
Definition: TauDefs.h:344
PanTau::Tool_DetailsArranger::execute
virtual StatusCode execute(PanTau::PanTauSeed *inSeed, xAOD::ParticleContainer &pi0Container, xAOD::PFOContainer &neutralPFOContainer) const
Definition: Tool_DetailsArranger.cxx:64
xAOD::TauJet_v3::addPi0Link
void addPi0Link(const ElementLink< IParticleContainer > &tr)
add a pi0 link to the tau
Definition: TauJet_v3.cxx:649
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
xAOD::Particle_v1
Description of a generic particle.
Definition: Particle_v1.h:31
xAOD::TauJetParameters::Mode_3p0n
@ Mode_3p0n
Definition: TauDefs.h:389
xAOD::PFO_v1
Class describing a particle flow object.
Definition: PFO_v1.h:35
Tool_DetailsArranger.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
PanTau::HelperFunctions::bindToolHandle
static StatusCode bindToolHandle(ToolHandle< T > &, std::string)
Definition: Reconstruction/PanTau/PanTauAlgs/PanTauAlgs/HelperFunctions.h:60
Particle.h
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_2
@ PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_2
Definition: TauDefs.h:371
PanTau::Tool_DetailsArranger::Tool_DetailsArranger
Tool_DetailsArranger(const std::string &name)
Definition: Tool_DetailsArranger.cxx:21
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
PanTau::PanTauSeed::t_NoConstituentsAtAll
@ t_NoConstituentsAtAll
Definition: PanTauSeed.h:35
xAOD::TauJet_v3::pi0PFOLinks
const PFOLinks_t & pi0PFOLinks() const
xAOD::PFODetails::nPi0Proto
@ nPi0Proto
Definition: Event/xAOD/xAODPFlow/xAODPFlow/PFODefs.h:31
xAOD::TauJet_v3::setChargedPFOLinks
void setChargedPFOLinks(const PFOLinks_t &chargedPFOs)
xAOD::TauJet_v3::clearChargedPFOLinks
void clearChargedPFOLinks()
Remove all charged PFOs from the tau.
Definition: TauJet_v3.cxx:828
PanTau::Tool_DetailsArranger::SetNeutralConstituentVectorMasses
static void SetNeutralConstituentVectorMasses(const std::vector< ElementLink< xAOD::PFOContainer > > &neutralPFOLinks, xAOD::PFOContainer &neutralPFOContainer, double mass)
Definition: Tool_DetailsArranger.cxx:387
PanTau::Tool_DetailsArranger::t_Float
@ t_Float
Definition: Tool_DetailsArranger.h:45
PanTau::TauConstituent::t_Pi0Neut
@ t_Pi0Neut
Definition: TauConstituent.h:46
xAOD::PFO_v1::setP4
void setP4(const FourMom_t &vec)
set the 4-vec
Definition: PFO_v1.cxx:107
xAOD::TauJet_v3::setPi0PFOLinks
void setPi0PFOLinks(const PFOLinks_t &pi0PFOs)
xAOD::TauJetParameters::PanTauDetails
PanTauDetails
Enum for tau details (scalar) calculated by pantau.
Definition: TauDefs.h:355
xAOD::TauJetParameters::PanTau_BDTVar_Charged_StdDev_Et_WrtEtAllConsts
@ PanTau_BDTVar_Charged_StdDev_Et_WrtEtAllConsts
Definition: TauDefs.h:368
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PanTau::PanTauSeed::isOfTechnicalQuality
bool isOfTechnicalQuality(int pantauSeed_TechnicalQuality) const
Definition: PanTauSeed.cxx:349
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TauJet.h
PanTau::Tool_DetailsArranger::createPi0Vectors
static void createPi0Vectors(xAOD::TauJet *tauJet, std::vector< TLorentzVector > &vPi0s, std::vector< std::vector< ElementLink< xAOD::PFOContainer > > > &vec_pi0pfos)
Definition: Tool_DetailsArranger.cxx:444
PanTau::PanTauSeed::t_NoSelectedConstituents
@ t_NoSelectedConstituents
Definition: PanTauSeed.h:36
xAOD::TauJet_v3::protoChargedPFOLinks
const PFOLinks_t & protoChargedPFOLinks() const
cellbased pfos
xAOD::TauJet_v3::setDetail
void setDetail(TauJetParameters::Detail detail, int value)
Definition: TauJet_v3.cxx:337
xAOD::TauJetParameters::Mode_3pXn
@ Mode_3pXn
Definition: TauDefs.h:390
xAOD::TauJetParameters::PanTau_isPanTauCandidate
@ PanTau_isPanTauCandidate
Definition: TauDefs.h:357
xAOD::TauJetParameters::PanTau_BDTVar_Basic_NNeutralConsts
@ PanTau_BDTVar_Basic_NNeutralConsts
Definition: TauDefs.h:366
PanTau::Tool_DetailsArranger::m_Tool_InformationStoreName
std::string m_Tool_InformationStoreName
Definition: Tool_DetailsArranger.h:59
xAOD::TauJet_v3::chargedPFOLinks
const PFOLinks_t & chargedPFOLinks() const
default pfos
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Shots_NPhotonsInSeed
@ PanTau_BDTVar_Neutral_Shots_NPhotonsInSeed
Definition: TauDefs.h:374
xAOD::TauJetParameters::PanTau_BDTVar_Charged_HLV_SumM
@ PanTau_BDTVar_Charged_HLV_SumM
Definition: TauDefs.h:379
xAOD::TauJetParameters::Mode_NotSet
@ Mode_NotSet
Definition: TauDefs.h:392
xAOD::TauJetParameters::PanTau_BDTVar_Charged_JetMoment_EtDRxTotalEt
@ PanTau_BDTVar_Charged_JetMoment_EtDRxTotalEt
Definition: TauDefs.h:367
readCCLHist.float
float
Definition: readCCLHist.py:83
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_Ratio_EtOverEtAllConsts
@ PanTau_BDTVar_Neutral_Ratio_EtOverEtAllConsts
Definition: TauDefs.h:373
xAOD::TauJetParameters::Mode_Other
@ Mode_Other
Definition: TauDefs.h:391
PanTau::PanTauSeed
Definition: PanTauSeed.h:24
xAOD::TauJetParameters::PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_1
@ PanTau_BDTVar_Neutral_PID_BDTValues_BDTSort_1
Definition: TauDefs.h:370