CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Geometry/HcalTowerAlgo/src/HcalFlexiHardcodeGeometryLoader.cc

Go to the documentation of this file.
00001 #include "Geometry/HcalTowerAlgo/interface/HcalFlexiHardcodeGeometryLoader.h"
00002 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00003 #include "Geometry/CaloGeometry/interface/IdealObliquePrism.h"
00004 #include "Geometry/CaloGeometry/interface/IdealZPrism.h"
00005 #include "Geometry/HcalTowerAlgo/interface/HcalGeometry.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 #include <vector>
00009 
00010 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00011 
00012 namespace {
00013   const int MAX_HCAL_PHI = 72;
00014   const float DEGREE2RAD = M_PI / 180.;
00015 
00016   // Parameter objects
00017 
00018   struct HBHOCellParameters {
00019     HBHOCellParameters (int f_eta, int f_depth, int f_phiFirst, int f_phiStep, int f_dPhi, float f_rMin, float f_rMax, float f_etaMin, float f_etaMax)
00020       : eta(f_eta), depth(f_depth), phiFirst(f_phiFirst), phiStep(f_phiStep), dphi(f_dPhi), rMin(f_rMin), rMax(f_rMax), etaMin(f_etaMin), etaMax(f_etaMax)
00021     {}
00022  
00023     int eta;
00024     int depth;
00025     int phiFirst;
00026     int phiStep;
00027     int dphi;
00028     float rMin;
00029     float rMax;
00030     float etaMin;
00031     float etaMax;
00032   };
00033 
00034   struct HECellParameters {
00035     HECellParameters (int f_eta, int f_depth, int f_phiFirst, int f_phiStep, int f_dPhi, float f_zMin, float f_zMax, float f_etaMin, float f_etaMax)
00036       : eta(f_eta), depth(f_depth), phiFirst(f_phiFirst), phiStep(f_phiStep), dphi(f_dPhi), zMin(f_zMin), zMax(f_zMax), etaMin(f_etaMin), etaMax(f_etaMax)
00037     {}
00038  
00039     int eta;
00040     int depth;
00041     int phiFirst;
00042     int phiStep;
00043     int dphi;
00044     float zMin;
00045     float zMax;
00046     float etaMin;
00047     float etaMax;
00048   };
00049 
00050   struct HFCellParameters {
00051     HFCellParameters (int f_eta, int f_depth, int f_phiFirst, int f_phiStep, int f_dPhi, float f_zMin, float f_zMax, float f_rMin, float f_rMax)
00052       : eta(f_eta), depth(f_depth), phiFirst(f_phiFirst), phiStep(f_phiStep), dphi(f_dPhi), zMin(f_zMin), zMax(f_zMax), rMin(f_rMin), rMax(f_rMax)
00053     {}
00054  
00055     int eta;
00056     int depth;
00057     int phiFirst;
00058     int phiStep;
00059     int dphi;
00060     float zMin;
00061     float zMax;
00062     float rMin;
00063     float rMax;
00064   };
00065 
00066 
00067 
00068   // ----------> HB <-----------
00069   std::vector <HBHOCellParameters> makeHBCells () {
00070     const float HBRMIN = 181.1;
00071     const float HBRMAX = 288.8;
00072     
00073     HBHOCellParameters cells [] = {
00074       // eta, depth, firstPhi, stepPhi, deltaPhi, rMin, rMax, etaMin, etaMax
00075       HBHOCellParameters ( 1, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*0, 0.087*1),
00076       HBHOCellParameters ( 2, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*1, 0.087*2),
00077       HBHOCellParameters ( 3, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*2, 0.087*3),
00078       HBHOCellParameters ( 4, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*3, 0.087*4),
00079       HBHOCellParameters ( 5, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*4, 0.087*5),
00080       HBHOCellParameters ( 6, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*5, 0.087*6),
00081       HBHOCellParameters ( 7, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*6, 0.087*7),
00082       HBHOCellParameters ( 8, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*7, 0.087*8),
00083       HBHOCellParameters ( 9, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*8, 0.087*9),
00084       HBHOCellParameters (10, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*9, 0.087*10),
00085       HBHOCellParameters (11, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*10, 0.087*11),
00086       HBHOCellParameters (12, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*11, 0.087*12),
00087       HBHOCellParameters (13, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*12, 0.087*13),
00088       HBHOCellParameters (14, 1, 1, 1, 5, HBRMIN, HBRMAX, 0.087*13, 0.087*14),
00089       HBHOCellParameters (15, 1, 1, 1, 5, HBRMIN, 258.4,  0.087*14, 0.087*15),
00090       HBHOCellParameters (15, 2, 1, 1, 5, 258.4,  HBRMAX, 0.087*14, 0.087*15),
00091       HBHOCellParameters (16, 1, 1, 1, 5, HBRMIN, 190.4,  0.087*15, 0.087*16),
00092       HBHOCellParameters (16, 2, 1, 1, 5, 190.4,  232.6,  0.087*15, 0.087*16)
00093     };
00094     int nCells = sizeof(cells)/sizeof(HBHOCellParameters);
00095     std::vector <HBHOCellParameters> result;
00096     result.reserve (nCells);
00097     for (int i = 0; i < nCells; ++i) result.push_back (cells[i]);
00098     return result;
00099   }
00100 
00101   // ----------> HO <-----------
00102   std::vector <HBHOCellParameters> makeHOCells () {
00103     const float HORMIN0 = 390.0;
00104     const float HORMIN1 = 412.6;
00105     const float HORMAX = 413.6;
00106     
00107     HBHOCellParameters cells [] = {
00108       // eta, depth, firstPhi, stepPhi, deltaPhi, rMin, rMax, etaMin, etaMax
00109       HBHOCellParameters ( 1, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087*0, 0.087*1),
00110       HBHOCellParameters ( 2, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087*1, 0.087*2),
00111       HBHOCellParameters ( 3, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087*2, 0.087*3),
00112       HBHOCellParameters ( 4, 4, 1, 1, 5, HORMIN0, HORMAX, 0.087*3, 0.3075),
00113       HBHOCellParameters ( 5, 4, 1, 1, 5, HORMIN1, HORMAX, 0.3395,  0.087*5),
00114       HBHOCellParameters ( 6, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*5, 0.087*6),
00115       HBHOCellParameters ( 7, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*6, 0.087*7),
00116       HBHOCellParameters ( 8, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*7, 0.087*8),
00117       HBHOCellParameters ( 9, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*8, 0.087*9),
00118       HBHOCellParameters (10, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*9,  0.8494),
00119       HBHOCellParameters (11, 4, 1, 1, 5, HORMIN1, HORMAX, 0.873, 0.087*11),
00120       HBHOCellParameters (12, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*11, 0.087*12),
00121       HBHOCellParameters (13, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*12, 0.087*13),
00122       HBHOCellParameters (14, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*13, 0.087*14),
00123       HBHOCellParameters (15, 4, 1, 1, 5, HORMIN1, HORMAX, 0.087*14, 0.087*15)
00124     };
00125     int nCells = sizeof(cells)/sizeof(HBHOCellParameters);
00126     std::vector <HBHOCellParameters> result;
00127     result.reserve (nCells);
00128     for (int i = 0; i < nCells; ++i) result.push_back (cells[i]);
00129     return result;
00130   }
00131 
00132   // ----------> HE <-----------
00133   std::vector <HECellParameters> makeHECells () {
00134     const float HEZMIN = 400.458;
00135     const float HEZMID = 436.168;
00136     const float HEZMAX = 549.268;
00137     
00138     HECellParameters cells [] = {
00139       // eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, etaMin, etaMax
00140       HECellParameters ( 16, 3, 1, 1, 5,418.768,470.968, 0.087*15, 0.087*16),
00141       HECellParameters ( 17, 1, 1, 1, 5,409.698,514.468, 0.087*16, 0.087*17),
00142       HECellParameters ( 18, 1, 1, 1, 5,391.883,427.468, 0.087*17, 0.087*18),
00143       HECellParameters ( 18, 2, 1, 1, 5,427.468,540.568, 0.087*17, 0.087*18),
00144       HECellParameters ( 19, 1, 1, 1, 5, HEZMIN, HEZMID, 0.087*18, 0.087*19),
00145       HECellParameters ( 19, 2, 1, 1, 5, HEZMID, HEZMAX, 0.087*18, 0.087*19),
00146       HECellParameters ( 20, 1, 1, 1, 5, HEZMIN, HEZMID, 0.087*19, 1.74),
00147       HECellParameters ( 20, 2, 1, 1, 5, HEZMID, HEZMAX, 0.087*19, 1.74),
00148       HECellParameters ( 21, 1, 1, 2,10, HEZMIN, HEZMID, 1.74, 1.83),
00149       HECellParameters ( 21, 2, 1, 2,10, HEZMID, HEZMAX, 1.74, 1.83),
00150       HECellParameters ( 22, 1, 1, 2,10, HEZMIN, HEZMID, 1.83, 1.93),
00151       HECellParameters ( 22, 2, 1, 2,10, HEZMID, HEZMAX, 1.83, 1.93),
00152       HECellParameters ( 23, 1, 1, 2,10, HEZMIN, HEZMID, 1.93, 2.043),
00153       HECellParameters ( 23, 2, 1, 2,10, HEZMID, HEZMAX, 1.93, 2.043),
00154       HECellParameters ( 24, 1, 1, 2,10, HEZMIN, HEZMID, 2.043, 2.172),
00155       HECellParameters ( 24, 2, 1, 2,10, HEZMID, HEZMAX, 2.043, 2.172),
00156       HECellParameters ( 25, 1, 1, 2,10, HEZMIN, HEZMID, 2.172, 2.322),
00157       HECellParameters ( 25, 2, 1, 2,10, HEZMID, HEZMAX, 2.172, 2.322),
00158       HECellParameters ( 26, 1, 1, 2,10, HEZMIN, HEZMID, 2.322, 2.500),
00159       HECellParameters ( 26, 2, 1, 2,10, HEZMID, HEZMAX, 2.322, 2.500),
00160       HECellParameters ( 27, 1, 1, 2,10, HEZMIN,418.768, 2.500, 2.650),
00161       HECellParameters ( 27, 2, 1, 2,10,418.768, HEZMID, 2.500, 2.650),
00162       HECellParameters ( 27, 3, 1, 2,10, HEZMID, HEZMAX, 2.500, 2.650),
00163       HECellParameters ( 28, 1, 1, 2,10, HEZMIN,418.768, 2.650, 2.868),
00164       HECellParameters ( 28, 2, 1, 2,10,418.768, HEZMID, 2.650, 2.868),
00165       HECellParameters ( 28, 3, 1, 2,10, HEZMID, HEZMAX, 2.650, 3.000),
00166       HECellParameters ( 29, 1, 1, 2,10, HEZMIN, HEZMID, 2.868, 3.000),
00167       HECellParameters ( 29, 2, 1, 2,10,418.768, HEZMID, 2.868, 3.000)
00168     };
00169     int nCells = sizeof(cells)/sizeof(HECellParameters);
00170     std::vector <HECellParameters> result;
00171     result.reserve (nCells);
00172     for (int i = 0; i < nCells; ++i) result.push_back (cells[i]);
00173     return result;
00174   }
00175 
00176 
00177   // ----------> HE @ H2 <-----------
00178   std::vector <HECellParameters> makeHECells_H2 () {
00179     const float HEZMIN_H2 = 400.715;
00180     const float HEZMID_H2 = 436.285;
00181     const float HEZMAX_H2 = 541.885;
00182     
00183     HECellParameters cells [] = {
00184       // eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, etaMin, etaMax
00185       HECellParameters ( 16, 3, 1, 1, 5, 409.885,   462.685,   1.305, 1.373),
00186       HECellParameters ( 17, 1, 1, 1, 5, HEZMIN_H2, 427.485,   1.373, 1.444),
00187       HECellParameters ( 17, 2, 1, 1, 5, 427.485,   506.685,   1.373, 1.444),
00188       HECellParameters ( 18, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.444, 1.521),
00189       HECellParameters ( 18, 2, 1, 1, 5, HEZMID_H2, 524.285,   1.444, 1.521),
00190       HECellParameters ( 19, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.521, 1.603),
00191       HECellParameters ( 19, 2, 1, 1, 5, HEZMID_H2, HEZMAX_H2, 1.521, 1.603),
00192       HECellParameters ( 20, 1, 1, 1, 5, HEZMIN_H2, HEZMID_H2, 1.603, 1.693),
00193       HECellParameters ( 20, 2, 1, 1, 5, HEZMID_H2, HEZMAX_H2, 1.603, 1.693),
00194       HECellParameters ( 21, 1, 1, 2, 5, HEZMIN_H2, HEZMID_H2, 1.693, 1.79),
00195       HECellParameters ( 21, 2, 1, 2, 5, HEZMID_H2, HEZMAX_H2, 1.693, 1.79),
00196       HECellParameters ( 22, 1, 1, 2,10, HEZMIN_H2, HEZMID_H2, 1.79, 1.88),
00197       HECellParameters ( 22, 2, 1, 2,10, HEZMID_H2, HEZMAX_H2, 1.79, 1.88),
00198       HECellParameters ( 23, 1, 1, 2,10, HEZMIN_H2, HEZMID_H2, 1.88, 1.98),
00199       HECellParameters ( 23, 2, 1, 2,10, HEZMID_H2, HEZMAX_H2, 1.88, 1.98),
00200       HECellParameters ( 24, 1, 1, 2,10, HEZMIN_H2, 418.685,   1.98, 2.09),
00201       HECellParameters ( 24, 2, 1, 2,10, 418.685,   HEZMID_H2, 1.98, 2.09),
00202       HECellParameters ( 24, 3, 1, 2,10, HEZMID_H2, HEZMAX_H2, 1.98, 2.09),
00203       HECellParameters ( 25, 1, 1, 2,10, HEZMIN_H2, 418.685,   2.09, 2.21),
00204       HECellParameters ( 25, 2, 1, 2,10, 418.685,   HEZMID_H2, 2.09, 2.21),
00205       HECellParameters ( 25, 3, 1, 2,10, HEZMID_H2, HEZMAX_H2, 2.09, 2.21)
00206     };
00207     int nCells = sizeof(cells)/sizeof(HECellParameters);
00208     std::vector <HECellParameters> result;
00209     result.reserve (nCells);
00210     for (int i = 0; i < nCells; ++i) result.push_back (cells[i]);
00211     return result;
00212   }
00213 
00214   // ----------> HF <-----------
00215   std::vector <HFCellParameters> makeHFCells () {
00216     const float HFZMIN1 = 1115.;
00217     const float HFZMIN2 = 1137.;
00218     const float HFZMAX = 1280.1;
00219     
00220     HFCellParameters cells [] = {
00221       // eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, rMin, rMax
00222       HFCellParameters (29, 1, 1, 2, 10, HFZMIN1, HFZMAX,116.2,130.0),
00223       HFCellParameters (29, 2, 1, 2, 10, HFZMIN2, HFZMAX,116.2,130.0),
00224       HFCellParameters (30, 1, 1, 2, 10, HFZMIN1, HFZMAX, 97.5,116.2),
00225       HFCellParameters (30, 2, 1, 2, 10, HFZMIN2, HFZMAX, 97.5,116.2),
00226       HFCellParameters (31, 1, 1, 2, 10, HFZMIN1, HFZMAX, 81.8, 97.5),
00227       HFCellParameters (31, 2, 1, 2, 10, HFZMIN2, HFZMAX, 81.8, 97.5),
00228       HFCellParameters (32, 1, 1, 2, 10, HFZMIN1, HFZMAX, 68.6, 81.8),
00229       HFCellParameters (32, 2, 1, 2, 10, HFZMIN2, HFZMAX, 68.6, 81.8),
00230       HFCellParameters (33, 1, 1, 2, 10, HFZMIN1, HFZMAX, 57.6, 68.6),
00231       HFCellParameters (33, 2, 1, 2, 10, HFZMIN2, HFZMAX, 57.6, 68.6),
00232       HFCellParameters (34, 1, 1, 2, 10, HFZMIN1, HFZMAX, 48.3, 57.6),
00233       HFCellParameters (34, 2, 1, 2, 10, HFZMIN2, HFZMAX, 48.3, 57.6),
00234       HFCellParameters (35, 1, 1, 2, 10, HFZMIN1, HFZMAX, 40.6, 48.3),
00235       HFCellParameters (35, 2, 1, 2, 10, HFZMIN2, HFZMAX, 40.6, 48.3),
00236       HFCellParameters (36, 1, 1, 2, 10, HFZMIN1, HFZMAX, 34.0, 40.6),
00237       HFCellParameters (36, 2, 1, 2, 10, HFZMIN2, HFZMAX, 34.0, 40.6),
00238       HFCellParameters (37, 1, 1, 2, 10, HFZMIN1, HFZMAX, 28.6, 34.0),
00239       HFCellParameters (37, 2, 1, 2, 10, HFZMIN2, HFZMAX, 28.6, 34.0),
00240       HFCellParameters (38, 1, 1, 2, 10, HFZMIN1, HFZMAX, 24.0, 28.6),
00241       HFCellParameters (38, 2, 1, 2, 10, HFZMIN2, HFZMAX, 24.0, 28.6),
00242       HFCellParameters (39, 1, 1, 2, 10, HFZMIN1, HFZMAX, 20.1, 24.0),
00243       HFCellParameters (39, 2, 1, 2, 10, HFZMIN2, HFZMAX, 20.1, 24.0),
00244       HFCellParameters (40, 1, 3, 4, 20, HFZMIN1, HFZMAX, 16.9, 20.1),
00245       HFCellParameters (40, 2, 3, 4, 20, HFZMIN2, HFZMAX, 16.9, 20.1),
00246       HFCellParameters (41, 1, 3, 4, 20, HFZMIN1, HFZMAX, 12.5, 16.9),
00247       HFCellParameters (41, 2, 3, 4, 20, HFZMIN2, HFZMAX, 12.5, 16.9)
00248     };
00249     int nCells = sizeof(cells)/sizeof(HFCellParameters);
00250     std::vector <HFCellParameters> result;
00251     result.reserve (nCells);
00252     for (int i = 0; i < nCells; ++i) result.push_back (cells[i]);
00253     return result;
00254   }
00255 
00256   //
00257   // Convert constants to appropriate cells
00258   //
00259   void fillHBHO (CaloSubdetectorGeometry* fGeometry, const std::vector <HBHOCellParameters>& fCells, bool fHB) {
00260     for (size_t iCell = 0; iCell < fCells.size(); ++iCell) {
00261       const HBHOCellParameters& param = fCells[iCell];
00262       for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
00263         for (int iside = -1; iside <= 1; iside += 2) { // both detector sides are identical
00264           HcalDetId hid (fHB ? HcalBarrel : HcalOuter, param.eta*iside, iPhi, param.depth);
00265           float phiCenter = ((iPhi-1)*360./MAX_HCAL_PHI + 0.5*param.dphi) * DEGREE2RAD; // middle of the cell
00266           float etaCenter = 0.5*(param.etaMin + param.etaMax);
00267           float x = param.rMin* cos (phiCenter);
00268           float y = param.rMin* sin (phiCenter);
00269           float z = iside * param.rMin * sinh(etaCenter);
00270           // make cell geometry
00271           GlobalPoint refPoint (x,y,z); // center of the cell's face
00272           std::vector<CCGFloat> cellParams;
00273           cellParams.reserve (5);
00274           cellParams.push_back (0.5 * (param.etaMax - param.etaMin)); // deta_half
00275           cellParams.push_back (0.5 * param.dphi * DEGREE2RAD);  // dphi_half
00276           cellParams.push_back (0.5 * (param.rMax - param.rMin) * cosh (etaCenter)); // dr_half
00277           cellParams.push_back ( fabs( refPoint.eta()));
00278           cellParams.push_back ( fabs( refPoint.z() ) ) ;
00279           
00280 //        std::cout << "HcalFlexiHardcodeGeometryLoader::fillHBHO-> " << hid << hid.ieta() << '/' << hid.iphi() << '/' << hid.depth()
00281 //                  << refPoint << '/' << cellParams [0] << '/' << cellParams [1] << '/' << cellParams [2] << std::endl;
00282           
00283           fGeometry->newCell( refPoint,  refPoint,  refPoint, 
00284                               CaloCellGeometry::getParmPtr(
00285                                  cellParams, 
00286                                  fGeometry->parMgr(), 
00287                                  fGeometry->parVecVec() ),
00288                               hid ) ;
00289         }
00290       }
00291     }
00292   }
00293   
00294   void fillHE (CaloSubdetectorGeometry* fGeometry, const std::vector <HECellParameters>& fCells) {
00295     for (size_t iCell = 0; iCell < fCells.size(); ++iCell) {
00296       const HECellParameters& param = fCells[iCell];
00297       for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
00298         for (int iside = -1; iside <= 1; iside += 2) { // both detector sides are identical
00299           HcalDetId hid (HcalEndcap, param.eta*iside, iPhi, param.depth);
00300           float phiCenter = ((iPhi-1)*360./MAX_HCAL_PHI + 0.5*param.dphi) * DEGREE2RAD; // middle of the cell
00301           float etaCenter = 0.5 * (param.etaMin + param.etaMax);
00302 
00303           float perp = param.zMin / sinh (etaCenter);
00304           float x = perp * cos (phiCenter);
00305           float y = perp * sin (phiCenter);
00306           float z = iside * param.zMin;
00307           // make cell geometry
00308           GlobalPoint refPoint (x,y,z); // center of the cell's face
00309           std::vector<CCGFloat> cellParams;
00310           cellParams.reserve (5);
00311           cellParams.push_back (0.5 * (param.etaMax - param.etaMin)); // deta_half
00312           cellParams.push_back (0.5 * param.dphi * DEGREE2RAD);  // dphi_half
00313           cellParams.push_back (-0.5 * (param.zMax - param.zMin) / tanh (etaCenter)); // dz_half, "-" means edges in Z
00314           cellParams.push_back ( fabs( refPoint.eta()));
00315           cellParams.push_back ( fabs( refPoint.z() ) ) ;
00316           
00317 //        std::cout << "HcalFlexiHardcodeGeometryLoader::fillHE-> " << hid << refPoint << '/' << cellParams [0] << '/' << cellParams [1] << '/' << cellParams [2] << std::endl;
00318           
00319           fGeometry->newCell( refPoint,  refPoint,  refPoint, 
00320                               CaloCellGeometry::getParmPtr(
00321                                  cellParams, 
00322                                  fGeometry->parMgr(), 
00323                                  fGeometry->parVecVec() ) ,
00324                               hid ) ;
00325         }
00326       }
00327     }
00328   }
00329 
00330   void fillHF (CaloSubdetectorGeometry* fGeometry, const std::vector <HFCellParameters>& fCells) {
00331     for (size_t iCell = 0; iCell < fCells.size(); ++iCell) {
00332       const HFCellParameters& param = fCells[iCell];
00333       for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
00334         for (int iside = -1; iside <= 1; iside += 2) { // both detector sides are identical
00335           HcalDetId hid (HcalForward, param.eta*iside, iPhi, param.depth);
00336           float phiCenter = ((iPhi-1)*360./MAX_HCAL_PHI + 0.5*param.dphi) * DEGREE2RAD; // middle of the cell
00337           GlobalPoint inner (param.rMin, 0., param.zMin);
00338           GlobalPoint outer (param.rMax, 0., param.zMin);
00339           float iEta = inner.eta();
00340           float oEta = outer.eta();
00341           float etaCenter = 0.5 * ( iEta + oEta );
00342 
00343           float perp = param.zMin / sinh (etaCenter);
00344           float x = perp * cos (phiCenter);
00345           float y = perp * sin (phiCenter);
00346           float z = iside * param.zMin;
00347           // make cell geometry
00348           GlobalPoint refPoint (x,y,z); // center of the cell's face
00349           std::vector<CCGFloat> cellParams;
00350           cellParams.reserve (5);
00351           cellParams.push_back (0.5 * ( iEta - oEta )); // deta_half
00352           cellParams.push_back (0.5 * param.dphi * DEGREE2RAD);  // dphi_half
00353           cellParams.push_back (0.5 * (param.zMax - param.zMin)); // dz_half
00354           cellParams.push_back ( fabs( refPoint.eta()));
00355           cellParams.push_back ( fabs( refPoint.z() ) ) ;
00356           
00357 //        std::cout << "HcalFlexiHardcodeGeometryLoader::fillHF-> " << hid << refPoint << '/' << cellParams [0] << '/' << cellParams [1] << '/' << cellParams [2] << std::endl;
00358           
00359           fGeometry->newCell( refPoint,  refPoint,  refPoint, 
00360                               CaloCellGeometry::getParmPtr(
00361                                  cellParams, 
00362                                  fGeometry->parMgr(), 
00363                                  fGeometry->parVecVec() ),
00364                               hid ) ;
00365         }
00366       }
00367     }
00368   }
00369 
00370 }  // end of local stuff
00371 
00372 // ==============> Loader Itself <==========================
00373 
00374 HcalFlexiHardcodeGeometryLoader::HcalFlexiHardcodeGeometryLoader()
00375 {
00376 }
00377 
00378 CaloSubdetectorGeometry* HcalFlexiHardcodeGeometryLoader::load(const HcalTopology& fTopology) {
00379   CaloSubdetectorGeometry* hcalGeometry = new HcalGeometry (&fTopology);
00380   if( 0 == hcalGeometry->cornersMgr() ) hcalGeometry->allocateCorners ( 
00381      HcalGeometry::k_NumberOfCellsForCorners ) ;
00382   if( 0 == hcalGeometry->parMgr() ) hcalGeometry->allocatePar (
00383      HcalGeometry::k_NumberOfParametersPerShape*HcalGeometry::k_NumberOfShapes,
00384      HcalGeometry::k_NumberOfParametersPerShape ) ;
00385   // ugly kluge to extract H2 mode from the topology 
00386   if (fTopology.firstHEDoublePhiRing() < 22) { // regular geometry
00387     fillHBHO (hcalGeometry, makeHBCells(), true);
00388     fillHBHO (hcalGeometry, makeHOCells(), false);
00389     fillHF (hcalGeometry, makeHFCells());
00390     fillHE (hcalGeometry, makeHECells());
00391   }
00392   else { // TB geometry
00393     fillHBHO (hcalGeometry, makeHBCells(), true);
00394     fillHBHO (hcalGeometry, makeHOCells(), false);
00395     fillHE (hcalGeometry, makeHECells_H2());
00396   }
00397   return hcalGeometry;
00398 }
00399 
00400 
00401