ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimMatrixGenAlgo.h
Go to the documentation of this file.
1// Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3#ifndef FPGATrackSimMatrixGenAlgo_h
4#define FPGATrackSimMatrixGenAlgo_h
5
19
20
21#include "GaudiKernel/ITHistSvc.h"
40
41#include "TTree.h"
42#include "TFile.h"
43#include "TH1I.h"
44
45#include <string>
46#include <vector>
47
48
49class ITHistSvc;
50class TH1F;
51class TH2F;
53
55{
56 public:
57 FPGATrackSimMatrixGenAlgo(const std::string& name, ISvcLocator* pSvcLocator);
58 virtual ~FPGATrackSimMatrixGenAlgo() = default;
59
60 StatusCode initialize() override;
61 StatusCode execute() override;
62 StatusCode finalize() override;
63
64 private:
65
67 // Objects
68
69 // Main logic. For each sector, store a struct that accumulates the track parameters, hit coordinates, etc.
70 std::vector<AccumulateMap> m_sector_cum; // Index by region
71
73 // Handles
74
75 ServiceHandle<IFPGATrackSimMappingSvc> m_FPGATrackSimMapping{this,"FPGATrackSimMappingSvc","FPGATrackSimMappingSvc"};
76 ServiceHandle<IFPGATrackSimEventSelectionSvc> m_EvtSel{this,"FPGATrackSimEventSelectionSvc",""};
77 ServiceHandle<ITHistSvc> m_tHistSvc{this,"THistSvc","THistSvc"};
78
79 ToolHandle<IFPGATrackSimInputTool> m_hitInputTool {this, "FPGATrackSimSGToRawHitsTool", "FPGATrackSimSGToRawHitsTool/FPGATrackSimSGToRawHits", "input handler"};
80 ToolHandle<FPGATrackSimRawToLogicalHitsTool> m_hitMapTool {this, "FPGATrackSimRawToLogicalHitsTool", "FPGATrackSimRawToLogicalHitsTool/FPGATrackSim_RawToLogicalHitsTool", "FPGATrackSim_RawToLogicalHitsTool"};
81 ToolHandle<FPGATrackSimClusteringToolI> m_clusteringTool { this, "FPGATrackSimClusteringFTKTool", "FPGATrackSimClusteringFTKTool/FPGATrackSimClusteringFTKTool", "FPGATrackSimClusteringFTKTool" };
82 ToolHandle<FPGATrackSimSpacePointsToolI> m_spacePointsTool { this, "SpacePointTool", "FPGATrackSimSpacePointsTool/FPGATrackSimSpacePointsTool", "FPGATrackSimSpacePointsTool" };
83 const FPGATrackSimPlaneMap* m_pmap = nullptr; // alias to m_FPGATrackSimMapping->PlaneMap();
84 ToolHandle<FPGATrackSimRoadUnionTool> m_roadFinderTool {this, "RoadFinder", "RoadFinder"};
85 ToolHandle<FPGATrackSimTrackFitterTool> m_trackFitterTool_1st {this, "TrackFitter_1st", "FPGATrackSimTrackFitterTool/FPGATrackSimTrackFitterTool_1st", "1st stage track fit tool"};
86
87 ToolHandle<IFPGATrackSimTrackExtensionTool> m_trackExtensionTool {this, "TrackExtensionTool", "FPGATrackSimTrackExtensionTool", "Track extensoin tool"};
88 ToolHandle<FPGATrackSimOverlapRemovalTool> m_overlapRemovalTool {this, "OverlapRemoval_1st", "FPGATrackSimOverlapRemovalTool/FPGATrackSimOverlapRemovalTool_1st", "1st stage overlap removal tool"};
89
90
91 const FPGATrackSimPlaneMap* m_pmap_1st = nullptr; // alias to m_FPGATrackSimMapping->PlaneMap();
92 const FPGATrackSimPlaneMap* m_pmap_2nd = nullptr; // alias to m_FPGATrackSimMapping->PlaneMap();
93
94
96 // Configuration
97 Gaudi::Property<int> m_nRegions {this, "NBanks", 0, "Number of banks to make"};
98 Gaudi::Property<bool> m_doClustering {this, "Clustering", true, "Do cluster?"};
99 Gaudi::Property<bool> m_doSecondStage {this, "SecondStage", false, "Run second stage?"};
100 Gaudi::Property<bool> m_doSpacePoints {this, "SpacePoints", true, "Do spacepoints?"};
101 Gaudi::Property<int> m_ideal_geom {this, "IdealiseGeometry", 0, "Ideal geo flag, 0 is non, 1 is 1st order, 2 is 2nd order"};
102 Gaudi::Property<bool> m_single {this, "SingleSector", false, "Run single sector"};
103 Gaudi::Property<bool> m_doHoughConstants {this, "HoughConstants", true, "If true will run Hough Transform to set q/pt and phi0"};
104 Gaudi::Property<bool> m_doDeltaPhiConsts {this, "DeltaPhiConstants", false, "If true will generate delta phi constants"};
105 Gaudi::Property<int> m_MaxWC {this, "WCmax", 0, "Max number of WCs"};
106 Gaudi::Property<int> m_minSpacePlusPixel {this, "minSpacePlusPixel", 4, "Require that tracks in training have a certain number of pixel hits + spacepoints" };
107 Gaudi::Property<float> m_PT_THRESHOLD {this, "PT_THRESHOLD", 0., "Min pt"};
108 Gaudi::Property<float> m_D0_THRESHOLD {this, "D0_THRESHOLD", 1., "Max d0"};
109 Gaudi::Property<int> m_TRAIN_PDG {this, "TRAIN_PDG", 0, "PDG of particles to train on"};
110 Gaudi::Property<float> m_temp_c_min {this, "par_c_min", -1, "Min curvature"};
111 Gaudi::Property<float> m_temp_c_max {this, "par_c_max", 1, "Max curvature"};
112 Gaudi::Property<float> m_temp_phi_min {this, "par_phi_min", -TMath::Pi(), "Min phi"};
113 Gaudi::Property<float> m_temp_phi_max {this, "par_phi_max", TMath::Pi(), "Max phi"};
114 Gaudi::Property<float> m_temp_d0_min {this, "par_d0_min", -2, "Min d0"};
115 Gaudi::Property<float> m_temp_d0_max {this, "par_d0_max", 2, "Max d0"};
116 Gaudi::Property<float> m_temp_z0_min {this, "par_z0_min", -200, "Min z0"};
117 Gaudi::Property<float> m_temp_z0_max {this, "par_z0_max", 200, "Max z0"};
118 Gaudi::Property<float> m_temp_eta_min {this, "par_eta_min", -5, "Min eta"};
119 Gaudi::Property<float> m_temp_eta_max {this, "par_eta_max", 5, "Max eta"};
120 Gaudi::Property<int> m_temp_c_slices {this, "par_c_slices", 100, "Number of c slides"};
121 Gaudi::Property<int> m_temp_phi_slices {this, "par_phi_slices", 100, "Number of phi slices"};
122 Gaudi::Property<int> m_temp_d0_slices {this, "par_d0_slices", 100, "Number of d0 slices"};
123 Gaudi::Property<int> m_temp_z0_slices {this, "par_z0_slices", 100, "Number of z0 slices"};
124 Gaudi::Property<int> m_temp_eta_slices {this, "par_eta_slices", 100, "Number of eta slices"};
125 Gaudi::Property<bool> m_absQOverPtBinning{this, "qptAbsBinning", false, "This property controls whether or not to interpret the bins as q/pt or |q/pt|"};
126 Gaudi::Property<std::vector<double> > m_qOverPtBins{this, "sectorQPtBins", {}, "q/pt bins for sector definition"};
127 Gaudi::Property<bool> m_dropHitsAndFill{this, "dropHitsAndFill", false, "If true, we can drop hits to fill the accumulator"};
128
130 int m_nDim_1st = 0;
131
133 int m_nDim_2nd = 0;
134
135
139
141
143 // Meta Data
144
145 size_t m_nTracks = 0; // Total number of truth tracks encountered
146 size_t m_nTracksUsed = 0; // Total number of tracks after filtering, i.e. used to fit constants
147
149 // Helper Functions
150
152
153 StatusCode bookHistograms();
154 std::vector<FPGATrackSimHit> getLogicalHits() ;
155 std::vector<FPGATrackSimTruthTrack> filterTrainingTracks(std::vector<FPGATrackSimTruthTrack> const & truth_tracks) const;
156 std::map<int, std::vector<FPGATrackSimHit>> makeBarcodeMap(std::vector<FPGATrackSimHit> const & hits, std::vector<FPGATrackSimTruthTrack> const & tracks) const;
157 selectHit_returnCode selectHit(FPGATrackSimHit const & old_hit, FPGATrackSimHit const & new_hit, bool is1ststage, int subregion) const;
158 bool filterSectorHits(std::vector<FPGATrackSimHit> const & all_hits, std::vector<FPGATrackSimHit> & sector_hits, FPGATrackSimTruthTrack const & t, bool is1ststage, int subregion) const;
159 int getRegion(std::vector<FPGATrackSimHit> const & hits, bool is1ststage) const;
160 StatusCode makeAccumulator(std::vector<FPGATrackSimHit> const & sector_hits, FPGATrackSimTruthTrack const & track, std::pair<std::vector<module_t>, FPGATrackSimMatrixAccumulator> & accumulator) const;
161 StatusCode fillAccumulatorByDropping(std::vector<FPGATrackSimHit> & sector_hits, bool is1ststage, double x, double y, std::vector<module_t> &modules, AccumulateMap &map, FPGATrackSimTruthTrack const & track, int subregion) const;
162
163 std::vector<TTree*> createMatrixTrees();
164 void fillMatrixTrees(std::vector<TTree*> const & matrixTrees);
165 void writeSliceTree();
166
168 // Histograms
169
170 // These are ordered as in FPGATrackSimTrackPars, phi, curvature, d0, z0, eta
176
177 TH1I* m_h_trackQoP_okHits = nullptr;
178 TH1I* m_h_trackQoP_okRegion = nullptr;
179 TH1I* m_h_nHit = nullptr;
180};
181
182#endif // FPGATrackSimMatrixGenAlgo_h
Declares an abstract class that implements an interface for pixel clustering. This class is implement...
std::unordered_map< std::vector< module_t >, FPGATrackSimMatrixAccumulator, container_hash< std::vector< module_t > > > AccumulateMap
Classes to read/write matrix files event by event.
Overlap removal tool for FPGATrackSimTrack.
Maps physical layers to logical layers.
Maps ITK module indices to FPGATrackSim regions.
Wrapper class to combine multiple road-finding tools.
Declares an abstract class that implements an interface for spacepoint formation. This class is imple...
Default track extension algorithm to produce "second stage" roads.
This declares a basic interface for input tools which provide the FPGATrackSimEventInputHeader data t...
#define y
#define x
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ToolHandle< FPGATrackSimRawToLogicalHitsTool > m_hitMapTool
std::map< int, std::vector< FPGATrackSimHit > > makeBarcodeMap(std::vector< FPGATrackSimHit > const &hits, std::vector< FPGATrackSimTruthTrack > const &tracks) const
Gaudi::Property< float > m_temp_c_max
FPGATrackSimMatrixGenAlgo(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_doDeltaPhiConsts
std::vector< TTree * > createMatrixTrees()
Gaudi::Property< float > m_temp_d0_max
const FPGATrackSimPlaneMap * m_pmap_2nd
std::vector< FPGATrackSimTruthTrack > filterTrainingTracks(std::vector< FPGATrackSimTruthTrack > const &truth_tracks) const
Gaudi::Property< std::vector< double > > m_qOverPtBins
Gaudi::Property< float > m_temp_phi_max
Gaudi::Property< int > m_temp_z0_slices
Gaudi::Property< float > m_PT_THRESHOLD
Gaudi::Property< int > m_temp_d0_slices
Gaudi::Property< int > m_temp_eta_slices
TH1I * m_h_trainingTrack[FPGATrackSimTrackPars::NPARS]
Gaudi::Property< int > m_temp_phi_slices
ToolHandle< FPGATrackSimRoadUnionTool > m_roadFinderTool
Gaudi::Property< float > m_temp_c_min
Gaudi::Property< float > m_temp_z0_max
Gaudi::Property< float > m_temp_eta_min
Gaudi::Property< float > m_D0_THRESHOLD
Gaudi::Property< bool > m_doSpacePoints
Gaudi::Property< bool > m_absQOverPtBinning
Gaudi::Property< float > m_temp_phi_min
Gaudi::Property< float > m_temp_z0_min
StatusCode makeAccumulator(std::vector< FPGATrackSimHit > const &sector_hits, FPGATrackSimTruthTrack const &track, std::pair< std::vector< module_t >, FPGATrackSimMatrixAccumulator > &accumulator) const
virtual ~FPGATrackSimMatrixGenAlgo()=default
ToolHandle< FPGATrackSimClusteringToolI > m_clusteringTool
ToolHandle< FPGATrackSimOverlapRemovalTool > m_overlapRemovalTool
Gaudi::Property< bool > m_doClustering
TH1I * m_h_notEnoughHits[FPGATrackSimTrackPars::NPARS]
Gaudi::Property< int > m_minSpacePlusPixel
const FPGATrackSimPlaneMap * m_pmap_1st
TH1I * m_h_sectorPars[FPGATrackSimTrackPars::NPARS]
std::vector< FPGATrackSimHit > getLogicalHits()
TH1I * m_h_3hitsInLayer[FPGATrackSimTrackPars::NPARS]
FPGATrackSimEventInputHeader * m_eventHeader
ToolHandle< FPGATrackSimTrackFitterTool > m_trackFitterTool_1st
ServiceHandle< ITHistSvc > m_tHistSvc
selectHit_returnCode selectHit(FPGATrackSimHit const &old_hit, FPGATrackSimHit const &new_hit, bool is1ststage, int subregion) const
std::vector< AccumulateMap > m_sector_cum
StatusCode fillAccumulatorByDropping(std::vector< FPGATrackSimHit > &sector_hits, bool is1ststage, double x, double y, std::vector< module_t > &modules, AccumulateMap &map, FPGATrackSimTruthTrack const &track, int subregion) const
Gaudi::Property< float > m_temp_d0_min
Gaudi::Property< bool > m_dropHitsAndFill
Gaudi::Property< int > m_temp_c_slices
ToolHandle< IFPGATrackSimTrackExtensionTool > m_trackExtensionTool
ServiceHandle< IFPGATrackSimMappingSvc > m_FPGATrackSimMapping
Gaudi::Property< bool > m_doHoughConstants
ServiceHandle< IFPGATrackSimEventSelectionSvc > m_EvtSel
int getRegion(std::vector< FPGATrackSimHit > const &hits, bool is1ststage) const
const FPGATrackSimPlaneMap * m_pmap
bool filterSectorHits(std::vector< FPGATrackSimHit > const &all_hits, std::vector< FPGATrackSimHit > &sector_hits, FPGATrackSimTruthTrack const &t, bool is1ststage, int subregion) const
Gaudi::Property< float > m_temp_eta_max
void fillMatrixTrees(std::vector< TTree * > const &matrixTrees)
TH1I * m_h_SHfailure[FPGATrackSimTrackPars::NPARS]
ToolHandle< FPGATrackSimSpacePointsToolI > m_spacePointsTool
Gaudi::Property< bool > m_doSecondStage
ToolHandle< IFPGATrackSimInputTool > m_hitInputTool
STL class.
TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)