1#include "CgemGeomSvc/CgemGeoReadoutPlane.h"
8 double phiMin,
double dX_strip,
double dV,
9 double w,
double zmin,
double L,
10 int NXStrip,
int NVStrip,
double Xpitch,
double XstripWidth,
double Vpitch,
double VstripWidth,
double stereoAngle,
11 double midROfGap,
double outROfGap){
26 m_XstripWidth = XstripWidth;
28 m_VstripWidth = VstripWidth;
33 m_StereoAngle = stereoAngle / 180.*CLHEP::pi;
34 m_k = stereoAngle/fabs(stereoAngle);
35 m_MidRGap = midROfGap;
36 m_OutRGap = outROfGap;
41 while(m_Phimin<-
M_PI) m_Phimin+=2*
M_PI;
42 while(m_Phimin>
M_PI) m_Phimin-=2*
M_PI;
44 m_Xmin = m_Phimin*m_Rmid;
48 m_Phimin_strip = dX_strip/m_Rmid;
51 m_Xmin_strip = m_Phimin_strip*m_Rmid;
52 m_Xmax_strip = m_Xmin_strip+NXStrip*m_XPitch;
53 m_Phimax_strip = m_Xmax_strip/m_Rmid;
62 m_Vtot = NXStrip*m_XPitch*
cos(m_StereoAngle)+m_L*fabs(
sin(m_StereoAngle));
63 dV=(m_Vtot-NVStrip*m_VPitch)/2.0;
65 m_Vmax = m_Vmin_strip+NVStrip*m_VPitch;
68 cout<<
" dX = "<<dX_strip<<endl;
77 cout<<
"construct one readout-plane with: "<<endl;
78 cout<<
" iLayer "<<m_iLayer<<
", iSheet "<<m_iSheet<<endl;
79 cout<<
" Rx, Rv, Xmin, width = "<< m_RX<<
", "<<m_RV<<
", "<<m_Xmin<<
", "<<m_W<<endl;
80 cout<<
" Zmin, L = "<< m_Zmin <<
", "<<m_L<<endl;
81 cout<<
" XPitch, XstripWidth ="<<m_XPitch<<
", "<<m_XstripWidth<<endl;
82 cout<<
" sensitive X (Xmin as origin): "<<m_Xmin_strip<<
" to "<<m_Xmax_strip<<endl;
83 cout<<
" sensitive range in phi (phimin as origin): "<<m_Phimin_strip<<
" to "<<m_Xmax_strip/m_Rmid<<endl;
85 cout<<
" VPitch, VstripWidth, StereoAngle, k ="<<m_VPitch<<
", "<<m_VstripWidth<<
", "<<m_StereoAngle<<
", "<<m_k<<endl;
86 cout<<
" Vtot, Vmin, Vmax = "<<m_Vtot<<
", "<<m_Vmin_strip<<
", "<<m_Vmax<<endl;
87 cout<<
" N_Xstrips, N_Vstrips="<<m_NXstrips<<
", "<<m_NVstrips<<endl;
88 cout<<
" MidRGap="<<m_MidRGap<<
", OutRGap="<<m_OutRGap<<endl;
93 double dPhi = phi - m_Phimin;
94 while(dPhi<0) dPhi += CLHEP::twopi;
95 while(dPhi>=CLHEP::twopi) dPhi -= CLHEP::twopi;
96 if(dPhi>m_Phimax_strip) {
97 double dphi_start = phi-(m_Phimin+m_Phimin_strip);
98 while(dphi_start> 0) dphi_start-=2.*
M_PI;
99 while(dphi_start<=-2.*
M_PI) dphi_start+=2.*
M_PI;
103 double dphi_end = dPhi-m_Phimax_strip;
104 if(dphi_start+dphi_end>0) dPhi=dphi_start+m_Phimin_strip;
106 double X = m_Rmid*dPhi;
112 double X =
getX(phi);
116 int xID = floor(X/m_XPitch);
120 if(xID>=m_NXstrips) xID=-2;
134 if(xID2==-2) xID2=m_NXstrips-1;
135 double X =
getX(phi);
162 if(xID2==-2) xID2=m_NXstrips-1;
163 if(xID2>=0&&xID2<m_NXstrips) {
164 double X =
getX(phi);
177 double phi=atan2(y,
x);
200 }
else if(z > m_Zmin+m_L){
203 double phi = pos.phi();
209 if(V_ID==-2) vid2=m_NVstrips-1;
223 }
else if(z > m_Zmin+m_L){
226 double phi = pos.phi();
231 if(V_ID==-2) vid2=m_NVstrips-1;
269 double phi=(X+m_Xmin)/m_Rmid;
270 while(phi<-
M_PI) phi+=CLHEP::twopi;
271 while(phi>
M_PI) phi-=CLHEP::twopi;
276 double localX = X-m_Xmin_strip;
278 if( (checkVRange==0||((V>=m_Vmin_strip)&&(V<m_Vmax))) && ((checkXRange==0)||((localX>=0.0)&&(localX<=m_Xmax_strip-m_Xmin_strip))) ){
284 double z0=m_Zmax;
if(m_k<0) z0=m_Zmin;
285 z = localX/
tan(m_StereoAngle) - V/
sin(m_StereoAngle) + z0;
291 vector<int>& vecXID, vector<int>& vecVID)
const {
293 bool printDebug =
false;
297 if( (z[0]<m_Zmin && z[1]<m_Zmin) || (z[0]>(m_Zmin+m_L) && z[1]>(m_Zmin+m_L)) )
return;
300 double phimin=-CLHEP::pi;
303 if(fabs(phi[1]-phi[0])>CLHEP::pi){
305 for(
int i=0; i<2; i++)
if(phi[i]<0.0) phi[i]+=CLHEP::twopi;
315 if(printDebug) cout<<
"phimin="<<phimin<<
", phi[0,1]="<<phi[0]<<
","<<phi[1]<<
", z[0,1]="<<z[0]<<
","<<z[1]<<endl;
316 for(
int i=0; i<2; i++){
318 double phiTmp=(phi[1]-phi[0])/(z[1]-z[0])*(m_Zmin-z[0])+phi[0];
322 if(z[i]>(m_Zmin+m_L)){
323 double phiTmp=(phi[1]-phi[0])/(z[1]-z[0])*(m_Zmin+m_L-z[0])+phi[0];
328 double phiActiveMin=m_Phimin+m_Phimin_strip+10e-10;
329 double phiActiveMax=m_Phimin+m_Phimax_strip-10e-10;
330 if(printDebug) cout<<
"phimin="<<phimin<<
", phiActiveMin="<<phiActiveMin<<
", phiActiveMax="<<phiActiveMax<<
", phi[0,1]="<<phi[0]<<
","<<phi[1]<<
", z[0,1]="<<z[0]<<
","<<z[1]<<endl;
331 while(phiActiveMax>=CLHEP::twopi) phiActiveMax-=CLHEP::twopi;
332 while(phiActiveMin>=CLHEP::twopi) phiActiveMin-=CLHEP::twopi;
333 while(phiActiveMax<0 ) phiActiveMax+=CLHEP::twopi;
334 while(phiActiveMin<0 ) phiActiveMin+=CLHEP::twopi;
335 if(phimin==-CLHEP::pi)
341 while(phiActiveMin>CLHEP::pi) phiActiveMin-=CLHEP::twopi;
342 while(phiActiveMax>CLHEP::pi) phiActiveMax-=CLHEP::twopi;
344 if(printDebug) cout<<
"phimin="<<phimin<<
", phiActiveMin="<<phiActiveMin<<
", phiActiveMax="<<phiActiveMax<<
", phi[0,1]="<<phi[0]<<
","<<phi[1]<<
", z[0,1]="<<z[0]<<
","<<z[1]<<endl;
347 if(phiActiveMin<=phi[0])
349 if(phiActiveMax<=phiActiveMin) iCase=1;
350 else if(phiActiveMax<=phi[0]) iCase=2;
351 else if(phiActiveMax<=phi[1]) iCase=3;
354 else if(phiActiveMin<=phi[1])
356 if(phiActiveMax<=phi[0]) iCase=5;
357 else if(phiActiveMax<=phiActiveMin) iCase=6;
358 else if(phiActiveMax<=phi[1]) iCase=7;
363 if(phiActiveMax<=phi[0]) iCase=9;
364 else if(phiActiveMax<=phi[1]) iCase=10;
365 else if(phiActiveMax<=phiActiveMin) iCase=11;
368 if(printDebug) cout<<
"iCase = "<<iCase<<endl;
371 zBoundary[0]=z[0]+(z[1]-z[0])/(phi[1]-phi[0])*(phiActiveMin-phi[0]);
372 zBoundary[1]=z[0]+(z[1]-z[0])/(phi[1]-phi[0])*(phiActiveMax-phi[0]);
401 cout<<
"Error in CgemGeoReadoutPlane::getFiredStripID: iCase = "<<iCase<<endl;
404 if(printDebug) cout<<
"phimin="<<phimin<<
", phiActiveMin="<<phiActiveMin<<
", phiActiveMax="<<phiActiveMax<<
", phi[0,1]="<<phi[0]<<
","<<phi[1]<<
", z[0,1]="<<z[0]<<
","<<z[1]<<endl;
406 G4ThreeVector pos_1,pos_2;
407 pos_1.setRhoPhiZ(m_Rmid,phi[0],z[0]);
408 pos_2.setRhoPhiZ(m_Rmid,phi[1],z[1]);
409 int XID_min(-9),XID_max(-9);
410 int VID_min(-9),VID_max(-9);
413 if( iCase!=6 && VID_max<VID_min ) {
419 cout<<
"on the sheet: phi "<<phi[0]<<
" to "<<phi[1]<<
", z "<<z[0]<<
" to "<<z[1]<<endl;
420 cout<<
" XID "<<XID_min<<
" to "<<XID_max<<
", VID "<<VID_min<<
" to "<<VID_max<<endl;
425 for(
int i=0; i<=
abs(XID_min-XID_max);i++) vecXID.push_back(XID_min+i);
426 for(
int i=0; i<=
abs(VID_min-VID_max);i++) vecVID.push_back(VID_min+i);
430 pos_1.setRhoPhiZ(m_Rmid,phiActiveMax,zBoundary[1]);
431 pos_2.setRhoPhiZ(m_Rmid,phiActiveMin,zBoundary[0]);
432 int XID_1(-9),XID_2(-9);
433 int VID_1(-9),VID_2(-9);
436 for(
int i=0; i<=
abs(XID_min-XID_1);i++) vecXID.push_back(XID_min+i);
437 for(
int i=0; i<=
abs(XID_max-XID_2);i++) vecXID.push_back(XID_2+i);
438 int VID_0=min(VID_1,VID_min);
439 for(
int i=0; i<=
abs(VID_min-VID_1);i++) vecVID.push_back(VID_0+i);
440 VID_0=min(VID_2,VID_max);
441 for(
int i=0; i<=
abs(VID_max-VID_2);i++) vecVID.push_back(VID_0+i);
double abs(const EvtComplex &c)
double tan(const BesAngle a)
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
CgemGeoReadoutPlane(int iLayer, int iSheet, double rx, double rv, double phi_min, double dX_strip, double dV, double w, double zmin, double L, int NXStrip, int NVStrip, double Xpitch, double XstripWidth, double Vpitch, double VstripWidth, double stereoAngle, double midROfGap, double outROfGap)
void getFiredStripID(G4ThreeVector pos1, G4ThreeVector pos2, vector< int > &vecXID, vector< int > &vecVID) const
double getCentralXFromXID(int X_ID) 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
int getVIDFromV(double V) const
double getVFromPhiZ(double phi, double z) 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)