TestSpacing.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 
26 vector<Double_t> MakeBins(bool isAbs)
27 {
28  vector<Double_t> bins;
29 
30  Double_t highEdge, binWidth;
31 
32  if (isAbs) {
33  Double_t currEdge = 0.0;
34  bins.push_back(currEdge);
35  highEdge = 50.0; binWidth = 2.5;
36  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
37  highEdge = 100.0; binWidth = 5.0;
38  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
39  highEdge = 200.0; binWidth = 10.0;
40  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
41  highEdge = 500.0; binWidth = 20.0;
42  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
43  }
44  else {
45  Double_t currEdge = -500.0;
46  bins.push_back(currEdge);
47  highEdge = -200.0; binWidth = 20.0;
48  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
49  highEdge = -100.0; binWidth = 10.0;
50  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
51  highEdge = -50.0; binWidth = 5.0;
52  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
53  highEdge = 0.0; binWidth = 2.5;
54  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
55  highEdge = 50.0; binWidth = 2.5;
56  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
57  highEdge = 100.0; binWidth = 5.0;
58  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
59  highEdge = 200.0; binWidth = 10.0;
60  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
61  highEdge = 500.0; binWidth = 20.0;
62  while( currEdge < highEdge - 1e-3 ) {currEdge += binWidth; bins.push_back(currEdge);}
63  }
64 
65  return bins;
66 }
67 
68 
70 {
71  double z = 750.0;
72  TRandom2 generator(0);
73 
74  TH1D* hEffVSpacing = new TH1D("hEffVSpacing", ";Fiber Spacing (cm);Collection Efficiency", 100, 0.1, 6.15);
75 
76  Long64_t iterations = 1e6;
77  cout.setf(ios::left);
78  for (int i = 1; i <= hEffVSpacing->GetXaxis()->GetNbins(); ++i)
79  {
80  double spacing = hEffVSpacing->GetXaxis()->GetBinCenter(i);
81  PhotonTracer tracer(spacing);
82  Long64_t successes(0);
83  for (Long64_t i = 0; i < iterations; ++i)
84  {
85  if (i%2000 == 0)
86  {
87  double percent_done = 100.0*((double)i/(double)iterations);
88  cout << "percent done: " << setprecision(2) << fixed << percent_done << "%\r" << flush;
89  }
90  if ( tracer.TraceOnePhoton( z ) ) successes += 1.0;
91  }
92  hEffVSpacing->SetBinContent(i, successes/(double)iterations);
93  }
94 
95  hEffVSpacing->Draw();
96 }
97 
const Binning bins
z
Definition: test.py:28
OStream cout
Definition: OStream.cxx:6
vector< Double_t > MakeBins(bool isAbs)
Definition: TestSpacing.C:26
void TestSpacing()
Definition: TestSpacing.C:69
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 e
Definition: plot.C:35
Long64_t iterations[nThreads]
Definition: PhotonSim_mp.C:71