Geometry/HGCalCommonData/test/HGCalCellUVTester.cc
// ------------ method called to produce the data  ------------
method called to produce the data
method called to produce the data
void HGCalCellUVTester::analyze(const edm::Event&, const edm::EventSetup&) {
  const int nFine(12), nCoarse(8);
  HGCalCellUV wafer(waferSize_, 0.0, nFine, nCoarse);
  HGCalCell wafer2(waferSize_, nFine, nCoarse);
  double r2 = 0.5 * waferSize_;
  double R2 = 2 * r2 / sqrt(3);
  int nCells = (waferType_ == 0) ? nFine : nCoarse;
  int indexMin = (placeIndex_ >= 0) ? placeIndex_ : 0;
  int indexMax = (placeIndex_ >= 0) ? placeIndex_ : 11;
  edm::LogVerbatim("HGCalGeom") << "\nHGCalCellUVTester:: nCells " << nCells << " and placement index between "
                                << indexMin << " and " << indexMax << "\n\n";
  auto start_t = std::chrono::high_resolution_clock::now();
  for (int i = 0; i < 100000; i++) {
    double xi = (2 * r2 * (float)rand() / RAND_MAX) - r2;
    double yi = (2 * R2 * (float)rand() / RAND_MAX) - R2;
    double c1 = yi + xi / sqrt(3);
    double c2 = yi - (xi / sqrt(3));
    if ((xi < r2) && (xi > -1 * r2) && (c1 < R2) && (c1 > -1 * R2) && (c2 < R2) &&
        (c2 > -1 * R2)) {  
      std::pair<int32_t, int32_t> uv1 = wafer.cellUVFromXY1(xi, yi, placeIndex_, waferType_, 0, 0);
      std::pair<int32_t, int32_t> uv2 = wafer.cellUVFromXY2(xi, yi, placeIndex_, waferType_, 0, 0);
      std::pair<int32_t, int32_t> uv3 = wafer.cellUVFromXY3(xi, yi, placeIndex_, waferType_, 1, 0);
      std::string comment = ((uv1.first != uv3.first) || (uv2.first != uv3.first) || (uv1.second != uv3.second) ||
                             (uv2.second != uv3.second))
                                ? " ***** ERROR *****"
                                : "";
      edm::LogVerbatim("HGCalGeom") << "x = " << xi << " y = " << yi << " type = " << waferType_ << " placement index "
                                    << placeIndex_ << " u " << uv1.first << ":" << uv2.first << ":" << uv3.first
                                    << " v " << uv1.second << ":" << uv2.second << ":" << uv3.second << ":" << comment;
    }
  }
  auto end_t = std::chrono::high_resolution_clock::now();
  auto diff_t = end_t - start_t;
  edm::LogVerbatim("HGCalGeom") << "Execution time for 100000 events = "
                                << std::chrono::duration<double, std::milli>(diff_t).count() << " ms";
}
void HGCalCellUVTester :: analyze ( const edm :: Event & , const edm :: EventSetup & ) { const int nFine ( 12 ) , nCoarse ( 8 ) ; HGCalCellUV wafer ( waferSize_ , 0.0 , nFine , nCoarse ) ; HGCalCell wafer2 ( waferSize_ , nFine , nCoarse ) ; double r2 = 0.5 * waferSize_ ; double R2 = 2 * r2 / sqrt ( 3 ) ; int nCells = ( waferType_ == 0 ) ? nFine : nCoarse ; int indexMin = ( placeIndex_ >= 0 ) ? placeIndex_ : 0 ; int indexMax = ( placeIndex_ >= 0 ) ? placeIndex_ : 11 ; edm :: LogVerbatim ( " " ) << " \n " << nCells << " " << indexMin << " " << indexMax << " \n \n " ; auto start_t = std :: chrono :: high_resolution_clock :: now ( ) ; for ( int i = 0 ; i < 100000 ; i ++ ) { double xi = ( 2 * r2 * ( float ) rand ( ) / RAND_MAX ) - r2 ; double yi = ( 2 * R2 * ( float ) rand ( ) / RAND_MAX ) - R2 ; double c1 = yi + xi / sqrt ( 3 ) ; double c2 = yi - ( xi / sqrt ( 3 ) ) ; if ( ( xi < r2 ) && ( xi > -1 * r2 ) && ( c1 < R2 ) && ( c1 > -1 * R2 ) && ( c2 < R2 ) && ( c2 > -1 * R2 ) ) { std :: pair < int32_t , int32_t > uv1 = wafer . cellUVFromXY1 ( xi , yi , placeIndex_ , waferType_ , 0 , 0 ) ; std :: pair < int32_t , int32_t > uv2 = wafer . cellUVFromXY2 ( xi , yi , placeIndex_ , waferType_ , 0 , 0 ) ; std :: pair < int32_t , int32_t > uv3 = wafer . cellUVFromXY3 ( xi , yi , placeIndex_ , waferType_ , 1 , 0 ) ; std :: string comment = ( ( uv1 . first != uv3 . first ) || ( uv2 . first != uv3 . first ) || ( uv1 . second != uv3 . second ) || ( uv2 . second != uv3 . second ) ) ? " " : " " ; edm :: LogVerbatim ( " " ) << " " << xi << " " << yi << " " << waferType_ << " " << placeIndex_ << " " << uv1 . first << " " << uv2 . first << " " << uv3 . first << " " << uv1 . second << " " << uv2 . second << " " << uv3 . second << " " << comment ; } } auto end_t = std :: chrono :: high_resolution_clock :: now ( ) ; auto diff_t = end_t - start_t ; edm :: LogVerbatim ( " " ) << " " << std :: chrono :: duration < double , std :: milli > ( diff_t ) . count ( ) << " " ; }
method called to produce the data
method called to produce the data
//Only allowing (x, y) inside a wafer //std::pair<int32_t, int32_t> uv2 = wafer.HGCalCellUVFromXY2(xi, yi, placeIndex_, waferType_, 1, 0);