Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GbtsSeedingTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #if defined(FLATTEN) && defined(__GNUC__)
6 // Avoid warning in dbg build
7 #pragma GCC optimize "-fno-var-tracking-assignments"
8 #endif
9 
10 #include "src/GbtsSeedingTool.h"
11 #include "CxxUtils/inline_hints.h"
12 
13 namespace ActsTrk {
14 
16  const std::string& name,
17  const IInterface* parent)
18  : base_class(type, name, parent)
19  {}
20 
22  ATH_MSG_DEBUG("Initializing " << name() << "...");
23 
24  ATH_CHECK( detStore()->retrieve(m_pixelId, "PixelID") );
25  ATH_CHECK( detStore()->retrieve(m_pixelManager, "ITkPixel") );
26 
28 
29  ATH_MSG_DEBUG("Properties Summary:");
30  ATH_MSG_DEBUG(" * Used by SeedFinderGbtsConfig");
31 
32  // Make the logger And Propagate to ACTS routines
33  m_logger = makeActsAthenaLogger(this, "Acts");
34 
36 
37  // input trig vector
38  m_finderCfg.m_layerGeometry = LayerNumbering();
39 
40  std::ifstream input_ifstream(
41  m_finderCfg.ConnectorInputFile.c_str(), std::ifstream::in); //change to connector input file
42  // connector
43  std::unique_ptr<Acts::Experimental::GbtsConnector> inputConnector =
44  std::make_unique<Acts::Experimental::GbtsConnector>(input_ifstream);
45 
46  m_gbtsGeo = std::make_unique<Acts::Experimental::GbtsGeometry<xAOD::SpacePoint>>(
47  m_finderCfg.m_layerGeometry, inputConnector);
48 
49  return StatusCode::SUCCESS;
50  }
51 
54  GbtsSeedingTool::createSeeds(const EventContext& ctx,
55  const Acts::SpacePointContainer<ActsTrk::SpacePointCollector, Acts::detail::RefHolder>& spContainer,
56  const Acts::Vector3& beamSpotPos,
57  const Acts::Vector3& bField,
58  ActsTrk::SeedContainer& seedContainer ) const
59  {
60  // Seed Finder Options
61  Acts::SeedFinderOptions finderOpts;
62  finderOpts.beamPos = Acts::Vector2(beamSpotPos[Amg::x],
63  beamSpotPos[Amg::y]);
64  finderOpts.bFieldInZ = bField[2];
65  finderOpts = finderOpts.toInternalUnits().calculateDerivedQuantities(m_finderCfg);
66 
67  // // // Compute seeds
69  ATH_CHECK(pixelDetEleHandle.isValid()) ;
70  const InDetDD::SiDetectorElementCollection* pixelElements = pixelDetEleHandle.cptr();
71 
72 
73  std::vector<Acts::Experimental::GbtsSP<xAOD::SpacePoint>> GbtsSpacePoints;
74  GbtsSpacePoints.reserve(
75  spContainer.size());
76 
77  // for loop filling space
78  for (const auto& spacePoint : spContainer) { //xaod space points
79  // loop over space points, get necessary info from athena:
80  const std::vector<xAOD::DetectorIDHashType>& elementlist = spacePoint.externalSpacePoint().elementIdList() ;
81 
82  for (const xAOD::DetectorIDHashType element : elementlist) {
83 
84  const InDetDD::SiDetectorElement* pixelElement = pixelElements->getDetectorElement(element);
85 
86  Identifier Identifier = pixelElement->identify() ;
87 
88  int eta_mod = m_pixelId->eta_module(Identifier);
89  short barrel_ec = m_pixelId->barrel_ec(Identifier);
90  int lay_id = m_pixelId->layer_disk(Identifier);
91  int combined_id = getCombinedID(eta_mod,barrel_ec,lay_id).first ;
92  int Gbts_id = getCombinedID(eta_mod,barrel_ec,lay_id).second ;
93 
94  // fill Gbts vector with current sapce point and ID
95  float ClusterWidth = 0; //for now trying to fill this
96 
97  // fill Gbts vector with current sapce point and ID
98  GbtsSpacePoints.emplace_back(&spacePoint.externalSpacePoint(), Gbts_id, combined_id, ClusterWidth);
99  //constructor takes (const space_point_t *sp,
100 
101  }
102 
103  }
104 
105  ATH_MSG_VERBOSE("Space points successfully assigned Gbts ID");
106 
107  Acts::Experimental::SeedFinderGbts<xAOD::SpacePoint> finder = Acts::Experimental::SeedFinderGbts<xAOD::SpacePoint>(m_finderCfg,*m_gbtsGeo);
108 
109  finder.loadSpacePoints(GbtsSpacePoints);
110  //temporary solution until trigger ROIs implemented
111  Acts::Experimental::RoiDescriptor internalRoi(0, -4.5, 4.5, 0, -std::numbers::pi, std::numbers::pi, 0, -150.0,150.0); //(eta,etaMinus,etaPlus,phi,phiMinus,Phiplus,z,zMinus,zPlus)
112 
113  std::vector<Acts::Seed<xAOD::SpacePoint, 3ul>> groupSeeds = finder.createSeeds(internalRoi, *m_gbtsGeo);
114 
115  // Store seeds
116 
117  seedContainer.reserve(groupSeeds.size());
118  for( Acts::Seed<xAOD::SpacePoint, 3ul>& seed: groupSeeds) {
119  //turn interim into group seeds
120 
121  const auto& spacepoints = seed.sp() ;
122  assert(spacepoints.size()==3) ;
123  const xAOD::SpacePoint* sp1 = spacepoints[0] ;
124  const xAOD::SpacePoint* sp2 = spacepoints[1] ;
125  const xAOD::SpacePoint* sp3 = spacepoints[2] ;
126 
127  std::unique_ptr<seed_type> to_add = std::make_unique<seed_type>(*sp1, *sp2, *sp3);
128  to_add->setVertexZ(seed.z());
129  to_add->setQuality(seed.seedQuality());
130  seedContainer.push_back(std::move(to_add));
131 
132  }
133 
134  return StatusCode::SUCCESS;
135  }
136 
137  // own class functions
138  std::vector<Acts::Experimental::TrigInDetSiLayer>
140  std::vector<std::size_t> count_vector;
141  std::vector<Acts::Experimental::TrigInDetSiLayer> input_vector;
142 
143  for(int hash = 0; hash<static_cast<int>(m_pixelId->wafer_hash_max()); hash++) {
144  const Identifier offlineId = m_pixelId->wafer_id(hash);
145  const int eta_mod = m_pixelId->eta_module(offlineId);
146  const short barrel_ec = m_pixelId->barrel_ec(offlineId);
147  const int lay_id = m_pixelId->layer_disk(offlineId);
148 
149  const int combined_id = getCombinedID(eta_mod,barrel_ec,lay_id).first ;
150 
151  float rc = 0.0;
152  float minBound = std::numeric_limits<float>::max();
153  float maxBound = -std::numeric_limits<float>::max();
154 
155  //want center and bounds!
157  const Amg::Vector3D C = p->center() ;
158 
159  if(barrel_ec == 0) {
160  rc += std::sqrt(C(0)*C(0)+C(1)*C(1));
161  if(p->zMin() < minBound) minBound = p->zMin();
162  if(p->zMax() > maxBound) maxBound = p->zMax();
163  }
164  else {
165  rc += C(2);
166  if(p->rMin() < minBound) minBound = p->rMin();
167  if(p->rMax() > maxBound) maxBound = p->rMax();
168  }
169 
170 
171  auto current_index =
172  find_if(input_vector.begin(), input_vector.end(),
173  [combined_id](auto n) { return n.m_subdet == combined_id; });
174  if (current_index != input_vector.end()) { // not end so does exist
175  std::size_t index = std::distance(input_vector.begin(), current_index);
176  input_vector[index].m_refCoord += rc;
177  input_vector[index].m_minBound += minBound;
178  input_vector[index].m_maxBound += maxBound;
179  count_vector[index] += 1; // increase count at the index
180 
181  } else { // end so doesn't exists
182  // make new if one with Gbts ID doesn't exist:
183  Acts::Experimental::TrigInDetSiLayer new_Gbts_ID(combined_id, barrel_ec, rc, minBound,
184  maxBound);
185  input_vector.push_back(new_Gbts_ID);
186  count_vector.push_back(
187  1); // so the element exists and not divinding by 0
188  }
189 
190  }
191  for (std::size_t i = 0; i < input_vector.size(); ++i) {
192  assert(count_vector[i] != 0);
193  input_vector[i].m_refCoord = input_vector[i].m_refCoord / count_vector[i];
194  }
195 
196  return input_vector;
197  }
198 
199  //this is called in initialise
200  StatusCode
202  {
203  // Configuration Acts::SeedFinderGbts
204 
205  m_finderCfg.minPt = m_minPt;
206  m_finderCfg.sigmaScattering = m_sigmaScattering;
207  m_finderCfg.highland = m_highland;
208  m_finderCfg.maxScatteringAngle2 = m_maxScatteringAngle2;
209  m_finderCfg.helixCutTolerance = m_helixCutTolerance ;
210  m_finderCfg.m_phiSliceWidth = m_phiSliceWidth ;
211  m_finderCfg.m_nMaxPhiSlice = m_nMaxPhiSlice;
212  m_finderCfg.m_useClusterWidth = m_useClusterWidth;
213  m_finderCfg.ConnectorInputFile = m_ConnectorInputFile;
214  m_finderCfg.m_useEtaBinning = m_useEtaBinning;
215  m_finderCfg.m_doubletFilterRZ = m_doubletFilterRZ ;
216  m_finderCfg.m_minDeltaRadius = m_minDeltaRadius;
217  m_finderCfg.m_tripletD0Max = m_tripletD0Max;
218  m_finderCfg.m_maxTripletBufferLength = m_maxTripletBufferLength;
219  m_finderCfg.MaxEdges = m_MaxEdges;
220  m_finderCfg.cut_dphi_max = m_cut_dphi_max;
221  m_finderCfg.cut_dcurv_max = m_cut_dcurv_max;
222  m_finderCfg.cut_tau_ratio_max = m_cut_tau_ratio_max;
223  m_finderCfg.maxOuterRadius = m_maxOuterRadius;
224  m_finderCfg.m_PtMin = m_PtMin;
225  m_finderCfg.m_tripletPtMinFrac = m_tripletPtMinFrac;
226  m_finderCfg.m_tripletPtMin = m_tripletPtMin;
227  m_finderCfg.ptCoeff = m_ptCoeff;
228 
229  m_finderCfg = m_finderCfg.toInternalUnits();
230 
231 
232  return StatusCode::SUCCESS;
233  }
234 
235  std::pair<int,int> GbtsSeedingTool::getCombinedID(const int eta_mod, const short barrel_ec, const int lay_id) const {
236  int vol_id = -1 ;
237  if(barrel_ec== 0) vol_id = 8;
238  if(barrel_ec==-2) vol_id = 7;
239  if(barrel_ec== 2) vol_id = 9;
240 
241  int new_vol=0, new_lay=0;
242  if(vol_id == 7 || vol_id == 9) {
243  new_vol = 10*vol_id + lay_id;
244  new_lay = eta_mod;
245  }
246  else if(vol_id == 8) {
247  new_lay = 0;
248  new_vol = 10*vol_id + lay_id;
249  }
250  //make into the form needed for acts
251  int Gbts_id = new_vol ;
252  int combined_id = new_vol * 1000 + new_lay;
253 
254  return std::make_pair(combined_id,Gbts_id) ;
255  }
256 
257 } // namespace ActsTrk
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ActsTrk::GbtsSeedingTool::initialize
virtual StatusCode initialize() override
Definition: GbtsSeedingTool.cxx:21
ActsTrk::GbtsSeedingTool::m_pixelId
const PixelID * m_pixelId
Definition: GbtsSeedingTool.h:86
inline_hints.h
InDetDD::SiDetectorElementCollection
Definition: SiDetectorElementCollection.h:30
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
index
Definition: index.py:1
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
Amg::y
@ y
Definition: GeoPrimitives.h:35
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
ActsTrk::GbtsSeedingTool::m_minPt
Gaudi::Property< float > m_minPt
Definition: GbtsSeedingTool.h:90
ActsTrk::GbtsSeedingTool::m_doubletFilterRZ
Gaudi::Property< bool > m_doubletFilterRZ
Definition: GbtsSeedingTool.h:114
xAOD::SpacePoint_v1
Definition: SpacePoint_v1.h:29
ActsTrk::GbtsSeedingTool::m_gbtsGeo
std::unique_ptr< Acts::Experimental::GbtsGeometry< xAOD::SpacePoint > > m_gbtsGeo
Definition: GbtsSeedingTool.h:84
ActsTrk::GbtsSeedingTool::m_ConnectorInputFile
Gaudi::Property< std::string > m_ConnectorInputFile
Definition: GbtsSeedingTool.h:110
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ActsTrk::GbtsSeedingTool::m_pixelManager
const InDetDD::PixelDetectorManager * m_pixelManager
Definition: GbtsSeedingTool.h:87
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
pi
#define pi
Definition: TileMuonFitter.cxx:65
ActsTrk::GbtsSeedingTool::m_MaxEdges
Gaudi::Property< int > m_MaxEdges
Definition: GbtsSeedingTool.h:118
ActsTrk::GbtsSeedingTool::m_maxScatteringAngle2
Gaudi::Property< float > m_maxScatteringAngle2
Definition: GbtsSeedingTool.h:102
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
makeActsAthenaLogger
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
Definition: Tracking/Acts/ActsInterop/src/Logger.cxx:64
ActsTrk::GbtsSeedingTool::m_minDeltaRadius
Gaudi::Property< float > m_minDeltaRadius
Definition: GbtsSeedingTool.h:115
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ActsTrk::GbtsSeedingTool::m_useClusterWidth
Gaudi::Property< bool > m_useClusterWidth
Definition: GbtsSeedingTool.h:109
GbtsSeedingTool.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
ActsTrk::GbtsSeedingTool::m_pixelDetEleCollKey
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
Definition: GbtsSeedingTool.h:165
ATH_FLATTEN
#define ATH_FLATTEN
Definition: inline_hints.h:52
beamspotman.n
n
Definition: beamspotman.py:731
ActsTrk::GbtsSeedingTool::m_useEtaBinning
Gaudi::Property< bool > m_useEtaBinning
Definition: GbtsSeedingTool.h:113
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActsTrk::GbtsSeedingTool::LayerNumbering
std::vector< Acts::Experimental::TrigInDetSiLayer > LayerNumbering() const
Definition: GbtsSeedingTool.cxx:139
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Amg::x
@ x
Definition: GeoPrimitives.h:34
ActsTrk::GbtsSeedingTool::m_maxOuterRadius
Gaudi::Property< float > m_maxOuterRadius
Definition: GbtsSeedingTool.h:122
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ActsTrk::GbtsSeedingTool::GbtsSeedingTool
GbtsSeedingTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: GbtsSeedingTool.cxx:15
ActsTrk::GbtsSeedingTool::m_phiSliceWidth
Gaudi::Property< float > m_phiSliceWidth
Definition: GbtsSeedingTool.h:107
ActsTrk::GbtsSeedingTool::m_tripletPtMinFrac
Gaudi::Property< float > m_tripletPtMinFrac
Definition: GbtsSeedingTool.h:124
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsTrk::GbtsSeedingTool::m_nMaxPhiSlice
Gaudi::Property< float > m_nMaxPhiSlice
Definition: GbtsSeedingTool.h:108
ActsTrk::GbtsSeedingTool::m_ptCoeff
Gaudi::Property< double > m_ptCoeff
Definition: GbtsSeedingTool.h:126
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
xAOD::DetectorIDHashType
unsigned int DetectorIDHashType
@ detector ID element hash
Definition: MeasurementDefs.h:43
ActsTrk::GbtsSeedingTool::getCombinedID
std::pair< int, int > getCombinedID(const int eta_mod, const short barrel_ec, const int lay_id) const
Definition: GbtsSeedingTool.cxx:235
ActsTrk::GbtsSeedingTool::m_highland
Gaudi::Property< float > m_highland
Definition: GbtsSeedingTool.h:101
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ActsTrk::GbtsSeedingTool::m_logger
std::unique_ptr< const Acts::Logger > m_logger
logging instance
Definition: GbtsSeedingTool.h:170
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ActsTrk::GbtsSeedingTool::m_PtMin
Gaudi::Property< float > m_PtMin
Definition: GbtsSeedingTool.h:123
ActsTrk::GbtsSeedingTool::m_maxTripletBufferLength
Gaudi::Property< unsigned int > m_maxTripletBufferLength
Definition: GbtsSeedingTool.h:117
ActsTrk::GbtsSeedingTool::m_finderCfg
Acts::Experimental::SeedFinderGbtsConfig< xAOD::SpacePoint > m_finderCfg
Definition: GbtsSeedingTool.h:82
ActsTrk::GbtsSeedingTool::m_cut_tau_ratio_max
Gaudi::Property< float > m_cut_tau_ratio_max
Definition: GbtsSeedingTool.h:121
ActsTrk::GbtsSeedingTool::m_cut_dcurv_max
Gaudi::Property< float > m_cut_dcurv_max
Definition: GbtsSeedingTool.h:120
DeMoScan.index
string index
Definition: DeMoScan.py:364
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ActsTrk::GbtsSeedingTool::m_sigmaScattering
Gaudi::Property< float > m_sigmaScattering
Definition: GbtsSeedingTool.h:93
ActsTrk::GbtsSeedingTool::createSeeds
virtual StatusCode createSeeds(const EventContext &ctx, const Acts::SpacePointContainer< ActsTrk::SpacePointCollector, Acts::detail::RefHolder > &spContainer, const Acts::Vector3 &beamSpotPos, const Acts::Vector3 &bField, ActsTrk::SeedContainer &seedContainer) const override
Definition: GbtsSeedingTool.cxx:54
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:55
ActsTrk::GbtsSeedingTool::m_tripletPtMin
Gaudi::Property< float > m_tripletPtMin
Definition: GbtsSeedingTool.h:125
ActsTrk::GbtsSeedingTool::m_cut_dphi_max
Gaudi::Property< float > m_cut_dphi_max
Definition: GbtsSeedingTool.h:119
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
python.TrkVertexSeedFinderToolsConfig.finder
finder
Definition: TrkVertexSeedFinderToolsConfig.py:99
InDetDD::SiDetectorElementCollection::getDetectorElement
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Definition: SiDetectorElementCollection.cxx:15
InDetDD::SolidStateDetectorElementBase::identify
virtual Identifier identify() const override final
identifier of this detector element (inline)
ActsTrk::GbtsSeedingTool::prepareConfiguration
StatusCode prepareConfiguration()
Definition: GbtsSeedingTool.cxx:201
ActsTrk::GbtsSeedingTool::m_helixCutTolerance
Gaudi::Property< float > m_helixCutTolerance
Definition: GbtsSeedingTool.h:104
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67
ActsTrk::GbtsSeedingTool::m_tripletD0Max
Gaudi::Property< float > m_tripletD0Max
Definition: GbtsSeedingTool.h:116
Identifier
Definition: IdentifierFieldParser.cxx:14