1 | // ESAF : Euso Simulation and Analysis Framework |
---|
2 | // $Id: RadiativeTransfer.cc 2304 2005-10-31 10:56:12Z moreggia $ |
---|
3 | // D. De Marco - M. Pallavicini created Jan, 20 2002 |
---|
4 | |
---|
5 | #include "RadiativeTransfer.hh" |
---|
6 | #include "Ground.hh" |
---|
7 | #include "EsafRandom.hh" |
---|
8 | #include "PhotonsOnPupil.hh" |
---|
9 | |
---|
10 | ClassImp(RadiativeTransfer) |
---|
11 | |
---|
12 | //______________________________________________________________________________ |
---|
13 | RadiativeTransfer::RadiativeTransfer(): EsafConfigurable(), EsafMsgSource(), fGround(0), fDetAtGrnd(false) { |
---|
14 | // |
---|
15 | // ctor |
---|
16 | // |
---|
17 | } |
---|
18 | |
---|
19 | //______________________________________________________________________________ |
---|
20 | RadiativeTransfer::~RadiativeTransfer() { |
---|
21 | // |
---|
22 | // dtor |
---|
23 | // |
---|
24 | SafeDelete(fGround); |
---|
25 | } |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | //_______________________________________________________________________________________________________________________ |
---|
30 | void RadiativeTransfer::RamdomPosOnPupil(const PhotonsOnPupil* photons, TVector3& pos, TVector3& local_dir) const { |
---|
31 | // |
---|
32 | // Sample a random photon position on pupil |
---|
33 | // |
---|
34 | Double_t x, y, r, phi; |
---|
35 | TRandom* rndm = EsafRandom::Get(); |
---|
36 | if(fDecoupled) { |
---|
37 | TVector3 origin(pos); |
---|
38 | TVector3 dir = (EUSO() - origin).Unit(); |
---|
39 | |
---|
40 | r = 1; |
---|
41 | while ( r > 0.25 ) { |
---|
42 | x = rndm->Rndm()-0.5; |
---|
43 | y = rndm->Rndm()-0.5; |
---|
44 | r = x*x+y*y; |
---|
45 | } |
---|
46 | x *= EusoRadius()/0.5; |
---|
47 | y *= EusoRadius()/0.5; |
---|
48 | TVector3 xAxis = dir.Orthogonal(); |
---|
49 | TVector3 yAxis = dir.Cross(xAxis); |
---|
50 | |
---|
51 | pos = x*xAxis+y*yAxis; |
---|
52 | // other possible method. Which is the swiftest? |
---|
53 | // TRotation rot; |
---|
54 | // rot.SetZAxis(dir); |
---|
55 | // pos *= rot; |
---|
56 | } |
---|
57 | else { |
---|
58 | r = EusoRadius() * sqrt(rndm->Rndm()); |
---|
59 | phi = TMath::TwoPi() * rndm->Rndm(); |
---|
60 | pos.SetXYZ(r*cos(phi),r*sin(phi),0); |
---|
61 | local_dir *= *(GetDetGeometry()->GetToLocal()); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | //_______________________________________________________________________________________________________________________ |
---|
66 | void RadiativeTransfer::BuildPupilFrame(PhotonsOnPupil* photons) const { |
---|
67 | // |
---|
68 | // definition of frame contained by PhotonOnPupil object |
---|
69 | // |
---|
70 | EsafRefFrame *frame = new EsafRefFrame; |
---|
71 | // if radiative transfer is decoupled from the detector |
---|
72 | // then assume the std set of axis (1,0,0),(0,1,0),(0,0,1) and set only the position |
---|
73 | if (fDecoupled) frame->SetPos(GetDetGeometry()->GetPos()); |
---|
74 | else GetDetGeometry()->EsafRefFrame::Copy(*frame); |
---|
75 | |
---|
76 | photons->AddFrame(frame); |
---|
77 | } |
---|