1 | using namespace TMath; |
---|
2 | |
---|
3 | /****************************************************************************** |
---|
4 | * |
---|
5 | * How to calculate the radiance |
---|
6 | * |
---|
7 | * Rad = radiance |
---|
8 | * N = Number of photons on the entrance disc |
---|
9 | * A = Area of the entrance disk |
---|
10 | * ThetaMax = max incident angle |
---|
11 | * |
---|
12 | * RadCos = (N*Power(Csc(ThetaMax),2))/(A*Pi) |
---|
13 | * |
---|
14 | * RadFlat = N/(2.*A*Pi*(1 - Cos(ThetaMax))) |
---|
15 | * |
---|
16 | ******************************************************************************/ |
---|
17 | |
---|
18 | |
---|
19 | //______________________________________________________________________________ |
---|
20 | void MakeNGDensity() { |
---|
21 | |
---|
22 | TTree* t = (TTree*)gDirectory->Get("etree"); |
---|
23 | |
---|
24 | Double_t xmin = 0; |
---|
25 | Double_t xmax = 1130; //size of the ideal focal surface |
---|
26 | const Int_t nbins = 100; |
---|
27 | Double_t xbins[nbins+1]; |
---|
28 | Double_t area = Pi()*xmax*xmax/nbins; |
---|
29 | Double_t radius = 0; |
---|
30 | |
---|
31 | |
---|
32 | Printf("Area: %f",area); |
---|
33 | for(Int_t i(0); i<nbins; i++) { |
---|
34 | xbins[i] = radius; |
---|
35 | xbins[i+1] = Sqrt((area+Pi()*radius*radius)/Pi()); |
---|
36 | radius = xbins[i+1]; |
---|
37 | } |
---|
38 | |
---|
39 | TH1D* density = new TH1D("density","density",nbins,0.,xmax); |
---|
40 | // TH1D* density = new TH1D("density","density",nbins,xbins); |
---|
41 | |
---|
42 | |
---|
43 | cout << "Entries "<<etree->Draw("sqrt(fPhotons.fIdealFocalPosX*fPhotons.fIdealFocalPosX+fPhotons.fIdealFocalPosY*fPhotons.fIdealFocalPosY) >> density","fPhotons.CrossedIFS()","") << endl; |
---|
44 | |
---|
45 | Stat_t x; |
---|
46 | TAxis* ax = density->GetXaxis(); |
---|
47 | |
---|
48 | for( Int_t i(1); i <= density->GetNbinsX(); i++){ |
---|
49 | x = density->GetBinContent(i); |
---|
50 | |
---|
51 | area = TMath::Pi()*(ax->GetBinUpEdge(i)*ax->GetBinUpEdge(i) |
---|
52 | -ax->GetBinLowEdge(i)*ax->GetBinLowEdge(i)); |
---|
53 | |
---|
54 | density->SetBinContent(i,x/area); |
---|
55 | |
---|
56 | } |
---|
57 | |
---|
58 | density->Draw(); |
---|
59 | |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | //______________________________________________________________________________ |
---|
65 | void Dummy() { |
---|
66 | |
---|
67 | EPhoton *photon; |
---|
68 | TClonesArray *array = new TClonesArray(); |
---|
69 | |
---|
70 | Double_t thetamax = 35*DegToRad(); |
---|
71 | // parent initialization with useless values |
---|
72 | ParentPhoton* parent = new ParentPhoton(0, spos, pos, 0., 0., 0., 0, kFluorescence); |
---|
73 | |
---|
74 | Photon* ph; |
---|
75 | Photon* phCopy; |
---|
76 | |
---|
77 | TRandom* rndm = EsafRandom::Get(); |
---|
78 | |
---|
79 | Int_t ntrans(0), nhits(0); |
---|
80 | TVector3 dir; |
---|
81 | Double_t alpha, radius; |
---|
82 | |
---|
83 | for( Int_t i(0); i<nph; i++) { |
---|
84 | if ( (i+1)%(nph/100) == 0 ) |
---|
85 | cout << "\rTracing " << (i+1)/(nph/100) << '%' << flush; |
---|
86 | |
---|
87 | // new photon position |
---|
88 | radius = sqrt(rndm->Rndm())*gDiscRadius; |
---|
89 | alpha = rndm->Rndm()*TwoPi(); |
---|
90 | pos[0] = radius*Cos(alpha); |
---|
91 | pos[1] = radius*Sin(alpha); |
---|
92 | |
---|
93 | // new incident direction |
---|
94 | dir = CosThetaDist(0,thetamax); |
---|
95 | |
---|
96 | ph = &(parent->GetPhoton()); |
---|
97 | phCopy = ph; |
---|
98 | |
---|
99 | // update the parent |
---|
100 | parent->Build(0, spos, pos, dir.Theta(), dir.Phi(), spec->GetLambda(), 0, kFluorescence); |
---|
101 | |
---|
102 | ph = os->Transport(ph); |
---|
103 | |
---|
104 | // reject dead photons and going downward |
---|
105 | if (!ph || ph->dir.Z() < 0.) continue; |
---|
106 | ntrans++; |
---|
107 | |
---|
108 | ifs->HitPosition(ph); |
---|
109 | if (!ph->hitIfs) continue; |
---|
110 | |
---|
111 | points[nhits] = ph->posOnIfs; |
---|
112 | nhits++; |
---|
113 | |
---|
114 | } |
---|
115 | cout << "\rTracing done" << endl; |
---|
116 | |
---|
117 | } |
---|
118 | |
---|
119 | //______________________________________________________________________________ |
---|
120 | TVector3 FlatDist( Double_t theta1, Double_t theta2) { |
---|
121 | // |
---|
122 | // |
---|
123 | // |
---|
124 | |
---|
125 | TVector3 dir; |
---|
126 | Double_t c1 = Cos(theta1); |
---|
127 | Double_t c2 = Cos(theta2); |
---|
128 | dir.SetMagThetaPhi(1.,ACos(rndm->Uniform(c1,c2)), TwoPi()*rndm->Rndm() ); |
---|
129 | |
---|
130 | return dir; |
---|
131 | } |
---|
132 | |
---|
133 | //______________________________________________________________________________ |
---|
134 | TVector3 CosThetaDist( Double_t theta1, Double_t theta2 ) { |
---|
135 | // |
---|
136 | // |
---|
137 | // |
---|
138 | |
---|
139 | TVector3 dir; |
---|
140 | Double_t c1 = Cos(2*theta1); |
---|
141 | Double_t c2 = Cos(2*theta2); |
---|
142 | dir.SetMagThetaPhi(1.,ACos(rndm->Uniform(c1,c2))/2., TwoPi()*rndm->Rndm() ); |
---|
143 | |
---|
144 | return dir; |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | |
---|
149 | //______________________________________________________________________________ |
---|
150 | void PrintDataFile() { |
---|
151 | // |
---|
152 | // |
---|
153 | // |
---|
154 | Printf("%.4f %e",density->GetXaxis()->GetBinLowEdge(1), density->GetBinContent(1)); |
---|
155 | for(Int_t i(1); i<=density->GetNbinsX(); i++) |
---|
156 | Printf("%.4f %e",density->GetXaxis()->GetBinUpEdge(i), density->GetBinContent(i)); |
---|
157 | |
---|
158 | } |
---|