CbmRoot
Loading...
Searching...
No Matches
CbmL1.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2025 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ivan Kisel, Sergey Gorbunov [committer], Valentina Akishina, Igor Kulakov, Maksym Zyzak, Sergei Zharko */
4
5/*
6 *====================================================================
7 *
8 * CBM Level 1 Reconstruction
9 *
10 * Authors: I.Kisel, S.Gorbunov
11 *
12 * e-mail : ikisel@kip.uni-heidelberg.de
13 *
14 *====================================================================
15 *
16 * L1 main program
17 *
18 *====================================================================
19 */
20
21#include "CbmL1.h"
22
23#include "CaMcHitInfo.h"
24#include "CbmKfTarget.h"
25#include "CbmMCDataManager.h"
26#include "CbmSetup.h"
27#include "KfDefs.h"
28
29#include <boost/filesystem.hpp>
30// TODO: include of CbmSetup.h creates problems on Mac
31// #include "CbmSetup.h"
32#include "CaFramework.h"
33#include "CaHit.h"
34#include "CaToolsDebugger.h"
35#include "CbmEvent.h"
37#include "CbmMCDataObject.h"
38#include "CbmStsFindTracks.h"
39#include "CbmStsHit.h"
40#include "FairField.h"
41#include "FairRunAna.h"
42#include "KfRootUtils.h"
43#include "KfToolsField.h"
44#include "TGeoArb8.h"
45#include "TGeoBoolNode.h"
46#include "TGeoCompositeShape.h"
47#include "TGeoManager.h"
48#include "TGeoNode.h"
49#include "TMatrixD.h"
50#include "TNtuple.h"
51#include "TProfile2D.h"
52#include "TROOT.h"
53#include "TRandom3.h"
54#include "TSystem.h"
55#include "TVector3.h"
56#include "TVectorD.h"
57
58#include <TFile.h>
59
60#include <chrono>
61#include <fstream>
62#include <iomanip>
63#include <list>
64#include <sstream>
65
66using namespace cbm::algo; // TODO: remove this line
67
74
75
77
78static ca::Framework gAlgo _fvecalignment; // TODO: Change coupling logic between ca::Framework and CbmL1
79
80CbmL1* CbmL1::fpInstance = nullptr;
81
82
83// ---------------------------------------------------------------------------------------------------------------------
84//
85CbmL1::CbmL1() : CbmL1("L1") {}
86
87// ---------------------------------------------------------------------------------------------------------------------
88//
89CbmL1::CbmL1(const char* name, Int_t verbose, Int_t performance) : FairTask(name, verbose), fPerformance(performance)
90{
91 if (!fpInstance) fpInstance = this;
92
93 switch (fSTAPDataMode) {
94 case 1: LOG(info) << "CbmL1: input data will be written for a standalone usage"; break;
95 case 2: LOG(info) << "CbmL1: input data will be read from external files"; break;
96 default: LOG(info) << "CbmL1: tracking will be run without external data R/W"; break;
97 }
98
99 fpIODataManager = std::make_shared<ca::DataManager>();
100}
101
102// ---------------------------------------------------------------------------------------------------------------------
103//
105{
106 if (fpInstance == this) fpInstance = nullptr;
107}
108
109// ---------------------------------------------------------------------------------------------------------------------
110//
112{
113 if (ca::EDetectorID::END != detID) {
114 fvmDisabledStationIDs[detID].insert(iSt);
115 }
116}
117
118// ---------------------------------------------------------------------------------------------------------------------
119//
120InitStatus CbmL1::ReInit()
121{
122 SetParContainers();
123 return Init();
124}
125
126// ---------------------------------------------------------------------------------------------------------------------
127//
128InitStatus CbmL1::Init()
129try {
130 this->DefineSTAPNames();
131
132 if (fVerbose > 1) {
133 char y[20] = " [0;33;44m"; // yellow
134 char Y[20] = " [1;33;44m"; // yellow bold
135 char W[20] = " [1;37;44m"; // white bold
136 char o[20] = " [0m\n"; // color off
137 Y[0] = y[0] = W[0] = o[0] = 0x1B; // escape character
138 std::stringstream ss;
139
140 ss << "\n\n";
141 ss << " " << W << " " << o;
142 ss << " " << W << " ===////====================================================== " << o;
143 ss << " " << W << " = = " << o;
144 ss << " " << W << " = " << Y << "L1 on-line finder" << W << " = " << o;
145 ss << " " << W << " = = " << o;
146 ss << " " << W << " = " << W << "Cellular Automaton 3.1 Vector" << y << " with " << W << "KF Quadro" << y
147 << " technology" << W << " = " << o;
148 ss << " " << W << " = = " << o;
149 ss << " " << W << " = " << y << "Designed for CBM collaboration" << W << " = " << o;
150 ss << " " << W << " = " << y << "All rights reserved" << W << " = " << o;
151 ss << " " << W << " = = " << o;
152 ss << " " << W << " ========================================================////= " << o;
153 ss << " " << W << " " << o;
154 ss << "\n\n";
155
156 LOG(info) << ss.str();
157 }
158
160
161 fHistoDir = gROOT->mkdir("L1");
162 fHistoDir->mkdir("Input");
163 fHistoDir->mkdir("Fit");
164
165 fTableDir = gROOT->mkdir("L1Tables");
166
167 // turn on reconstruction in sub-detectors
168
169
170 // Create parameters shared pointer in double precision
171 // NOTE: for now with interpolated magnetic field, but later it can be changed with a setter
172 std::shared_ptr<const ca::Parameters<double>> pParameters{nullptr};
173 if (2 == fSTAPDataMode) { // Read parameters object from a binary file
174 TString filename = fSTAPDataDir + "/" + fSTAPDataPrefix + "." + TString(kSTAPParamSuffix.data());
175 pParameters =
176 std::make_shared<const ca::Parameters<double>>(std::move(ca::ParametersIO::Load<double>(filename.Data())));
177 }
178 else { // Create fresh parameters
179 auto parBuilder = cbm::ca::ParametersBuilder{};
180 parBuilder.SetRequireHitPresence(true);
181 std::string mainConfig = std::string(gSystem->Getenv("VMCWORKDIR")) + "/macro/L1/configs/";
182 switch (fTrackingMode) {
183 case ca::TrackingMode::kSts: mainConfig += "ca_params_sts.yaml"; break;
184 case ca::TrackingMode::kMcbm: mainConfig += "ca_params_mcbm.yaml"; break;
185 case ca::TrackingMode::kGlobal: mainConfig += "ca_params_global.yaml"; break;
186 }
187 parBuilder.SetMainConfig(mainConfig);
188 parBuilder.SetUserConfig(fsUserConfig);
189
190 // Disable stations, if it is required by the framework
191 for (auto detId : cbm::ca::kDetIds) {
192 const auto& locIds = fvmDisabledStationIDs[detId];
193 for (int locId : locIds) {
194 parBuilder.DisableStation(detId, locId);
195 }
196 }
197
198 // Explicitly disable MVD, if it is not required from the STSFindTracks task
199 if (auto* pTrackFinderTask = dynamic_cast<CbmStsFindTracks*>(FairRunAna::Instance()->GetTask("STSFindTracks"))) {
200 if (!pTrackFinderTask->MvdUsage()) {
201 parBuilder.DisableStation(EDetectorID::kMvd, -1);
202 }
203 }
204
205 // Build parameters
206 pParameters = std::make_shared<const ca::Parameters<double>>(
207 std::move(parBuilder.Build(FloatTag<double>{}, EFieldMode::Interpolated)));
208
209 // Write parameters object to file if needed
210 if (1 == fSTAPDataMode || 4 == fSTAPDataMode) {
211 TString filename =
212 fSTAPParamFile.IsNull()
213 ? fSTAPDataDir + "/" + fSTAPDataPrefix + "." + TString(kSTAPParamSuffix.data())
215 cbm::algo::ca::ParametersIO::Store(*pParameters, filename.Data());
216 }
217 }
218
220 LOG(info) << '\n' << pParameters->ToString(1);
221 return kSUCCESS;
222 }
223
224
225 // Init L1 algo core
226
227 // FIXME: SZh 22.08.2023:
228 // Re-organize the the relation between CbmL1 and ca::Framework. I believe, we don't need a global pointer to the ca::Framework
229 // instance.
230 fpAlgo = &gAlgo;
231
232 //
233 // ** Send formed parameters object to ca::Framework instance **
234 //
235 fpAlgo->ReceiveParameters(std::move(ca::Parameters<fvec>(*pParameters)));
236 fpAlgo->Init(fTrackingMode);
237
238 cbm::ca::DetIdArr_t<bool> bUsed = {}; // Is detId used
239 const auto& rSetup = pParameters->GetSetup();
240 for (auto detId : cbm::ca::kDetIds) {
241 bUsed[detId] = rSetup.GetNofActStations(detId) > 0;
242 }
243
244 // Initialize time-slice reader
245 fpTSReader = std::make_unique<TimeSliceReader>();
246 for (auto detId : cbm::ca::kDetIds) {
247 fpTSReader->SetDetector(detId, bUsed[detId]);
248 }
249 fpTSReader->RegisterParameters(pParameters);
250 fpTSReader->RegisterHitIndexContainer(fvExternalHits);
251 fpTSReader->RegisterIODataManager(fpIODataManager);
252 fpTSReader->RegisterQaHitContainer(fvHitDebugInfo);
253 if (!fpTSReader->InitRun()) {
254 return kFATAL;
255 }
256
257 if (fPerformance) {
258 fpMCModule = std::make_unique<MCModule>(fVerbose, fPerformance);
259 for (auto detId : cbm::ca::kDetIds) {
260 fpMCModule->SetDetector(detId, bUsed[detId]);
261 }
262
263 fpMCModule->RegisterMcData(fMCData);
264 fpMCModule->RegisterRecoTrackContainer(fvRecoTracks);
265 fpMCModule->RegisterHitIndexContainer(fvExternalHits);
266 fpMCModule->RegisterParameters(pParameters);
267 fpMCModule->RegisterQaHitContainer(fvHitDebugInfo);
268 fpMCModule->RegisterFirstHitIndexes(fpTSReader->GetHitFirstIndexDet());
269 if (!fpMCModule->InitRun()) {
270 return kFATAL;
271 }
272 }
273
274 LOG(info) << pParameters->ToString(1);
275 LOG(info) << "----- Numbers of stations active in tracking -----";
276 LOG(info) << " MVD: " << pParameters->GetNstationsActive(ca::EDetectorID::kMvd);
277 LOG(info) << " STS: " << pParameters->GetNstationsActive(ca::EDetectorID::kSts);
278 LOG(info) << " MuCh: " << pParameters->GetNstationsActive(ca::EDetectorID::kMuch);
279 LOG(info) << " TRD: " << pParameters->GetNstationsActive(ca::EDetectorID::kTrd);
280 LOG(info) << " TOF: " << pParameters->GetNstationsActive(ca::EDetectorID::kTof);
281 LOG(info) << " Total: " << pParameters->GetNstationsActive();
282
283 fNStations = pParameters->GetNstationsActive();
284
285 // TODO: Probably move from CbmL1 to a more proper place (e.g. kf::Setup)
286 {
287 //std::stringstream msg;
288 //msg << " ----- Material budget map monitoring: active setup -----\n";
289 const auto& activeSetup = pParameters->GetActiveSetup();
290 for (int iSt = 0; iSt < activeSetup.GetNofLayers(); ++iSt) {
291 fMaterialMonitor.emplace_back(&(activeSetup.GetMaterial(iSt)), Form("Station %d", iSt));
292 //msg << monitor.ToString() << '\n';
293 }
294 //msg << " --------------------------------------------------------";
295 //LOG(info) << '\n' << msg.str();
296 }
297
298 DumpMaterialToFile("L1material.root", pParameters);
299
300 // Initialize monitor
301 fMonitor.Reset();
302
303 return kSUCCESS;
304}
305catch (const std::exception& err) {
306 LOG(error) << "CbmL1: initialization failed. Reason: " << err.what();
307 return kFATAL;
308}
309
310// ---------------------------------------------------------------------------------------------------------------------
311//
313{
314 ca::TrackingMonitorData monitorData;
315 LOG(warning) << "CbmL1::Reconstruct called";
316 fpTSReader->ReadEvent(event);
317 if (fPerformance) {
318 fpMCModule->InitEvent(event); // reads points and MC tracks
319 fpMCModule->MatchHits(); // matches points with hits
320 fpMCModule->InitMcTrackInfo();
321 fpAlgo->SetMcData(fpMCModule->GetMcData());
322 }
323
324 fpAlgo->ReceiveInputData(fpIODataManager->TakeInputData());
325 LOG(warning) << "CbmL1::Reconstruct: after ReceiveInputData";
326 //LOG(warning) << "CbmL1::Reconstruct: input data received, hits = " << fpAlgo->GetInputData().GetNofHits();
327 // Material monitoring: mark active areas
328 {
329 for (const auto& hit : fpAlgo->GetInputData().GetHits()) {
330 fMaterialMonitor[hit.Station()].MarkActiveBin(hit.X(), hit.Y());
331 }
332 }
333 //LOG(info) << "CHECK: hit ids = " << fvExternalHits.size() << ", hits = " << fpIODataManager->GetNofHits()
334 //<< ", dbg hits = " << fvHitDebugInfo.size();
335
336 fpAlgo->SetMonitorData(monitorData);
337
338 if (nullptr != event) {
339 LOG_IF(debug, fVerbose > 0) << "\n======= Ca Track finder: processing event " << event->GetNumber() << " ...";
340 }
341 else {
342 LOG_IF(debug, fVerbose > 0) << "\n======= Ca Track finder: processing timeslice ...";
343 }
344 LOG(warning) << "CbmL1::Reconstruct: before FindTracks";
345 fpAlgo->FindTracks();
346 LOG(warning) << "CbmL1::Reconstruct: after FindTracks";
347 // IdealTrackFinder();
348 fTrackingTime = fpAlgo->fCaRecoTime; // TODO: remove (not used)
349
350 LOG_IF(debug, fVerbose > 0) << "Ca Track Finder finished, found " << fpAlgo->fRecoTracks.size() << " tracks";
351
352 // Update monitor data after the actual tracking
353 monitorData = fpAlgo->GetMonitorData();
354
355 // save reconstructed tracks
356
357 fvRecoTracks.clear();
358 fvRecoTracks.reserve(fpAlgo->fRecoTracks.size());
359
360 int trackFirstHit = 0;
361
362 // FIXME: Rewrite
363 for (const auto& caTrk : fpAlgo->fRecoTracks) {
364 CbmL1Track t;
365 t.Set(caTrk.fParFirst);
366 t.TLast.Set(caTrk.fParLast);
367 t.Tpv.Set(caTrk.fParPV);
368 t.Hits.clear();
369
370 for (int i = 0; i < caTrk.fNofHits; i++) {
371 int caHitId = fpAlgo->fRecoHits[trackFirstHit + i];
372 int cbmHitID = fpAlgo->GetInputData().GetHit(caHitId).Id();
373 t.Hits.push_back(cbmHitID);
374 }
375 fvRecoTracks.push_back(t);
376 trackFirstHit += caTrk.fNofHits;
377 //fMonitor.IncrementCounter(EMonitorKey::kRecoHit, it->fNofHits);
378 }
379
380 //fMonitor.IncrementCounter(EMonitorKey::kRecoTrack, fvRecoTracks.size());
381 LOG(warning) << "CA Track Finder: " << fpAlgo->fCaRecoTime << " s/sub-ts";
382
383 // output performance
384 if (fPerformance) {
385 LOG_IF(info, fVerbose) << "Performance...";
386
387 fpMCModule->MatchTracks(); // matches reco and MC tracks, fills the MC-truth fields of reco tracks
388
389 //
390 // tracker input performance is moved to external QA tasks.
391 // InputPerformance() method is not optimised to run with the event builder
392 // TODO: verify QA tasks and remove InputPerformance()
393 // InputPerformance();
394 //
395
396
400 if (fsMcTripletsOutputFilename.size()) {
402 }
403 // TimeHist();
405 LOG_IF(info, fVerbose > 1) << "Tracking performance... done";
406 }
407 LOG(warning) << "End of CA";
408
409 ++fEventNo;
410 fMonitor.AddMonitorData(monitorData);
411}
412
413// ----- Finish CbmStsFitPerformanceTask task -----------------------------
415{
416 if (fPerformance) {
417 // FieldApproxCheck();
418 // FieldIntegralCheck();
420 }
421
422 {
423 // monitor the material
424 std::stringstream msg;
425 msg << '\n';
426 msg << "\033[31;1m ***************************\033[0m\n";
427 msg << "\033[31;1m ** CA Tracking monitor **\033[0m\n";
428 msg << "\033[31;1m ***************************\033[0m\n";
429
430 // TODO: Probably move from CbmL1 to a more proper place (e.g. kf::Setup)
431 {
432 msg << '\n';
433 msg << " ----- Material budget map monitoring: active setup -----\n";
434 for (auto& monitor : fMaterialMonitor) {
435 msg << monitor.ToString() << '\n';
436 }
437 msg << " --------------------------------------------------------\n";
438 }
439
440 // monitor of the reconstructed tracks
441 msg << '\n' << fMonitor.ToString();
442 LOG(info) << msg.str();
443 }
444
445 TDirectory* curr = gDirectory;
446 TFile* currentFile = gFile;
447
448
449 // Open output file and write histograms
450 boost::filesystem::path p = (FairRunAna::Instance()->GetUserOutputFileName()).Data();
451 std::string dir = p.parent_path().string();
452 if (dir.empty()) dir = ".";
453 {
454 std::string histoOutName = dir + "/L1_histo_" + p.filename().string();
455 LOG(info) << "\033[31;1mL1 performance histograms will be saved to: \033[0m" << histoOutName;
456 TFile* outfile = new TFile(histoOutName.c_str(), "RECREATE");
457 outfile->cd();
459 outfile->Close();
460 outfile->Delete();
461 }
462 {
463 std::string tablesOutName = dir + "/L1_perftable_" + p.filename().string();
464 LOG(info) << "\033[31;1mL1 performance tables will be saved to: \033[0m" << tablesOutName;
465 TFile* outfile = new TFile(tablesOutName.c_str(), "RECREATE");
466 outfile->cd();
468 outfile->Close();
469 outfile->Delete();
470 }
471
474 fpMcTripletsTree->Write();
475 fpMcTripletsOutFile->Close();
476 fpMcTripletsOutFile->Delete();
477 }
478
479 gFile = currentFile;
480 gDirectory = curr;
481 fpAlgo->Finish();
483}
484
485
486// ---------------------------------------------------------------------------------------------------------------------
487//
488void CbmL1::writedir2current(TObject* obj)
489{
490 if (!obj->IsFolder())
491 obj->Write();
492 else {
493 TDirectory* cur = gDirectory;
494 TDirectory* sub = cur->mkdir(obj->GetName());
495 sub->cd();
496 TList* listSub = (dynamic_cast<TDirectory*>(obj))->GetList();
497 TIter it(listSub);
498 while (TObject* obj1 = it())
499 writedir2current(obj1);
500 cur->cd();
501 }
502}
503
504// ---------------------------------------------------------------------------------------------------------------------
505//
507{
508 fpAlgo->fRecoTracks.clear();
509 fpAlgo->fRecoHits.clear();
510
511 for (auto& MC : fMCData.GetTrackContainer()) {
512 if (!MC.IsReconstructable()) continue;
513 if (!(MC.GetId() >= 0)) continue;
514
515 if (MC.GetNofHits() < 4) continue;
516
517 CaTrack algoTr;
518 algoTr.fNofHits = 0;
519
520 ca::Vector<int> hitIndices("CbmL1::hitIndices", fpAlgo->GetParameters().GetNstationsActive(), -1);
521
522 for (unsigned int iH : MC.GetHitIndexes()) {
524 const int iStation = hit.GetStationId();
525 if (iStation >= 0) hitIndices[iStation] = iH;
526 }
527
528
529 for (int iH = 0; iH < fpAlgo->GetParameters().GetNstationsActive(); iH++) {
530 const int hitI = hitIndices[iH];
531 if (hitI < 0) continue;
532
533 // fpAlgo->fRecoHits.push_back(hitI);
534 algoTr.fNofHits++;
535 }
536
537
538 if (algoTr.fNofHits < 3) continue;
539
540 for (int iH = 0; iH < fpAlgo->GetParameters().GetNstationsActive(); iH++) {
541 const int hitI = hitIndices[iH];
542 if (hitI < 0) continue;
543 fpAlgo->fRecoHits.push_back(hitI);
544 }
545
546 algoTr.fParFirst.X() = MC.GetStartX();
547 algoTr.fParFirst.Y() = MC.GetStartY();
548 algoTr.fParFirst.Z() = MC.GetStartZ();
549 algoTr.fParFirst.Tx() = MC.GetTx();
550 algoTr.fParFirst.Ty() = MC.GetTy();
551 algoTr.fParFirst.Qp() = MC.GetCharge() / MC.GetP();
552 algoTr.fParFirst.Time() = MC.GetStartT();
553 fpAlgo->fRecoTracks.push_back(algoTr);
554 }
555} // void CbmL1::IdealTrackFinder()
556
557
559
560// ---------------------------------------------------------------------------------------------------------------------
561//
563{
564 // FIXME: SZh 01.03.2023: Clean STAP names
565 namespace bfs = boost::filesystem;
566
567 if (fSTAPDataMode == 0) {
568 return;
569 }
570
571 // Define file prefix (/path/to/data/setup.reco.root -> "setup.reco")
572 bfs::path pathToRecoOutput = FairRunAna::Instance()->GetUserOutputFileName().Data();
573 fSTAPDataPrefix = pathToRecoOutput.filename().string();
574 fSTAPDataPrefix.ReplaceAll(".root", "");
575 fSTAPDataPrefix = fSTAPDataPrefix.Strip(TString::EStripType::kBoth, '.');
576
577 if (fSTAPDataDir.Length() == 0) {
578 fSTAPDataDir = pathToRecoOutput.parent_path().string();
579 }
580 else if (!bfs::exists(fSTAPDataDir.Data()) || !bfs::is_directory(fSTAPDataDir.Data())) {
581 fSTAPDataDir = ".";
582 }
583
584 // TODO: Clean-up the names and pathes
585 if (fSTAPDataDir.Length() == 0) {
586 fSTAPDataDir = ".";
587 }
588
589 LOG(info) << "CbmL1: STAP data root directory is \033[1;32m" << bfs::system_complete(fSTAPDataDir.Data())
590 << "\033[0m";
591
592 if (fSTAPDataMode == 4) {
593 return;
594 }
595
596 // Directory for handling L1InputData objects
597 TString sInputDataDir = fSTAPDataDir + "/" + fSTAPDataPrefix + "_cainputdata";
598 if (!bfs::exists(sInputDataDir.Data())) {
599 LOG(warn) << "CbmL1: directory for tracking input data does not exist. It will be created";
600 bfs::create_directories(sInputDataDir.Data());
601 }
602 LOG(info) << "CbmL1: STAP tracking input jobs directory is \033[1;32m" << bfs::system_complete(sInputDataDir.Data())
603 << "\033[0m";
604}
605
606// ---------------------------------------------------------------------------------------------------------------------
607//
608void CbmL1::WriteSTAPAlgoInputData(int iJob) // must be called after ReadEvent
609{
610 TString filename =
611 fSTAPDataDir + "/" + fSTAPDataPrefix + "_cainputdata/" + +TString::Format(kSTAPAlgoIDataSuffix.data(), iJob);
612
613 // Write file
614 fpIODataManager->WriteInputData(filename.Data());
615}
616
617// ---------------------------------------------------------------------------------------------------------------------
618//
619void CbmL1::WriteSTAPPerfInputData() // must be called after ReadEvent
620{
621 LOG(fatal) << "CbmL1: Running in standalone mode is not available at the moment. It will be updated soon...";
622}
623
624// ---------------------------------------------------------------------------------------------------------------------
625//
627{
628 TString filename = fSTAPDataDir + "/" + TString(kSTAPAlgoIDataDir) + "/" + fSTAPDataPrefix + "."
629 + TString::Format(kSTAPAlgoIDataSuffix.data(), iJob);
630
631 // Read file
632 fpIODataManager->ReadInputData(filename.Data());
633}
634
635// ---------------------------------------------------------------------------------------------------------------------
636//
638{
639 LOG(fatal) << "CbmL1: Running in standalone mode is not available at the moment. It will be updated soon...";
640}
641
642// ---------------------------------------------------------------------------------------------------------------------
643//
644void CbmL1::DumpMaterialToFile(TString fileName, std::shared_ptr<const ca::Parameters<double>> par)
645{
646 auto* currentFile = gFile;
647 TFile f = TFile{fileName, "RECREATE"};
648 f.cd();
649 // TODO: (!) replace CbmL1::Instance()->fpAlgo->GetParameters() with the cbm::ca::ParametersHandler::Instance()->Get()
650 // everywhere outside cbm::algo
651 const auto& activeTrackingSetup = par->GetActiveSetup();
652 for (int iSt = 0; iSt < activeTrackingSetup.GetNofLayers(); ++iSt) {
653 const auto& material = activeTrackingSetup.GetMaterial(iSt);
654 TString name = Form("tracking_station%d", iSt);
655 TString title = Form("Tracking station %d: Rad. thickness in %%. Z region [%.2f, %.2f] cm.", iSt,
656 material.GetZmin(), material.GetZmax());
658 title += " Horizontal projection.";
659 }
660 else {
661 title += " Radial projection.";
662 }
663 auto* h = ::kf::tools::RootUtils::ToHistogram(material, name, title);
664 h->SetStats(kFALSE);
665 h->SetDirectory(&f);
666 }
667 f.Write();
668 currentFile->cd();
669}
A generic hit for the CA tracker (header)
Tracking Debugger class (implementation)
Target property initialization and access in CBM (source)
cbm::algo::ca::Track CaTrack
Definition CbmL1.cxx:68
ClassImp(CbmL1)
Data class for a reconstructed hit in the STS.
Common constant definitions for the Kalman Filter library.
Different ROOT utility functions for the KF-framework (header)
#define _fvecalignment
Tracking Field class (header)
int Int_t
Generates beam ions for transport simulation.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
cbm::algo::kf::TrackParamD TLast
Track parameters in the end of the track.
Definition CbmL1Track.h:99
std::vector< int > Hits
Indexes of hits of this track.
Definition CbmL1Track.h:101
cbm::algo::kf::TrackParamD Tpv
Track parameters at primary vertex.
Definition CbmL1Track.h:98
Definition CbmL1.h:105
@ Param
Parameter initialization (when algorithm execution is not required)
Definition CbmL1.h:128
std::shared_ptr< ca::DataManager > fpIODataManager
Input-output data manager.
Definition CbmL1.h:412
bool fMatBudgetParallelProjection
Definition CbmL1.h:514
int fNStations
number of total active detector stations
Definition CbmL1.h:435
TDirectory * fHistoDir
Definition CbmL1.h:495
void Reconstruct(CbmEvent *event=nullptr)
Definition CbmL1.cxx:312
double fTrackingTime
time of track finding procedure
Definition CbmL1.h:438
std::vector< cbm::algo::kf::MaterialMonitor > fMaterialMonitor
Material monitors for each material budget map.
Definition CbmL1.h:519
void DefineSTAPNames()
Defines names for output in STAP mode.
Definition CbmL1.cxx:562
void EfficienciesPerformance(bool doFinish=kFALSE)
Calculates tracking efficiencies (counters)
TTree * fpMcTripletsTree
Tree to save MC-triplets.
Definition CbmL1.h:505
std::string fsMcTripletsOutputFilename
Name of file to save MC-triplets tree.
Definition CbmL1.h:506
void ReadSTAPPerfInputData()
Definition CbmL1.cxx:637
static CbmL1 * fpInstance
Instance of CbmL1.
Definition CbmL1.h:425
cbm::algo::ca::McData fMCData
MC Data object.
Definition CbmL1.h:410
virtual InitStatus Init()
Defines action in the beginning of the run (initialization)
Definition CbmL1.cxx:128
cbm::ca::DetIdArr_t< std::set< int > > fvmDisabledStationIDs
Definition CbmL1.h:488
CbmL1()
Default constructor.
Definition CbmL1.cxx:85
void WriteSTAPAlgoInputData(int iJob=0)
Definition CbmL1.cxx:608
void DisableTrackingStation(ca::EDetectorID detID, int iSt)
Disables tracking station for a given detector subsystem.
Definition CbmL1.cxx:111
std::unique_ptr< cbm::ca::MCModule > fpMCModule
MC module.
Definition CbmL1.h:409
void ReadSTAPAlgoInputData(int iJob=0)
Definition CbmL1.cxx:626
int fSTAPDataMode
Option to work with files for the standalone mode.
Definition CbmL1.h:447
ca::Vector< CbmL1HitId > fvExternalHits
Array of hits.
Definition CbmL1.h:479
Int_t fPerformance
performance mode: 0 - w\o perf. 1 - L1-Efficiency definition. 2 - QA-Eff.definition
Definition CbmL1.h:437
int fEventNo
Current number of event/TS.
Definition CbmL1.h:473
ca::Framework * fpAlgo
Pointer to the L1 track finder algorithm.
Definition CbmL1.h:418
TDirectory * fTableDir
Definition CbmL1.h:496
ca::TrackingMonitor fMonitor
Tracking monitor.
Definition CbmL1.h:257
std::string fsUserConfig
User config path.
Definition CbmL1.h:406
void WriteSTAPPerfInputData()
Definition CbmL1.cxx:619
static constexpr std::string_view kSTAPParamSuffix
Extension for IO of the L1Parameters object.
Definition CbmL1.h:455
EInitMode fInitMode
Initialization mode.
Definition CbmL1.h:512
ca::Vector< CbmL1Track > fvRecoTracks
Reconstructed tracks container.
Definition CbmL1.h:422
static constexpr std::string_view kSTAPAlgoIDataDir
Name of subdirectory for handling ca::InputData objects.
Definition CbmL1.h:467
void IdealTrackFinder()
Runs ideal track finder: copies all MC-tracks into reconstructed tracks.
Definition CbmL1.cxx:506
void TrackFitPerformance()
TString fSTAPParamFile
Name of the parameter file (generated automatically, if not provided manually)
Definition CbmL1.h:451
void Finish()
Defines action in the end of the run (saves results)
Definition CbmL1.cxx:414
TString fSTAPDataPrefix
Name of input/output file prefix. The prefix is defined by output TTree file.
Definition CbmL1.h:450
void DumpMaterialToFile(TString fileName, std::shared_ptr< const cbm::algo::ca::Parameters< double > > par)
Definition CbmL1.cxx:644
ca::TrackingMode fTrackingMode
Tracking mode.
Definition CbmL1.h:420
void DumpMCTripletsToTree()
std::unique_ptr< cbm::ca::TimeSliceReader > fpTSReader
event/TS reader
Definition CbmL1.h:408
~CbmL1()
Destructor.
Definition CbmL1.cxx:104
void HistoPerformance()
Fills performance histograms.
TString fSTAPDataDir
Name of input/output directory for running in a STAP mode.
Definition CbmL1.h:449
ca::Vector< cbm::algo::ca::McHitInfo > fvHitDebugInfo
Container of hits with extended information.
Definition CbmL1.h:482
static void writedir2current(TObject *obj)
Definition CbmL1.cxx:488
static constexpr std::string_view kSTAPAlgoIDataSuffix
Definition CbmL1.h:464
virtual InitStatus ReInit()
Reruns the initialization.
Definition CbmL1.cxx:120
TFile * fpMcTripletsOutFile
File to save MC-triplets tree.
Definition CbmL1.h:504
Class to handle QA-objects in the online reconstruction.
Definition QaData.h:27
int GetStationId() const
Gets global index of active tracking station.
Definition CaMcHitInfo.h:47
A container for all external parameters of the CA tracking algorithm.
Class representing an output track in the CA tracking algorithm.
Definition CaTrack.h:28
TrackParam_t fParFirst
Track parameters on the first station.
Definition CaTrack.h:48
int fNofHits
Number of hits in track.
Definition CaTrack.h:46
static Debugger & Instance()
Instance.
virtual void Write()=0
Write ntuples to the file.
T Tx() const
Gets slope along x-axis.
T X() const
Gets x position [cm].
T Y() const
Gets y position [cm].
T Qp() const
Gets charge over momentum [ec/GeV].
T Z() const
Gets z position [cm].
T Time() const
Gets time [ns].
void Set(const TrackParamBase< T1 > &Tb)
T Ty() const
Gets slope along y-axis.
Class CbmCaPerformance is an interface to communicate between.
Builds parameters for CBM CA tracking.
void SetRequireHitPresence(bool requireHitPresence)
Sets hit presence requirement.
A reader of time slice for CA tracker.
MonitorData< ECounter, ETimer > TrackingMonitorData
EDetectorID
Enumeration for the tracking detector subsystems in CBM-CA.
Definition CbmDefs.h:216
EFieldMode
Enumiration for the magnetic field representation variants in the track fitting algorithm.
Definition KfDefs.h:108
cbm::core::EnumArray< ca::EDetectorID, T > DetIdArr_t
Alias to array, indexed by L1DetectorID enum.
constexpr DetIdArr_t< ca::EDetectorID > kDetIds
List of detector.
void SetOriginalCbmField()
pass the original magnetic field to L1Algo
static void Store(const Parameters< double > &parameters, const std::string &fileName)
Stores parameter to file.
static Parameters< Float > Load(const std::string &fileName)
Loads parameters from file.
A floating-point tag for tag dispatching.
Definition KfDefs.h:117
static TH2F * ToHistogram(const cbm::algo::kf::MaterialMap &material, const TString &name, const TString &title)
Converts a material budget map into a TH2D histogram.