32 float thetaMax =
M_PI)
34 std::cout <<
"Opening file: " << inFile << std::endl;
35 TFile inputFile(inFile.c_str());
36 std::cout <<
"Reading tree: " << treeName << std::endl;
37 TTree*
tree = (TTree*)inputFile.Get(treeName.c_str());
42 std::vector<float>*
x =
new std::vector<float>;
43 std::vector<float>*
y =
new std::vector<float>;
44 std::vector<float>*
z =
new std::vector<float>;
46 tree->SetBranchAddress(
"nHits", &nHits);
47 tree->SetBranchAddress(
"Eta", &eta);
48 tree->SetBranchAddress(
"StepX", &x);
49 tree->SetBranchAddress(
"StepY", &y);
50 tree->SetBranchAddress(
"StepZ", &z);
52 Int_t entries = tree->GetEntries();
53 std::cout <<
"Creating new output file: " << outFile
57 TFile outputFile(outFile.c_str(),
"recreate");
60 TProfile* nHits_eta =
new TProfile(
61 "nHits_eta",
"Hits in sensitive Material", nBins, etaMin, etaMax);
62 nHits_eta->GetXaxis()->SetTitle(
"#eta");
63 nHits_eta->GetYaxis()->SetTitle(
"#hits");
64 TProfile* nHits_theta =
new TProfile(
65 "nHits_theta",
"Hits in sensitive Material", nBins, thetaMin, thetaMax);
66 nHits_theta->GetXaxis()->SetTitle(
"#theta [rad]");
67 nHits_theta->GetYaxis()->SetTitle(
"#hits");
68 TProfile* nHits_z =
new TProfile(
69 "nHits_z",
"Hits in sensitive Material", nBins, zMin, zMax);
70 nHits_z->GetXaxis()->SetTitle(
"z coordinate of momentum [mm]");
71 nHits_z->GetYaxis()->SetTitle(
"#hits");
74 TH1F*
Eta =
new TH1F(
"eta",
"Distribution of #eta", nBins, etaMin, etaMax);
75 Eta->GetXaxis()->SetTitle(
"#eta");
76 Eta->GetYaxis()->SetTitle(
"#events");
81 =
new TH1F(
"theta",
"Distribution of #theta", nBins, thetaMin, thetaMax);
82 Theta->GetXaxis()->SetTitle(
"#theta [rad]");
83 Theta->GetYaxis()->SetTitle(
"#events");
85 "z",
"Distribution of z coordinate of the momentum", nBins, zMin, zMax);
86 Z->GetXaxis()->SetTitle(
"z coordinate of momentum [mm]");
87 Z->GetYaxis()->SetTitle(
"#events");
90 TH1F* hitsEta =
new TH1F(
91 "hitsEta",
"Sensitive Hit Distribution", nBins, etaMin, etaMax);
92 hitsEta->GetXaxis()->SetTitle(
"#eta");
93 hitsEta->GetYaxis()->SetTitle(
"#hits");
94 TH1F* hitsTheta =
new TH1F(
95 "hitsTheta",
"Sensitive Hit Distribution", nBins, thetaMin, thetaMax);
96 hitsTheta->GetXaxis()->SetTitle(
"#theta");
97 hitsTheta->GetYaxis()->SetTitle(
"#hits");
99 =
new TH1F(
"hitsZ",
"Sensitive Hit Distribution", nBins, zMin, zMax);
100 hitsZ->GetXaxis()->SetTitle(
"z [mm]");
101 hitsZ->GetYaxis()->SetTitle(
"#hits");
103 for (
int i = 0; i < entries; i++) {
105 double theta = 2. * atan(exp(-eta));
106 double zDir = r / tan(theta);
108 nHits_eta->Fill(eta, nHits);
109 nHits_theta->Fill(theta, nHits);
110 nHits_z->Fill(zDir, nHits);
116 for (
int j = 0; j < x->size(); j++) {
118 = atan2(sqrt(x->at(j) * x->at(j) + y->at(j) * y->at(j)), z->at(j));
119 hitsEta->Fill(-log(tan(hitTheta * 0.5)));
120 hitsTheta->Fill(hitTheta);
121 hitsZ->Fill(z->at(j));
127 nHits_theta->Write();