ATLAS Offline Software
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 
16 class FPGATrackSimHit;
19 class FPGATrackSimRoad;
20 class FPGATrackSimTrack;
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 
41 
42  virtual StatusCode finalize() override;
43 
44  private:
45 
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
grepfile.info
info
Definition: grepfile.py:38
FPGATrackSimDataFlowTool::~FPGATrackSimDataFlowTool
virtual ~FPGATrackSimDataFlowTool()=default
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
FPGATrackSimLogicalEventInputHeader
Definition: FPGATrackSimLogicalEventInputHeader.h:21
FPGATrackSimDataFlowTool::m_nLayers_1st
unsigned m_nLayers_1st
Definition: FPGATrackSimDataFlowTool.h:80
FPGATrackSimDataFlowTool
Definition: FPGATrackSimDataFlowTool.h:27
FPGATrackSimDataFlowTool::FPGATrackSimDataFlowTool
FPGATrackSimDataFlowTool(std::string const &, std::string const &, IInterface const *)
Definition: FPGATrackSimDataFlowTool.cxx:18
FPGATrackSimCluster
Definition: FPGATrackSimCluster.h:24
FPGATrackSimDataFlowTool::m_FPGATrackSimMapping
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Definition: FPGATrackSimDataFlowTool.h:62
FPGATrackSimTrack
Definition: FPGATrackSimTrack.h:18
FPGATrackSimDataFlowTool::makeDataFlowTable
StatusCode makeDataFlowTable()
Definition: FPGATrackSimDataFlowTool.cxx:208
FPGATrackSimDataFlowTool::m_dataFlowDataI_max
std::unordered_map< std::string, int > m_dataFlowDataI_max
Definition: FPGATrackSimDataFlowTool.h:89
FPGATrackSimDataFlowTool::m_dataFlowHistsI
std::unordered_map< std::string, TH1I * > m_dataFlowHistsI
Definition: FPGATrackSimDataFlowTool.h:93
FPGATrackSimDataFlowTool::addTableBreak
void addTableBreak(unsigned const n=1)
Definition: FPGATrackSimDataFlowTool.cxx:467
IFPGATrackSimEventSelectionSvc
Definition: IFPGATrackSimEventSelectionSvc.h:22
IFPGATrackSimMappingSvc
Definition: IFPGATrackSimMappingSvc.h:17
FPGATrackSimDataFlowTool::m_evtSel
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_evtSel
Definition: FPGATrackSimDataFlowTool.h:63
FPGATrackSimDataFlowTool::m_tHistSvc
ServiceHandle< ITHistSvc > m_tHistSvc
Definition: FPGATrackSimDataFlowTool.h:61
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimDataFlowTool::m_dataFlowTeXName
std::string const m_dataFlowTeXName
Definition: FPGATrackSimDataFlowTool.h:72
FPGATrackSimDataFlowTool::m_tableDataWidth
unsigned const m_tableDataWidth
Definition: FPGATrackSimDataFlowTool.h:85
FPGATrackSimDataFlowTool::initialize
virtual StatusCode initialize() override
Definition: FPGATrackSimDataFlowTool.cxx:25
FPGATrackSimDataFlowTool::getHistDir
std::string const & getHistDir()
Definition: FPGATrackSimDataFlowTool.h:57
FPGATrackSimDataFlowTool::roundTo
double roundTo(double const v, int const nSigDigits) const
Definition: FPGATrackSimDataFlowTool.cxx:503
FPGATrackSimDataFlowTool::addDataFlow
StatusCode addDataFlow(float const n, std::string const &key, bool const isInt=true)
Definition: FPGATrackSimDataFlowTool.cxx:330
FPGATrackSimDataFlowInfo
Definition: FPGATrackSimDataFlowInfo.h:18
FPGATrackSimDataFlowTool::m_cut_chi2ndof
Gaudi::Property< float > m_cut_chi2ndof
Definition: FPGATrackSimDataFlowTool.h:68
FPGATrackSimDataFlowTool::m_runSecondStage
Gaudi::Property< bool > m_runSecondStage
Definition: FPGATrackSimDataFlowTool.h:66
FPGATrackSimDataFlowTool::clearHistDir
void clearHistDir()
Definition: FPGATrackSimDataFlowTool.h:58
FPGATrackSimDataFlowTool::getDataFlowInfo
StatusCode getDataFlowInfo(FPGATrackSimDataFlowInfo const &info)
Definition: FPGATrackSimDataFlowTool.cxx:144
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FPGATrackSimDataFlowTool::setMaxAcceptance
void setMaxAcceptance(TH1 *h, double const max_frac, double &max_value) const
Definition: FPGATrackSimDataFlowTool.cxx:488
AthAlgTool.h
FPGATrackSimDataFlowTool::finalize
virtual StatusCode finalize() override
Definition: FPGATrackSimDataFlowTool.cxx:321
FPGATrackSimDataFlowTool::m_tableTypeWidth
unsigned const m_tableTypeWidth
Definition: FPGATrackSimDataFlowTool.h:84
FPGATrackSimDataFlowTool::m_dataFlowDataF_max
std::unordered_map< std::string, float > m_dataFlowDataF_max
Definition: FPGATrackSimDataFlowTool.h:91
FPGATrackSimDataFlowTool::regHist
StatusCode regHist(std::string const &dir, TH1 *h)
Definition: FPGATrackSimDataFlowTool.h:59
FPGATrackSimDataFlowTool::m_dataFlowHistsF
std::unordered_map< std::string, TH1F * > m_dataFlowHistsF
Definition: FPGATrackSimDataFlowTool.h:94
FPGATrackSimDataFlowTool::m_dir
std::string m_dir
Definition: FPGATrackSimDataFlowTool.h:77
beamspotman.dir
string dir
Definition: beamspotman.py:623
FPGATrackSimDataFlowTool::setHistDir
void setHistDir(std::string const &dir)
Definition: FPGATrackSimDataFlowTool.h:56
FPGATrackSimDataFlowTool::m_max_frac
double const m_max_frac
Definition: FPGATrackSimDataFlowTool.h:86
FPGATrackSimDataFlowTool::calculateDataFlow
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)
Definition: FPGATrackSimDataFlowTool.cxx:43
FPGATrackSimDataFlowTool::m_outputtag
Gaudi::Property< std::string > m_outputtag
Definition: FPGATrackSimDataFlowTool.h:67
FPGATrackSimDataFlowTool::printDataFlow
StatusCode printDataFlow(std::string const &key, int const div=1)
Definition: FPGATrackSimDataFlowTool.cxx:405
FPGATrackSimDataFlowTool::m_dataFlowTxtName
std::string const m_dataFlowTxtName
Definition: FPGATrackSimDataFlowTool.h:71
FPGATrackSimDataFlowTool::findAndReplaceAll
void findAndReplaceAll(std::string &data, std::string const &toFind, std::string const &replaceStr) const
Definition: FPGATrackSimDataFlowTool.cxx:477
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimDataFlowTool::m_dataFlowTxt
std::ofstream m_dataFlowTxt
Definition: FPGATrackSimDataFlowTool.h:73
h
FPGATrackSimDataFlowTool::m_dataFlowDataI_min
std::unordered_map< std::string, int > m_dataFlowDataI_min
Definition: FPGATrackSimDataFlowTool.h:88
FPGATrackSimDataFlowTool::m_nSigDigits
unsigned const m_nSigDigits
Definition: FPGATrackSimDataFlowTool.h:83
AthAlgTool
Definition: AthAlgTool.h:26
FPGATrackSimDataFlowTool::m_nEvents
size_t m_nEvents
Definition: FPGATrackSimDataFlowTool.h:79
FPGATrackSimDataFlowTool::m_dataFlowTeX
std::ofstream m_dataFlowTeX
Definition: FPGATrackSimDataFlowTool.h:74
FPGATrackSimTypes.h
FPGATrackSimRoad
Definition: FPGATrackSimRoad.h:30
FPGATrackSimDataFlowTool::m_dataFlowDataF_min
std::unordered_map< std::string, float > m_dataFlowDataF_min
Definition: FPGATrackSimDataFlowTool.h:90
ServiceHandle< ITHistSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37