10 #include <TGraphErrors.h>
14 #include <TClonesArray.h>
16 #include <TPostScript.h>
23 frankSimu(
float rotAngle=0.,
long nEvents = 1000) {
56 ifstream inFile(
"BichselELossProbHighBG.dat");
57 double cl1, cl2, cl3, cl4, cl5, cl6, cl7;
58 for (
int i = 0; i < 10000; i++) {
59 inFile >> cl1 >> cl2 >> cl3 >> cl4 >> cl5 >> cl6>> cl7;
63 float angle = TMath::Pi() * rotAngle / 180.;
65 double pathLength = 3.2 / TMath::Cos(angle);
66 double pairsPerMM = 4.;
69 TRandom2* tR =
new TRandom2();
72 TH1F* hMean =
new TH1F(
"hMean",
"hMean", 100, -1, 1);
73 TH1F* hNP =
new TH1F(
"hNP",
"hNP", 35, -0.5, 34.5);
74 hNP->SetXTitle(
"Number of Primary Pairs");
75 TH1F* hElectron =
new TH1F(
"hElectron",
"hElectron", 250, -0.5, 249.5);
76 TH1F* hEnergy =
new TH1F(
"hEnergy",
"hEnergy", 250, 0, 5.);
77 hEnergy->SetXTitle(
"Energy Loss [keV]");
78 TH1F* hEPerColl =
new TH1F(
"hEPerColl",
"hEPerColl", 100, 0, 100);
79 hEPerColl->SetXTitle(
"Energy Loss per collision [eV]");
81 TF1* fElectronDist =
new TF1(
"fElectronDist",
"1/(x*x*x)", 0, 100);
83 Double_t weight[1000];
84 int totalElectrons = 0;
85 float totalEnergy = 0;
88 for (
int i = 0; i < nEvents; i++) {
96 double stepLength = - TMath::Log(tR->Uniform()) / pairsPerMM;
98 if (dist > pathLength)
break;
100 pos[np-1] = dist/pathLength -0.5;
102 int rndBin = ((int) (10000.0 * tR->Uniform()));
103 double eL = eLoss[rndBin];
105 int ns = 1 + ((int) ((eL-15.4)/26.));
110 totalElectrons += weight[np-1];
112 float mpos = TMath::Mean(np, pos, weight);
113 mpos = mpos * 3.2 * TMath::Sin(angle);
116 hElectron->Fill(totalElectrons);
117 totalEnergy = totalEnergy / 1000.;
118 hEnergy->Fill(totalEnergy);
121 TCanvas* c1 =
new TCanvas(
"SimuMean",
"SimuMean", 600, 450);
123 TCanvas* c2 =
new TCanvas(
"NumberOfPairs",
"NumberOfPairs", 600, 800);
129 TCanvas* c3 =
new TCanvas(
"NumberOfElectrons",
"NumberOfElectrons", 600, 800);