BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
FTGeom.cxx
Go to the documentation of this file.
1#include "FTGeom.h"
2#include "FTLayer.h"
3#include "FTSuperLayer.h"
4#include "FTWire.h"
5
6#include "GaudiKernel/ISvcLocator.h"
7
8#include "MdcGeomSvc/IMdcGeomSvc.h"
9
10FTGeom::FTGeom() : m_virtualWire( new FTWire() ) {
11 m_geom_relationship.clear();
12 m_layerGeomInfo.clear();
13 m_superLayerGeomInfo.clear();
14
15 auto mdcGeomSvc = Gaudi::svcLocator()->service<IMdcGeomSvc>( "MdcGeomSvc" );
16 if ( !mdcGeomSvc )
17 {
18 std::cerr << "FTGeom::FTGeom: can't get MdcGeomSvc" << std::endl;
19 return;
20 }
21
22 const int Nwire = mdcGeomSvc->getWireSize();
23 const int Nlyr = mdcGeomSvc->getLayerSize();
24 const int Nsup = mdcGeomSvc->getSuperLayerSize();
25
26 if ( !Nwire || !Nlyr )
27 {
28 std::cerr << "FTFINDER::GEOCDC not found (please put cdctable before l4)" << std::endl;
29 std::cerr << "JOB will stop" << std::endl;
30 exit( -1 );
31 }
32
33 // temporary variables for layer info
34 FTList<int> layer_superLayerId( Nlyr, -1 );
35 FTList<int> layer_wireStart( Nlyr, 9999 );
36 FTList<int> layer_wireEnd( Nlyr, 0 );
37
38 // temporary variables for super layer info
39 FTList<int> super_layerStart( Nsup, 9999 );
40 FTList<int> super_layerEnd( Nsup, 0 );
41 FTList<int> super_wireStart( Nsup, 9999 );
42 FTList<int> super_wireEnd( Nsup, 0 );
43
44 // loop over ids, fill the geometry information
45 for ( int wire_id = 0; wire_id < Nwire; wire_id++ )
46 {
47 int layer_id = mdcGeomSvc->Wire( wire_id )->Layer();
48 int superLayer_id = mdcGeomSvc->Layer( layer_id )->Sup()->Id();
49 m_geom_relationship.push_back( std::make_tuple( wire_id, layer_id, superLayer_id ) );
50
51 // layer info
52 if ( layer_superLayerId[layer_id] < 0 ) layer_superLayerId[layer_id] = superLayer_id;
53 layer_wireStart[layer_id] = std::min( layer_wireStart[layer_id], wire_id );
54 layer_wireEnd[layer_id] = std::max( layer_wireEnd[layer_id], wire_id );
55
56 // super layer info
57 super_layerStart[superLayer_id] = std::min( super_layerStart[superLayer_id], layer_id );
58 super_layerEnd[superLayer_id] = std::max( super_layerEnd[superLayer_id], layer_id );
59 super_wireStart[superLayer_id] = std::min( super_wireStart[superLayer_id], wire_id );
60 super_wireEnd[superLayer_id] = std::max( super_wireEnd[superLayer_id], wire_id );
61 }
62
63 // fill geom info
64 for ( int layer_id = 0; layer_id < Nlyr; layer_id++ )
65 {
66 m_layerGeomInfo.push_back( FTLayerGeomInfo( layer_id, //
67 layer_superLayerId[layer_id], //
68 layer_wireStart[layer_id], //
69 layer_wireEnd[layer_id] //
70 ) );
71 }
72
73 for ( int superLayer_id = 0; superLayer_id < Nsup; superLayer_id++ )
74 {
75
76 m_superLayerGeomInfo.push_back( FTSuperLayerGeomInfo( superLayer_id, //
77 super_layerStart[superLayer_id], //
78 super_layerEnd[superLayer_id], //
79 super_wireStart[superLayer_id], //
80 super_wireEnd[superLayer_id] //
81 ) );
82 }
83
84 // create FTSuperLayer
85 for ( int superLayer_id = 0; superLayer_id < Nsup; superLayer_id++ )
86 {
87 const MdcGeoSuper* superLayer = mdcGeomSvc->SuperLayer( superLayer_id );
88 m_superLayers.push_back( new FTSuperLayer( superLayer_id, //
89 superLayer2layerStart( superLayer_id ), //
90 superLayer2wireStart( superLayer_id ), //
91 superLayer2nLayers( superLayer_id ), //
92 superLayer2nWires( superLayer_id ) ) );
93 }
94
95 // create FTLayer
96 for ( int layer_id = 0; layer_id < Nlyr; layer_id++ )
97 {
98 const MdcGeoLayer* layer = mdcGeomSvc->Layer( layer_id );
99 m_layers.push_back( new FTLayer( 0.1 * layer->Radius(), //
100 layer->Slant(), //
101 0.1 * ( +layer->Length() / 2 ), //
102 0.1 * ( -layer->Length() / 2 ), //
103 0.1 * layer->Offset(), //
104 layer_id, //
105 this->layer2layerIndex( layer_id ), //
106 this->layer2nWires( layer_id ) ) );
107 }
108
109 // create FTWire
110 for ( auto row : m_geom_relationship )
111 {
112 int wire_id = std::get<0>( row );
113 int superLayer_id = std::get<2>( row );
114
115 const MdcGeoWire* wire = mdcGeomSvc->Wire( wire_id );
116 FTLayer* layer = getLayer( wire2layer( wire_id ) );
117 const float phi = (const float)2 * M_PI * wire2wireIndexLayer( wire_id ) /
118 (float)getLayer( wire2layer( wire_id ) )->NWire() +
119 getLayer( wire2layer( wire_id ) )->offset();
120
121 if ( superLayer_id == 2 || superLayer_id == 3 || superLayer_id == 4 ||
122 superLayer_id == 9 || superLayer_id == 10 )
123 {
124 m_wires.push_back(
125 new FTWire( 0.1 * (float)0.5 * ( wire->Backward().x() + wire->Forward().x() ), //
126 0.1 * (float)0.5 * ( wire->Backward().y() + wire->Forward().y() ), //
127 0., //
128 0., //
129 wire_id, //
130 layer, //
131 phi ) );
132 }
133 else
134 {
135 m_wires.push_back(
136 new FTWire( 0.1 * (float)wire->Backward().x(), //
137 0.1 * (float)wire->Backward().y(), //
138 0.1 * (float)wire->Forward().x() - 0.1 * (float)wire->Backward().x(), //
139 0.1 * (float)wire->Forward().y() - 0.1 * (float)wire->Backward().y(), //
140 wire_id, //
141 layer, //
142 phi ) );
143 }
144 }
145}
146
148 auto mdcGeomSvc = Gaudi::svcLocator()->service<IMdcGeomSvc>( "MdcGeomSvc" );
149 if ( !mdcGeomSvc )
150 {
151 std::cerr << "FTGeom::FTGeom: can't get MdcGeomSvc" << std::endl;
152 return;
153 }
154
155 const int Nwire = mdcGeomSvc->getWireSize();
156 // set neighbor
157 for ( int wire_id = 0; wire_id < Nwire; wire_id++ ) { m_wires[wire_id]->initNeighbor(); }
158}
159
160static FTGeom* instance_ptr = nullptr;
161
163 if ( !instance_ptr )
164 {
165 instance_ptr = new FTGeom();
166 instance_ptr->init();
167 }
168 return instance_ptr;
169}
#define M_PI
Definition TConstant.h:4
static FTGeom * instance()
Definition FTGeom.cxx:162
void init()
Definition FTGeom.cxx:147
Definition FTList.h:6
virtual const int getWireSize()=0