5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/IService.h"
7#include "GaudiKernel/ISvcLocator.h"
11static const int _layPerSL = 4;
13bool MdcDetector::_doSag =
false;
32 std::cout <<
" +---------------------------------------------------+\n"
33 <<
" | Creating Mdc Geometry information |\n"
34 <<
" +---------------------------------------------------+\n";
37 StatusCode sc = Gaudi::svcLocator()->getService(
"MdcGeomSvc",ser);
39 std::cout <<
" MdcDetector::Could not open Geometry Service"<<std::endl;
41 if(!mdcsvc) std::cout <<
"MdcDetector::Could not open Geometry Service"<<std::endl;
47 _senseWire =
new MdcSWire* [_nSWire];
52 for(
int iwire = 0; iwire < _nSWire; iwire++ ) {
58 if(_doSag) sag = geowir->
Sag()/10.;
61 _senseWire[iwire] =
new MdcSWire(eastP, westP, sag, geowir->
Id(), geowir->
Cell());
67 for(
int ilay = 0; ilay < _nLayer; ilay++ ) {
69 int nwir = geolay->
NCell();
70 int firstwir = geolay->
Wirst();
71 _dclayer[ilay] =
new MdcLayer(ilay, nwir, &_senseWire[firstwir],*
this);
72 _wires_in_layer[ilay] = nwir;
83 for(
int ilay = 0; ilay < _nLayer; ilay++) {
89 double height = fabs(
Layer(ilay)->rMid() - rOther);
98 for(
int iwire = 0; iwire < _nSWire; iwire++ ) {
99 delete _senseWire[iwire];
101 for(
int ilay = 0; ilay < _nLayer; ilay++ ) {
102 delete _dclayer[ilay];
104 for(
int islay =0; islay < _nSlay; islay++ ) {
105 _slayList[islay]->
print(std::cout);
106 delete _slayList[islay];
109 delete [] _senseWire;
116MdcDetector::buildpointers(
void)
120 for (
int index=0; index<_nLayer; index++) {
122 _nextlay[index]=0; _prevlay[index]=0;
123 _nextlayinvw[index]=0; _prevlayinvw[index]=0;
135 if ( index + 1 < _nLayer ) { _nextlay[index] =
Layer(index+1); }
136 if ( index > 0 ) { _prevlay[index] =
Layer(index-1); }
143 for (jndex=index+1; jndex<_nLayer; jndex++) {
148 if ( iview !=
Layer(jndex)->view() )
continue;
149 _nextlayinvw[index] =
Layer(jndex+1);
154 for (jndex=index-1; jndex>=0 ; jndex--) {
159 if ( iview!=
Layer(jndex)->view() )
continue;
160 _prevlayinvw[index] =
Layer(jndex);
169 MdcDetector::buildSuperLayers(
void)
173 _nSterSlay[0] = _nSterSlay[1] = 0;
178 _lastSlayNum = _nSlay;
182 _firstSlayInView[0] = _firstSlayInView[1] =_firstSlayInView[2] = 0;
183 _lastSlayInView[0] = _lastSlayInView[1] =_lastSlayInView[2] = 0;
188 for (islay = 0; islay < _nSlay; islay++) {
192 _slayList[islay] = superlay;
194 _firstSlay = _slayList[0];
195 _lastSlay = _slayList[_nSlay-1];
199 for (
int lay = 0; lay < _nLayer; lay++) {
200 int superlayer = lay / _layPerSL;
201 int index = lay % _layPerSL;
202 _slayList[superlayer]->addLayer(index,
getMdcLayer(lay));
207 for (islay = 0; islay < _nSlay; islay++) {
214 int iview = _slayList[islay]->
layer(0)->
view();
215 int viewIndex = iview+1;
217 if ( iview == 0 ) _nAxSlay++;
218 else if ( iview == -1 ) _nSterSlay[0]++;
219 else if ( iview == 1 ) _nSterSlay[1]++;
222 if ( islay > 0 )
prev = _slayList[islay - 1];
223 if ( islay < _nSlay-1 )
next = _slayList[islay + 1];
228 _lastSlayInView[viewIndex] = _slayList[islay];
230 _slayList[islay]->updateInfo(prev, next);
232 if (oldSlayByView[viewIndex] != 0) {
237 oldSlayByView[viewIndex] = _slayList[islay];
249 return Wire(layer, wire);
263 return Layer(layerid);
MdcLayer * getMdcLayer(int laynum) const
const MdcLayer * Layer(unsigned id) const
static MdcDetector * instance()
const MdcSWire * Wire(unsigned id) const
const MdcSuperLayer * firstSlayInView(int iview) const
const double Sag(void) const
HepPoint3D Forward(void) const
HepPoint3D Backward(void) const
const MdcGeoWire *const Wire(unsigned id)
const int getSuperLayerSize()
const MdcGeoLayer *const Layer(unsigned id)
static int layer(const Identifier &id)
Values of different levels (failure returns 0)
static int wire(const Identifier &id)
void print(std::ostream &o=std::cout) const
const MdcLayer * layer(int i) const
void setPrevInView(MdcSuperLayer *sl)
void setNextInView(MdcSuperLayer *sl)