47 std::cout <<
"Opening file: " << inFile << std::endl;
48 TFile inputFile(inFile.c_str());
49 TTree*
layer = (TTree*)inputFile.Get(layerName.c_str());
50 std::cout <<
"Reading tree: " << layerName << std::endl;
52 std::vector<float>*
loc0 =
new std::vector<float>;
53 std::vector<float>* loc1 =
new std::vector<float>;
54 std::vector<float>*
A =
new std::vector<float>;
55 std::vector<float>*
Z =
new std::vector<float>;
56 std::vector<float>*
x0 =
new std::vector<float>;
57 std::vector<float>* l0 =
new std::vector<float>;
58 std::vector<float>* d =
new std::vector<float>;
59 std::vector<float>*
rho =
new std::vector<float>;
60 std::vector<float>* dInX0 =
new std::vector<float>;
61 std::vector<float>* dInL0 =
new std::vector<float>;
62 std::vector<float>*
t =
new std::vector<float>;
64 std::vector<float>* globX =
new std::vector<float>;
65 std::vector<float>* globY =
new std::vector<float>;
66 std::vector<float>* globZ =
new std::vector<float>;
67 std::vector<float>* globR =
new std::vector<float>;
69 std::vector<float>* assignedGlobX =
new std::vector<float>;
70 std::vector<float>* assignedGlobY =
new std::vector<float>;
71 std::vector<float>* assignedGlobZ =
new std::vector<float>;
72 std::vector<float>* assignedGlobR =
new std::vector<float>;
74 layer->SetBranchAddress(
"loc0", &loc0);
75 layer->SetBranchAddress(
"loc1", &loc1);
76 layer->SetBranchAddress(
"A", &A);
77 layer->SetBranchAddress(
"Z", &Z);
78 layer->SetBranchAddress(
"x0", &x0);
79 layer->SetBranchAddress(
"l0", &l0);
80 layer->SetBranchAddress(
"thickness", &d);
81 layer->SetBranchAddress(
"rho", &rho);
82 layer->SetBranchAddress(
"tInX0", &dInX0);
83 layer->SetBranchAddress(
"tInL0", &dInL0);
84 layer->SetBranchAddress(
"thickness", &t);
86 if (layer->FindBranch(
"globX") && layer->FindBranch(
"globY")
87 && layer->FindBranch(
"globZ") && layer->FindBranch(
"globR")) {
88 layer->SetBranchAddress(
"globX", &globX);
89 layer->SetBranchAddress(
"globY", &globY);
90 layer->SetBranchAddress(
"globZ", &globZ);
91 layer->SetBranchAddress(
"globR", &globR);
94 if (layer->FindBranch(
"assignedGlobX") && layer->FindBranch(
"assignedGlobY")
95 && layer->FindBranch(
"assignedGlobZ")
96 && layer->FindBranch(
"assignedGlobR")) {
97 layer->SetBranchAddress(
"assignedGlobX", &assignedGlobX);
98 layer->SetBranchAddress(
"assignedGlobY", &assignedGlobY);
99 layer->SetBranchAddress(
"assignedGlobZ", &assignedGlobZ);
100 layer->SetBranchAddress(
"assignedGlobR", &assignedGlobR);
105 auto minmax0 = std::minmax_element(loc0->begin(), loc0->end());
106 float min0 = *minmax0.first;
107 float max0 = *minmax0.second;
109 auto minmax1 = std::minmax_element(loc1->begin(), loc1->end());
110 float min1 = *minmax1.first;
111 float max1 = *minmax1.second;
114 std::cout <<
"Creating new output file: " << outFile
118 TFile outputFile(outFile.c_str(),
"update");
119 TDirectory* dir = outputFile.mkdir(layerName.c_str());
123 =
new TProfile(
"dInX0_loc1",
"dInX0_loc1", binsLoc1, min1, max1);
125 =
new TProfile(
"dInX0_loc0",
"dInX0_loc0", binsLoc1, min0, max0);
126 TProfile2D* dInX0_map =
new TProfile2D(
127 "dInX0",
"dInX0", binsLoc1, min1, max1, binsLoc1, min0, max0);
130 =
new TProfile(
"dInL0_loc1",
"dInL0_loc1", binsLoc2, min1, max1);
132 =
new TProfile(
"dInL0_loc0",
"dInL0_loc0", binsLoc1, min0, max0);
133 TProfile2D* dInL0_map =
new TProfile2D(
134 "dInL0",
"dInL0", binsLoc2, min1, max1, binsLoc1, min0, max0);
136 TProfile* A_loc1 =
new TProfile(
"A_loc1",
"A_loc1", binsLoc2, min1, max1);
137 TProfile* A_loc0 =
new TProfile(
"A_loc0",
"A_loc0", binsLoc1, min0, max0);
139 =
new TProfile2D(
"A",
"A", binsLoc2, min1, max1, binsLoc1, min0, max0);
141 TProfile* Z_loc1 =
new TProfile(
"Z_loc1",
"Z_loc1", binsLoc2, min1, max1);
142 TProfile* Z_loc0 =
new TProfile(
"Z_loc0",
"Z_loc0", binsLoc1, min0, max0);
144 =
new TProfile2D(
"Z",
"Z", binsLoc2, min1, max1, binsLoc1, min0, max0);
147 =
new TProfile(
"rho_loc1",
"rho_loc1", binsLoc2, min1, max1);
149 =
new TProfile(
"rho_loc0",
"rho_loc0", binsLoc1, min0, max0);
150 TProfile2D* rho_map =
new TProfile2D(
151 "rho",
"rho", binsLoc2, min1, max1, binsLoc1, min0, max0);
153 TProfile* x0_loc1 =
new TProfile(
"x0_loc1",
"x0_loc1", binsLoc2, min1, max1);
154 TProfile* x0_loc0 =
new TProfile(
"x0_loc0",
"x0_loc0", binsLoc1, min0, max0);
156 =
new TProfile2D(
"x0",
"x0", binsLoc2, min1, max1, binsLoc1, min0, max0);
158 TProfile* l0_loc1 =
new TProfile(
"l0_loc1",
"l0_loc1", binsLoc2, min1, max1);
159 TProfile* l0_loc0 =
new TProfile(
"l0_loc0",
"l0_loc0", binsLoc1, min0, max0);
161 =
new TProfile2D(
"l0",
"l0", binsLoc2, min1, max1, binsLoc1, min0, max0);
164 TProfile* t_loc1 =
new TProfile(
"t_loc1",
"t_loc1", binsLoc2, min1, max1);
165 TProfile* t_loc0 =
new TProfile(
"t_loc0",
"t_loc0", binsLoc1, min0, max0);
167 =
new TProfile2D(
"t",
"t", binsLoc2, min1, max1, binsLoc1, min0, max0);
170 TH2F* glob_r_z =
new TH2F(
171 "r_z",
"r_z", binsZ, minGlobZ, maxGlobZ, binsR, minGlobR, maxGlobR);
172 TH2F* assigned_r_z =
new TH2F(
"r_z_assigned",
181 TH2F* glob_x_y =
new TH2F(
182 "x_y",
"x_y", binsR, -maxGlobR, maxGlobR, binsR, -maxGlobR, maxGlobR);
183 TH2F* assigned_x_y =
new TH2F(
"x_y_assigned",
192 size_t nEntries = loc1->size();
193 for (
int i = 0;
i < nEntries;
i++) {
195 A_loc1->Fill(loc1->at(
i), A->at(
i));
196 A_loc0->Fill(loc0->at(
i), A->at(
i));
197 A_map->Fill(loc1->at(
i), loc0->at(
i), A->at(
i));
199 Z_loc1->Fill(loc1->at(
i), Z->at(
i));
200 Z_loc0->Fill(loc0->at(
i), Z->at(
i));
201 Z_map->Fill(loc1->at(
i), loc0->at(
i), Z->at(
i));
203 x0_loc1->Fill(loc1->at(
i), x0->at(
i));
204 x0_loc0->Fill(loc0->at(
i), x0->at(
i));
205 x0_map->Fill(loc1->at(
i), loc0->at(
i), x0->at(
i));
207 l0_loc1->Fill(loc1->at(
i), l0->at(
i));
208 l0_loc0->Fill(loc0->at(
i), l0->at(
i));
209 l0_map->Fill(loc1->at(
i), loc0->at(
i), l0->at(
i));
211 rho_loc1->Fill(loc1->at(
i), rho->at(
i));
212 rho_loc0->Fill(loc0->at(
i), rho->at(
i));
213 rho_map->Fill(loc1->at(
i), loc0->at(
i), rho->at(
i));
215 dInX0_loc1->Fill(loc1->at(
i), dInX0->at(
i));
216 dInX0_loc0->Fill(loc0->at(
i), dInX0->at(
i));
217 dInX0_map->Fill(loc1->at(
i), loc0->at(
i), dInX0->at(
i));
219 dInL0_loc1->Fill(loc1->at(
i), dInL0->at(
i));
220 dInL0_loc0->Fill(loc0->at(
i), dInL0->at(
i));
221 dInL0_map->Fill(loc1->at(
i), loc0->at(
i), dInL0->at(
i));
223 t_loc1->Fill(loc1->at(
i), t->at(
i));
224 t_loc0->Fill(loc0->at(
i), t->at(
i));
225 t_map->Fill(loc1->at(
i), loc0->at(
i), t->at(
i));
228 if (globZ->size() && globR->size())
229 glob_r_z->Fill(globZ->at(
i), globR->at(
i));
231 if (assignedGlobZ->size() && assignedGlobR->size())
232 assigned_r_z->Fill(assignedGlobZ->at(
i), assignedGlobR->at(
i));
235 if (globX->size() && globY->size())
236 glob_x_y->Fill(globX->at(
i), globY->at(
i));
238 if (assignedGlobX->size() && assignedGlobY->size())
239 assigned_x_y->Fill(assignedGlobX->at(
i), assignedGlobY->at(
i));
242 gStyle->SetOptStat(0);
310 assigned_r_z->Write();
312 assigned_x_y->Write();