source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/detector/optics/src/JIdealFocalSurface.cc @ 117

Last change on this file since 117 was 117, checked in by moretto, 11 years ago

ESAF version compilable on mac OS

File size: 4.4 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: JIdealFocalSurface.cc 2136 2005-10-02 14:18:08Z thea $
3// A.Thea created Apr,  3 2003
4
5#include "JIdealFocalSurface.hh"
6#include "EVector.hh"
7#include "Photon.hh"
8#include "TMath.h"
9
10using namespace sou;
11
12ClassImp(JIdealFocalSurface)
13
14//______________________________________________________________________________
15JIdealFocalSurface::JIdealFocalSurface() { 
16    //
17    // Constructor
18    //
19   
20        fR   = Conf()->GetNum("JIdealFocalSurface.fR")*mm;
21        fPos = EVector(0,0,Conf()->GetNum("JIdealFocalSurface.fPos.Z"))*mm;
22
23    _rho = Conf()->GetNum("JIdealFocalSurface.rho");
24    _k = Conf()->GetNum("JIdealFocalSurface.k");
25    _a = Conf()->GetNum("JIdealFocalSurface.a");
26    _b = Conf()->GetNum("JIdealFocalSurface.b");
27    _c = Conf()->GetNum("JIdealFocalSurface.c");
28    _d = Conf()->GetNum("JIdealFocalSurface.d");
29    _prec = Conf()->GetNum("JIdealFocalSurface.precision")*mm;
30    fDZdown = TMath::Abs(Zfs(fR)); //TOCHECK
31#ifdef DEBUG
32    cout << "JIdealFocalSurface created" << endl;
33    cout << "rho=" << _rho << "\n" <<
34        "k=" << _k << "\n" <<
35        "a=" << _a << "\n" <<
36        "b=" << _b << "\n" <<
37        "c=" << _c << "\n" <<
38        "d=" << _d << "\n" << 
39        "prec=" << _prec << "\n" << 
40        "fDZdown" << fDZdown << "\n" << endl;
41    cout << "Zfs(0)=" << Zfs(0) << "\n" <<
42        "Zfs(100)=" << Zfs(100) << "\n" <<
43        "Zfs(200)=" << Zfs(200) << "\n" <<
44        "Zfs(300)=" << Zfs(300) << "\n" <<
45        "Zfs(400)=" << Zfs(400) << "\n" <<
46        "Zfs(500)=" << Zfs(500) << "\n" <<
47        "Zfs(600)=" << Zfs(600) << "\n" <<
48        "Zfs(700)=" << Zfs(700) << "\n" <<
49        "Zfs(800)=" << Zfs(800) << "\n" <<
50        "Zfs(900)=" << Zfs(900) << "\n" <<
51        "Zfs(1000)=" << Zfs(1000) << "\n" <<
52        "Zfs(1100)=" << Zfs(1100) << "\n" <<
53        "Zfs(1200)=" << Zfs(1200) << "\n" << endl;
54#endif
55}
56
57//______________________________________________________________________________
58JIdealFocalSurface::~JIdealFocalSurface() {
59    //
60    // Destructor
61    //
62}
63
64const Int_t kMaxIter=50;
65
66//______________________________________________________________________________
67Bool_t JIdealFocalSurface::HitPosition(Photon *p)
68{
69        TVector3 in_pos = p->pos-fPos;
70        EVector ax_pos(0,0,-fDZdown), ax_dir(0,0,1);
71        // check if the ph is in the IFS boundaries
72        EVector bottom_hit = in_pos+p->dir*((-fDZdown-in_pos[Z])/p->dir[Z]);
73
74        if (bottom_hit.Perp() > fR) {
75                return kFALSE;
76        }
77       
78        //the minimum distance between the photon and the Zfs axis
79        EVector dummy=ax_dir.Cross(p->dir);
80        Double_t min_dist=TMath::Abs((bottom_hit-ax_pos).Dot(dummy))/dummy.Mag();
81
82        //interaction point on top of the cilinder
83        //limit inclination of the photon
84       
85        EVector top_hit;
86        if (p->dir[Z]/p->dir.Perp() < (fDZup+fDZdown)/(2*fR)) {
87                // photon hit the lateral surface of the cylinder
88                top_hit=bottom_hit+p->dir*
89                        (fR*sqrt(1-min_dist*min_dist/(fR*fR))/p->dir.Perp());
90        } else {
91                // check if the photon hit the top of the cylinder
92                top_hit=bottom_hit+p->dir*((fDZup+fDZdown)/p->dir[Z]);
93                if (top_hit.Perp() > fR) {
94                        top_hit=bottom_hit+p->dir*
95                        (fR*sqrt(1-min_dist*min_dist/(fR*fR))/p->dir.Perp());
96                }
97        }
98#ifdef DEBUG
99                cout << "p->dir " << p->dir << endl;
100                cout << "top_hit= " << top_hit << " bottom_hit=" << bottom_hit << endl;
101#endif
102        EVector step=(top_hit-bottom_hit)*.5;
103        dummy=bottom_hit+step;
104        for(int i=0; i < kMaxIter ; i++) {
105#ifdef DEBUG
106                cout << "i=" << i << " dummy[Z]=" << dummy[Z] << " Zfs(dummy.Perp())=" << Zfs(dummy.Perp()) << endl;
107#endif
108                if (TMath::Abs(Zfs(dummy.Perp())-dummy[Z]) < _prec) {
109                        break;
110                }
111                step*=.5;
112                if (Zfs(dummy.Perp()) > dummy[Z]) dummy+=step;
113                else dummy-=step;
114        }
115
116        if ( dummy.Perp() < fR ) {     
117                p->posOnIfs=dummy+fPos;
118                p->hitIfs=kTRUE;
119        return kTRUE;
120        }
121       
122    return kFALSE;
123}
124
125//______________________________________________________________________________
126Double_t JIdealFocalSurface::Zfs(Double_t r) {
127    //
128    // Zfs returns the z value of the focal surface as a function of radius
129    //
130
131        Double_t rr=r*r;
132        return rr/((1+sqrt(1-((1+_k)*rr/(_rho*_rho))))*_rho)+
133                _a*rr*rr+_b*rr*rr*rr+_c*rr*rr*rr*rr+
134                _d*rr*rr*rr*rr*rr;
135}
136
137//______________________________________________________________________________
138Double_t JIdealFocalSurface::Profile(Double_t r) {
139    //
140    // Profile returns the z value of the focal surface as a function of radius
141    // in detector coordinates
142    //
143
144    return Zfs(r)+fPos.Z();
145}
146
Note: See TracBrowser for help on using the repository browser.