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