CbmRoot
Loading...
Searching...
No Matches
KfpV0FinderChain.cxx
Go to the documentation of this file.
1/* Copyright (C) 2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
11
13#include "CbmYaml.h"
16
17#include <sstream>
18
20
21// ---------------------------------------------------------------------------------------------------------------------
22//
23V0FinderChain::V0FinderChain(const std::unique_ptr<qa::Manager>& qaManager)
24 : fpFinderQa(qaManager != nullptr ? std::make_unique<kfp::V0FinderQa>(qaManager, "V0Finder") : nullptr)
25{
26}
27
28// ---------------------------------------------------------------------------------------------------------------------
29//
31{
32 GetMonitor(); // A hack to update the run monitor
33 L_(info) << fMonitorRun.ToString();
34}
35
36// ---------------------------------------------------------------------------------------------------------------------
37//
39{
41 fMonitorTimeslice.Reset();
42 fMonitorRun.AddMonitorData(monitorData);
43 return monitorData;
44}
45
46// ---------------------------------------------------------------------------------------------------------------------
47//
49try {
50 L_(info) << "kfp::V0FinderChain: initializing the V0-finder chain ...";
51
52 // ----- Read configuration file
53 L_(info) << config.ToString();
54
55 //* Check the V0 type
56 if (config.reconstructPdg != 3122) { // At the moment only Lambda analysis is possible
57 std::stringstream msg;
58 msg << "kfp::V0FinderChain: at the moment only lambda finding is possible. Provided PDG: " << config.reconstructPdg;
59 throw std::runtime_error(msg.str());
60 }
61
62 //* Define daughter particles
63 auto& particles{config.cuts.particles};
64 int iPion{-1};
65 int iProton{-1};
66 for (int iParticle = 0; iParticle < int(particles.size()); ++iParticle) {
67 const auto& particle = particles[iParticle];
68 auto CheckOutParticle = [&](int pdg, int& iParticleToFind) {
69 if (particle.pdg == pdg) {
70 if (iParticleToFind == -1) {
71 iParticleToFind = iParticle;
72 }
73 else {
74 std::stringstream msg;
75 msg << "kfp::V0FinderChain: entry for pdg= " << pdg << " is defined more then one time in the ";
76 msg << "config.cuts.particles";
77 throw std::runtime_error(msg.str());
78 }
79 }
80 };
81 CheckOutParticle(-211, iPion);
82 CheckOutParticle(2212, iProton);
83 }
84 if (iProton == -1 || iPion == -1) {
85 std::stringstream msg;
86 msg << "kfp::V0FinderChain: config cuts/particles: either pion or proton settings are not found";
87 throw std::runtime_error(msg.str());
88 }
89 const auto& pion{particles[iPion]};
90 const auto& proton{particles[iProton]};
91
92 // ----- Define a BMON diamond
93 if (fBmonDefinedAddresses.empty()) {
94 throw std::runtime_error("kfp::V0FinderChain: BMON available addresses were not set");
95 }
96 int iBmonPartitionSelect = -1;
97 for (int iPart = 0; iPart < static_cast<int>(fBmonDefinedAddresses.size()); ++iPart) {
98 if (config.bmonAddress == fBmonDefinedAddresses[iPart]) {
99 iBmonPartitionSelect = iPart;
100 break;
101 }
102 }
103 if (iBmonPartitionSelect < 0) {
104 std::stringstream msg;
105 msg << "kfp::V0FinderChain: a reference BMON address ( " << std::hex << config.bmonAddress << std::dec
106 << " ) differs from ones, provided by hitfinder. Please check your configuration";
107 throw std::runtime_error(msg.str());
108 }
109
110 // ----- Set the V0-finder properties
111 // TODO: In future, there are will be a several instances of the V0Finder, each for a particular thread
112 {
113 //* Set particle PID properties
114 fFinder.SetBmonPartitionIndex(iBmonPartitionSelect);
115 fFinder.SetMinPionDca(pion.minDca);
116 fFinder.SetMinProtonDca(proton.minDca);
117 fFinder.SetPionVelocityRange(pion.minVelocity, pion.maxVelocity);
118 fFinder.SetProtonVelocityRange(proton.minVelocity, proton.maxVelocity);
119
120 //* Set KFParticleFinder properties
121 auto& kfpCuts{config.cuts.kfp};
122 fFinder.SetLdLCut2D(kfpCuts.minDecayLDL);
123 fFinder.SetLCut(kfpCuts.minDecayLength);
124 fFinder.SetChi2Cut2D(kfpCuts.maxChi2NdfGeo);
125 fFinder.SetChiPrimaryCut2D(kfpCuts.maxChi2NdfPrim);
126
127 //* Set other properties
128 fFinder.SetTzeroOffset(config.tZeroOffset);
129 fFinder.SetQpAssignedUncertainty(config.qpAssignedUncertainty);
130 fFinder.AddDecayToReconstructionList(config.reconstructPdg);
131 fFinder.SetPrimaryAssignedPdg(config.primaryAssignedPdg);
132
133 //* Init the V0 finder
134 fFinder.Init();
135 }
136
137 if (fpFinderQa != nullptr) {
138 fpFinderQa->Init();
139 }
140
141 L_(info) << "kfp::V0FinderChain: initializing the V0-finder chain ... done";
142}
143catch (const std::exception& err) {
144 L_(info) << "kfp::V0FinderChain: initializing the V0-finder chain ... failed. Reason: " << err.what();
145 throw std::runtime_error("initialization of V0-finder chain failed");
146}
147
148// ---------------------------------------------------------------------------------------------------------------------
149//
151{
152 EventOutput res = fFinder.Process(recoEvent);
153 if (fpFinderQa != nullptr) {
154 fpFinderQa->Exec(recoEvent, fFinder);
155 }
156 fMonitorTimeslice.AddMonitorData(fFinder.GetEventMonitor());
157 return res;
158}
#define L_(level)
A chain for V0 finding.
Configuration structure for V0 selector in mCBM.
This file contains the definition of the ParFiles class.
V0FinderChain()=default
Default constructor.
A QA-task for the V0-finding algorithm.
A chain for the V0 finder.
CbmEventTriggers EventOutput
EventOutput ProcessEvent(const RecoResults &recoEvent)
Processes an event, returns a collection of fired triggers.
void Init(const kfp::V0FinderConfig &config)
Initializes the instance (called in the beginning of the run)
void Finalize()
Finalizes the instance (called in the end of the run)
PODVector< uint32_t > fBmonDefinedAddresses
Available addresses of BMON.
kfp::V0FinderMonitor fMonitorRun
Monitor per run.
kfp::V0FinderMonitorData_t fMonitorTimeslice
Monitor per timeslice.
kfp::V0Finder fFinder
Instance of the V0-finding algorithm.
kfp::V0FinderMonitorData_t GetMonitor()
Gets a monitor.
std::unique_ptr< kfp::V0FinderQa > fpFinderQa
QA module.
ca::MonitorData< ECounter, ETimer > V0FinderMonitorData_t
Specification of ca::MonitorData for the V0Finder.
Hash for CbmL1LinkKey.
std::vector< ParticlePid > particles
Daughter PID cuts and other properties.
CutsKfp kfp
Specific cuts for the KFParticleFinder.
Cuts cuts
Different selection cuts.
uint32_t bmonAddress
Address of BMON diamond (if multiple alternative are present, only one must be selected)
double tZeroOffset
Offset for T0 [ns].
int primaryAssignedPdg
Assigned PDG hypothesis for primary particles.
std::string ToString() const
String representation of the contents.
int reconstructPdg
PDG of the particle, the decay of which is to be reconstructed.
double qpAssignedUncertainty
Assigned relative uncertainty for q/p estimation.