CMS 3D CMS Logo

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