Skip to content

Commit f45987d

Browse files
committed
[DPG] Added unit test for validating reconstruction software
1 parent b178c96 commit f45987d

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed

DPG/Tasks/AOTTrack/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ o2physics_add_dpl_workflow(qa-tracksplitting
8080
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
8181
COMPONENT_NAME Analysis)
8282

83+
o2physics_add_dpl_workflow(unit-test-for-reconstruction
84+
SOURCES unitTestForReconstruction.cxx
85+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
86+
COMPONENT_NAME Analysis)
87+
8388
o2physics_add_dpl_workflow(tag-and-probe-dmesons
8489
SOURCES tagAndProbeDmesons.cxx
8590
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2::DetectorsVertexing O2Physics::MLCore
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
/// \file unitTestForReconstruction.cxx
13+
///
14+
/// \brief Unit test for validating the reconstruction software
15+
/// \author Alberto Caliva (alberto.caliva@cern.ch), Catalin-Lucian Ristea (catalin.ristea@cern.ch)
16+
/// \since September 9, 2025
17+
18+
19+
#include "Framework/ASoA.h"
20+
#include "Framework/ASoAHelpers.h"
21+
#include "Framework/AnalysisDataModel.h"
22+
#include "Framework/AnalysisTask.h"
23+
#include "Framework/DataTypes.h"
24+
#include "Framework/HistogramRegistry.h"
25+
#include "Framework/Logger.h"
26+
#include "Framework/RunningWorkflowInfo.h"
27+
#include "Framework/runDataProcessing.h"
28+
#include "ReconstructionDataFormats/DCA.h"
29+
#include "ReconstructionDataFormats/Track.h"
30+
31+
#include <cmath>
32+
#include <memory>
33+
#include <random>
34+
#include <string>
35+
#include <vector>
36+
37+
using namespace o2::soa;
38+
using namespace o2::aod;
39+
using namespace o2::framework;
40+
using namespace o2::framework::expressions;
41+
using namespace o2::constants::physics;
42+
using namespace o2::constants::math;
43+
44+
struct UnitTestForReconstruction {
45+
46+
// Histogram registry
47+
HistogramRegistry registryData{"registryData", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
48+
49+
// global IDs of events to be inspected
50+
Configurable<std::vector<int>> eventNr{"eventNr", {1, 5, 12, 44, 76, 99, 102, 115, 180, 220}, "eventNr"};
51+
std::unordered_set<int> eventSet;
52+
53+
void init(InitContext const&)
54+
{
55+
// Define histogram to monitor event counts at different selection stages
56+
registryData.add("eventCounter", "eventCounter", HistType::kTH1F, {{10, 0, 10, ""}});
57+
58+
// Define histogram for the transverse momentum spectrum of reconstructed charged tracks
59+
registryData.add("ptChargedTracks", "ptChargedTracks", HistType::kTH2F, {{11, 0, 11, "event"}, {1000, 0, 10, "#it{p}_{T} (GeV/#it{c})"}});
60+
61+
// Fast lookup set from configurable event list
62+
eventSet = std::unordered_set<int>(eventNr->begin(), eventNr->end());
63+
}
64+
65+
// Process Data
66+
void processData(o2::aod::Collisions const& collisions, o2::aod::Tracks const& tracks)
67+
{
68+
// Event index
69+
int eventIndex = 0;
70+
71+
// Loop over reconstructed events
72+
for (const auto& collision : collisions) {
73+
74+
// Event counter: before event selection
75+
registryData.fill(HIST("eventCounter"), 0.5);
76+
77+
// Check if event global index is in the list of events to process
78+
int ev = collision.globalIndex();
79+
if (eventSet.count(ev)) {
80+
81+
// Increment event index
82+
eventIndex++;
83+
84+
// Fill event counter
85+
registryData.fill(HIST("eventCounter"), 1.5);
86+
87+
// Loop over reconstructed tracks
88+
for (auto const& track : tracks) {
89+
registryData.fill(HIST("ptChargedTracks"), 0, track.pt());
90+
registryData.fill(HIST("ptChargedTracks"), eventIndex, track.pt());
91+
}
92+
}
93+
}
94+
}
95+
PROCESS_SWITCH(UnitTestForReconstruction, processData, "Process Data", true);
96+
};
97+
98+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
99+
{
100+
return WorkflowSpec{adaptAnalysisTask<UnitTestForReconstruction>(cfgc)};
101+
}

0 commit comments

Comments
 (0)