1 | // $Id: Pupil.cc 3021 2012-03-27 07:52:57Z mabl $ |
---|
2 | // Author: Alessandro Thea 2005/10/28 |
---|
3 | |
---|
4 | /***************************************************************************** |
---|
5 | * ESAF: Euso Simulation and Analysis Framework * |
---|
6 | * * |
---|
7 | * Id: Pupil * |
---|
8 | * Package: RadiativeTransfe * |
---|
9 | * Coordinator: Sylvain.Moreggia * |
---|
10 | * * |
---|
11 | *****************************************************************************/ |
---|
12 | |
---|
13 | //_____________________________________________________________________________ |
---|
14 | // |
---|
15 | // Pupil |
---|
16 | // |
---|
17 | // <extensive class description> |
---|
18 | // |
---|
19 | // Config file parameters |
---|
20 | // ====================== |
---|
21 | // |
---|
22 | // <parameter name>: <parameter description> |
---|
23 | // -Valid options: <available options> |
---|
24 | // |
---|
25 | |
---|
26 | #include "Pupil.hh" |
---|
27 | #include "DetectorGeometry.hh" |
---|
28 | #include "Etypes.hh" |
---|
29 | #include "Photon.hh" |
---|
30 | ClassImp(Pupil) |
---|
31 | |
---|
32 | //______________________________________________________________________________ |
---|
33 | Pupil::Pupil( PhotonsOnPupil* photons, DetectorGeometry* geo) : fPhotons(photons), |
---|
34 | fGeometry(geo) { |
---|
35 | // |
---|
36 | |
---|
37 | // Constructor |
---|
38 | // |
---|
39 | |
---|
40 | if (!fPhotons) { |
---|
41 | Msg(EsafMsg::Warning) << "*** Pupil: no photons ***" << MsgDispatch; |
---|
42 | return; |
---|
43 | } |
---|
44 | if ( !fPhotons->GetFrame() ) { |
---|
45 | Msg(EsafMsg::Debug) << "Pupil pre-tracking skipped" << MsgDispatch; |
---|
46 | return; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | Msg(EsafMsg::Debug) << "Pupil pre-tracking activated" << MsgDispatch; |
---|
52 | EsafRefFrame* frame = fPhotons->GetFrame(); |
---|
53 | |
---|
54 | fTrasl = fGeometry->GetPos()-frame->GetPos(); |
---|
55 | if ( (fTrasl).Mag() > 1*sou::m) { |
---|
56 | Msg(EsafMsg::Warning) << "PhotonsOnPupil and Detector are not in the same place." << MsgDispatch; |
---|
57 | MsgForm(EsafMsg::Warning,"Detector: (%.3f,%.3f,%.3f), PhP(%.3f,%.3f,%.3f)", |
---|
58 | fGeometry->GetPos()[0]/sou::km, fGeometry->GetPos()[1]/sou::km, fGeometry->GetPos()[2]/sou::km, |
---|
59 | frame->GetPos()[0]/sou::km, frame->GetPos()[1]/sou::km, frame->GetPos()[2]/sou::km); |
---|
60 | |
---|
61 | Msg(EsafMsg::Warning) << "Forcing pupil frame origin onto the detector" << MsgDispatch; |
---|
62 | fGeometry->SetPos(frame->GetPos()); |
---|
63 | fTrasl = TVector3(0,0,0); |
---|
64 | } |
---|
65 | |
---|
66 | fRotDet2PoP = (*(frame->GetToLocal()))*(*(geo->GetToGlobal())); |
---|
67 | fRotPoP2Det = fRotDet2PoP.Inverse(); |
---|
68 | |
---|
69 | } |
---|
70 | |
---|
71 | //______________________________________________________________________________ |
---|
72 | Pupil::~Pupil() { |
---|
73 | // |
---|
74 | // Destructor |
---|
75 | // |
---|
76 | |
---|
77 | ClearFrame(); |
---|
78 | } |
---|
79 | |
---|
80 | |
---|
81 | //______________________________________________________________________________ |
---|
82 | Photon* Pupil::GetPhoton() { |
---|
83 | // |
---|
84 | // Perform pre tracking of the photons using the DetectorGeometry |
---|
85 | // informations |
---|
86 | // |
---|
87 | if (!fPhotons) return 0; |
---|
88 | |
---|
89 | if ( !fPhotons->GetFrame() ) |
---|
90 | // nothing to do, return a plain photon |
---|
91 | return fPhotons->GetPhoton(); |
---|
92 | |
---|
93 | Photon* p = fPhotons->GetPhoton(); |
---|
94 | if (!p) return 0; |
---|
95 | |
---|
96 | |
---|
97 | p->pos -= fTrasl; |
---|
98 | p->pos.Transform(fRotPoP2Det); |
---|
99 | p->dir.Transform(fRotPoP2Det); |
---|
100 | |
---|
101 | // pretracking to Z=0 in detector's ref frame |
---|
102 | p->pos -= p->dir*((p->pos.Z()-fGeometry->GetTargetZ())/p->dir.Z()); |
---|
103 | |
---|
104 | // tag the photons which are outside the detector |
---|
105 | if ( p->pos.Perp() > fGeometry->GetRadius() ) |
---|
106 | p->history = kNotInside; |
---|
107 | |
---|
108 | return p; |
---|
109 | } |
---|