1 |
formato |
1.1 |
#ifndef PAMVMCPRIMARYGF |
2 |
|
|
#define PAMVMCPRIMARYGF |
3 |
|
|
|
4 |
|
|
#include <vector> |
5 |
|
|
//#include <TObjectTable.h> |
6 |
|
|
#include "TObject.h" |
7 |
|
|
#include "TrkParams.h" |
8 |
|
|
#include "TMath.h" |
9 |
|
|
#define ZOFFSET 49.229 |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
using TMath::Min; |
13 |
|
|
|
14 |
|
|
struct PamVMCPlCross |
15 |
|
|
{ |
16 |
|
|
Double_t fX, fY; |
17 |
|
|
Int_t fplID; |
18 |
|
|
PamVMCPlCross(Double_t x,Double_t y, Int_t id):fX(x), fY(y), fplID(id){ }; |
19 |
|
|
virtual ~PamVMCPlCross(){; }; |
20 |
|
|
}; |
21 |
|
|
|
22 |
|
|
typedef vector<PamVMCPlCross*> Plcrvec; |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
//variable NGF is defined in TrkParams.h |
26 |
|
|
class PamVMCPrimaryGF : public TObject |
27 |
|
|
{ |
28 |
|
|
Plcrvec vec; |
29 |
|
|
Double_t fXtol, fYtol; |
30 |
|
|
Bool_t fisinside; |
31 |
|
|
|
32 |
|
|
Int_t PlCross(Double_t z_prev, Double_t z_curr){ |
33 |
|
|
for(Int_t i = 0; i<NGF; i++){ |
34 |
|
|
if( ( (z_prev>=TrkParams::zGF[i] + ZOFFSET ) && (z_curr<=TrkParams::zGF[i] + ZOFFSET ) ) || ( (z_prev<=TrkParams::zGF[i] + ZOFFSET ) && (z_curr>=TrkParams::zGF[i] + ZOFFSET ) ) ) { |
35 |
|
|
return i; |
36 |
|
|
|
37 |
|
|
} |
38 |
|
|
} |
39 |
|
|
return -1; |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
Bool_t IsInside(Int_t id, Double_t z_prev, Double_t x_prev, Double_t y_prev, Double_t z_curr, Double_t x_curr, Double_t y_curr, Double_t* xc, Double_t* yc){ |
43 |
|
|
if (z_prev==z_curr){ |
44 |
|
|
*xc = x_curr; |
45 |
|
|
*yc = y_curr; |
46 |
|
|
if( (TrkParams::xGF_min[id]<=x_curr) && (TrkParams::xGF_max[id]>=x_curr) && |
47 |
|
|
(TrkParams::yGF_min[id]<=y_curr) && (TrkParams::yGF_max[id]>=y_curr) ) return kTRUE; |
48 |
|
|
} else { |
49 |
|
|
Double_t kx = (x_prev - x_curr)/(z_prev-z_curr); |
50 |
|
|
Double_t bx = x_prev - kx*z_prev; |
51 |
|
|
Double_t ky = (y_prev - y_curr)/(z_prev-z_curr); |
52 |
|
|
Double_t by = y_prev - ky*z_prev; |
53 |
|
|
*xc = kx*(TrkParams::zGF[id]+ZOFFSET)+bx; |
54 |
|
|
*yc = ky*(TrkParams::zGF[id]+ZOFFSET)+by; |
55 |
|
|
//cout<<"Trk_plane:"<<id<<" x_prev,y_prev,zprev:"<<x_prev<<","<<y_prev<<","<<z_prev<<endl; |
56 |
|
|
//cout<<"Trk_plane:"<<id<<" x_curr,y_curr,zcurr:"<<x_curr<<","<<y_curr<<","<<z_curr<<endl; |
57 |
|
|
//cout<<"Trk_plane:"<<id<<" xc,yc,zc:"<<*xc<<","<<*yc<<","<<TrkParams::zGF[id]+ZOFFSET<<endl; |
58 |
|
|
if( (TrkParams::xGF_min[id]<=*xc) && (TrkParams::xGF_max[id]>=*xc) && |
59 |
|
|
(TrkParams::yGF_min[id]<=*yc) && (TrkParams::yGF_max[id]>=*yc) ) return kTRUE; |
60 |
|
|
} |
61 |
|
|
return kFALSE; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
void AddPlane(Double_t x_cr, Double_t y_cr, Int_t pl_id){ |
65 |
|
|
vec.push_back( new PamVMCPlCross( x_cr, y_cr, pl_id) ); |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
public: |
71 |
|
|
PamVMCPrimaryGF():fXtol(-100.),fYtol(-100.), fisinside(kFALSE){ }; |
72 |
|
|
virtual ~PamVMCPrimaryGF() { }; |
73 |
|
|
|
74 |
|
|
|
75 |
|
|
//doing after each step of primary |
76 |
|
|
void CheckCrossing(Double_t z_prev, Double_t x_prev, Double_t y_prev, Double_t z_curr, Double_t x_curr, Double_t y_curr){ |
77 |
|
|
Int_t pl_id = PlCross(z_prev, z_curr); |
78 |
|
|
Double_t xc,yc; |
79 |
|
|
xc = yc = -100.; |
80 |
|
|
if(pl_id >= 0){ |
81 |
|
|
fisinside = IsInside(pl_id, z_prev, x_prev, y_prev, z_curr, x_curr, y_curr, &xc, &yc); |
82 |
|
|
if (fisinside) AddPlane(xc, yc, pl_id); |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
//doing after finishing primary track |
86 |
|
|
Bool_t IsInsideAcceptance(Double_t* xc, Double_t* yc, Double_t &xtol, Double_t &ytol){ |
87 |
|
|
Plcrvec::const_iterator p = vec.begin(); |
88 |
|
|
*xc = *yc = -100; |
89 |
|
|
xtol = ytol = 100.; |
90 |
|
|
Bool_t is_tol_outside = kFALSE; |
91 |
|
|
while( p!=vec.end() ) |
92 |
|
|
{ |
93 |
|
|
xc[(*p)->fplID] = (*p)->fX; |
94 |
|
|
yc[(*p)->fplID] = (*p)->fY; |
95 |
|
|
Double_t xtolpl = Min((*p)->fX-TrkParams::xGF_min[(*p)->fplID], TrkParams::xGF_max[(*p)->fplID]-(*p)->fX); |
96 |
|
|
Double_t ytolpl = Min((*p)->fY-TrkParams::yGF_min[(*p)->fplID], TrkParams::yGF_max[(*p)->fplID]-(*p)->fY); |
97 |
|
|
if( (xtolpl < 0.) || (ytolpl<0.)) is_tol_outside = kTRUE; |
98 |
|
|
//cout<<"xc="<<(*p)->fX<<" yc="<<(*p)->fY<<" xtolpl="<<xtolpl<<" ytolpl="<<ytolpl<<endl; |
99 |
|
|
xtol=(xtolpl<xtol)?xtolpl:xtol; |
100 |
|
|
ytol=(ytolpl<ytol)?ytolpl:ytol; |
101 |
|
|
p++; |
102 |
|
|
} |
103 |
|
|
if ( is_tol_outside ) xtol = ytol = -100.; |
104 |
|
|
//cout<<"xtolpl_FIN="<<xtol<<" ytolpl_FIN="<<ytol<<" PL:"<<vec.size()<<endl; |
105 |
|
|
if (vec.size() == NGF) return kTRUE; |
106 |
|
|
xtol = ytol = -100.; |
107 |
|
|
return kFALSE; |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
// calls after primary propagation to clean everything |
111 |
|
|
virtual void Clear(Option_t * = ""){ |
112 |
|
|
fXtol=fYtol=-100.; |
113 |
|
|
vec.clear(); |
114 |
|
|
} |
115 |
|
|
}; |
116 |
|
|
#endif |