21 return StatusCode::SUCCESS;
27 std::vector<std::shared_ptr<xAOD::TruthParticle>> true_taus_1p;
28 std::vector<std::shared_ptr<xAOD::TruthParticle>> true_taus_3p;
34 return {true_taus_1p, true_taus_3p};
43 for(
const auto xTruthParticle : *truth_cont) {
44 if(xTruthParticle->isTau()) {
45 ATH_MSG_DEBUG(
"Tau with status " << xTruthParticle->status() <<
" and charge " << xTruthParticle->charge());
48 std::shared_ptr xTruthTau = std::make_shared<xAOD::TruthParticle>();
49 xTruthTau->makePrivateStore(*xTruthParticle);
55 if(acc_isleptonic(*xTruthTau))
continue;
57 float pt = acc_ptvis(*xTruthTau);
58 float eta = acc_etavis(*xTruthTau);
64 int nTracks = acc_ntracks(*xTruthTau);
65 if(nTracks == 1) true_taus_1p.push_back(xTruthTau);
66 else if(nTracks == 3) true_taus_3p.push_back(xTruthTau);
70 return {true_taus_1p, true_taus_3p};
76 if(!xTruthTau->hasDecayVtx())
return StatusCode::FAILURE;
85 acc_isleptonic(*xTruthTau) =
false;
87 TLorentzVector VisSumTLV;
88 acc_ptvis(*xTruthTau) = 0.;
89 acc_etavis(*xTruthTau) = 0.;
90 acc_phivis(*xTruthTau) = 0.;
91 acc_mvis(*xTruthTau) = 0.;
92 acc_childChargeSum(*xTruthTau) = 0;
93 acc_ntracks(*xTruthTau) = 0;
98 for(std::size_t iChild = 0; iChild != nChildren; ++iChild) {
105 VisSumTLV += child->
p4();
106 acc_childChargeSum(*xTruthTau) += child->
charge();
107 acc_ntracks(*xTruthTau) += std::abs(child->
charge());
111 acc_ptvis(*xTruthTau) = VisSumTLV.Pt();
112 acc_etavis(*xTruthTau) = VisSumTLV.Eta();
113 acc_phivis(*xTruthTau) = VisSumTLV.Phi();
114 acc_mvis(*xTruthTau) = VisSumTLV.M();
116 if(acc_childChargeSum(*xTruthTau) != xTruthTau->charge() || acc_ntracks(*xTruthTau)%2 == 0) {
117 ATH_MSG_WARNING(
"Strange tau: charge " << acc_childChargeSum(*xTruthTau) <<
" and " << acc_ntracks(*xTruthTau) <<
" tracks");
119 for(std::size_t iChild = 0; iChild != nChildren; ++iChild) {
125 return StatusCode::SUCCESS;
133 std::vector<std::shared_ptr<xAOD::TruthParticle>> true_taus_1p = true_taus.first;
134 std::vector<std::shared_ptr<xAOD::TruthParticle>> true_taus_3p = true_taus.second;
136 for(
const std::string& trigger :
m_triggers) {
140 if( info.isHLTTandP() || info.isHLTDiTau())
continue;
143 std::vector<const xAOD::TauJet*> hlt_taus =
getOnlineTausAll(trigger,
true);
145 if(!true_taus_1p.empty()) {
150 if(!true_taus_3p.empty()) {
156 return StatusCode::SUCCESS;
162 ATH_MSG_DEBUG(
"Fill Truth Tau Matching to Offline and Online Taus efficiencies: " << trigger);
166 auto monGroup =
getGroup(trigger+
"_Truth_Efficiency_"+nProng);
181 for(
const std::shared_ptr<xAOD::TruthParticle>& true_tau : true_taus) {
182 pt_vis = acc_ptvis(*true_tau)/Gaudi::Units::GeV;
183 eta_vis = acc_etavis(*true_tau);
184 phi_vis = acc_phivis(*true_tau);
186 HLT_truth_match =
matchTruthObjects(true_tau.get(), online_tau_vec, 0.2) && hlt_fires;
188 bool is_highPt =
false;
189 if(info.isHLTSingleTau()) is_highPt = pt_vis > info.getHLTTauThreshold() + 20.0;
191 fill(monGroup, pt_vis, eta_vis, phi_vis, HLT_truth_match);
194 HLT_truth_match_highPt =
static_cast<bool>(HLT_truth_match);
195 fill(monGroup, eta_vis, phi_vis, HLT_truth_match_highPt);
206 auto monGroup =
getGroup(trigger+
"_TruthVars_"+nProng);
208 std::vector<float> ratio, ptvis, etavis, phivis, mvis;
216 float matchedRatio = -999, matchedptvis = -999, matchedetavis = 999, matchedphivis = 999, matchedmvis = -999;
228 for(
auto& HLTTau : ef_taus) {
229 for(
const std::shared_ptr<xAOD::TruthParticle>& true_tau : true_taus) {
231 double pt_vis = acc_ptvis(*true_tau);
232 matchedptvis = pt_vis/Gaudi::Units::GeV;
233 matchedetavis = acc_etavis(*true_tau);
234 matchedphivis = acc_phivis(*true_tau);
235 matchedmvis = acc_mvis(*true_tau);
236 matchedRatio = HLTTau->pt()/pt_vis - 1.;
240 if(matchedptvis > 0) {
241 ptvis.push_back(matchedptvis);
242 etavis.push_back(matchedetavis);
243 phivis.push_back(matchedphivis);
244 mvis.push_back(matchedmvis);
245 ratio.push_back(matchedRatio);
249 fill(monGroup, pt_vis, eta_vis, phi_vis, mass_vis, PtRatio);
Scalar eta() const
pseudorapidity method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Helper class to provide constant type-safe access to aux data.
Helper class to provide type-safe access to aux data.
ATLAS-specific HepMC functions.
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
PublicToolHandle< Trig::TrigDecisionTool > m_trigDecTool
Tool to tell whether a specific trigger is passed.
Declare a monitored scalar variable.
Helper class to provide type-safe access to aux data.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Helper class to provide constant type-safe access to aux data.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Gaudi::Property< bool > m_do_efficiency_plots
virtual StatusCode initialize() override
initialize
TrigTauMonitorBaseAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
bool matchTruthObjects(const T1 *true_tau, const std::vector< const T2 * > &tau_vec, float threshold) const
Gaudi::Property< std::vector< std::string > > m_triggers
const TrigTauInfo & getTrigInfo(const std::string &trigger) const
Gaudi::Property< bool > m_do_variable_plots
std::vector< const xAOD::TauJet * > getOnlineTausAll(const std::string &trigger, bool include_0P=true) const
virtual StatusCode processEvent(const EventContext &ctx) const override
void fillTruthEfficiency(const std::vector< const xAOD::TauJet * > &online_tau_vec_all, const std::vector< std::shared_ptr< xAOD::TruthParticle > > &true_taus, const std::string &trigger, const std::string &nProng) const
TrigTauMonitorTruthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleKey
virtual StatusCode initialize() override
initialize
std::pair< std::vector< std::shared_ptr< xAOD::TruthParticle > >, std::vector< std::shared_ptr< xAOD::TruthParticle > > > getTruthTaus(const EventContext &ctx, const float threshold=20.0) const
void fillTruthVars(const std::vector< const xAOD::TauJet * > &tau_vec, const std::vector< std::shared_ptr< xAOD::TruthParticle > > &true_taus, const std::string &trigger, const std::string &nProng) const
StatusCode examineTruthTau(const std::shared_ptr< xAOD::TruthParticle > &xTruthParticle) const
int status() const
Status code.
int pdgId() const
PDG ID code.
double charge() const
Physical charge.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
const TruthParticle_v1 * outgoingParticle(size_t index) const
Get one of the outgoing particles.
size_t nOutgoingParticles() const
Get the number of outgoing particles.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
bool isSMLepton(const T &p)
APID: the fourth generation leptons are not standard model leptons.
bool isSMNeutrino(const T &p)
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
static const unsigned int allowResurrectedDecision
static const unsigned int Physics
TruthVertex_v1 TruthVertex
Typedef to implementation.
TruthParticle_v1 TruthParticle
Typedef to implementation.