Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:07

0001 #include <algorithm>
0002 #include <cmath>
0003 #include <iomanip>
0004 #include <iostream>
0005 #include <fstream>
0006 #include <string>
0007 #include <vector>
0008   
0009 class HexGeometry {
0010 
0011 public :
0012   HexGeometry(bool fine);
0013   virtual ~HexGeometry() {}
0014 
0015   std::pair<double,double> position(const int cell);
0016 
0017 private :
0018   std::vector<std::pair<double,double> > xypos;
0019 
0020 };
0021 
0022 HexGeometry::HexGeometry(bool fine) {
0023   const int nC(15), nF(20);
0024   int nCoarse(11), nyCoarse(-42), nFine(15), nyFine(-56);
0025   int cellCoarse[nC] = {2,5,8,11,12,11,12,11,12,11,12,11,8,5,2};
0026   int cellFine[nF] = {3,6,9,12,15,16,15,16,15,16,15,16,15,16,15,14,11,8,5,2};
0027   double wafer(123.7);
0028 
0029   int    rows = (fine) ? nF : nC;
0030   double cell = (fine) ? wafer/nFine : wafer/nCoarse;
0031   double dx   = 0.5*cell;
0032   double dy   = 0.5*dx*tan(30.0*M_PI/180.0);
0033   int    ny   = (fine) ? nyFine : nyCoarse;
0034   for (int ir = 0; ir < rows; ++ir) {
0035     int    column = (fine) ? cellFine[ir] : cellCoarse[ir];
0036     int    nx     = 1 - column;
0037     double ypos   = dy*ny;
0038     for (int ic = 0; ic<column; ++ic) {
0039       double xpos = dx*nx;
0040       nx += 2;
0041       xypos.push_back(std::pair<double,double>(xpos,ypos));
0042     }
0043     ny += 6;
0044   }
0045   //std::cout << "Initialize HexGeometry for " << xypos.size() << " cells"
0046   //          << std::endl;
0047 }
0048 
0049 std::pair<double,double> HexGeometry::position(const int cell) {
0050   std::pair<double,double> xy;
0051   if (cell >= 0 && cell < (int)(xypos.size())) {
0052     xy = xypos[cell];
0053   } else {
0054     xy = std::pair<double,double>(0,0);
0055   }
0056   return xy;
0057 }
0058 
0059 
0060 void testGeometry() {
0061 
0062   HexGeometry geomc(false);
0063   for (int k = 0; k < 133; ++k) {
0064     std::pair<double,double> xy = geomc.position(k);
0065     std::cout << "Coarse Cell[" << k << "] " << xy.first << ":" << xy.second
0066           << std::endl;
0067   }
0068 
0069   HexGeometry geomf(true);
0070   for (int k = 0; k < 240; ++k) {
0071     std::pair<double,double> xy = geomf.position(k);
0072     std::cout << "Fine Cell[" << k << "] " << xy.first << ":" << xy.second
0073           << std::endl;
0074   }
0075 }