Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
219 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
--- | ||
macs -nw 2 --- | ||
Language: Cpp | ||
BasedOnStyle: Google | ||
ColumnLimit: 120 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
<use name="FWCore/MessageLogger"/> | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/Utilities"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
<use name="RecoLocalCalo/HGCalRecProducers"/> | ||
<use name="Geometry/HGCalGeometry"/> | ||
<use name="Geometry/HGCalCommonData"/> | ||
<use name="CondFormats/DataRecord"/> | ||
<use name="clhep"/> | ||
<use name="cuda"/> | ||
<use name="FWCore/MessageLogger"/> | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/Utilities"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="FWCore/ServiceRegistry"/> | ||
<use name="Geometry/HGCalGeometry"/> | ||
<use mame="Geometry/HGCalCommonData"/> | ||
<use name="CondFormats/DataRecord"/> | ||
<use name="CondFormats/HGCalObjects"/> | ||
<use name="DataFormats/HGCRecHit"/> | ||
<use name="DataFormats/ForwardDetId"/> | ||
<use name="CommonTools/UtilAlgos"/> | ||
<use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
<use name="HeterogeneousCore/CUDACore"/> | ||
<use name="HeterogeneousCore/CUDAUtilities"/> | ||
<use name="clhep"/> | ||
<export> | ||
<lib name="1"/> | ||
<lib name="1"/> | ||
</export> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<use name="cuda"/> | ||
<use name="HeterogeneousCore/CUDACore"/> | ||
<use name="HeterogeneousCore/CUDAUtilities"/> | ||
<use name="Geometry/CaloGeometry"/> | ||
<use name="FWCore/Framework"/> | ||
<use name="FWCore/Utilities"/> | ||
<use name="FWCore/ParameterSet"/> | ||
<use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
<use name="RecoLocalCalo/HGCalRecProducers"/> | ||
<use name="DataFormats/HGCDigi"/> | ||
<use name="DataFormats/HGCRecHit"/> | ||
<use name="DataFormats/HcalDetId"/> | ||
<use name="Geometry/CaloGeometry"/> | ||
<use name="Geometry/HGCalGeometry"/> | ||
<use name="Geometry/HGCalCommonData"/> | ||
<use name="RecoLocalCalo/HGCalRecAlgos"/> | ||
<use name="RecoLocalCalo/HGCalESProducers"/> | ||
<use name="FWCore/MessageLogger"/> | ||
<use name="CondFormats/DataRecord"/> | ||
<use name="CondFormats/HGCalObjects"/> | ||
<use name="PhysicsTools/UtilAlgos"/> | ||
<library file="*.cc *.cu" name="RecoLocalCaloHGCalESProducersPlugins"> | ||
<flags EDM_PLUGIN="1"/> | ||
</library> |
72 changes: 72 additions & 0 deletions
72
RecoLocalCalo/HGCalESProducers/plugins/HGCalCellPositionsKernelImpl.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
#include <inttypes.h> | ||
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" | ||
#include "RecoLocalCalo/HGCalESProducers/plugins/HGCalCellPositionsKernelImpl.cuh" | ||
|
||
__global__ | ||
void fill_positions_from_detids(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds) | ||
{ | ||
unsigned int tid = blockDim.x * blockIdx.x + threadIdx.x; | ||
|
||
for (unsigned int i = tid; i < conds->nelems_posmap; i += blockDim.x * gridDim.x) | ||
{ | ||
HeterogeneousHGCSiliconDetId did(conds->posmap.detid[i]); | ||
const float cU = static_cast<float>( did.cellU() ); | ||
const float cV = static_cast<float>( did.cellV() ); | ||
const float wU = static_cast<float>( did.waferU() ); | ||
const float wV = static_cast<float>( did.waferV() ); | ||
const float ncells = static_cast<float>( did.nCells() ); | ||
const int32_t layer = did.layer(); | ||
|
||
//based on `std::pair<float, float> HGCalDDDConstants::locateCell(const HGCSiliconDetId&, bool) | ||
const float r_x2 = conds->posmap.waferSize + conds->posmap.sensorSeparation; | ||
const float r = 0.5f * r_x2; | ||
const float sqrt3 = __fsqrt_rn(3.f); | ||
const float rsqrt3 = __frsqrt_rn(3.f); //rsqrt: 1 / sqrt | ||
const float R = r_x2 * rsqrt3; | ||
const float n2 = ncells / 2.f; | ||
const float yoff_abs = rsqrt3 * r_x2; | ||
const float yoff = (layer%2==1) ? yoff_abs : -1.f * yoff_abs; //CHANGE according to Sunanda's reply | ||
float xpos = (-2.f * wU + wV) * r; | ||
float ypos = yoff + (1.5f * wV * R); | ||
const float R1 = __fdividef( conds->posmap.waferSize, 3.f * ncells ); | ||
const float r1_x2 = R1 * sqrt3; | ||
xpos += (1.5f * (cV - ncells) + 1.f) * R1; | ||
ypos += (cU - 0.5f * cV - n2) * r1_x2; | ||
|
||
conds->posmap.x[i] = xpos; //* side; multiply by -1 if one wants to obtain the position from the opposite endcap. CAREFUL WITH LATER DETECTOR ALIGNMENT!!! | ||
conds->posmap.y[i] = ypos; | ||
} | ||
} | ||
|
||
__global__ | ||
void print_positions_from_detids(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds) | ||
{ | ||
unsigned int tid = blockDim.x * blockIdx.x + threadIdx.x; | ||
|
||
for (unsigned int i = tid; i < conds->nelems_posmap; i += blockDim.x * gridDim.x) | ||
{ | ||
HeterogeneousHGCSiliconDetId did(conds->posmap.detid[i]); | ||
const int32_t layer = did.layer(); | ||
float posz = conds->posmap.z_per_layer[ layer-1 ]; | ||
printf("PosX: %lf\t PosY: %lf\t Posz: %lf\n", conds->posmap.x[i], conds->posmap.y[i], posz); | ||
} | ||
} | ||
|
||
__global__ | ||
void test(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds) | ||
{ | ||
unsigned int tid = blockDim.x * blockIdx.x + threadIdx.x; | ||
|
||
if(tid == 0) | ||
{ | ||
printf("Nelems: %u\n", static_cast<unsigned>(conds->nelems_posmap)); | ||
for(unsigned i=0; i<10; ++i) | ||
{ | ||
printf("%lf ", conds->posmap.z_per_layer[i]); | ||
printf("%lf ", conds->posmap.x[i]); | ||
printf("\n"); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
RecoLocalCalo/HGCalESProducers/plugins/HGCalCellPositionsKernelImpl.cuh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef RecoLocalCalo_HGCalESProducers_HGCalCellPositionsKernelImpl_cuh | ||
#define RecoLocalCalo_HGCalESProducers_HGCalCellPositionsKernelImpl_cuh | ||
|
||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
|
||
#include "CUDADataFormats/HGCal/interface/HGCConditions.h" | ||
#include "RecoLocalCalo/HGCalESProducers/plugins/KernelManagerHGCalCellPositions.h" | ||
|
||
__global__ | ||
void fill_positions_from_detids(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds); | ||
|
||
__global__ | ||
void print_positions_from_detids(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds); | ||
|
||
__global__ | ||
void test(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* conds); | ||
|
||
#endif //RecoLocalCalo_HGCalESProducers_HGCalCellPositionsKernelImpl_cuh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
RecoLocalCalo/HGCalESProducers/plugins/KernelManagerHGCalCellPositions.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
#include <inttypes.h> | ||
#include "RecoLocalCalo/HGCalESProducers/plugins/KernelManagerHGCalCellPositions.h" | ||
#include "RecoLocalCalo/HGCalESProducers/plugins/HGCalCellPositionsKernelImpl.cuh" | ||
|
||
KernelManagerHGCalCellPositions::KernelManagerHGCalCellPositions(const size_t& nelems) | ||
{ | ||
::nb_celpos_ = (nelems + ::nt_celpos_.x - 1) / ::nt_celpos_.x; | ||
} | ||
|
||
void KernelManagerHGCalCellPositions::fill_positions(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* d_conds) | ||
{ | ||
fill_positions_from_detids<<<::nb_celpos_,::nt_celpos_>>>(d_conds); | ||
cudaCheck( cudaGetLastError() ); | ||
} | ||
|
||
void KernelManagerHGCalCellPositions::test_cell_positions(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct* d_conds) | ||
{ | ||
test<<<::nb_celpos_,::nt_celpos_>>>(d_conds); | ||
cudaCheck( cudaGetLastError() ); | ||
} |
37 changes: 37 additions & 0 deletions
37
RecoLocalCalo/HGCalESProducers/plugins/KernelManagerHGCalCellPositions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef RecoLocalCalo_HGCalESProducers_KernelManagerHGCalCellPositions_h | ||
#define RecoLocalCalo_HGCalESProducers_KernelManagerHGCalCellPositions_h | ||
|
||
#include "FWCore/Utilities/interface/Exception.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/MessageLogger.h" | ||
#include "DataFormats/DetId/interface/DetId.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h" | ||
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h" | ||
#include "RecoLocalCalo/HGCalESProducers/plugins/HGCalCellPositionsKernelImpl.cuh" | ||
#include "CUDADataFormats/HGCal/interface/HGCConditions.h" | ||
|
||
#include <vector> | ||
#include <algorithm> //std::swap | ||
#include <variant> | ||
#include <cuda.h> | ||
#include <cuda_runtime.h> | ||
|
||
/* | ||
#ifdef __CUDA_ARCH__ | ||
extern __constant__ uint32_t calo_rechit_masks[]; | ||
#endif | ||
*/ | ||
|
||
namespace { //kernel parameters | ||
dim3 nb_celpos_; | ||
constexpr dim3 nt_celpos_(256); | ||
} | ||
|
||
class KernelManagerHGCalCellPositions { | ||
public: | ||
KernelManagerHGCalCellPositions(const size_t&); | ||
|
||
void fill_positions(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct*); | ||
void test_cell_positions(const hgcal_conditions::HeterogeneousHEFCellPositionsConditionsESProduct*); | ||
}; | ||
|
||
#endif //RecoLocalCalo_HGCalESProducers_KernelManagerHGCalCellPositions_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.