00001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00002 #include "Geometry/ForwardGeometry/interface/CastorHardcodeGeometryLoader.h"
00003 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
00004 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
00005 #include "CastorGeometryData.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <algorithm>
00008
00009 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader() {
00010 init();
00011 }
00012
00013 CastorHardcodeGeometryLoader::CastorHardcodeGeometryLoader(const CastorTopology& ht) :
00014 theTopology(ht) {
00015 init();
00016 }
00017
00018 void CastorHardcodeGeometryLoader::init() {
00019 theEMSectiondX = 2.*dXEMPlate;
00020 theEMSectiondY = 2.*dYEMPlate;
00021 theEMSectiondZ = 101.0;
00022 theHADSectiondX = 2.*dXHADPlate;
00023 theHADSectiondY = 2.*dYHADPlate;
00024 theHADSectiondZ = 1212.;
00025 }
00026
00027 std::auto_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load(DetId::Detector det, int subdet){
00028 std::auto_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(&theTopology));
00029 if(subdet == HcalCastorDetId::SubdetectorId){
00030 fill(HcalCastorDetId::EM,hg.get());
00031 fill(HcalCastorDetId::HAD,hg.get());
00032 }
00033 return hg;
00034 }
00035
00036 std::auto_ptr<CaloSubdetectorGeometry> CastorHardcodeGeometryLoader::load() {
00037 std::auto_ptr<CaloSubdetectorGeometry> hg(new CastorGeometry(&theTopology));
00038 fill(HcalCastorDetId::EM,hg.get());
00039 fill(HcalCastorDetId::HAD,hg.get());
00040 return hg;
00041 }
00042
00043 void CastorHardcodeGeometryLoader::fill(HcalCastorDetId::Section section, CaloSubdetectorGeometry* geom)
00044 {
00045
00046 std::vector<HcalCastorDetId> castorIds;
00047 HcalCastorDetId id;
00048 int firstCell = theTopology.firstCell(section);
00049 int lastCell = theTopology.lastCell(section);
00050 for(int imodule = firstCell; imodule <= lastCell; ++imodule) {
00051 for(int isector = 1; isector < 17; ++isector) {
00052 id = HcalCastorDetId(section, true, isector, imodule);
00053 if(theTopology.valid(id)) castorIds.push_back(id);
00054 id = HcalCastorDetId(section, false, isector, imodule);
00055 if(theTopology.valid(id)) castorIds.push_back(id);
00056 }
00057 }
00058 edm::LogInfo("CastorHardcodeGeometry") << "Number of Castor DetIds made: " << section << " " << castorIds.size();
00059
00060
00061
00062 for(std::vector<HcalCastorDetId>::const_iterator castorIdItr = castorIds.begin();
00063 castorIdItr != castorIds.end(); ++castorIdItr)
00064 {
00065 const CaloCellGeometry * geometry = makeCell(*castorIdItr, geom );
00066 geom->addCell(*castorIdItr, geometry);
00067 }
00068 }
00069
00070 const CaloCellGeometry*
00071 CastorHardcodeGeometryLoader::makeCell(const HcalCastorDetId & detId, CaloSubdetectorGeometry* geom) const {
00072
00073 float zside = detId.zside();
00074 HcalCastorDetId::Section section = detId.section();
00075 int module = detId.module();
00076
00077
00078 float xMother = X0;
00079 float yMother = Y0;
00080 float zMother = Z0;
00081 float dx = 0;
00082 float dy = 0;
00083 float dz = 0;
00084 float theTiltAngle = 0.7854;
00085 float xfaceCenter = 0;
00086 float yfaceCenter = 0;
00087 float zfaceCenter = 0;
00088
00089 if(section==HcalCastorDetId::EM){
00090 dx = theEMSectiondX;
00091 dy = theEMSectiondY;
00092 dz = theEMSectiondZ;
00093
00094 xfaceCenter = xMother + (theXChannelBoundaries[module-1] + theEMSectiondX/2);
00095 yfaceCenter = yMother;
00096 zfaceCenter = (zMother + theZSectionBoundaries[0])*zside;
00097 }
00098
00099 if(section==HcalCastorDetId::HAD){
00100 dx = theHADSectiondX;
00101 dy = theHADSectiondY;
00102 dz = theHADSectiondZ;
00103 theTiltAngle = tiltangle;
00104 xfaceCenter = xMother;
00105 yfaceCenter = yMother;
00106 zfaceCenter = (zMother + theHadmodulesBoundaries[module-1])*zside;
00107 }
00108 GlobalPoint faceCenter(xfaceCenter, yfaceCenter, zfaceCenter);
00109
00110 std::vector<float> zz ;
00111 zz.resize(3) ;
00112 zz.push_back( dx ) ;
00113 zz.push_back( dy ) ;
00114 zz.push_back( dz ) ;
00115 return new calogeom::IdealCastorTrapezoid(
00116 faceCenter,
00117 geom->cornersMgr(),
00118 CaloCellGeometry::getParmPtr( zz,
00119 geom->parMgr(),
00120 geom->parVecVec() ) );
00121
00122 }
00123
00124