Skip to content

Commit

Permalink
minor improvements (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
pillot committed May 29, 2023
1 parent c4c72d1 commit 9162e21
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 143 deletions.
7 changes: 3 additions & 4 deletions Detectors/MUON/MCH/Evaluation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ This package offers a few helpers to assess (some) performance of MCH.

The class [ExtendedTrack](include/MCHEvaluation/ExtendedTrack.h) converts a standalone MCH track (found in `mchtracks.root` files) into a track extrapolated to a vertex (that must be provided). It's a convenient object that also packs the clusters associated to the track (contrary to what's found in the `mchtracks.root` where tracks and clusters are in two different containers).

The `o2-mch-compare-tracks-workflow` can be used to produce many histograms (output is a root file and optionally a pdf file) comparing tracks from two different `mchtracks.root` files.
The `o2-mch-compare-tracks-workflow` can be used to produce many histograms (output is a root file and optionally a pdf file) comparing tracks from two different `mchtracks.root` files.

For instance to compare tracks coming from reconstructions using the two different clustering we have :
For instance to compare tracks coming from reconstructions using the two different clustering we have :

```shell
$ o2-mch-tracks-reader-workflow --hbfutils-config o2_tfidinfo.root --infile mchtracks.legacy.root | o2-mch-tracks-reader-workflow --hbfutils-config o2_tfidinfo.root --infile mchtracks.gem.root --subspec 1 | o2-mch-compare-tracks-worfklow -pdf-outfile compare.pdf -b
$ o2-mch-tracks-reader-workflow --hbfutils-config o2_tfidinfo.root --infile mchtracks.legacy.root | o2-mch-tracks-reader-workflow --hbfutils-config o2_tfidinfo.root --infile mchtracks.gem.root --subspec 1 | o2-mch-compare-tracks-worfklow --pdf-outfile compare.pdf -b
$ root
root[0] o2::mch::eval::drawAll("compare.root")
```

6 changes: 3 additions & 3 deletions Detectors/MUON/MCH/Evaluation/include/MCHEvaluation/Draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ TCanvas* autoCanvas(const char* title, const char* name,
int* nPadsx = nullptr,
int* nPadsy = nullptr);

void drawResidualsAtFirstCluster(std::vector<TH1*>& histos, TCanvas* c = nullptr);
void drawResiduals(const std::array<std::vector<TH1*>, 5>& histos, TCanvas* c = nullptr);
void drawTrackResiduals(std::vector<TH1*>& histos, TCanvas* c = nullptr);
void drawClusterResiduals(const std::array<std::vector<TH1*>, 5>& histos, TCanvas* c = nullptr);
void drawClusterClusterResiduals(const std::vector<TH1*>& histos, const char* extension, TCanvas* c = nullptr);
void drawClusterTrackResiduals(const std::vector<TH1*>& histos1, const std::vector<TH1*>& histos2, const char* extension, TCanvas* c = nullptr);
void drawClusterTrackResidualsSigma(const std::vector<TH1*>& histos1, const std::vector<TH1*>& histos2, const char* extension, TCanvas* c = nullptr);
void drawRatioResiduals(const std::vector<TH1*>& histos1, const std::vector<TH1*>& histos2, const char* extension, TCanvas* c = nullptr);
void drawClusterTrackResidualsRatio(const std::vector<TH1*>& histos1, const std::vector<TH1*>& histos2, const char* extension, TCanvas* c = nullptr);

void drawHistosAtVertex(const std::array<std::vector<TH1*>, 2>& histos, TCanvas* c = nullptr);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ExtendedTrack
/** create an ExtendedTrack from a TrackMCH and its clusters.
*
* The given TrackMCH will be extrapolated to the given vertex {x,y,z}.
* Throw an exception if the track fitting fails
*/
ExtendedTrack(const TrackMCH& track,
gsl::span<const Cluster>& clusters,
Expand All @@ -62,7 +63,7 @@ class ExtendedTrack

double getDCA() const { return mDCA; }
double getRabs() const { return mRabs; }
short getCharge() const { return mSign; }
double getCharge() const { return param().getCharge(); }

const ROOT::Math::PxPyPzMVector& P() const { return mMomentum4D; }

Expand All @@ -77,7 +78,6 @@ class ExtendedTrack
ROOT::Math::PxPyPzMVector mMomentum4D{};
bool mHasMatchFound;
bool mHasMatchIdentical;
short mSign{0};
double mDCA{0.};
double mRabs{0.};
static constexpr double sChi2Max{2. * 4. * 4.};
Expand Down
44 changes: 22 additions & 22 deletions Detectors/MUON/MCH/Evaluation/src/CompareTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,35 @@ void CompareTask::pdfOutput()
toPdf5(drawComparisonsAtVertex);

c->Clear();
drawResidualsAtFirstCluster(mResidualsAtFirstCluster, c);
drawTrackResiduals(mTrackResidualsAtFirstCluster, c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawClusterClusterResiduals(mResiduals[4], "ClCl", c);
drawClusterClusterResiduals(mClusterResiduals[4], "ClCl", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawClusterTrackResiduals(mResiduals[0], mResiduals[1], "All", c);
drawClusterTrackResiduals(mClusterResiduals[0], mClusterResiduals[1], "AllTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawClusterTrackResidualsSigma(mResiduals[0], mResiduals[1], "All", c);
drawClusterTrackResidualsSigma(mClusterResiduals[0], mClusterResiduals[1], "AllTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawClusterTrackResiduals(mResiduals[2], mResiduals[3], "Matched", c);
drawClusterTrackResiduals(mClusterResiduals[2], mClusterResiduals[3], "SimilarTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawClusterTrackResidualsSigma(mResiduals[2], mResiduals[3], "Matched", c);
drawClusterTrackResidualsSigma(mClusterResiduals[2], mClusterResiduals[3], "SimilarTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawRatioResiduals(mResiduals[0], mResiduals[1], "All", c);
drawClusterTrackResidualsRatio(mClusterResiduals[0], mClusterResiduals[1], "AllTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
drawRatioResiduals(mResiduals[2], mResiduals[3], "Matched", c);
drawClusterTrackResidualsRatio(mClusterResiduals[2], mClusterResiduals[3], "SimilarTracks", c);
c->Print(mOutputPdfFileName.c_str());

c->Clear();
Expand All @@ -126,12 +126,12 @@ void CompareTask::init(InitContext& ic)
createHistosAtVertex(mComparisonsAtVertex[2], "similar2");
createHistosAtVertex(mComparisonsAtVertex[3], "additional");
createHistosAtVertex(mComparisonsAtVertex[4], "missing");
createHistosResiduals(mResiduals[0], "All1", 2.);
createHistosResiduals(mResiduals[1], "All2", 2.);
createHistosResiduals(mResiduals[2], "Matched1", 2.);
createHistosResiduals(mResiduals[3], "Matched2", 2.);
createHistosResiduals(mResiduals[4], "ClCl", 0.2);
createHistosResidualsAtFirstCluster(mResidualsAtFirstCluster);
createHistosForClusterResiduals(mClusterResiduals[0], "AllTracks1", 2.);
createHistosForClusterResiduals(mClusterResiduals[1], "AllTracks2", 2.);
createHistosForClusterResiduals(mClusterResiduals[2], "SimilarTracks1", 2.);
createHistosForClusterResiduals(mClusterResiduals[3], "SimilarTracks2", 2.);
createHistosForClusterResiduals(mClusterResiduals[4], "ClCl", 0.2);
createHistosForTrackResiduals(mTrackResidualsAtFirstCluster);

mNofDifferences = 0;

Expand All @@ -143,8 +143,8 @@ void CompareTask::init(InitContext& ic)
mOutputRootFile->cd();
mOutputRootFile->WriteObject(&mHistosAtVertex, "histosAtVertex");
mOutputRootFile->WriteObject(&mComparisonsAtVertex, "comparisonsAtVertex");
mOutputRootFile->WriteObject(&mResidualsAtFirstCluster, "residualsAtFirstCluster");
mOutputRootFile->WriteObject(&mResiduals, "residuals");
mOutputRootFile->WriteObject(&mTrackResidualsAtFirstCluster, "trackResidualsAtFirstCluster");
mOutputRootFile->WriteObject(&mClusterResiduals, "clusterResiduals");
mOutputRootFile->Close();
};
ic.services().get<CallbackService>().set<CallbackService::Id::Stop>(stop);
Expand Down Expand Up @@ -224,16 +224,16 @@ void CompareTask::run(ProcessingContext& pc)
fillHistosAtVertex(tracks1, mHistosAtVertex[0]);
fillHistosAtVertex(tracks2, mHistosAtVertex[1]);

fillResiduals(tracks1, mResiduals[0], false);
fillResiduals(tracks2, mResiduals[1], false);
fillClusterTrackResiduals(tracks1, mClusterResiduals[0], false);
fillClusterTrackResiduals(tracks2, mClusterResiduals[1], false);

int nDiff = compareEvents(tracks1, tracks2,
mPrecision,
mPrintAll,
mResidualsAtFirstCluster,
mResiduals);
fillResiduals(tracks1, mResiduals[2], true);
fillResiduals(tracks2, mResiduals[3], true);
mTrackResidualsAtFirstCluster,
mClusterResiduals[4]);
fillClusterTrackResiduals(tracks1, mClusterResiduals[2], true);
fillClusterTrackResiduals(tracks2, mClusterResiduals[3], true);
if (nDiff > 0) {
LOG(warning) << "--> " << nDiff << " differences found in ROF " << rofs1[i];
mNofDifferences += nDiff;
Expand Down
4 changes: 2 additions & 2 deletions Detectors/MUON/MCH/Evaluation/src/CompareTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class CompareTask
std::unique_ptr<TFile> mOutputRootFile;
std::string mOutputPdfFileName;
std::array<std::vector<TH1*>, 2> mHistosAtVertex;
std::vector<TH1*> mResidualsAtFirstCluster{};
std::vector<TH1*> mTrackResidualsAtFirstCluster{};
std::array<std::vector<TH1*>, 5> mComparisonsAtVertex;
std::array<std::vector<TH1*>, 5> mResiduals;
std::array<std::vector<TH1*>, 5> mClusterResiduals;
bool mApplyTrackSelection;
double mPrecision;
bool mPrintAll;
Expand Down
40 changes: 7 additions & 33 deletions Detectors/MUON/MCH/Evaluation/src/CompareTracks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
//_________________________________________________________________________________________________

#include "CompareTracks.h"
#include "Histos.h"
#include <TH1F.h>
Expand All @@ -31,7 +31,6 @@ void printResiduals(const TrackParam& param1, const TrackParam& param2)
<< "}" << std::endl;
}

//_________________________________________________________________________________________________
void printCovResiduals(const TMatrixD& cov1, const TMatrixD& cov2)
{
/// print cov2 - cov1
Expand All @@ -43,8 +42,8 @@ int compareEvents(std::list<ExtendedTrack>& tracks1,
std::list<ExtendedTrack>& tracks2,
double precision,
bool printAll,
std::vector<TH1*>& residualsAtFirstCluster,
std::array<std::vector<TH1*>, 5>& residuals)
std::vector<TH1*>& trackResidualsAtFirstCluster,
std::vector<TH1*>& clusterClusterResiduals)
{
/// compare the tracks between the 2 events

Expand All @@ -62,7 +61,7 @@ int compareEvents(std::list<ExtendedTrack>& tracks1,
itTrack2->setMatchFound(true);
track1.setMatchIdentical(true);
itTrack2->setMatchIdentical(true);
fillResiduals(track1, *itTrack2, residuals[4]);
fillClusterClusterResiduals(track1, *itTrack2, clusterClusterResiduals);
// compare the track parameters
bool areParamCompatible = areCompatible(track1.param(), itTrack2->param(), precision);
bool areCovCompatible = areCompatible(track1.param().getCovariances(), itTrack2->param().getCovariances(), precision);
Expand All @@ -75,17 +74,7 @@ int compareEvents(std::list<ExtendedTrack>& tracks1,
if (printAll || !areCovCompatible) {
printCovResiduals(track1.param().getCovariances(), itTrack2->param().getCovariances());
}
fillResiduals(track1.param(), itTrack2->param(), residualsAtFirstCluster);
// FIXME : use params at MID or not ?
// // compare the track parameters at MID (if any)
// if (track1.paramAtMID.z < 0. && itTrack2->paramAtMID.z < 0.) {
// if (!areTrackParamCompatible(track1.paramAtMID, itTrack2->paramAtMID, precision)) {
// printResiduals(track1.paramAtMID, itTrack2->paramAtMID);
// }
// if (!areTrackParamCovCompatible(track1.covAtMID, itTrack2->covAtMID, precision)) {
// printCovResiduals(track1.covAtMID, itTrack2->covAtMID);
// }
// }
fillTrackResiduals(track1.param(), itTrack2->param(), trackResidualsAtFirstCluster);
}
}

Expand All @@ -100,12 +89,7 @@ int compareEvents(std::list<ExtendedTrack>& tracks1,
if (!track2.hasMatchFound() && track2.isMatching(track1)) {
track1.setMatchFound(true);
track2.setMatchFound(true);
// if (track2.getNClustersInCommon(track1) == track2.clusters.size()) {
// track1.matchIdentical = true;
// track2.matchIdentical = true;
// } else {
// track1.printClusterDifferences(track2);
// }
fillClusterClusterResiduals(track1, track2, clusterClusterResiduals);
// compare the track parameters
bool areParamCompatible = areCompatible(track1.param(), track2.param(), precision);
bool areCovCompatible = areCompatible(track1.param().getCovariances(), track2.param().getCovariances(), precision);
Expand All @@ -118,17 +102,7 @@ int compareEvents(std::list<ExtendedTrack>& tracks1,
if (printAll || !areCovCompatible) {
printCovResiduals(track1.param().getCovariances(), track2.param().getCovariances());
}
fillResiduals(track1.param(), track2.param(), residualsAtFirstCluster);
// FIXME : use params at MID or not ?
// // compare the track parameters at MID (if any)
// if (track1.paramAtMID.z < 0. && track2.paramAtMID.z < 0.) {
// if (!areTrackParamCompatible(track1.paramAtMID, track2.paramAtMID, precision)) {
// printResiduals(track1.paramAtMID, track2.paramAtMID);
// }
// if (!areTrackParamCovCompatible(track1.covAtMID, track2.covAtMID, precision)) {
// printCovResiduals(track1.covAtMID, track2.covAtMID);
// }
// }
fillTrackResiduals(track1.param(), track2.param(), trackResidualsAtFirstCluster);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Detectors/MUON/MCH/Evaluation/src/CompareTracks.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace o2::mch::eval
{
int compareEvents(std::list<ExtendedTrack>& tracks1, std::list<ExtendedTrack>& tracks2,
double precision, bool printAll,
std::vector<TH1*>& paramHistos,
std::array<std::vector<TH1*>, 5>& residualHistos);
std::vector<TH1*>& trackResidualsAtFirstCluster,
std::vector<TH1*>& clusterClusterResiduals);

bool areCompatible(const TrackParam& param1, const TrackParam& param2, double precision);

Expand Down
Loading

0 comments on commit 9162e21

Please sign in to comment.