00001
00002 #include "GaudiKernel/MsgStream.h"
00003 #include "GaudiKernel/SvcFactory.h"
00004
00005 #include "CalRecon/CalGeometrySvc.h"
00006
00007 static const SvcFactory<CalGeometrySvc> s_factory;
00008 const ISvcFactory& CalGeometrySvcFactory = s_factory;
00009
00010
00011 CalGeometrySvc::CalGeometrySvc(const std::string& name, ISvcLocator* pSvcLocator)
00012
00013 :Service(name, pSvcLocator)
00014 {
00015 declareProperty("geometryType", m_geoType = 0);
00016 declareProperty("balloonFlight", m_balloonFlight = 0);
00017
00018
00019
00020
00021
00022
00023 m_nviews = 2;
00024 m_nlayers = 4;
00025 m_nLogs = 10;
00026 m_nmodx = 1;
00027 m_nmody = 1;
00028
00029
00030 m_Z0 = -25.9602;
00031
00032
00033 m_layerWidth = 31.05;
00034 m_layerHeight = 2.614;
00035
00036 m_logWidth = 3.05;
00037 m_logLength = 31.05;
00038 m_logHeight = 2.35;
00039 m_logGap = 0.06;
00040 m_latt = 0.35;
00041
00042
00043
00044
00045
00046
00047 }
00048
00049
00050
00051 StatusCode CalGeometrySvc::initialize()
00052
00053 {
00054 StatusCode sc = StatusCode::SUCCESS;
00055 Service::initialize();
00056 setProperties();
00057
00058
00059 if (m_geoType == 0 && m_balloonFlight == 1) m_Z0 = -24.346;
00060
00061 if (m_geoType == 1)
00062 {
00063
00064
00065 m_nviews = 2;
00066 m_nlayers = 4;
00067 m_nLogs = 12;
00068 m_nmodx = 4;
00069 m_nmody = 4;
00070
00071 m_modWidth = 39.37;
00072 m_Z0 = -34.094;
00073
00074 m_layerWidth = 36.99;
00075 m_layerHeight = 2.446;
00076
00077 m_logWidth = 3.00;
00078 m_logLength = 36.99;
00079 m_logHeight = 2.10;
00080 m_logGap = 0.084;
00081 m_latt = 0.35;
00082
00083 }
00084 else if (m_geoType == 2)
00085 {
00086
00087
00088 m_nviews = 2;
00089 m_nlayers = 4;
00090 m_nLogs = 12;
00091 m_nmodx = 4;
00092 m_nmody = 4;
00093
00094
00095
00096
00097 m_modWidth = 37.45;
00098
00099
00100
00101
00102
00103
00104
00105 m_Z0 = -30.9176;
00106
00107 m_layerWidth = 33.3;
00108 m_layerHeight = 2.139;
00109
00110 m_logWidth = 2.6714;
00111 m_logLength = 33.3;
00112 m_logHeight = 1.99;
00113 m_logGap = 0.113;
00114 m_latt = 0.35;
00115
00116 }
00117 return sc;
00118 }
00119
00120
00121
00122 StatusCode CalGeometrySvc::finalize()
00123
00124 {
00125 return StatusCode::SUCCESS;
00126 }
00127
00128
00129
00130
00131
00132 CalDetGeo CalGeometrySvc::getLayer(int ilayer, CalDetGeo::axis a)
00133
00134 {
00135 double xpos = 0.;
00136 double ypos = 0.;
00137 double zfar = 0.;
00138 if (a == CalDetGeo::Y) zfar = layerHeight();
00139 double zpos = Z0()+2.*ilayer*layerHeight()+zfar;
00140
00141 double xsize = layerWidth();
00142 double ysize = layerWidth();
00143 double zsize = layerHeight();
00144
00145 Point P(xpos,ypos,zpos);
00146 Point S(0.5*xsize,0.5*ysize,0.5*zsize);
00147
00148 CalDetGeo layer(ilayer,a,ilayer,P,S);
00149 return layer;
00150 }
00151
00152 CalDetGeo CalGeometrySvc::getLog(int ilayer, CalDetGeo::axis a, int ilog, idents::ModuleId mod)
00153
00154 {
00155
00156 double xmod = (mod.ix()-(m_nmodx+1)*0.5)*m_modWidth;
00157 double ymod = (mod.iy()-(m_nmody+1)*0.5)*m_modWidth;
00158 Vector modcenter(xmod,ymod,0);
00159 CalDetGeo log = getLog(ilayer, a, ilog);
00160 log.setPosition(log.position()+modcenter);
00161 return log;
00162 }
00163
00164 CalDetGeo CalGeometrySvc::getLog(int ilayer, CalDetGeo::axis a, int ilog)
00165
00166 {
00167 CalDetGeo layer = getLayer(ilayer,a);
00168 double xpos = layer.position().x();
00169 double ypos = layer.position().y();
00170 double zpos = layer.position().z();
00171
00172 int nlogs = numLogs();
00173 double posRef = -0.5*(nlogs-1)*(logWidth()+logGap());
00174 double pos = posRef+ilog*(logWidth()+logGap());
00175 if (fabs(pos) < 1e-5) pos =0.;
00176 if (a == CalDetGeo::X) xpos = pos;
00177 else ypos = pos;
00178
00179 double xsize = logLength();
00180 double ysize = logLength();
00181 if (a == CalDetGeo::X) xsize = logWidth();
00182 else ysize = logWidth();
00183 double zsize = logHeight();
00184
00185 Point P(xpos,ypos,zpos);
00186 Point S(0.5*xsize,0.5*ysize,0.5*zsize);
00187
00188 CalDetGeo log(ilayer,a,ilog,P,S);
00189
00190 return log;
00191 }
00192
00193
00194 StatusCode CalGeometrySvc::queryInterface (const IID& riid, void **ppvIF)
00195 {
00196 if (IID_ICalGeometrySvc == riid) {
00197 *ppvIF = dynamic_cast<ICalGeometrySvc*> (this);
00198 return StatusCode::SUCCESS;
00199 }
00200 else {
00201 return Service::queryInterface (riid, ppvIF);
00202 }
00203 }
00204
00205
00206 const IID& CalGeometrySvc::type () const {
00207 return IID_ICalGeometrySvc;
00208 }
00209