26#include <TGraphAsymmErrors.h>
63 declareInterface<ITruthNtupleTool>(
this);
87 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
125StatusCode
Trk::TruthNtupleTool::initBranches(
const std::vector<const Trk::ITrackTruthClassifier*>& classifiers,
bool fillJets,
const std::vector<std::string>& trackCollectionNames) {
139 for (
unsigned int classifierIndex = 0; classifierIndex < classifiers.size(); ++classifierIndex ) {
140 if (!(classifiers[classifierIndex])) {
141 ATH_MSG_ERROR (
"Got NULL pointer to truth classifier tool!");
142 return StatusCode::FAILURE;
144 std::string classifierName = classifiers[classifierIndex]->nameOfClassifier();
147 std::string branchName =
"Class_" + classifierName;
148 std::string branchDescription =
"Class_" + classifierName +
"/I";
151 for (
unsigned int clIndex = 0; clIndex < classifiers[classifierIndex]->numberOfClassifiers(); clIndex++) {
153 (
"true"+classifiers[classifierIndex]->classificationAsString(clIndex)).c_str(),
154 (
"true"+classifiers[classifierIndex]->classificationAsString(clIndex)).c_str(),
160 (
"reco"+classifiers[classifierIndex]->classificationAsString(clIndex)).c_str(),
161 (
"reco"+classifiers[classifierIndex]->classificationAsString(clIndex)).c_str(),
170 ATH_MSG_ERROR (
"Track links seem to be already initialized! Do NOT call initBranches() twice!");
171 return StatusCode::FAILURE;
174 m_mc_prob.resize(trackCollectionNames.size(),
nullptr);
175 for (
unsigned int trackColIndex = 0; trackColIndex < trackCollectionNames.size(); ++trackColIndex ) {
177 std::string branchName =
"TrackLinkIndex_" + trackCollectionNames[trackColIndex];
179 m_mc_prob[trackColIndex] =
new std::vector<float>();
180 branchName =
"truth_prob_" + trackCollectionNames[trackColIndex];
181 m_nt->Branch(branchName.c_str(), &(
m_mc_prob[trackColIndex]));
183 return StatusCode::SUCCESS;
197 for (
unsigned int clIndex = 0; clIndex <
m_trackTruthClassifiers[classifierIndex]->numberOfClassifiers(); clIndex++) {
200 msg() << std::resetiosflags(std::ios::right) << std::setiosflags(std::ios::left) << std::setw(15) <<
m_trackTruthClassifiers[classifierIndex]->classificationAsString(clIndex);
201 msg() << std::resetiosflags(std::ios::left) << std::setiosflags(std::ios::right);
202 for (
int etaBin = 0; etaBin <
m_recoTrackCounts[classifierIndex][clIndex]->GetNbinsX(); etaBin++) {
204 double reco =
m_recoTrackCounts[classifierIndex][clIndex]->GetBinContent(etaBin+1);
205 msg() << std::resetiosflags(std::ios::fixed | std::ios::showpoint) << std::setprecision(8) << std::setw(8) << reco <<
"/" << std::setw(8) << truth;
206 msg() << std::setiosflags(std::ios::fixed | std::ios::showpoint | std::ios::right ) << std::setw(7)
207 <<
" (" << std::setprecision(4) << (truth>0. ? reco/truth : 0.) <<
")";
212 std::string graphName =
"trackEff_" +
m_trackTruthClassifiers[classifierIndex]->classificationAsString(clIndex);
213 effPlot->SetNameTitle(graphName.c_str(), graphName.c_str());
229 for (
unsigned int trackColIndex = 0; trackColIndex <
m_TrackLinkIndex.size(); ++trackColIndex ) {
233 return StatusCode::SUCCESS;
240 const std::vector< Trk::ValidationTrackTruthData >& truthData) {
242 ATH_MSG_DEBUG (
"in writeTruthData(...) with ValTrackTruthData size = "<<truthData.size());
246 if (!evt.isValid()) {
248 return StatusCode::FAILURE;
257 genParticle = truthData[
index].genParticle;
258 truePerigee = truthData[
index].truthPerigee;
259 if (genParticle==
nullptr || truePerigee==
nullptr) {
261 ", problem with truth selection logic?");
264 for (
unsigned int trackColIndex = 0; trackColIndex <
m_mc_prob.size(); ++trackColIndex ) {
293 m_mc_prodR = fabs(genParticle->production_vertex()->position().perp());
294 m_mc_prodz = fabs(genParticle->production_vertex()->position().z());
296 for (
unsigned int trackColIndex = 0; trackColIndex < truthData[
index].truthToTrackIndices.size(); ++trackColIndex ) {
298 (*(
m_mc_prob[trackColIndex])) = truthData[
index].truthToTrackMatchingProbabilities[trackColIndex];
307 for (
unsigned int classIndex = 0; classIndex <
m_classifications.size(); ++classIndex ) {
309 if (!truthData[
index].truthToTrackIndices[0].
empty()) {
321 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static const Attributes_t empty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
double eta() const
Access method for pseudorapidity - from momentum.
constexpr int UNDEFINED_ID
const GenParticle * ConstGenParticlePtr
ParametersBase< TrackParametersDim, Charged > TrackParameters