CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcGeomSvc-00-01-42/MdcGeomSvc/MdcGeomSvc.h
Go to the documentation of this file.
1// header file for a class called "MdcGeomSvc"
2#ifndef MDCGEOMSVC_H
3#define MDCGEOMSVC_H
4
5#include <CLHEP/Units/PhysicalConstants.h>
6#include <CLHEP/Geometry/Point3D.h>
7#include <vector>
8#include <iostream>
9#include "GaudiKernel/Algorithm.h"
10
11#include "MdcGeomSvc/MdcGeoWire.h"
12#include "MdcGeomSvc/MdcGeoLayer.h"
13#include "MdcGeomSvc/MdcGeoGeneral.h"
14#include "MdcGeomSvc/MdcGeoSuper.h"
15#include "MdcGeomSvc/MdcGeoMisc.h"
16#include "MdcGeomSvc/MdcGeoEnd.h"
17#include "GaudiKernel/IIncidentListener.h"
18#include "GaudiKernel/Service.h"
19#include "GaudiKernel/IInterface.h"
20#include "MdcGeomSvc/IMdcGeomSvc.h"
21#include "GaudiKernel/IDataProviderSvc.h"
22#include "GaudiKernel/IIncidentListener.h"
23#include "CLHEP/Vector/TwoVector.h"
24
25//class MdcGeomSvc : public Service, virtual public IMdcGeomSvc,virtual public IIncidentListener
26class MdcGeomSvc : public Service, virtual public IMdcGeomSvc, virtual public IIncidentListener
27{
28 public:
29 // Constructors and destructors
30 MdcGeomSvc( const std::string& name, ISvcLocator* svcloc );
32
33 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
34 virtual StatusCode initialize ( );
35 virtual StatusCode finalize ( );
36 void handle(const Incident& inc);
37
38 // Access by others
39 const MdcGeoWire * const Wire(unsigned id);
40 const MdcGeoWire * const Wire(unsigned lyrid,unsigned wirid);
41 const MdcGeoLayer * const Layer(unsigned id);
42 const MdcGeoSuper * const SuperLayer(unsigned id);
43 const MdcGeoGeneral * const GeneralLayer(unsigned id);
44 const MdcGeoMisc * const Misc(void);
45 const MdcGeoEnd * const End(unsigned id);
46 const int getWireSize();
47 const int getLayerSize();
48 const int getSuperLayerSize();
49 const int getGeneralLayerSize();
50 const int getSegmentNo();
51 void Dump();
52 static bool getSagFlag(void);
53
54 // CrossPoint relevant
55 /**
56 * @brief forms a line in x-y space, ax + by + c = 0
57 */
59 const static double INFTY;
60 double a, b, c, // ax + by + c = 0
61 x0,y0,z0, //a point coordinate on the line, center of two tangant points
62 angle2D, //angle of the line and the 'plane' from two wires at z=z0 plane given
63 angle3D; //angle of the line and the 'plane' from two wires
64 AdjCandiTgtLine2D ():a(INFTY),b(INFTY),c(INFTY),x0(INFTY),y0(INFTY),z0(INFTY),angle2D(INFTY),angle3D(INFTY){};// float point NaN or Infinity
65 /**
66 * @brief get direction vector of a line. garanteed to be outwards
67 */
68 CLHEP::Hep2Vector direction(){
69 CLHEP::Hep2Vector ret(b,-a);
70 if (ret.dot(location())<0)
71 ret=-ret;
72 return ret;
73 }
74 /**
75 * @brief returns the cosine of angle of the line with R at its location (x0,y0). note that location is the mid point of two wires at selected plane.
76 *
77 * @return double
78 */
79 double angleWithR(){
80 CLHEP::Hep2Vector directionR(x0,y0);
81 CLHEP::Hep2Vector dirRRot90(-y0,x0);
82 CLHEP::Hep2Vector dirL=direction();
83 int sgn=dirRRot90.dot(dirL)>0; // bad-optimized code for telling rotate L-R.
84 return sgn*directionR.angle(dirL);
85 }
86
87 CLHEP::Hep2Vector location(){
88 CLHEP::Hep2Vector ret(x0,y0);
89 return ret;
90 }
92 HepPoint3D ret(x0,y0,z0);
93 return ret;
94 }
96 return x0<99999 && x0>-99999;
97 }
98 };
99
100 vector<HepPoint3D> getAdjacentIntersectionShape(const MdcGeoWire* wireA,const MdcGeoWire* wireB) ;
101 vector<double> getAdjacentIntersectionBounds(const MdcGeoWire* wireA,const MdcGeoWire* wireB);
102 HepPoint3D getAdjacentIntersectionPointFast(const MdcGeoWire* wireA,const MdcGeoWire* wireB);//dont use!
104 vector<AdjCandiTgtLine2D> getAdjacentCandidateWithDriftCircle(const MdcGeoWire* wireA,const MdcGeoWire* wireB, double driftA, double driftB);
105 vector<AdjCandiTgtLine2D> getAdjacentCandidateWithDriftCircle(const MdcGeoWire* wireA,const MdcGeoWire* wireB, double driftA, double driftB, double expectedZ);
106
108
109
110
111
112 public:
113 static bool m_doSag;
114 static bool m_readAlignParDataBase;
115 static bool m_nomcalignment;
116
117 // private method
118 private:
119 void clean(); // clean the fWires,fGenerals,fLayers,fSupers,,fEnd,etc...
120 void ReadFilePar(); //get geometry data from file SimUtil/dat/Mdc.txt
121 void ReadTensionDataBase(std::vector<double> & wireTensionVec);
122 void ReadWirePosDataBase(std::vector<vector<double> > & wirePosVec);
123 void ReadAliParDataBase(vector<double>& Sx, vector<double>& Sy, vector<double>& Sz,
124 vector<double>& Rx, vector<double>& Ry, vector<double>& Rz);
125 void Fill(); //get geometry data from Database
126 void AddWireNeighbors();
127 void RenewWireNeighbors(double range);
128 const int getAlignParIndexEast(int lyr) const;
129 const int getAlignParIndexWest(int lyr) const;
130
131 const double CalculatePhi(double phi) const;
132
133
134
135 // private data members
136 private:
137 double m_wholeShiftX;
138 double m_wholeShiftY;
139 double m_wholeShiftZ;
140 double m_wholeRotatX;
141 double m_wholeRotatY;
142 double m_wholeRotatZ;
143 int m_mindex;
144 std::string m_alignFilePath;
145 std::string m_wirePosFilePath;
146 std::string m_wireTensionFilePath;
147 bool m_updataalign;
148 bool m_useCgem;
149
150 double m_NeighborRange;//
151
152 bool m_conf_testAdjacentIntersection;
153
154 vector <MdcGeoWire*> fWires; //wire list (6860)
155 vector <MdcGeoGeneral> fGenerals; //general layer list (90)
156 vector <MdcGeoLayer*> fLayers; //sense wire layer list (43)
157 vector <MdcGeoSuper*> fSupers; //super layer list (11)
158 MdcGeoMisc fMisc; // parms. of MDC misc
159 vector <MdcGeoEnd*> fEnd; // tube and endplate list (67)
160 IDataProviderSvc* m_pCalibDataSvc;
161
162};
163
164
165#endif
166
167
MdcGeomSvc(const std::string &name, ISvcLocator *svcloc)
vector< AdjCandiTgtLine2D > getAdjacentCandidateWithDriftCircle(const MdcGeoWire *wireA, const MdcGeoWire *wireB, double driftA, double driftB)
give the lines that is tangent to both drift circles at the approximate z that the wires cross....
void Dump()
const MdcGeoSuper *const SuperLayer(unsigned id)
const MdcGeoWire *const Wire(unsigned id)
const MdcGeoGeneral *const GeneralLayer(unsigned id)
HepPoint3D getAdjacentIntersectionPointFast(const MdcGeoWire *wireA, const MdcGeoWire *wireB)
find the z where points on wireA, wireB has same phi. point is given as avg(A(z),B(z))
void handle(const Incident &inc)
HepPoint3D getAdjacentIntersectionPointSlower(const MdcGeoWire *wireA, const MdcGeoWire *wireB)
const int getSuperLayerSize()
vector< double > getAdjacentIntersectionBounds(const MdcGeoWire *wireA, const MdcGeoWire *wireB)
get bounding box in \varphi and z of touching shape of 2 adjacent layer wires.
const MdcGeoEnd *const End(unsigned id)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode finalize()
const MdcGeoLayer *const Layer(unsigned id)
const int getSegmentNo()
const int getWireSize()
vector< HepPoint3D > getAdjacentIntersectionShape(const MdcGeoWire *wireA, const MdcGeoWire *wireB)
get touching shape of 2 adjacent layer wires. return vertexs of intersection shape if the wires' se...
static bool getSagFlag(void)
const MdcGeoWire *const Wire(unsigned lyrid, unsigned wirid)
const int getGeneralLayerSize()
const int getLayerSize()
virtual StatusCode initialize()
const MdcGeoMisc *const Misc(void)
forms a line in x-y space, ax + by + c = 0
double angleWithR()
returns the cosine of angle of the line with R at its location (x0,y0). note that location is the mid...
CLHEP::Hep2Vector direction()
get direction vector of a line. garanteed to be outwards