ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimDataFlowTool.h
Go to the documentation of this file.
1// Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimDATAFLOWTOOL_H
4#define FPGATrackSimDATAFLOWTOOL_H
5
7#include "GaudiKernel/ServiceHandle.h"
8#include "GaudiKernel/ITHistSvc.h"
10
11#include "TH1.h"
13#include <fstream>
14#include <string_view>
15
16
18class FPGATrackSimHit;
23
26
29{
30 public:
31 template<typename T>
32 using DataFlowMap_t = std::unordered_map<std::string, T, CxxUtils::TransparentStringHash, std::equal_to<>>;
33
34 FPGATrackSimDataFlowTool(std::string const &, std::string const &, IInterface const *);
35 virtual ~FPGATrackSimDataFlowTool() = default;
36
37 virtual StatusCode initialize() override;
38
40 std::vector<FPGATrackSimCluster> const & clusters_1st,
41 const std::vector<FPGATrackSimRoad> & roads_1st, std::vector<FPGATrackSimTrack> const & tracks_1st,
42 const std::vector<FPGATrackSimRoad> & roads_2nd, std::vector<FPGATrackSimTrack> const & tracks_2nd);
43
44 StatusCode getDataFlowInfo(FPGATrackSimDataFlowInfo const & info);
45
46 virtual StatusCode finalize() override;
47
48 private:
49
50 StatusCode makeDataFlowTable();
51
52 StatusCode addDataFlow(float const n, std::string_view key, bool const isInt = true);
53 StatusCode printDataFlow(std::string const & key, int const div = 1);
54
55 void addTableBreak(unsigned const n = 1);
56 void findAndReplaceAll(std::string & data, std::string const & toFind, std::string const & replaceStr) const;
57 void setMaxAcceptance(TH1* h, double const max_frac, double& max_value) const;
58 double roundTo(double const v, int const nSigDigits) const;
59
60 void setHistDir(std::string const & dir) { m_dir = "/MONITOROUT" + dir; }
61 std::string const & getHistDir() { return m_dir; }
62 void clearHistDir() { m_dir = ""; }
63 StatusCode regHist (std::string const & dir, TH1* h) { return m_tHistSvc->regHist (dir + h->GetName(), h); }
64
65 ServiceHandle<ITHistSvc> m_tHistSvc{this,"THistSvc","THistSvc"};
66 ServiceHandle<IFPGATrackSimMappingSvc> m_FPGATrackSimMapping{this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"};
67 ServiceHandle<IFPGATrackSimEventSelectionSvc> m_evtSel{this,"FPGATrackSimEventSelectionSvc","FPGATrackSimEventSelectionSvc"};
68
69
70 Gaudi::Property<bool> m_runSecondStage {this, "RunSecondStage", false, "flag to enable running the second stage fitting"};
71 Gaudi::Property<std::string> m_outputtag {this, "outputTag", "", "Extra string to use in output folder names - default none"};
72 Gaudi::Property<float> m_cut_chi2ndof {this, "Chi2ndofCut", 40., "cut on Chi2 of FPGATrackSimTrack"};
73
74 // data flow output
75 std::string const m_dataFlowTxtName = "./dataflow.txt";
76 std::string const m_dataFlowTeXName = "./dataflow.tex";
77 std::ofstream m_dataFlowTxt;
78 std::ofstream m_dataFlowTeX;
79
80 // histogram directory
81 std::string m_dir;
82
83 size_t m_nEvents = 0;
84 unsigned m_nLayers_1st = 0U; // alias to m_FPGATrackSimMapping->PlaneMap1stStage()->getNLogiLayers();
85
86 // constants used for data flow table
87 unsigned const m_nSigDigits = 2;
88 unsigned const m_tableTypeWidth = 32;
89 unsigned const m_tableDataWidth = 9;
90 double const m_max_frac = 0.99; // Maximum acceptance fraction of data mimicking data loss
91
96
99};
100
101#endif // FPGATrackSimDataFlowTool_h
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Header file for AthHistogramAlgorithm.
Gaudi::Property< bool > m_runSecondStage
DataFlowMap_t< float > m_dataFlowDataF_min
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
void setMaxAcceptance(TH1 *h, double const max_frac, double &max_value) const
DataFlowMap_t< float > m_dataFlowDataF_max
StatusCode getDataFlowInfo(FPGATrackSimDataFlowInfo const &info)
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_evtSel
Gaudi::Property< float > m_cut_chi2ndof
virtual StatusCode initialize() override
virtual ~FPGATrackSimDataFlowTool()=default
std::unordered_map< std::string, T, CxxUtils::TransparentStringHash, std::equal_to<> > DataFlowMap_t
StatusCode printDataFlow(std::string const &key, int const div=1)
double roundTo(double const v, int const nSigDigits) const
StatusCode calculateDataFlow(FPGATrackSimDataFlowInfo *info, FPGATrackSimLogicalEventInputHeader const *header_1st, std::vector< FPGATrackSimCluster > const &clusters_1st, const std::vector< FPGATrackSimRoad > &roads_1st, std::vector< FPGATrackSimTrack > const &tracks_1st, const std::vector< FPGATrackSimRoad > &roads_2nd, std::vector< FPGATrackSimTrack > const &tracks_2nd)
void addTableBreak(unsigned const n=1)
virtual StatusCode finalize() override
DataFlowMap_t< TH1F * > m_dataFlowHistsF
DataFlowMap_t< TH1I * > m_dataFlowHistsI
FPGATrackSimDataFlowTool(std::string const &, std::string const &, IInterface const *)
ServiceHandle< ITHistSvc > m_tHistSvc
void setHistDir(std::string const &dir)
StatusCode addDataFlow(float const n, std::string_view key, bool const isInt=true)
Gaudi::Property< std::string > m_outputtag
void findAndReplaceAll(std::string &data, std::string const &toFind, std::string const &replaceStr) const
StatusCode regHist(std::string const &dir, TH1 *h)
DataFlowMap_t< int > m_dataFlowDataI_min
DataFlowMap_t< int > m_dataFlowDataI_max