23 float zMax,
float etaMin,
float etaMax,
24 float thetaMin = 0.,
float thetaMax = M_PI) {
25 std::cout <<
"Opening file: " << inFile << std::endl;
26 TFile inputFile(inFile.c_str());
27 std::cout <<
"Reading tree: " << treeName << std::endl;
28 TTree*
tree = (TTree*)inputFile.Get(treeName.c_str());
33 std::vector<float>*
x =
new std::vector<float>;
34 std::vector<float>*
y =
new std::vector<float>;
35 std::vector<float>*
z =
new std::vector<float>;
37 tree->SetBranchAddress(
"nHits", &nHits);
38 tree->SetBranchAddress(
"Eta", &eta);
39 tree->SetBranchAddress(
"StepX", &x);
40 tree->SetBranchAddress(
"StepY", &y);
41 tree->SetBranchAddress(
"StepZ", &z);
43 Int_t entries = tree->GetEntries();
44 std::cout <<
"Creating new output file: " << outFile
48 TFile outputFile(outFile.c_str(),
"recreate");
51 TProfile* nHits_eta =
new TProfile(
"nHits_eta",
"Hits in sensitive Material",
52 nBins, etaMin, etaMax);
53 nHits_eta->GetXaxis()->SetTitle(
"#eta");
54 nHits_eta->GetYaxis()->SetTitle(
"#hits");
55 TProfile* nHits_theta =
new TProfile(
56 "nHits_theta",
"Hits in sensitive Material", nBins, thetaMin, thetaMax);
57 nHits_theta->GetXaxis()->SetTitle(
"#theta [rad]");
58 nHits_theta->GetYaxis()->SetTitle(
"#hits");
60 new TProfile(
"nHits_z",
"Hits in sensitive Material", nBins, zMin, zMax);
61 nHits_z->GetXaxis()->SetTitle(
"z coordinate of momentum [mm]");
62 nHits_z->GetYaxis()->SetTitle(
"#hits");
65 TH1F*
Eta =
new TH1F(
"eta",
"Distribution of #eta", nBins, etaMin, etaMax);
66 Eta->GetXaxis()->SetTitle(
"#eta");
67 Eta->GetYaxis()->SetTitle(
"#events");
72 new TH1F(
"theta",
"Distribution of #theta", nBins, thetaMin, thetaMax);
73 Theta->GetXaxis()->SetTitle(
"#theta [rad]");
74 Theta->GetYaxis()->SetTitle(
"#events");
75 TH1F*
Z =
new TH1F(
"z",
"Distribution of z coordinate of the momentum", nBins,
77 Z->GetXaxis()->SetTitle(
"z coordinate of momentum [mm]");
78 Z->GetYaxis()->SetTitle(
"#events");
82 new TH1F(
"hitsEta",
"Sensitive Hit Distribution", nBins, etaMin, etaMax);
83 hitsEta->GetXaxis()->SetTitle(
"#eta");
84 hitsEta->GetYaxis()->SetTitle(
"#hits");
85 TH1F* hitsTheta =
new TH1F(
"hitsTheta",
"Sensitive Hit Distribution", nBins,
87 hitsTheta->GetXaxis()->SetTitle(
"#theta");
88 hitsTheta->GetYaxis()->SetTitle(
"#hits");
90 new TH1F(
"hitsZ",
"Sensitive Hit Distribution", nBins, zMin, zMax);
91 hitsZ->GetXaxis()->SetTitle(
"z [mm]");
92 hitsZ->GetYaxis()->SetTitle(
"#hits");
94 for (
int i = 0;
i < entries;
i++) {
96 double theta = 2. * atan(exp(-eta));
97 double zDir = r / tan(theta);
99 nHits_eta->Fill(eta, nHits);
100 nHits_theta->Fill(theta, nHits);
101 nHits_z->Fill(zDir, nHits);
107 for (
int j = 0;
j < x->size();
j++) {
108 float hitTheta = std::atan2(std::hypot(x->at(
j), y->at(
j)), z->at(
j));
109 hitsEta->Fill(-log(tan(hitTheta * 0.5)));
110 hitsTheta->Fill(hitTheta);
111 hitsZ->Fill(z->at(
j));
117 nHits_theta->Write();