14 #include "CLHEP/Units/SystemOfUnits.h"
25 std::stringstream sSS(sInput);
27 while (std::getline(sSS, sItem, cDelim))
28 vOut.push_back(sItem);
34 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
36 while (std::getline(sSS, sItem, cDelim))
37 vOut.push_back(sItem);
43 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
45 while (std::getline(sSS, sItem, cDelim))
46 vOut.push_back(
size_t(stoi(sItem)));
52 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
54 while (std::getline(sSS, sItem, cDelim))
55 vOut.push_back(stoi(sItem));
61 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
63 while (std::getline(sSS, sItem, cDelim))
64 vOut.push_back(stoi(sItem));
70 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
72 while (std::getline(sSS, sItem, cDelim))
73 vOut.push_back(stof(sItem));
79 std::stringstream sSS(rEnv.GetValue(sKey.c_str(),
""));
81 while (std::getline(sSS, sItem, cDelim))
82 vOut.push_back(stod(sItem));
88 return xTau.
pt()/1000.;
95 return xTau.
p4().P()/1000.;
109 return std::abs(xTau.
eta());
144 double dTrackEta = 0.;
145 double dTrackMaxPt = 0.;
146 for(
unsigned int iNumTrack = 0; iNumTrack < xTau.
nTracks(); iNumTrack++)
148 if (xTau.
track(iNumTrack)->
pt() > dTrackMaxPt)
150 dTrackMaxPt = xTau.
track(iNumTrack)->
pt();
151 dTrackEta = xTau.
track(iNumTrack)->
eta();
165 if (xTruthTau!=
nullptr && accIsHadronicTau (*xTruthTau))
166 return xTruthTau->
pt()/
GeV;
179 if (xTruthTau!=
nullptr && accIsHadronicTau (*xTruthTau))
180 return std::abs(xTruthTau->
eta());
190 return static_cast<double>(iDecayMode);
198 if (!accTruthParticleLink(xTau))
200 Error(
"TauAnalysisTools::getTruth",
"No truth match information available. Please run TauTruthMatchingTool first");
203 const Link_t xTruthTauLink = accTruthParticleLink(xTau);
216 if (xTruthTau!=
nullptr && accIsHadronicTau(*xTruthTau))
240 else if (iCharged == 3)
246 if (iCharged == 2 or iCharged == 4 or iCharged == 5)
248 if (iCharged == 0 or iCharged >=6)
262 Warning(
"TauAnalysisTools::getNTauDecayParticles",
"passed truth particle is not a truth tau, return 0");
266 for(
auto iPdgId2 : accDecayModeVector(xTruthTau))
267 if (!bCompareAbsoluteValues)
269 if (iPdgId2 == iPdgId) iNum++;
273 if (std::abs(iPdgId2) == std::abs(iPdgId)) iNum++;
284 std::ifstream fInputFile;
285 fInputFile.open(sFileName);
286 if(!fInputFile.is_open())
289 fInputFile.seekg(-1,fInputFile.end);
291 bool bKeepLooping =
true;
297 if((
int)fInputFile.tellg() <= 1)
300 bKeepLooping =
false;
303 bKeepLooping =
false;
305 fInputFile.seekg(-2,fInputFile.cur);
308 std::string sLastLine;
309 getline(fInputFile,sLastLine);
312 return (sLastLine.size() == 0 or sLastLine[0] ==
'#');
325 size_t iNumPi0PFO = xTau->
nPi0PFOs();
331 Error(
"TauAnalysisTools::createPi0Vectors",
"Failed to retrieve panTauDetail decay mode.");
339 float fMassPi0Squared = 18219.6004;
344 vPi0s.push_back(xPfo1->
p4() + xPfo2->
p4());
347 double dNewMomentum = std::sqrt(vPi0s[0].
E() * vPi0s[0].
E() - fMassPi0Squared);
348 vPi0s[0].SetPxPyPzE(vPi0s[0].Vect().Unit().Px() * dNewMomentum,
349 vPi0s[0].Vect().Unit().Py() * dNewMomentum,
350 vPi0s[0].Vect().Unit().Pz() * dNewMomentum,
358 vPi0s.push_back(xPfo->
p4());
361 double dNewMomentum = std::sqrt(vPi0s[0].
E() / 2 * vPi0s[0].
E() / 2 - vPi0s[0].M() / 2. * vPi0s[0].M() / 2.);
362 vPi0s[0].SetVectM(vPi0s[0].Vect() * (dNewMomentum / vPi0s[0].
P()), vPi0s[0].M() / 2.);
365 vPi0s.push_back(vPi0s[0]);
370 for (
size_t iPFO = 0; iPFO < iNumPi0PFO; iPFO++)
372 vPi0s.push_back(xTau->
pi0PFO(iPFO)->
p4());
381 correctedPi0s.clear();
387 Error(
"TauAnalysisTools::correctedPi0Vectors",
"Failed to retrieve panTauDetail decay mode.");
392 std::vector<TLorentzVector> vPi0s;
397 TLorentzVector Sum_vPi0s;
398 for(
unsigned int i = 0;
i < vPi0s.size() ;
i++){
399 Sum_vPi0s += vPi0s[
i];
403 TLorentzVector Sum_ChrgPFOP4;
405 Sum_ChrgPFOP4 +=
track->p4();
409 TLorentzVector FinalCalibP4 = xTau->
p4();
412 double px = FinalCalibP4.Px() - Sum_ChrgPFOP4.Px();
413 double py = FinalCalibP4.Py() - Sum_ChrgPFOP4.Py();
414 double pz = FinalCalibP4.Pz() - Sum_ChrgPFOP4.Pz();
417 double p_vPi0s = Sum_vPi0s.P();
420 double X = p_correctedPi0s/p_vPi0s;
423 double px_scaled, py_scaled, pz_scaled,
e;
424 double mPi0 = 134.977;
425 for(
unsigned int i = 0;
i < vPi0s.size() ;
i++){
426 px_scaled = vPi0s[
i].Px() *
X;
427 py_scaled = vPi0s[
i].Py() *
X;
428 pz_scaled = vPi0s[
i].Pz() *
X;
432 TLorentzVector P4_correctedPi0s;
433 P4_correctedPi0s.SetPxPyPzE(px_scaled,py_scaled,pz_scaled,
e);
434 correctedPi0s.push_back(P4_correctedPi0s);
437 correctedPi0s = vPi0s;
444 TF1 DeltaRdist(
"DeltaRdist",
"pol3", 0, 67500);
445 DeltaRdist.SetParameter(0, 0.07924);
446 DeltaRdist.SetParameter(1, -2.078/1000000.);
447 DeltaRdist.SetParameter(2, 2.619/100000000000.);
448 DeltaRdist.SetParameter(3, -1.238/10000000000000000.);
451 TLorentzVector SumPi0_P4;
452 for(
unsigned int i = 0 ;
i < correctedPi0s.size() ;
i++){
453 SumPi0_P4 += correctedPi0s[
i];
456 float SumPi0_pt = SumPi0_P4.Pt();
460 if(SumPi0_pt >= 67500){
463 deltaR = DeltaRdist.Eval(SumPi0_pt);
466 TLorentzVector correctedPi0_0, correctedPi0_1;
467 correctedPi0_0.SetPtEtaPhiM( correctedPi0s[0].
Pt()/
cos(0.5*
deltaR/std::sqrt(2.0)), correctedPi0s[0].
Eta()+0.5*
deltaR/std::sqrt(2.0), correctedPi0s[0].
Phi()+0.5*
deltaR/std::sqrt(2.0), correctedPi0s[0].M() );
468 correctedPi0_1.SetPtEtaPhiM( correctedPi0s[1].
Pt()/
cos(0.5*
deltaR/std::sqrt(2.0)), correctedPi0s[1].
Eta()-0.5*
deltaR/std::sqrt(2.0), correctedPi0s[1].
Phi()-0.5*
deltaR/std::sqrt(2.0), correctedPi0s[1].M() );
470 std::vector<TLorentzVector> AngleCorrectedPi0s;
471 AngleCorrectedPi0s.push_back(correctedPi0_0);
472 AngleCorrectedPi0s.push_back(correctedPi0_1);
475 TLorentzVector PionCluster_angleCorrected = AngleCorrectedPi0s[0]+AngleCorrectedPi0s[1];
477 double dNewMomentum = std::sqrt(PionCluster_angleCorrected.E()/2. * PionCluster_angleCorrected.E()/2. - PionCluster_angleCorrected.M() / 2. * PionCluster_angleCorrected.M() / 2.);
478 correctedPi0s[0].SetVectM(PionCluster_angleCorrected.Vect() * (dNewMomentum / PionCluster_angleCorrected.P()), PionCluster_angleCorrected.M() / 2.);
479 correctedPi0s[1] = correctedPi0s[0];
484 TauP4 +=
track->p4();
487 for(
unsigned int iPi0=0; iPi0 < correctedPi0s.size(); iPi0++) {
488 TauP4 += correctedPi0s[iPi0];
496 vChargedHadrons.clear();
497 vNeutralHadrons.clear();
502 Warning(
"TauAnalysisTools::truthHadrons",
"Passed truth particle has no decay vertex.");
510 Warning(
"TauAnalysisTools::truthHadrons",
"Passed truth particle has no valid decay vertex.");
515 for (
size_t iOutgoingParticle = 0; iOutgoingParticle < xDecayVertex->
nOutgoingParticles(); ++iOutgoingParticle )
520 Warning(
"TauAnalysisTools::truthHadrons",
"Truth daughter of tau decay was not found. Please ensure that this container has the full tau decay information or produce the TruthTaus container in AtlasDerivation.\nInformation on how to do this can be found here:\nhttps://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/TauPreRecommendations2015#Accessing_Tau_Truth_Information");
525 if ( xTruthDaughter->
isTau() )
527 Warning(
"TauAnalysisTools::truthHadrons",
"Tau decays into a tau itself. Skip this decay");
536 vChargedHadrons.push_back(xTruthDaughter);
538 vNeutralHadrons.push_back(xTruthDaughter);
548 vChargedHadrons.clear();
549 vNeutralHadrons.clear();
556 Error(
"TauAnalysisTools::truthHadrons",
"No truth match information available. Please run TauTruthMatchingTool first");
559 const Link_t xTruthTauLink = accTruthParticleLink(*xTau);
563 if (xTruthTau!=
nullptr && accIsHadronicTau(*xTruthTau))
565 truthHadrons(xTruthTau, vChargedHadrons, vNeutralHadrons);
577 Error(
"TauAnalysisTools::getTruthParticleType",
"No truth match information available. Please run TauTruthMatchingTool first.");
582 if (xTruthParticle->
isTau())
585 if ((
bool)accIsHadronicTau(*xTruthParticle))
590 if (xTruthParticle->
isMuon())
600 if (lTruthParticleLink.
isValid())
610 Error(
"TauAnalysisTools::getTruthParticleType",
"No truth match information available. Please run DiTauTruthMatchingTool first");
614 if (accIsTruthHadronic(xDiTau))
617 return eTruthMatchedParticleType;
626 std::vector<const xAOD::TauJet*> taus_murm_vec(taus_muonRM->
begin(), taus_muonRM->
end());
627 std::vector<const xAOD::TauJet*> taus_combined;
629 originalTauJetAcc (
"originalTauJet");
631 auto replacement_itr = std::find_if(taus_murm_vec.begin(), taus_murm_vec.end(),
633 auto link_to_ori_tau = originalTauJetAcc (*tau_murm);
634 if (!link_to_ori_tau.isValid()) { return false; }
635 if (*link_to_ori_tau == tau_std){
return true; }
639 if (replacement_itr == taus_murm_vec.end()) { taus_combined.push_back(tau_std); }
643 taus_combined.push_back(*replacement_itr);
644 taus_murm_vec.erase(replacement_itr);
650 assert(taus_murm_vec.empty());
651 return taus_combined;