Skip to content

Commit

Permalink
General code cleanup
Browse files Browse the repository at this point in the history
General clean up of the pixel local reconstructon code:
  - improve comments, remove commented out code and obsolete comments
  - replace std::cout with LogDebug
  - update variable names to follow the coding rules
  - reuse existing constants
  - remove some obsolete code
  • Loading branch information
fwyzard committed Dec 16, 2020
1 parent 9dc3931 commit b7c5879
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ SiPixelROCsStatusAndMappingWrapper::SiPixelROCsStatusAndMappingWrapper(SiPixelFe
cablingMapHost->link[index] = link;
cablingMapHost->roc[index] = roc;
if (pixelRoc != nullptr) {
cablingMapHost->RawId[index] = pixelRoc->rawId();
cablingMapHost->rawId[index] = pixelRoc->rawId();
cablingMapHost->rocInDet[index] = pixelRoc->idInDetUnit();
modToUnpDefault[index] = false;
if (badPixelInfo != nullptr)
cablingMapHost->badRocs[index] = badPixelInfo->IsRocBad(pixelRoc->rawId(), pixelRoc->idInDetUnit());
else
cablingMapHost->badRocs[index] = false;
} else { // store some dummy number
cablingMapHost->RawId[index] = 9999;
cablingMapHost->rawId[index] = 9999;
cablingMapHost->rocInDet[index] = 9999;
cablingMapHost->badRocs[index] = true;
modToUnpDefault[index] = true;
Expand All @@ -62,23 +62,23 @@ SiPixelROCsStatusAndMappingWrapper::SiPixelROCsStatusAndMappingWrapper(SiPixelFe
} // end of FED loop

// Given FedId, Link and idinLnk; use the following formula
// to get the RawId and idinDU
// to get the rawId and idinDU
// index = (FedID-1200) * MAX_LINK* MAX_ROC + (Link-1)* MAX_ROC + idinLnk;
// where, MAX_LINK = 48, MAX_ROC = 8 for Phase1 as mentioned Danek's email
// FedID varies between 1200 to 1338 (In total 108 FED's)
// Link varies between 1 to 48
// idinLnk varies between 1 to 8

for (int i = 1; i < index; i++) {
if (cablingMapHost->RawId[i] == 9999) {
if (cablingMapHost->rawId[i] == 9999) {
cablingMapHost->moduleId[i] = 9999;
} else {
/*
std::cout << cablingMapHost->RawId[i] << std::endl;
std::cout << cablingMapHost->rawId[i] << std::endl;
*/
auto gdet = trackerGeom.idToDetUnit(cablingMapHost->RawId[i]);
auto gdet = trackerGeom.idToDetUnit(cablingMapHost->rawId[i]);
if (!gdet) {
LogDebug("SiPixelROCsStatusAndMapping") << " Not found: " << cablingMapHost->RawId[i] << std::endl;
LogDebug("SiPixelROCsStatusAndMapping") << " Not found: " << cablingMapHost->rawId[i] << std::endl;
continue;
}
cablingMapHost->moduleId[i] = gdet->index();
Expand All @@ -89,7 +89,7 @@ SiPixelROCsStatusAndMappingWrapper::SiPixelROCsStatusAndMappingWrapper(SiPixelFe
<< i << std::setw(20) << cablingMapHost->fed[i] << std::setw(20) << cablingMapHost->link[i] << std::setw(20)
<< cablingMapHost->roc[i] << std::endl;
LogDebug("SiPixelROCsStatusAndMapping")
<< i << std::setw(20) << cablingMapHost->RawId[i] << std::setw(20) << cablingMapHost->rocInDet[i]
<< i << std::setw(20) << cablingMapHost->rawId[i] << std::setw(20) << cablingMapHost->rocInDet[i]
<< std::setw(20) << cablingMapHost->moduleId[i] << std::endl;
LogDebug("SiPixelROCsStatusAndMapping")
<< i << std::setw(20) << (bool)cablingMapHost->badRocs[i] << std::setw(20) << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct SiPixelROCsStatusAndMapping {
alignas(128) unsigned int fed[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int link[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int roc[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int RawId[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int rawId[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int rocInDet[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned int moduleId[pixelgpudetails::MAX_SIZE];
alignas(128) unsigned char badRocs[pixelgpudetails::MAX_SIZE];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// CMSSW includes
#include "CUDADataFormats/SiPixelCluster/interface/gpuClusteringConstants.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelROCsStatusAndMapping.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
#include "HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h"
Expand All @@ -46,7 +48,7 @@ namespace pixelgpudetails {
const cms_uint32_t *src,
unsigned int length) {
std::memcpy(word_.get() + wordCounterGPU, src, sizeof(cms_uint32_t) * length);
std::memset(fedId_.get() + wordCounterGPU / 2, fedId - 1200, length / 2);
std::memset(fedId_.get() + wordCounterGPU / 2, fedId - FEDNumbering::MINSiPixeluTCAFEDID, length / 2);
}

////////////////////
Expand All @@ -59,15 +61,15 @@ namespace pixelgpudetails {

__device__ uint32_t getADC(uint32_t ww) { return ((ww >> pixelgpudetails::ADC_shift) & pixelgpudetails::ADC_mask); }

__device__ bool isBarrel(uint32_t rawId) { return (1 == ((rawId >> 25) & 0x7)); }
__device__ bool isBarrel(uint32_t rawId) { return (PixelSubdetector::PixelBarrel == ((rawId >> DetId::kSubdetOffset) & DetId::kSubdetMask)); }

__device__ pixelgpudetails::DetIdGPU getRawId(const SiPixelROCsStatusAndMapping *cablingMap,
uint8_t fed,
uint32_t link,
uint32_t roc) {
uint32_t index = fed * MAX_LINK * MAX_ROC + (link - 1) * MAX_ROC + roc;
pixelgpudetails::DetIdGPU detId = {
cablingMap->RawId[index], cablingMap->rocInDet[index], cablingMap->moduleId[index]};
cablingMap->rawId[index], cablingMap->rocInDet[index], cablingMap->moduleId[index]};
return detId;
}

Expand Down Expand Up @@ -137,16 +139,14 @@ namespace pixelgpudetails {

uint32_t gRow = rowOffset + slopeRow * local.row;
uint32_t gCol = colOffset + slopeCol * local.col;
//printf("Inside frameConversion row: %u, column: %u\n", gRow, gCol);
// inside frameConversion row: gRow, column: gCol
pixelgpudetails::Pixel global = {gRow, gCol};
return global;
}

__device__ uint8_t conversionError(uint8_t fedId, uint8_t status, bool debug = false) {
uint8_t errorType = 0;

// debug = true;

switch (status) {
case (1): {
if (debug)
Expand Down Expand Up @@ -181,11 +181,8 @@ namespace pixelgpudetails {
}

__device__ bool rocRowColIsValid(uint32_t rocRow, uint32_t rocCol) {
uint32_t numRowsInRoc = 80;
uint32_t numColsInRoc = 52;

/// row and collumn in ROC representation
return ((rocRow < numRowsInRoc) & (rocCol < numColsInRoc));
/// row and column in ROC representation
return ((rocRow < pixelgpudetails::numRowsInRoc) & (rocCol < pixelgpudetails::numColsInRoc));
}

__device__ bool dcolIsValid(uint32_t dcol, uint32_t pxid) { return ((dcol < 26) & (2 <= pxid) & (pxid < 162)); }
Expand Down Expand Up @@ -287,7 +284,7 @@ namespace pixelgpudetails {
//cabling.pxid = 2;
uint32_t roc = 1;
uint32_t link = (errWord >> pixelgpudetails::LINK_shift) & pixelgpudetails::LINK_mask;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).RawId;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).rawId;
if (rID_temp != 9999)
rID = rID_temp;
break;
Expand Down Expand Up @@ -323,7 +320,7 @@ namespace pixelgpudetails {
//cabling.pxid = 2;
uint32_t roc = 1;
uint32_t link = chanNmbr;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).RawId;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).rawId;
if (rID_temp != 9999)
rID = rID_temp;
break;
Expand All @@ -334,7 +331,7 @@ namespace pixelgpudetails {
//cabling.pxid = 2;
uint32_t roc = (errWord >> pixelgpudetails::ROC_shift) & pixelgpudetails::ROC_mask;
uint32_t link = (errWord >> pixelgpudetails::LINK_shift) & pixelgpudetails::LINK_mask;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).RawId;
uint32_t rID_temp = getRawId(cablingMap, fedId, link, roc).rawId;
if (rID_temp != 9999)
rID = rID_temp;
break;
Expand Down Expand Up @@ -397,7 +394,7 @@ namespace pixelgpudetails {
continue;
}

uint32_t rawId = detId.RawId;
uint32_t rawId = detId.rawId;
uint32_t rocIdInDetUnit = detId.rocInDet;
bool barrel = isBarrel(rawId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace pixelgpudetails {
const uint32_t OMIT_ERR_mask = ~(~uint32_t(0) << OMIT_ERR_bits);

struct DetIdGPU {
uint32_t RawId;
uint32_t rawId;
uint32_t rocInDet;
uint32_t moduleId;
};
Expand Down Expand Up @@ -207,19 +207,6 @@ namespace pixelgpudetails {
SiPixelDigiErrorsCUDA digiErrors_d;
};

// see RecoLocalTracker/SiPixelClusterizer
// all are runtime const, should be specified in python _cfg.py
struct ADCThreshold {
const int thePixelThreshold = 1000; // default Pixel threshold in electrons
const int theSeedThreshold = 1000; // seed thershold in electrons not used in our algo
const float theClusterThreshold = 4000; // cluster threshold in electron
const int ConversionFactor = 65; // adc to electron conversion factor

const int theStackADC_ = 255; // the maximum adc count for stack layer
const int theFirstStack_ = 5; // the index of the fits stack layer
const double theElectronPerADCGain_ = 600; // ADC to electron conversion
};

} // namespace pixelgpudetails

#endif // RecoLocalTracker_SiPixelClusterizer_plugins_SiPixelRawToClusterGPUKernel_h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace gpuClustering {
}

__global__
// __launch_bounds__(256,4)
void
findClus(uint16_t const* __restrict__ id, // module id of each pixel
uint16_t const* __restrict__ x, // local coordinates of each pixel
Expand Down
4 changes: 2 additions & 2 deletions RecoLocalTracker/SiPixelRecHits/src/PixelCPEFast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ void PixelCPEFast::errorFromTemplates(DetParam const& theDetParam,
float dummy;

SiPixelGenError gtempl(thePixelGenError_);
int gtemplID_ = theDetParam.detTemplateId;
int gtemplID = theDetParam.detTemplateId;

theClusterParam.qBin_ = gtempl.qbin(gtemplID_,
theClusterParam.qBin_ = gtempl.qbin(gtemplID,
theClusterParam.cotalpha,
theClusterParam.cotbeta,
locBz,
Expand Down

0 comments on commit b7c5879

Please sign in to comment.