From 729b6d96120d350d4bd2ebe12cc13e87c99f2aee Mon Sep 17 00:00:00 2001 From: Slava Krutelyov Date: Tue, 14 Nov 2023 15:04:38 -0800 Subject: [PATCH] make modules data pointers const --- SDL/Hit.h | 2 +- SDL/MiniDoublet.h | 4 ++-- SDL/Module.h | 56 +++++++++++++++++++++++----------------------- SDL/PixelTriplet.h | 4 ++-- SDL/Quintuplet.h | 2 +- SDL/Segment.h | 4 ++-- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/SDL/Hit.h b/SDL/Hit.h index 6dcc2139..c8ae8f1c 100644 --- a/SDL/Hit.h +++ b/SDL/Hit.h @@ -185,7 +185,7 @@ namespace SDL }; ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE int binary_search( - unsigned int *data, // Array that we are searching over + const unsigned int *data, // Array that we are searching over unsigned int search_val, // Value we want to find in data array unsigned int ndata) // Number of elements in data array { diff --git a/SDL/MiniDoublet.h b/SDL/MiniDoublet.h index 74d5a4d5..00214401 100644 --- a/SDL/MiniDoublet.h +++ b/SDL/MiniDoublet.h @@ -448,11 +448,11 @@ namespace SDL float drprime; // The radial shift size in x-y plane projection float drprime_x; // x-component of drprime float drprime_y; // y-component of drprime - float& slope = modulesInGPU.slopes[lowerModuleIndex]; // The slope of the possible strip hits for a given module in x-y plane + const float& slope = modulesInGPU.slopes[lowerModuleIndex]; // The slope of the possible strip hits for a given module in x-y plane float absArctanSlope; float angleM; // the angle M is the angle of rotation of the module in x-y plane if the possible strip hits are along the x-axis, then angleM = 0, and if the possible strip hits are along y-axis angleM = 90 degrees float absdzprime; // The distance between the two points after shifting - float& drdz_ = modulesInGPU.drdzs[lowerModuleIndex]; + const float& drdz_ = modulesInGPU.drdzs[lowerModuleIndex]; // Assign hit pointers based on their hit type if (modulesInGPU.moduleType[lowerModuleIndex] == PS) { diff --git a/SDL/Module.h b/SDL/Module.h index 5882ae31..99ebda26 100644 --- a/SDL/Module.h +++ b/SDL/Module.h @@ -185,33 +185,33 @@ namespace SDL struct modules { - unsigned int* detIds; - uint16_t* moduleMap; - unsigned int* mapdetId; - uint16_t* mapIdx; - uint16_t* nConnectedModules; - float* drdzs; - float* slopes; - uint16_t *nModules; - uint16_t *nLowerModules; - uint16_t* partnerModuleIndices; - - short* layers; - short* rings; - short* modules; - short* rods; - short* subdets; - short* sides; - float* eta; - float* r; - bool* isInverted; - bool* isLower; - bool* isAnchor; - ModuleType* moduleType; - ModuleLayerType* moduleLayerType; - int* sdlLayers; - - unsigned int* connectedPixels; + const unsigned int* detIds; + const uint16_t* moduleMap; + const unsigned int* mapdetId; + const uint16_t* mapIdx; + const uint16_t* nConnectedModules; + const float* drdzs; + const float* slopes; + const uint16_t *nModules; + const uint16_t *nLowerModules; + const uint16_t* partnerModuleIndices; + + const short* layers; + const short* rings; + const short* modules; + const short* rods; + const short* subdets; + const short* sides; + const float* eta; + const float* r; + const bool* isInverted; + const bool* isLower; + const bool* isAnchor; + const ModuleType* moduleType; + const ModuleLayerType* moduleLayerType; + const int* sdlLayers; + + const unsigned int* connectedPixels; static bool parseIsInverted(short subdet, short side, short module, short layer) { @@ -284,7 +284,7 @@ namespace SDL }; template - void setData(TBuff& modulesbuf) + void setData(const TBuff& modulesbuf) { detIds = alpaka::getPtrNative(modulesbuf.detIds_buf); moduleMap = alpaka::getPtrNative(modulesbuf.moduleMap_buf); diff --git a/SDL/PixelTriplet.h b/SDL/PixelTriplet.h index a209ec90..47ad9743 100644 --- a/SDL/PixelTriplet.h +++ b/SDL/PixelTriplet.h @@ -1894,7 +1894,7 @@ namespace SDL moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; + const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; slopes[i] = modulesInGPU.slopes[lowerModuleIndices[i]]; //category 1 - barrel PS flat if(moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) @@ -2220,7 +2220,7 @@ namespace SDL const int moduleSubdet = modulesInGPU.subdets[lowerModuleIndex]; residual = (moduleSubdet == SDL::Barrel) ? (zs[i] - zPix[0]) - slope * (rts[i] - rtPix[0]) : (rts[i] - rtPix[0]) - (zs[i] - zPix[0])/slope; - float& drdz = modulesInGPU.drdzs[lowerModuleIndex]; + const float& drdz = modulesInGPU.drdzs[lowerModuleIndex]; //PS Modules if(moduleType == 0) { diff --git a/SDL/Quintuplet.h b/SDL/Quintuplet.h index 32c4352d..0d798330 100644 --- a/SDL/Quintuplet.h +++ b/SDL/Quintuplet.h @@ -1048,7 +1048,7 @@ namespace SDL moduleType = modulesInGPU.moduleType[lowerModuleIndices[i]]; moduleSubdet = modulesInGPU.subdets[lowerModuleIndices[i]]; moduleSide = modulesInGPU.sides[lowerModuleIndices[i]]; - float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; + const float& drdz = modulesInGPU.drdzs[lowerModuleIndices[i]]; slopes[i] = modulesInGPU.slopes[lowerModuleIndices[i]]; //category 1 - barrel PS flat if(moduleSubdet == Barrel and moduleType == PS and moduleSide == Center) diff --git a/SDL/Segment.h b/SDL/Segment.h index f3160307..0b9f0a71 100644 --- a/SDL/Segment.h +++ b/SDL/Segment.h @@ -289,8 +289,8 @@ namespace SDL bool isInnerTilted = modulesInGPU.subdets[innerLowerModuleIndex] == SDL::Barrel and modulesInGPU.sides[innerLowerModuleIndex] != SDL::Center; bool isOuterTilted = modulesInGPU.subdets[outerLowerModuleIndex] == SDL::Barrel and modulesInGPU.sides[outerLowerModuleIndex] != SDL::Center; - float& drdzInner = modulesInGPU.drdzs[innerLowerModuleIndex]; - float& drdzOuter = modulesInGPU.drdzs[outerLowerModuleIndex]; + const float& drdzInner = modulesInGPU.drdzs[innerLowerModuleIndex]; + const float& drdzOuter = modulesInGPU.drdzs[outerLowerModuleIndex]; float innerModuleGapSize = SDL::moduleGapSize_seg(modulesInGPU, innerLowerModuleIndex); float outerModuleGapSize = SDL::moduleGapSize_seg(modulesInGPU, outerLowerModuleIndex); const float innerminiTilt = isInnerTilted ? (0.5f * pixelPSZpitch * drdzInner / alpaka::math::sqrt(acc, 1.f + drdzInner * drdzInner) / innerModuleGapSize) : 0;