1 #ifndef RecoTracker_LSTCore_src_ModuleMethods_h 2 #define RecoTracker_LSTCore_src_ModuleMethods_h 43 }
else if (subdet ==
Barrel) {
47 }
else if (layer >= 4) {
55 }
else if (layer == 3) {
69 std::vector<unsigned int>,
71 std::vector<unsigned int>,
73 std::vector<unsigned int>>
75 std::vector<unsigned int> connectedModuleDetIds;
76 std::vector<unsigned int> connectedModuleDetIds_pos;
77 std::vector<unsigned int> connectedModuleDetIds_neg;
79 unsigned int totalSizes = 0;
80 unsigned int totalSizes_pos = 0;
81 unsigned int totalSizes_neg = 0;
82 for (
unsigned int isuperbin = 0; isuperbin <
size_superbins; isuperbin++) {
84 for (
auto const& mCM_pLS : pLStoLayer[0]) {
85 std::vector<unsigned int> connectedModuleDetIds_pLS =
87 connectedModuleDetIds.insert(
88 connectedModuleDetIds.end(), connectedModuleDetIds_pLS.begin(), connectedModuleDetIds_pLS.end());
89 sizes += connectedModuleDetIds_pLS.size();
96 for (
auto const& mCM_pLS : pLStoLayer[1]) {
97 std::vector<unsigned int> connectedModuleDetIds_pLS_pos = mCM_pLS.getConnectedModuleDetIds(isuperbin);
98 connectedModuleDetIds_pos.insert(connectedModuleDetIds_pos.end(),
99 connectedModuleDetIds_pLS_pos.begin(),
100 connectedModuleDetIds_pLS_pos.end());
101 sizes_pos += connectedModuleDetIds_pLS_pos.size();
105 totalSizes_pos += sizes_pos;
108 for (
auto const& mCM_pLS : pLStoLayer[2]) {
109 std::vector<unsigned int> connectedModuleDetIds_pLS_neg = mCM_pLS.getConnectedModuleDetIds(isuperbin);
110 connectedModuleDetIds_neg.insert(connectedModuleDetIds_neg.end(),
111 connectedModuleDetIds_pLS_neg.begin(),
112 connectedModuleDetIds_pLS_neg.end());
113 sizes_neg += connectedModuleDetIds_pLS_neg.size();
117 totalSizes_neg += sizes_neg;
120 nPixels = totalSizes + totalSizes_pos + totalSizes_neg;
123 connectedModuleDetIds,
125 connectedModuleDetIds_pos,
127 connectedModuleDetIds_neg};
134 uint16_t* nConnectedModules =
modules.nConnectedModules();
137 unsigned int detId =
it->first;
140 nConnectedModules[
index] = connectedModules.size();
141 for (uint16_t
i = 0;
i < nConnectedModules[
index];
i++) {
148 uint16_t* mapIdx =
modules.mapIdx();
149 unsigned int* mapdetId =
modules.mapdetId();
153 unsigned int detId =
it->first;
154 unsigned int index =
it->second;
162 unsigned short& layer,
163 unsigned short&
ring,
166 unsigned short& subdet,
167 unsigned short&
side,
173 subdet = (
detId & (7 << 25)) >> 25;
175 layer = (subdet ==
Endcap) ? (
detId & (7 << 18)) >> 18 : (
detId & (7 << 20)) >> 20;
178 rod = (subdet ==
Endcap) ? 0 : (
detId & (127 << 10)) >> 10;
180 r =
std::sqrt(m_x * m_x + m_y * m_y + m_z * m_z);
181 eta = ((m_z > 0) - (m_z < 0)) * std::acosh(r /
std::sqrt(m_x * m_x + m_y * m_y));
186 if (!
ifile.is_open()) {
191 while (!
ifile.eof()) {
192 unsigned int temp_detId;
193 float module_x, module_y, module_z;
196 ifile.read(reinterpret_cast<char*>(&temp_detId),
sizeof(temp_detId));
197 ifile.read(reinterpret_cast<char*>(&module_x),
sizeof(module_x));
198 ifile.read(reinterpret_cast<char*>(&module_y),
sizeof(module_y));
199 ifile.read(reinterpret_cast<char*>(&module_z),
sizeof(module_z));
200 ifile.read(reinterpret_cast<char*>(&module_type),
sizeof(module_type));
204 mmd.
module_x[temp_detId] = module_x;
205 mmd.
module_y[temp_detId] = module_y;
206 mmd.
module_z[temp_detId] = module_z;
211 throw std::runtime_error(
"Failed to read data for detId: " +
std::to_string(temp_detId));
222 const char* moduleMetaDataFilePath,
224 uint16_t& nLowerModules,
225 unsigned int& nPixels,
236 connectedModuleDetIds,
238 connectedModuleDetIds_pos,
240 connectedModuleDetIds_neg] =
getConnectedPixels(nModules, nPixels, pixelMapping, pLStoLayer);
242 std::array<int, 2>
const modules_sizes{{
static_cast<int>(nModules), static_cast<int>(nPixels)}};
246 auto modules_view = modulesHC->view<
ModulesSoA>();
249 unsigned int* host_detIds = modules_view.detIds();
250 short* host_layers = modules_view.layers();
251 short* host_rings = modules_view.rings();
252 short* host_rods = modules_view.rods();
253 short* host_modules = modules_view.modules();
254 short* host_subdets = modules_view.subdets();
255 short* host_sides = modules_view.sides();
256 float* host_eta = modules_view.eta();
257 float* host_r = modules_view.r();
258 bool* host_isInverted = modules_view.isInverted();
259 bool* host_isLower = modules_view.isLower();
260 bool* host_isAnchor = modules_view.isAnchor();
261 ModuleType* host_moduleType = modules_view.moduleType();
262 ModuleLayerType* host_moduleLayerType = modules_view.moduleLayerType();
263 float* host_dxdys = modules_view.dxdys();
264 float* host_drdzs = modules_view.drdzs();
265 uint16_t* host_nModules = &modules_view.nModules();
266 uint16_t* host_nLowerModules = &modules_view.nLowerModules();
267 uint16_t* host_partnerModuleIndices = modules_view.partnerModuleIndices();
268 int* host_lstLayers = modules_view.lstLayers();
271 nLowerModules = (nModules - 1) / 2;
272 uint16_t lowerModuleCounter = 0;
273 uint16_t upperModuleCounter = nLowerModules + 1;
276 unsigned int detId =
it->first;
286 bool isInverted, isLower;
299 setDerivedQuantities(
detId, layer,
ring, rod,
module, subdet,
side, m_x, m_y, m_z,
eta, r);
304 index = lowerModuleCounter;
305 lowerModuleCounter++;
306 }
else if (
detId != 1) {
307 index = upperModuleCounter;
308 upperModuleCounter++;
310 index = nLowerModules;
315 host_layers[
index] = layer;
317 host_rods[
index] = rod;
319 host_subdets[
index] = subdet;
323 host_isInverted[
index] = isInverted;
324 host_isLower[
index] = isLower;
330 host_dxdys[
index] = 0;
331 host_drdzs[
index] = 0;
332 host_isAnchor[
index] =
false;
338 host_isAnchor[
index] =
true;
340 host_isAnchor[
index] =
true;
342 host_isAnchor[
index] =
false;
349 host_lstLayers[
index] =
358 host_partnerModuleIndices[
index] =
361 if (host_drdzs[
index] == 0) {
362 host_drdzs[
index] = host_drdzs[host_partnerModuleIndices[
index]];
364 if (host_dxdys[
index] == 0) {
365 host_dxdys[
index] = host_dxdys[host_partnerModuleIndices[
index]];
370 *host_nModules = nModules;
371 *host_nLowerModules = nLowerModules;
377 auto connectedPixels =
379 for (
unsigned int icondet = 0; icondet < totalSizes; icondet++) {
380 connectedPixels[icondet] = mmd.
detIdToIndex.at(connectedModuleDetIds[icondet]);
382 for (
unsigned int icondet = 0; icondet < totalSizes_pos; icondet++) {
383 connectedPixels[icondet + totalSizes] = mmd.
detIdToIndex.at(connectedModuleDetIds_pos[icondet]);
385 for (
unsigned int icondet = 0; icondet < totalSizes_neg; icondet++) {
386 connectedPixels[icondet + totalSizes + totalSizes_pos] = mmd.
detIdToIndex.at(connectedModuleDetIds_neg[icondet]);
std::shared_ptr< ModulesHostCollection > loadModulesFromFile(MapPLStoLayer const &pLStoLayer, const char *moduleMetaDataFilePath, uint16_t &nModules, uint16_t &nLowerModules, unsigned int &nPixels, PixelMap &pixelMapping, const EndcapGeometry &endcapGeometry, const TiltedGeometry &tiltedGeometry, const ModuleConnectionMap &moduleConnectionMap)
void loadCentroidsFromFile(const char *filePath, ModuleMetaData &mmd, uint16_t &nModules)
std::vector< unsigned int > connectedPixelsIndexNeg
ALPAKA_FN_ACC int side(int ieta, int iphi)
unsigned int parsePartnerModuleId(unsigned int detId, bool isLowerx, bool isInvertedx)
bool parseIsInverted(short subdet, short side, short module, short layer)
std::vector< unsigned int > connectedPixelsIndex
static std::string to_string(const XMLCh *ch)
std::vector< unsigned int > connectedPixelsSizes
void fillConnectedModuleArrayExplicit(Modules modules, ModuleMetaData const &mmd, ModuleConnectionMap const &moduleConnectionMap)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
filePath
CUSTOMIZE FOR ML.
const std::vector< unsigned int > & getConnectedModuleDetIds(unsigned int detid) const
float getdxdy_slope(unsigned int detid) const
void setDerivedQuantities(unsigned int detId, unsigned short &layer, unsigned short &ring, unsigned short &rod, unsigned short &module, unsigned short &subdet, unsigned short &side, float m_x, float m_y, float m_z, float &eta, float &r)
std::tuple< unsigned int, std::vector< unsigned int >, unsigned int, std::vector< unsigned int >, unsigned int, std::vector< unsigned int > > getConnectedPixels(uint16_t nModules, unsigned int &nPixels, PixelMap &pixelMapping, MapPLStoLayer const &pLStoLayer)
std::vector< unsigned int > connectedPixelsSizesNeg
std::array< std::array< ModuleConnectionMap, 4 >, 3 > MapPLStoLayer
void fillMapArraysExplicit(Modules modules, ModuleMetaData const &mmd)
uint16_t pixelModuleIndex
static std::atomic< unsigned int > counter
std::vector< unsigned int > connectedPixelsIndexPos
bool parseIsLower(bool isInvertedx, unsigned int detId)
float getDrDz(unsigned int detid) const
constexpr unsigned int size_superbins
float getDxDy(unsigned int detid) const
std::vector< unsigned int > connectedPixelsSizesPos