|
| 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 | +#include "Framework/ASoA.h" |
| 19 | +#include "Framework/ASoAHelpers.h" |
| 20 | +#include "Framework/AnalysisDataModel.h" |
| 21 | +#include "Framework/AnalysisTask.h" |
| 22 | +#include "Framework/DataTypes.h" |
| 23 | +#include "Framework/HistogramRegistry.h" |
| 24 | +#include "Framework/Logger.h" |
| 25 | +#include "Framework/RunningWorkflowInfo.h" |
| 26 | +#include "Framework/runDataProcessing.h" |
| 27 | +#include "ReconstructionDataFormats/DCA.h" |
| 28 | +#include "ReconstructionDataFormats/Track.h" |
| 29 | + |
| 30 | +#include <cmath> |
| 31 | +#include <memory> |
| 32 | +#include <random> |
| 33 | +#include <string> |
| 34 | +#include <unordered_set> |
| 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 | + static constexpr int indexAllEvts = 0; |
| 71 | + |
| 72 | + // Loop over reconstructed events |
| 73 | + for (const auto& collision : collisions) { |
| 74 | + |
| 75 | + // Event counter: before event selection |
| 76 | + registryData.fill(HIST("eventCounter"), 0.5); |
| 77 | + |
| 78 | + // Check if event global index is in the list of events to process |
| 79 | + int ev = collision.globalIndex(); |
| 80 | + if (eventSet.count(ev)) { |
| 81 | + |
| 82 | + // Increment event index |
| 83 | + eventIndex++; |
| 84 | + |
| 85 | + // Fill event counter |
| 86 | + registryData.fill(HIST("eventCounter"), 1.5); |
| 87 | + |
| 88 | + // Loop over reconstructed tracks |
| 89 | + for (auto const& track : tracks) { |
| 90 | + registryData.fill(HIST("ptChargedTracks"), indexAllEvts, track.pt()); |
| 91 | + registryData.fill(HIST("ptChargedTracks"), eventIndex, track.pt()); |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + PROCESS_SWITCH(UnitTestForReconstruction, processData, "Process Data", true); |
| 97 | +}; |
| 98 | + |
| 99 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 100 | +{ |
| 101 | + return WorkflowSpec{adaptAnalysisTask<UnitTestForReconstruction>(cfgc)}; |
| 102 | +} |
0 commit comments