source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/detector/optics/src/KIdealFocalSurface.cc @ 114

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

actual version of ESAF at CCin2p3

File size: 4.7 KB
Line 
1// $Id: KIdealFocalSurface.cc 2136 2005-10-02 14:18:08Z thea $
2// Author: J.Watts    2003/09/21
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: KIdealFocalSurface                                                   *
8 *  Package: Optics                                                          *
9 *  Coordinator: Alessandro.Thea                                             *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14//
15// KIdealFocalSurface
16//
17//   KIdealFocalSurface is the optimized focal surface for the KOpticalSystem
18//   Its shape is described by the radial profile:
19//
20//                       r^2
21//   z(r) =  --------------------------- + A*r^4 + B*r^6 + C*r^8 + D*r^10
22//          (1+(sqrt( (1+k)*(r/rho)^2) ))
23//
24//   Config file parameters
25//   ======================
26//
27//   fR [mm] : Maximum extension of the ideal focal surface from the optical
28//   axis.
29//
30//   fPos [mm] : z coodinate of the tip of the surface in detector coordinate
31//   system.
32//
33//   fRho, fK, fA, fB, fC, fD : focal surface parameters.
34//   
35//   fPrec [mm] : precision required to claim that the photon has hit the FS.
36//
37
38#include "KIdealFocalSurface.hh"
39#include <TVector3.h>
40#include "Photon.hh"
41#include "TMath.h"
42
43ClassImp(KIdealFocalSurface)
44   
45const Int_t kMaxIter=50;
46
47using namespace sou;
48using namespace TMath;
49
50//______________________________________________________________________________
51KIdealFocalSurface::KIdealFocalSurface() {
52    //
53    // Constructor
54    //
55
56        fR   = Conf()->GetNum("KIdealFocalSurface.fR")*mm;
57        fPos = TVector3(0,0,Conf()->GetNum("KIdealFocalSurface.fPos.Z"))*mm;
58   
59    fRho = Conf()->GetNum("KIdealFocalSurface.rho");
60    fK = Conf()->GetNum("KIdealFocalSurface.k");
61    fA = Conf()->GetNum("KIdealFocalSurface.a");
62    fB = Conf()->GetNum("KIdealFocalSurface.b");
63    fC = Conf()->GetNum("KIdealFocalSurface.c");
64    fD = Conf()->GetNum("KIdealFocalSurface.d");
65    fPrec = Conf()->GetNum("KIdealFocalSurface.precision")*mm;
66    fDZdown = Abs(Zfs(fR)); //TOCHECK
67
68}
69
70//______________________________________________________________________________
71KIdealFocalSurface::~KIdealFocalSurface() {
72    //
73    // Destructor
74    //
75
76}
77
78//______________________________________________________________________________
79Bool_t KIdealFocalSurface::HitPosition(Photon *p) {
80    //
81    // Find whether the photons hits the ideal surface, and in such a case
82    // calculated the final position
83    //
84
85
86    // reject photons going downward
87    if ( p->dir.Z() < 0 )
88        return kFALSE;
89
90
91    TVector3 in_pos = p->pos-fPos;
92    TVector3 ax_pos(0,0,-fDZdown), ax_dir(0,0,1);
93
94    TVector3 bottomHit = in_pos+p->dir*((-fDZdown-in_pos[Z])/p->dir[Z]);
95
96    if (bottomHit.Perp() > fR)
97        return kFALSE;
98
99    //the minimum distance between the photon and the Zfs axis
100    TVector3 dummy=ax_dir.Cross(p->dir);
101    //double min_dist=Abs((bottomHit-ax_pos).Dot(dummy))/dummy.Mag();
102
103    //interaction point on top of the cylinder
104    //limit inclination of the photon
105
106    Double_t  dt = NextInt( bottomHit+fPos, p->dir);
107
108    TVector3 topHit = bottomHit+p->dir*dt;
109/*
110#ifdef DEBUG
111    cout << "p->dir " << p->dir << endl;
112    cout << "topHit= " << topHit << " bottomHit=" << bottomHit << endl;
113#endif
114*/
115    TVector3 step = (topHit-bottomHit)*.5;
116    dummy=bottomHit+step;
117
118    for(int i=0; i < kMaxIter ; i++) {
119/*
120#ifdef DEBUG
121        cout << "i=" << i << " dummy[Z]=" << dummy[Z] << " Zfs(dummy.Perp())=" << Zfs(dummy.Perp()) << endl;
122#endif
123*/
124        if (Abs(Zfs(dummy.Perp())-dummy[Z]) < fPrec) {
125            break;
126        }
127        step*=.5;
128        if (Zfs(dummy.Perp()) > dummy[Z]) dummy+=step;
129        else dummy-=step;
130    }
131
132
133    if ( dummy.Perp() > fR )
134        return kFALSE;
135
136    p->posOnIfs=dummy+fPos;
137    p->hitIfs=kTRUE;
138
139    return kTRUE;
140}
141
142
143//______________________________________________________________________________
144Double_t KIdealFocalSurface::Zfs(Double_t r) {
145    //
146    // Zfs returns the z value of the focal surface as a function of radius in
147    // local coordinates
148    //
149
150        Double_t rr=r*r;
151        return rr/((1+sqrt(1-((1+fK)*rr/(fRho*fRho))))*fRho)+
152                fA*rr*rr+fB*rr*rr*rr+fC*rr*rr*rr*rr+
153                fD*rr*rr*rr*rr*rr;
154}
155
156//______________________________________________________________________________
157Double_t KIdealFocalSurface::Profile(Double_t r) {
158    //
159    // Profile returns the z value of the focal surface as a function of radius
160    // in detector coordinates
161    //
162
163    return Zfs(r)+fPos.Z();
164}
165
Note: See TracBrowser for help on using the repository browser.