1#include "MdcGeom/MdcDetector.h"
2#include "Identifier/MdcID.h"
3#include "MdcGeomSvc/IMdcGeomSvc.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/IService.h"
7#include "GaudiKernel/ISvcLocator.h"
9static const int _layPerSL = 4;
11bool MdcDetector::_doSag =
false;
19 if ( 0 == _myself ) { _myself =
new MdcDetector(); }
25 std::cout <<
" +---------------------------------------------------+\n"
26 <<
" | Creating Mdc Geometry information |\n"
27 <<
" +---------------------------------------------------+\n";
36 if ( !mdcsvc ) std::cout <<
"MdcDetector::Could not open Geometry Service" << std::endl;
47 for (
int iwire = 0; iwire < _nSWire; iwire++ )
55 if ( _doSag ) sag = geowir->
Sag() / 10.;
58 _senseWire[iwire] =
new MdcSWire( eastP, westP, sag, geowir->
Id(), geowir->
Cell() );
62 for (
int ilay = 0; ilay < _nLayer; ilay++ )
65 int nwir = geolay->
NCell();
66 int firstwir = geolay->
Wirst();
67 _dclayer[ilay] =
new MdcLayer( ilay, nwir, &_senseWire[firstwir], *
this );
68 _wires_in_layer[ilay] = nwir;
79 for (
int ilay = 0; ilay < _nLayer; ilay++ )
81 if ( ilay == 0 ) { rOther =
Layer( ilay + 1 )->
rMid(); }
82 else { rOther =
Layer( ilay - 1 )->
rMid(); }
83 double height = fabs(
Layer( ilay )->rMid() - rOther );
84 const_cast<MdcLayer*
>(
Layer( ilay ) )->setCellHeight( height );
89 for (
int iwire = 0; iwire < _nSWire; iwire++ ) {
delete _senseWire[iwire]; }
90 for (
int ilay = 0; ilay < _nLayer; ilay++ ) {
delete _dclayer[ilay]; }
91 for (
int islay = 0; islay < _nSlay; islay++ )
93 _slayList[islay]->print( std::cout );
94 delete _slayList[islay];
102void MdcDetector::buildpointers(
void ) {
105 for (
int index = 0; index < _nLayer; index++ )
110 _nextlayinvw[index] = 0;
111 _prevlayinvw[index] = 0;
123 if ( index + 1 < _nLayer ) { _nextlay[index] =
Layer( index + 1 ); }
124 if ( index > 0 ) { _prevlay[index] =
Layer( index - 1 ); }
131 for ( jndex = index + 1; jndex < _nLayer; jndex++ )
137 if ( iview !=
Layer( jndex )->view() )
continue;
138 _nextlayinvw[index] =
Layer( jndex + 1 );
143 for ( jndex = index - 1; jndex >= 0; jndex-- )
149 if ( iview !=
Layer( jndex )->view() )
continue;
150 _prevlayinvw[index] =
Layer( jndex );
157void MdcDetector::buildSuperLayers(
void ) {
160 _nSterSlay[0] = _nSterSlay[1] = 0;
165 _lastSlayNum = _nSlay;
169 _firstSlayInView[0] = _firstSlayInView[1] = _firstSlayInView[2] = 0;
170 _lastSlayInView[0] = _lastSlayInView[1] = _lastSlayInView[2] = 0;
175 for ( islay = 0; islay < _nSlay; islay++ )
178 MdcSuperLayer* superlay =
new MdcSuperLayer( islay );
180 _slayList[islay] = superlay;
182 _firstSlay = _slayList[0];
183 _lastSlay = _slayList[_nSlay - 1];
187 for (
int lay = 0; lay < _nLayer; lay++ )
189 int superlayer = lay / _layPerSL;
190 int index = lay % _layPerSL;
191 _slayList[superlayer]->addLayer( index,
getMdcLayer( lay ) );
194 MdcSuperLayer* oldSlayByView[3] = { 0, 0, 0 };
196 for ( islay = 0; islay < _nSlay; islay++ )
198 const MdcSuperLayer*
prev = 0;
199 const MdcSuperLayer*
next = 0;
204 int iview = _slayList[islay]->layer( 0 )->view();
205 int viewIndex = iview + 1;
207 if ( iview == 0 ) _nAxSlay++;
208 else if ( iview == -1 ) _nSterSlay[0]++;
209 else if ( iview == 1 ) _nSterSlay[1]++;
212 if ( islay > 0 )
prev = _slayList[islay - 1];
213 if ( islay < _nSlay - 1 )
next = _slayList[islay + 1];
216 if (
firstSlayInView( iview ) == 0 ) _firstSlayInView[viewIndex] = _slayList[islay];
217 _lastSlayInView[viewIndex] = _slayList[islay];
219 _slayList[islay]->updateInfo( prev, next );
221 if ( oldSlayByView[viewIndex] != 0 )
224 _slayList[islay]->setPrevInView( oldSlayByView[viewIndex] );
227 oldSlayByView[viewIndex] = _slayList[islay];
234 return Wire( layer, wire );
246 return Layer( layerid );
HepGeom::Point3D< double > HepPoint3D
virtual const int getLayerSize()=0
virtual const MdcGeoLayer *const Layer(unsigned id)=0
virtual const MdcGeoWire *const Wire(unsigned id)=0
virtual const int getWireSize()=0
virtual const int getSuperLayerSize()=0
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
static int layer(const Identifier &id)
Values of different levels (failure returns 0).
static int wire(const Identifier &id)
void setNextInView(MdcSuperLayer *sl)