9 #include <TTreeReader.h>
10 #include <TTreeReaderValue.h>
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());
39 TTreeReader reader(treeName.c_str(), &inputFile);
46 std::vector<float>*
x =
new std::vector<float>;
47 std::vector<float>*
y =
new std::vector<float>;
48 std::vector<float>*
z =
new std::vector<float>;
49 std::vector<float>* sens =
new std::vector<float>;
50 std::vector<float>*
mat =
new std::vector<float>;
51 std::vector<float>* bounds =
new std::vector<float>;
53 tree->SetBranchAddress(
"step_x", &x);
54 tree->SetBranchAddress(
"step_y", &y);
55 tree->SetBranchAddress(
"step_z", &z);
56 tree->SetBranchAddress(
"sensitive", &sens);
58 if (tree->FindBranch(
"boundary")) {
59 std::cout <<
"No BoundarySteps are given." << std::endl;
60 tree->SetBranchAddress(
"boundary", &bounds);
62 if (tree->FindBranch(
"material")) {
63 std::cout <<
"No MaterialSteps are given." << std::endl;
64 tree->SetBranchAddress(
"material", &mat);
66 Int_t entries = tree->GetEntries();
67 std::cout <<
"Creating new output file: " << outFile
68 <<
" and writing out histograms. " << std::endl;
69 TFile outputFile(outFile.c_str(),
"recreate");
72 TH2F* Full_xy =
new TH2F(
73 "Full_xy",
"Full material", nBins, rmin, rmax, nBins, rmin, rmax);
74 TH2F* Full_zr =
new TH2F(
75 "Full_zr",
"Full material", nBins, zmin, zmax, nBins, 0., rmax);
78 TH2F* Sens_xy =
new TH2F(
79 "Sens_xy",
"Sensitive material", nBins, rmin, rmax, nBins, rmin, rmax);
80 Sens_xy->GetXaxis()->SetTitle(
"x [mm]");
81 Sens_xy->GetYaxis()->SetTitle(
"y [mm]");
82 TH2F* Sens_zx =
new TH2F(
83 "Sens_zx",
"Sensitive material", nBins, zmin, zmax, nBins, rmin, rmax);
84 Sens_zx->GetXaxis()->SetTitle(
"z [mm]");
85 Sens_zx->GetYaxis()->SetTitle(
"x [mm]");
86 TH2F* Sens_zy =
new TH2F(
87 "Sens_zy",
"Sensitive material", nBins, zmin, zmax, nBins, rmin, rmax);
88 Sens_zy->GetXaxis()->SetTitle(
"z [mm]");
89 Sens_zy->GetYaxis()->SetTitle(
"y [mm]");
90 TH2F* Sens_zr =
new TH2F(
91 "Sens_zr",
"Sensitive material", nBins, zmin, zmax, nBins, 0., rmax);
92 Sens_zr->GetXaxis()->SetTitle(
"z [mm]");
93 Sens_zr->GetYaxis()->SetTitle(
"r [mm]");
96 TH2F* Bounds_xy =
new TH2F(
97 "Bounds_xy",
"Boundaries", nBins, rmin, rmax, nBins, rmin, rmax);
98 Bounds_xy->GetXaxis()->SetTitle(
"x [mm]");
99 Bounds_xy->GetYaxis()->SetTitle(
"y [mm]");
100 TH2F* Bounds_zx =
new TH2F(
101 "Bounds_zx",
"Boundaries", nBins, zmin, zmax, nBins, rmin, rmax);
102 Bounds_zx->GetXaxis()->SetTitle(
"z [mm]");
103 Bounds_zx->GetYaxis()->SetTitle(
"x [mm]");
104 TH2F* Bounds_zy =
new TH2F(
105 "Bounds_zy",
"Boundaries", nBins, zmin, zmax, nBins, rmin, rmax);
106 Bounds_zy->GetXaxis()->SetTitle(
"z [mm]");
107 Bounds_zy->GetYaxis()->SetTitle(
"y [mm]");
109 =
new TH2F(
"Bounds_zr",
"Boundaries", nBins, zmin, zmax, nBins, 0., rmax);
110 Bounds_zr->GetXaxis()->SetTitle(
"z [mm]");
111 Bounds_zr->GetYaxis()->SetTitle(
"r [mm]");
115 =
new TH2F(
"Mat_xy",
"Material", nBins, rmin, rmax, nBins, rmin, rmax);
116 Mat_xy->GetXaxis()->SetTitle(
"x [mm]");
117 Mat_xy->GetYaxis()->SetTitle(
"y [mm]");
119 =
new TH2F(
"Mat_zx",
"Material", nBins, zmin, zmax, nBins, rmin, rmax);
120 Mat_zx->GetXaxis()->SetTitle(
"z [mm]");
121 Mat_zx->GetYaxis()->SetTitle(
"x [mm]");
123 =
new TH2F(
"Mat_zy",
"Material", nBins, zmin, zmax, nBins, rmin, rmax);
124 Mat_zy->GetXaxis()->SetTitle(
"z [mm]");
125 Mat_zy->GetYaxis()->SetTitle(
"y [mm]");
127 =
new TH2F(
"Mat_zr",
"Material", nBins, zmin, zmax, nBins, 0., rmax);
128 Mat_zr->GetXaxis()->SetTitle(
"z [mm]");
129 Mat_zr->GetYaxis()->SetTitle(
"r [mm]");
131 for (
int i = 0; i < entries; i++) {
134 for (
int j = 0; j < x->size(); j++) {
136 if (z->at(j) >= zmin && z->at(j) <= zmax) {
137 Sens_xy->Fill(x->at(j), y->at(j), sens->at(j));
138 Full_xy->Fill(x->at(j), y->at(j));
140 Sens_zx->Fill(z->at(j), x->at(j), sens->at(j));
141 Sens_zy->Fill(z->at(j), y->at(j), sens->at(j));
142 Sens_zr->Fill(z->at(j), sqrt(x->at(j) * x->at(j) + y->at(j) * y->at(j)));
143 Full_zr->Fill(z->at(j), sqrt(x->at(j) * x->at(j) + y->at(j) * y->at(j)));
146 if (tree->FindBranch(
"boundary")) {
147 if (z->at(j) >= zmin && z->at(j) <= zmax)
148 Bounds_xy->Fill(x->at(j), y->at(j), bounds->at(j));
149 Bounds_zx->Fill(z->at(j), x->at(j), bounds->at(j));
150 Bounds_zy->Fill(z->at(j), y->at(j), bounds->at(j));
151 Bounds_zr->Fill(z->at(j),
152 sqrt(x->at(j) * x->at(j) + y->at(j) * y->at(j)),
156 if (tree->FindBranch(
"material")) {
157 if (z->at(j) >= zmin && z->at(j) <= zmax)
158 Mat_xy->Fill(x->at(j), y->at(j), mat->at(j));
159 Mat_zx->Fill(z->at(j), x->at(j), mat->at(j));
160 Mat_zy->Fill(z->at(j), y->at(j), mat->at(j));
161 Mat_zr->Fill(z->at(j),
162 sqrt(x->at(j) * x->at(j) + y->at(j) * y->at(j)),