File indexing completed on 2025-12-16 09:20:52
0001 #ifndef TRACKRECO_PHACTSSILICONSEEDING_H
0002 #define TRACKRECO_PHACTSSILICONSEEDING_H
0003
0004 #include <fun4all/SubsysReco.h>
0005 #include <trackbase/ActsGeometry.h>
0006 #include <trackbase/ClusterErrorPara.h>
0007 #include <trackbase/TrkrDefs.h>
0008
0009 #include <Acts/Definitions/Algebra.hpp>
0010 #include <Acts/Definitions/Units.hpp>
0011 #include <Acts/Geometry/GeometryIdentifier.hpp>
0012 #include <Acts/Seeding/SeedFinder.hpp>
0013
0014 #include <Acts/Seeding/SpacePointGrid.hpp>
0015 #include <Acts/Utilities/GridBinFinder.hpp>
0016
0017 #include <trackbase/SpacePoint.h>
0018
0019 #include <TFile.h>
0020 #include <TH1.h>
0021 #include <TH2.h>
0022 #include <TTree.h>
0023 #include <map>
0024 #include <string>
0025
0026 class PHCompositeNode;
0027 class PHG4CylinderGeomContainer;
0028 class TrackSeed;
0029 class TrackSeedContainer;
0030 class TrkrCluster;
0031 class TrkrClusterContainer;
0032 class TrkrClusterIterationMap;
0033 class TrkrClusterCrossingAssoc;
0034
0035 using GridSeeds = std::vector<std::vector<Acts::Seed<SpacePoint>>>;
0036
0037
0038
0039
0040
0041
0042
0043 class PHActsSiliconSeeding : public SubsysReco
0044 {
0045 public:
0046 PHActsSiliconSeeding(const std::string &name = "PHActsSiliconSeeding");
0047 ~PHActsSiliconSeeding() override;
0048 int Init(PHCompositeNode *topNode) override;
0049 int InitRun(PHCompositeNode *topNode) override;
0050 int process_event(PHCompositeNode *topNode) override;
0051 int End(PHCompositeNode *topNode) override;
0052
0053 void isStreaming()
0054 {
0055 m_streaming = true;
0056 }
0057
0058 void setStrobeRange(const int low, const int high)
0059 {
0060 m_lowStrobeIndex = low;
0061 m_highStrobeIndex = high;
0062 }
0063 void setunc(float unc) { m_uncfactor = unc; }
0064
0065 void useTruthClusters(bool useTruthClusters)
0066 {
0067 m_useTruthClusters = useTruthClusters;
0068 }
0069
0070
0071 void seedAnalysis(bool seedAnalysis)
0072 {
0073 m_seedAnalysis = seedAnalysis;
0074 }
0075
0076 void setinttRPhiSearchWindow(const float win)
0077 {
0078 m_inttrPhiSearchWin = win;
0079 }
0080 void setinttZSearchWindow(const float &win)
0081 {
0082 m_inttzSearchWin = win;
0083 }
0084 void setmvtxRPhiSearchWindow(const float win)
0085 {
0086 m_mvtxrPhiSearchWin = win;
0087 }
0088 void setmvtxZSearchWindow(const float &win)
0089 {
0090 m_mvtxzSearchWin = win;
0091 }
0092
0093
0094 void cleanSeeds(bool cleanSeeds)
0095 {
0096 m_cleanSeeds = cleanSeeds;
0097 }
0098
0099 void rMax(const float rMax)
0100 {
0101 m_rMax = rMax;
0102 }
0103 void rMin(const float rMin)
0104 {
0105 m_rMin = rMin;
0106 }
0107 void zMax(const float zMax)
0108 {
0109 m_zMax = zMax;
0110 }
0111 void zMin(const float zMin)
0112 {
0113 m_zMin = zMin;
0114 }
0115 void deltaRMax(const float deltaRMax)
0116 {
0117 m_deltaRMax = deltaRMax;
0118 }
0119 void cotThetaMax(const float cotThetaMax)
0120 {
0121 m_cotThetaMax = cotThetaMax;
0122 }
0123 void gridFactor(const float gridFactor)
0124 {
0125 m_gridFactor = gridFactor;
0126 }
0127 void sigmaScattering(const float sigma)
0128 {
0129 m_sigmaScattering = sigma;
0130 }
0131 void maxPtScattering(const float pt)
0132 {
0133 m_maxPtScattering = pt;
0134 }
0135 void sigmaError(const float sigma)
0136 {
0137 m_sigmaError = sigma;
0138 }
0139 void zalign(const float z)
0140 {
0141 m_zalign = z;
0142 }
0143 void ralign(const float r)
0144 {
0145 m_ralign = r;
0146 }
0147 void tolerance(const float tolerance)
0148 {
0149 m_tolerance = tolerance;
0150 }
0151 void helixcut(const float cut)
0152 {
0153 m_helixcut = cut;
0154 }
0155 void bfield(const float field)
0156 {
0157 m_bField = field;
0158 }
0159 void minpt(const float pt)
0160 {
0161 m_minSeedPt = pt;
0162 }
0163
0164
0165
0166 void largeGridSpacing(const bool spacing);
0167
0168 void set_track_map_name(const std::string &map_name) { _track_map_name = map_name; }
0169 void iteration(int iter) { m_nIteration = iter; }
0170 void searchInIntt() { m_searchInIntt = true; }
0171 void strobeWindowLowSearch(const int width) { m_strobeLowWindow = width; }
0172 void strobeWindowHighSearch(const int width) { m_strobeHighWindow = width; }
0173 private:
0174 int getNodes(PHCompositeNode *topNode);
0175 int createNodes(PHCompositeNode *topNode);
0176
0177 int m_strobeLowWindow = -1;
0178 int m_strobeHighWindow = 2;
0179
0180 void runSeeder();
0181
0182
0183
0184 void configureSeeder();
0185 void configureSPGrid();
0186 Acts::SeedFilterConfig configureSeedFilter() const;
0187
0188
0189 void makeSvtxTracks(const GridSeeds &seedVector);
0190
0191
0192 void makeSvtxTracksWithTime(const GridSeeds &seedVector, const int &strobe);
0193
0194
0195 SpacePointPtr makeSpacePoint(
0196 const Surface &surf,
0197 const TrkrDefs::cluskey,
0198
0199 TrkrCluster *clus);
0200
0201
0202 std::vector<const SpacePoint *> getSiliconSpacePoints(Acts::Extent &rRangeSPExtent,
0203 const int strobe);
0204 void printSeedConfigs(Acts::SeedFilterConfig &sfconfig);
0205 bool isTimingMismatched(TrackSeed& seed) const;
0206
0207
0208
0209 std::vector<TrkrDefs::cluskey>
0210 findMatches(
0211 std::vector<Acts::Vector3> &clusters,
0212 std::vector<TrkrDefs::cluskey> &keys,
0213 TrackSeed &seed);
0214
0215 std::vector<std::vector<TrkrDefs::cluskey>> findMatchesWithTime(
0216 std::map<TrkrDefs::cluskey, Acts::Vector3> &positions,
0217 const int &strobe);
0218 std::vector<std::vector<TrkrDefs::cluskey>> iterateLayers(const int &startLayer,
0219 const int &endLayer, const int &strobe,
0220 const std::vector<TrkrDefs::cluskey> &keys,
0221 const std::vector<Acts::Vector3> &positions);
0222 std::vector<TrkrDefs::cluskey> matchInttClusters(std::vector<Acts::Vector3> &clusters,
0223 TrackSeed &seed,
0224 const double xProj[],
0225 const double yProj[],
0226 const double zProj[]);
0227 short int getCrossingIntt(TrackSeed &si_track);
0228 std::vector<short int> getInttCrossings(TrackSeed &si_track);
0229
0230 void createHistograms();
0231 void writeHistograms();
0232 double normPhi2Pi(const double phi);
0233 void clearTreeVariables();
0234
0235 TrkrClusterCrossingAssoc *_cluster_crossing_map = nullptr;
0236 TTree *m_tree = nullptr;
0237 int m_seedid = std::numeric_limits<int>::quiet_NaN();
0238 std::vector<float> m_mvtxgx = {};
0239 std::vector<float> m_mvtxgy = {};
0240 std::vector<float> m_mvtxgz = {};
0241 std::vector<float> m_mvtxgr = {};
0242 float m_projgx = std::numeric_limits<float>::quiet_NaN();
0243 float m_projgy = std::numeric_limits<float>::quiet_NaN();
0244 float m_projgz = std::numeric_limits<float>::quiet_NaN();
0245 float m_projgr = std::numeric_limits<float>::quiet_NaN();
0246 float m_projlx = std::numeric_limits<float>::quiet_NaN();
0247 float m_projlz = std::numeric_limits<float>::quiet_NaN();
0248 float m_clusgx = std::numeric_limits<float>::quiet_NaN();
0249 float m_clusgy = std::numeric_limits<float>::quiet_NaN();
0250 float m_clusgz = std::numeric_limits<float>::quiet_NaN();
0251 float m_clusgr = std::numeric_limits<float>::quiet_NaN();
0252 float m_cluslx = std::numeric_limits<float>::quiet_NaN();
0253 float m_cluslz = std::numeric_limits<float>::quiet_NaN();
0254
0255 ActsGeometry *m_tGeometry = nullptr;
0256 TrackSeedContainer *m_seedContainer = nullptr;
0257 TrkrClusterContainer *m_clusterMap = nullptr;
0258 PHG4CylinderGeomContainer *m_geomContainerIntt = nullptr;
0259 PHG4CylinderGeomContainer *m_geomContainerMvtx = nullptr;
0260 int m_lowStrobeIndex = 0;
0261 int m_highStrobeIndex = 1;
0262
0263 Acts::SeedFinderConfig<SpacePoint> m_seedFinderCfg;
0264 Acts::CylindricalSpacePointGridConfig m_gridCfg;
0265 Acts::CylindricalSpacePointGridOptions m_gridOptions;
0266 Acts::SeedFinderOptions m_seedFinderOptions;
0267
0268
0269
0270 bool m_streaming = false;
0271
0272
0273 float m_strobeWidth = 10;
0274
0275 bool m_searchInIntt = false;
0276
0277
0278
0279 float m_minSeedPt = 100 * Acts::UnitConstants::MeV;
0280 float m_uncfactor = 3.18;
0281
0282
0283
0284 int m_maxSeedsPerSpM = 1;
0285
0286
0287 float m_rMax = 200. * Acts::UnitConstants::mm;
0288 float m_rMin = 15. * Acts::UnitConstants::mm;
0289 float m_zMax = 500. * Acts::UnitConstants::mm;
0290 float m_zMin = -500. * Acts::UnitConstants::mm;
0291
0292
0293 float m_helixcut = 1;
0294 float m_tolerance = 1.1 * Acts::UnitConstants::mm;
0295 float m_ralign = 0;
0296 float m_zalign = 0;
0297 float m_maxPtScattering = 10;
0298 float m_sigmaScattering = 5.;
0299 float m_sigmaError = 5;
0300
0301
0302
0303 float m_gridFactor = 2.3809;
0304
0305
0306 float m_deltaRMax = 15 * Acts::UnitConstants::mm;
0307 float m_deltaRMin = 1. * Acts::UnitConstants::mm;
0308
0309 float m_cotThetaMax = 2.9;
0310
0311
0312 float m_impactMax = 20 * Acts::UnitConstants::mm;
0313
0314
0315
0316 int m_numPhiNeighbors = 1;
0317
0318
0319
0320 float m_bField = 1.4 * Acts::UnitConstants::T;
0321 std::vector<std::pair<int, int>> zBinNeighborsTop;
0322 std::vector<std::pair<int, int>> zBinNeighborsBottom;
0323 int nphineighbors = 1;
0324 std::unique_ptr<const Acts::GridBinFinder<2ul>> m_bottomBinFinder;
0325 std::unique_ptr<const Acts::GridBinFinder<2ul>> m_topBinFinder;
0326
0327 int m_event = 0;
0328
0329
0330 double m_maxSeedPCA = 2.;
0331
0332
0333 double m_inttrPhiSearchWin = 0.1;
0334 float m_inttzSearchWin = 2.0;
0335 double m_mvtxrPhiSearchWin = 0.2;
0336 float m_mvtxzSearchWin = 0.5;
0337
0338 bool m_useTruthClusters = false;
0339
0340 bool m_cleanSeeds = false;
0341
0342 int m_nBadUpdates = 0;
0343 int m_nBadInitialFits = 0;
0344 TrkrClusterIterationMap *_iteration_map = nullptr;
0345 int m_nIteration = 0;
0346 std::string _track_map_name = "SiliconTrackSeedContainer";
0347
0348 bool m_seedAnalysis = false;
0349 TFile *m_file = nullptr;
0350 TH2 *h_nInttProj = nullptr;
0351 TH1 *h_nMvtxHits = nullptr;
0352 TH1 *h_nInttHits = nullptr;
0353 TH1 *h_nMatchedClusters = nullptr;
0354 TH2 *h_nHits = nullptr;
0355 TH1 *h_nSeeds = nullptr;
0356 TH1 *h_nActsSeeds = nullptr;
0357 TH1 *h_nTotSeeds = nullptr;
0358 TH1 *h_nInputMeas = nullptr;
0359 TH1 *h_nInputMvtxMeas = nullptr;
0360 TH1 *h_nInputInttMeas = nullptr;
0361 TH2 *h_hits = nullptr;
0362 TH2 *h_zhits = nullptr;
0363 TH2 *h_projHits = nullptr;
0364 TH2 *h_zprojHits = nullptr;
0365 TH2 *h_resids = nullptr;
0366 };
0367
0368 #endif