TransverseEff.C
Go to the documentation of this file.
1 #include <cmath>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 
6 #include <TF1.h>
7 #include <TH1D.h>
8 #include <TH2D.h>
9 #include <TFile.h>
10 #include <TProfile.h>
11 #include <TCanvas.h>
12 #include <TRandom2.h>
13 #include <TVector3.h>
14 #include <TString.h>
15 #include <TLatex.h>
16 #include <TLine.h>
17 #include <TROOT.h>
18 #include <TMath.h>
19 
20 #include "include/RootUtils.hh"
21 #include "include/PhotonTracer.hh"
22 
23 using namespace std;
24 using namespace TMath;
25 
27 {
28  double z = 750.0;
29  TRandom2 generator(0);
30 
31  //fiberSeparation = 6.15 cm at the retaining ring
32  //PhotonTracer tracer(6.15);
33  PhotonTracer tracer(5.0);
34 
35  TH2D* hTransverseEff = new TH2D("hTransverseEff", ";X (cm);Y (cm)", 100, -0.5, 4.1, 100, -0.5, 6.14);
36  int nbins = hTransverseEff->GetXaxis()->GetNbins()*hTransverseEff->GetYaxis()->GetNbins();
37 
38  Long64_t iterations = 1e4;
39  Long64_t totalIter(0);
40  cout.setf(ios::left);
41  for (int iX = 1; iX <= hTransverseEff->GetXaxis()->GetNbins(); ++iX)
42  {
43  for (int iY = 1; iY <= hTransverseEff->GetYaxis()->GetNbins(); ++iY)
44  {
45  //cout << "Bin (" << iX << ", " << iY << ")" << endl;
46  //cout << endl;
47  double x = hTransverseEff->GetXaxis()->GetBinCenter(iX);
48  double y = hTransverseEff->GetYaxis()->GetBinCenter(iY);
49 
50  Long64_t successes(0);
51  for (Long64_t i = 0; i < iterations; ++i)
52  {
53  totalIter += 1;
54  if (i%2000 == 0)
55  {
56  double percent_done = 100.0*((double)totalIter/(double)(iterations*nbins));
57  cout << "percent done: " << setprecision(2) << fixed << percent_done << "%\r" << flush;
58  }
59  if ( tracer.TraceOnePhoton( z, x, y, false ) ) successes += 1.0;
60  }
61  hTransverseEff->SetBinContent(iX, iY, successes/(double)iterations);
62  }
63  //cout << endl;
64  }
65 
66  hTransverseEff->Draw("colz");
67 }
68 
const int nbins
Definition: cellShifts.C:15
z
Definition: test.py:28
OStream cout
Definition: OStream.cxx:6
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:104
Float_t iX
void TransverseEff()
Definition: TransverseEff.C:26
Long64_t iterations[nThreads]
Definition: PhotonSim_mp.C:71