source: JEM-EUSO/esaf_lal/tags/v1_r0/esaf/packages/simulation/detector/optics/src/NIdealFocalSurface.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.9 KB
Line 
1// $Id: LIdealFocalSurface.cc 2824 2009-03-16 14:36:44Z naumov $
2// Author: Dmitry V.Naumov  2007/11/16
3
4/*****************************************************************************
5 * ESAF: Euso Simulation and Analysis Framework                              *
6 *                                                                           *
7 *  Id: NIdealFocalSurface                                                   *
8 *  Package: Optics                                                          *
9 *  Coordinator: Alessandro.Thea                                             *
10 *                                                                           *
11 *****************************************************************************/
12
13//_____________________________________________________________________________
14//
15// NIdealFocalSurface
16//
17//   NIdealFocalSurface is the optimized focal surface for the MOpticalSystem
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 coordinate 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 "NIdealFocalSurface.hh"
39#include "Ntrace_optics.hh"
40#include <TVector3.h>
41#include "Photon.hh"
42#include "TMath.h"
43#include <cmath>
44
45ClassImp(NIdealFocalSurface)
46
47const Int_t kMaxIter=50;
48
49using namespace sou;
50using namespace TMath;
51using namespace NTraceLens;
52
53
54
55//______________________________________________________________________________
56NIdealFocalSurface::NIdealFocalSurface() {
57    //
58    // Constructor
59    //
60    const char* lens_dir = Conf()->GetStr("NOpticalSystem.lens_dir").data();
61    const char* tel_par = Conf()->GetStr("NOpticalSystem.tel_par").data();
62    ReadTelParm(lens_dir,tel_par);
63    fR   = fOpticalSystemParam->r_fs;
64    Double_t FS_Offset = fOpticalSystemParam->surface[0].Sz+fOpticalSystemParam->FS_OFFSET;
65    fPos = TVector3(0,0,FS_Offset*mm);
66    fDZdown = Zfs(0)-Zfs(fR*mm)-1.*mm;
67}
68
69//______________________________________________________________________________
70NIdealFocalSurface::~NIdealFocalSurface() {
71    //
72    // Destructor
73    //
74
75}
76
77//______________________________________________________________________________
78Bool_t NIdealFocalSurface::HitPosition(Photon *p) {
79    //
80    // Find whether the photons hits the ideal surface, and in such a case
81    // calculated the final position
82    //
83
84
85    // reject photons going downward
86    if ( p->dir.Z() < 0 )
87        return kFALSE;
88
89    TVector3 in_pos = p->pos;
90    TVector3 ax_pos(0,0,-fDZdown), ax_dir(0,0,1);
91
92    TVector3 bottomHit = in_pos+p->dir*((fPos[Z]-fDZdown-in_pos[Z])/p->dir[Z]);
93
94    if ( bottomHit.Perp()>fR )
95        return kFALSE;
96    //the minimum distance between the photon and the Zfs axis
97    TVector3 dummy=ax_dir.Cross(p->dir);
98    //cout <<" dummy[Z]=" << dummy[Z] << endl;
99    //double min_dist=Abs((bottomHit-ax_pos).Dot(dummy))/dummy.Mag();
100
101    //interaction point on top of the cylinder
102    //limit inclination of the photon
103
104    Double_t  dt = NextInt( bottomHit, p->dir);
105    //cout << "dt " << dt << endl;
106    TVector3 topHit = bottomHit+p->dir*dt;
107   // cout << "p->dir " << p->dir << endl;
108   // cout << "topHit= " << topHit << " bottomHit=" << bottomHit << endl;
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     double r_cut = 950.;
132    if ( dummy.Perp() > fR || fabs(dummy[Y])>r_cut)
133        return kFALSE;
134
135
136
137    p->posOnIfs=dummy;
138    //cout <<" dummy[Z]=" << dummy[Z] <<" dummy[Y]=" << dummy[Y]  <<" dummy[X]=" << dummy[X] << endl;
139    p->hitIfs=kTRUE;
140
141    return kTRUE;
142}
143
144
145//______________________________________________________________________________
146Double_t NIdealFocalSurface::Zfs(Double_t r) {
147    //
148    // Zfs returns the z value of the focal surface as a function of radius in
149    // local coordinates
150    //
151
152    return FocalSurface(r,fOpticalSystemParam);
153}
154
155//______________________________________________________________________________
156Double_t NIdealFocalSurface::Profile(Double_t r) {
157    //
158    // Profile returns the z value of the focal surface as a function of radius
159    // in detector coordinates
160    //
161
162    return Zfs(r)+fPos.Z();
163}
Note: See TracBrowser for help on using the repository browser.