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