CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Cgem/CgemGeomSvc/CgemGeomSvc-00-00-31-p01/CgemGeomSvc/CgemGeoReadoutPlane.h
Go to the documentation of this file.
1#ifndef CGEMGEOREADOUTPLANE_H
2#define CGEMGEOREADOUTPLANE_H
3
4#include <string>
5#include <vector>
6#include <CLHEP/Units/PhysicalConstants.h>
7#include <CLHEP/Units/SystemOfUnits.h>
8#include "G4ThreeVector.hh"
9
10using namespace std;
11
13
14 public:
15 CgemGeoReadoutPlane(int iLayer, int iSheet,
16 double rx, double rv,
17 double phi_min, double dX_strip, double dV,
18 double w, double zmin, double L,
19 int NXStrip, int NVStrip,
20 double Xpitch, double XstripWidth, double Vpitch, double VstripWidth, double stereoAngle,
21 double midROfGap, double outROfGap);
23
24 void print();
25
26 int getLayerId() {return m_iLayer;};
27 int getSheetId() {return m_iSheet;};
28 double getRX() {return m_RX;};
29 double getRV() {return m_RV;};
30 double getPhimin() {return m_Phimin;};
31 double getXmin() {return m_Xmin;};
32 double getWidth() {return m_W;};
33 double getZmin() {return m_Zmin;};
34 double getLength() {return m_L;};
35 double getXPitch() {return m_XPitch;};
36 double getVPitch() {return m_VPitch;};
37 double getStereoAngle() {return m_StereoAngle;};
38 double getMidRAtGap() {return m_MidRGap;};
39 double getVmax() {return m_Vmax;};
40 int getNXstrips() const { return m_NXstrips; };
41 int getNVstrips() const { return m_NVstrips; };
42
43 bool OnThePlane(double phi, double z) const;// check (phi,z) in the sensitive area or not
44
45 double getX(double phi) const;// X with m_Xmin as origin
46 int getXStripID(double phi) const;// -1: beyond start, -2: beyond end
47 int getXStripID(double x, double y) const;// -1: beyond start, -2: beyond end, -3: x=y=0
48 int getXStripID(G4ThreeVector pos) const; // -1: beyond start, -2: beyond end, -3: x=y=0
49 int getClosestXStripID(double phi, double& dist) ; // dist to the border of the closest strips, <0 inside of the strip, >0 outside of the strip
50 int getClosestVStripID(G4ThreeVector pos, double& dist) const;// dist to the border of the closest strips, <0 inside of the strip, >0 outside of the strip
51 double getDist2ClosestXStripCenter(double phi, int& id) ; // distance to the center of the closest strip
52 double getDist2ClosestVStripCenter(G4ThreeVector pos, int& id) ;// distance to the center of the closest strip
53 void getStripID(G4ThreeVector pos, int& X_ID, int& V_ID) const; // get the closest XID/VID
54 void getFiredStripID(G4ThreeVector pos1, G4ThreeVector pos2, vector<int>& vecXID, vector<int>& vecVID) const;
55
56 double getVFromLocalXZ(double x,double zeta) const;// input: local X, Zeta @ X plane with (phi_min_strip,-L/2) as origin, output: local V @ V plane
57 double getVFromPhiZ(double phi, double z) const;
58 double getVInNextSheetFromV(double v, double phiminNext) const {
59 double dPhi = phiminNext-m_Phimin;// assume the next m_Phimin_strip is the same
60 while(dPhi<=0) dPhi+=CLHEP::twopi;
61 while(dPhi>CLHEP::twopi) dPhi-=CLHEP::twopi;
62 //cout<<"getVInNextSheetFromV: dphi = "<<dPhi<<endl;
63 double dX = dPhi*m_Rmid;
64 return v-dX*cos(m_StereoAngle);
65 }
66 int getVIDFromV(double V) const; // -1: beyond start, -2: beyond end
67 int getVIDInNextSheetFromVID(int vID, double phimin_next) const;
68
69 double getPhiMin_strip() const {return m_Phimin_strip+m_Phimin;}
70 double getCentralXFromXID(int X_ID) const
71 { //X_ID=X_ID-m_NXstrips*m_iSheet;
72 return (X_ID+0.5)*m_XPitch+m_Xmin_strip;
73 }// central X with m_Xmin as origin
74 double getPhiFromXID(int X_ID) const; /* from -pi to pi */
75 double getCentralVFromVID(int V_ID) const
76 {
77 //V_ID=V_ID-m_NVstrips*m_iSheet;
78 return (V_ID+0.5)*m_VPitch+m_Vmin_strip;
79 }
80 double getVStripLength(int V_ID) const
81 {
82 double vStripLegth(0.);
83 if(V_ID>=0&&V_ID<m_NVstrips)
84 {
85 double V=getCentralVFromVID(V_ID);
86 double Lz=V/fabs(sin(m_StereoAngle));
87 if(Lz<=m_L)
88 {
89 vStripLegth=Lz/cos(m_StereoAngle);
90 }
91 else if(V/cos(m_StereoAngle)<=m_NXstrips*m_XPitch)
92 {
93 vStripLegth=m_L/cos(m_StereoAngle);
94 }
95 else vStripLegth=(m_Vtot-V)/fabs(sin(m_StereoAngle)*cos(m_StereoAngle));
96 }
97 return vStripLegth;
98 }
99
100 double getZFromXV(double X, double V, int checkXRange=1, int checkVRange=1) const;// X with m_Xmin as origin
101 double getZFromPhiV(double phi, double V, int checkXRange=1) const;
102
103 /* bool intersection(int iX, int iV) */
104 /* { */
105 /* double V=getCentralVFromVID(iV); */
106 /* double Xmin=(V/sin(m_StereoAngle)-m_L); */
107 /* } */
108
109 private:
110 int m_iLayer; // layer id: 0, 1 ,2
111 int m_iSheet; // sheet id: 0, 1
112 double m_RX; // radius (mm) for X strips
113 double m_RV; // radius (mm) for V strips
114 double m_Rmid; // middle radius (mm) for anode
115 double m_MidRGap;// middle radius of the drift region (mm)
116 double m_OutRGap;// outer radius of the drift region (mm)
117 double m_Zmin; // starting position of the readout plane in Z (mm)
118 double m_Zmax; // ending position of the readout plane in Z (mm)
119 double m_L; // length in z (mm)
120
121 double m_W; // width in X (mm) excluding gap area (to be connected by bands)
122 double m_Phimin; // starting position of the readout plane in phi (radian) (-pi to pi)
123 double m_Xmin; // starting position of the readout plane in X (mm) = m_Phimin*m_RX
124 double m_Phimin_strip;// position of the first strip in phi (radian) center -0.5*pitch (-pi,pi) with m_Phimin as origin
125 double m_Xmin_strip; // position of the first strip in X (mm) = m_Phimin_strip*m_Rmid (center-0.5*pitch) with m_Xmin as origin
126 double m_Phimax_strip;// position of the last strip in phi (radian) center +0.5*pitch (-pi,pi) with m_Phimin as origin
127 double m_Xmax_strip; // position of the last strip in X (mm) = m_Xmin_strip+m_XPitch*m_NXstrips (center+0.5*pitch) with m_Xmin as origin
128
129 //double m_Vmin;
130 double m_Vtot; // total V in the sensitive rectangle area (m_XPitch*m_NXstrips, L)
131 double m_Vmin_strip; // position of the first V strip in V (mm) center-0.5*pitch with respect to the corner of the sensitive area
132 double m_Vmax; // position of the last V strip in V (mm) center+0.5*pitch with respect to the corner of the sensitive area
133
134 //double m_Wdead; // dead area (mm)
135
136 double m_XPitch; // pitch in X (mm)
137 double m_VPitch; // pitch in V (mm)
138 double m_XstripWidth; // width of X strips (mm)
139 double m_VstripWidth; // width of V strips (mm)
140 double m_StereoAngle; // Stereo angle (rad)
141 double m_k; // +1 or -1, sign of the stereo angle
142
143 int m_NXstrips;
144 int m_NVstrips;
145};
146
147inline bool CgemGeoReadoutPlane::OnThePlane(double phi, double z) const
148{
149 double dPhi=phi-m_Phimin;// [0, 2pi) with m_Phimin as origin
150 while(dPhi<0) dPhi+=CLHEP::twopi;
151 while(dPhi>=2*M_PI) dPhi-=CLHEP::twopi;
152 if(dPhi>=m_Phimin_strip && dPhi<=m_Xmax_strip/m_Rmid && z>=m_Zmin && z<=m_Zmax) return true;
153 else return false;
154}
155
156inline double CgemGeoReadoutPlane::getVFromLocalXZ(double x, double zeta) const
157{
158 if( x>=0. && x<=m_NXstrips*m_XPitch && zeta>=0 && zeta<=m_L )
159 {
160 //double X = x/m_RX*m_RV;// X at V plane
161 //if(m_StereoAngle>0) return zeta*sin(m_StereoAngle) + X*cos(m_StereoAngle);
162 //else return (zeta-m_L)*sin(m_StereoAngle)+X*cos(m_StereoAngle);
163 double z0=m_Zmax; if(m_k<0) z0=m_Zmin;
164 //return X*cos(m_StereoAngle)+((m_k-1.0)*m_L/2.0-zeta)*sin(m_StereoAngle);
165 return x*cos(m_StereoAngle)+(z0-zeta-m_Zmin)*sin(m_StereoAngle);
166 } else {
167 return -9999.0;
168 }
169}
170
171inline double CgemGeoReadoutPlane::getVFromPhiZ(double phi, double z) const
172{
173 double dPhi=phi-m_Phimin;
174 while(dPhi<0) dPhi+=CLHEP::twopi;
175 while(dPhi>=CLHEP::twopi) dPhi-=CLHEP::twopi;
176 double X=dPhi*m_Rmid;// X with m_Xmin as origin
177 double x=X-m_Xmin_strip;// x with m_Xmin_strip as origin
178 double zeta=z-m_Zmin;// local zeta [0,L]
179 return getVFromLocalXZ(x,zeta);
180}
181
182
183inline int CgemGeoReadoutPlane::getVIDInNextSheetFromVID(int vID, double phimin_next) const {
184 int vId_next = -1;
185 //vID=vID-m_NVstrips*m_iSheet;
186 if( (vID>=0) && (vID<m_NVstrips) ){
187 double v = getCentralVFromVID(vID);
188 double v2 = getVInNextSheetFromV(v, phimin_next);
189 //if(v2>=0.) return floor(v2/m_VPitch);
190 vId_next = getVIDFromV(v2);// assume the next sheet with the same configuration
191 //if(m_iLayer>0) { vId_next=vId_next+(1-2*m_iSheet)*m_NVstrips;// with assumption Nsheet=2 for layerID>0 FIXME}
192 }
193 return vId_next;
194}
195
196inline double CgemGeoReadoutPlane::getZFromPhiV(double phi, double V, int checkXRange) const {
197 phi = phi-m_Phimin;
198 while(phi<0) phi+=CLHEP::twopi;
199 while(phi>=CLHEP::twopi) phi-=CLHEP::twopi;
200 return getZFromXV(phi*m_Rmid, V, checkXRange);
201}
202
203inline int CgemGeoReadoutPlane::getVIDFromV(double V) const{
204 double Vid = floor((V-m_Vmin_strip)/m_VPitch);
205 if(Vid<0) Vid=-1;
206 if(Vid>=m_NVstrips) Vid=-2;
207 //Vid=Vid+m_NVstrips*m_iSheet;
208 return Vid;
209}
210#endif /* CGEMGEOREADOUTPLANE_H */
Double_t x[10]
double sin(const BesAngle a)
double cos(const BesAngle a)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
#define M_PI
Definition: TConstant.h:4
void getFiredStripID(G4ThreeVector pos1, G4ThreeVector pos2, vector< int > &vecXID, vector< int > &vecVID) const
double getZFromPhiV(double phi, double V, int checkXRange=1) const
double getPhiFromXID(int X_ID) const
double getZFromXV(double X, double V, int checkXRange=1, int checkVRange=1) const
double getDist2ClosestXStripCenter(double phi, int &id)
int getClosestXStripID(double phi, double &dist)
int getXStripID(double phi) const
double getX(double phi) const
int getClosestVStripID(G4ThreeVector pos, double &dist) const
void getStripID(G4ThreeVector pos, int &X_ID, int &V_ID) const
double getDist2ClosestVStripCenter(G4ThreeVector pos, int &id)