2065{
2066
2067 this->SetName(Form(
"Rt_%s",
folder.c_str()));
2068
2069 TFile *
file =
new TFile(infile);
2070 cout << "in RtGraphs. Infile: " << string(infile) << endl;
2072 TDirectory *trt = nullptr;
2073
2074 map<string, string> titlemap;
2075 if (!isAr)
2076 {
2077
2078 trt = (TDirectory *)
file->FindKey(
"TRT_all")->ReadObj();
2079 titlemap["WholeBarrel_1"] = "whole barrel";
2080 titlemap["Detector_-1"] = "barrel C";
2081 titlemap["Detector_1"] = "barrel A";
2082 titlemap["Detector_-2"] = "end-cap C";
2083 titlemap["Detector_2"] = "end-cap A";
2084 if (trt)
2085 cout << " Xenon. Found TRT_all " << endl;
2086 if (!trt)
2087 cout << " Xenon. Did not find TRT_all " << endl;
2088 }
2089
2090 else
2091 {
2092
2093 trt = (TDirectory *)
file->FindKey(
"TRT_Ar_all")->ReadObj();
2094 titlemap["WholeBarrel_Ar_1"] = "whole Ar barrel";
2095 titlemap["Detector_Ar_-1"] = "barrel Ar C";
2096 titlemap["Detector_Ar_1"] = "barrel Ar A";
2097 titlemap["Detector_Ar_-2"] = "end-cap Ar C";
2098 titlemap["Detector_Ar_2"] = "end-cap Ar A";
2099 if (trt)
2100 cout << " Argon. Found TRT_Ar_all " << endl;
2101 if (!trt)
2102 cout << " Argon. Did not find TRT_Ar_all " << endl;
2103 }
2104
2105 if (trt and (not
folder.empty()))
2106 {
2107 cout <<
" PLOT FOR " <<
folder << endl;
2108 TDirectory *
det = (TDirectory *)trt->FindKey(
folder.c_str())->ReadObj();
2109 if (
det->FindKey(
"rt-relation"))
2110 {
2111 cout << " found rt-relation " << endl;
2114 rthist->GetXaxis()->SetRangeUser(0, 40);
2116 sprintf(name, "rt (%s)", titlemap[folder].c_str());
2118 if (
det->FindKey(
"rtgraph"))
2119 {
2120 rtgraph = (TGraphErrors *)
det->FindKey(
"rtgraph")->ReadObj();
2121 cout << " found also rtgraph " << endl;
2122 }
2123 else
2124 {
2126 cout << " did not found rtgraph " << endl;
2127 }
2128 if (
det->FindKey(
"trgraph"))
2129 {
2130 trgraph = (TGraphErrors *)
det->FindKey(
"trgraph")->ReadObj();
2131 cout << " found also trgraph " << endl;
2132 }
2133 else
2134 {
2136 cout << " did not found trgraph " << endl;
2137 }
2138 if (
det->FindKey(
"oldrtfunc"))
2139 {
2140 oldrtfunc = (TF1 *)
det->FindKey(
"oldrtfunc")->ReadObj();
2141 cout << " found also oldrtfunc " << endl;
2142 }
2143 else
2144 {
2146 cout << " did not find oldrtfunc " << endl;
2147 }
2148 }
2149 else
2150 {
2151 throw string(" NO RT OBJECTS FOUND");
2152 }
2153 }
2154 else if (trt and trt->FindKey("rt-relation"))
2155 {
2156 cout << " No folder. Found rt-relation. PLOT FOR TRT" << endl;
2157 rthist = (
TH2F *)trt->FindKey(
"rt-relation")->ReadObj();
2159 rthist->GetXaxis()->SetRangeUser(0, 40);
2160 rthist->SetTitle(
"r(t) for whole TRT");
2161 if (trt->FindKey("rtgraph"))
2162 {
2163 rtgraph = (TGraphErrors *)trt->FindKey(
"rtgraph")->ReadObj();
2164 cout << " found also rtgraph " << endl;
2165 }
2166 else
2167 {
2169 cout << " did not find rtgraph " << endl;
2170 }
2171 if (trt->FindKey("trgraph"))
2172 {
2173 trgraph = (TGraphErrors *)trt->FindKey(
"trgraph")->ReadObj();
2174 cout << " found also trgraph " << endl;
2175 }
2176 else
2177 {
2179 cout << " did not find trgraph " << endl;
2180 }
2181 if (trt->FindKey("oldrtfunc"))
2182 {
2183 oldrtfunc = (TF1 *)trt->FindKey(
"oldrtfunc")->ReadObj();
2184 cout << " found also oldtrtfunc " << endl;
2185 }
2186 else
2187 {
2189 cout << " did not find oldtrtfunc " << endl;
2190 }
2191 }
2192 else
2193 {
2194 cout << " No folder. No rt-relation." << endl;
2198 }
2199
2201 this->Divide(2, 1, 0.01, 0.01);
2203
2204 TPad *c1_3 = new TPad("c1_3", "newpad", 0.01, 0.33, 0.99, 0.99);
2205 c1_3->Draw();
2206 c1_3->cd();
2207 c1_3->SetTopMargin(0.1);
2208 c1_3->SetBottomMargin(0.01);
2209 c1_3->SetRightMargin(0.1);
2210 c1_3->SetFillStyle(0);
2211 c1_3->SetGrid();
2212
2214 {
2215 if (folder == "")
2216 {
2217 cout << " found rtgraph for entire TRT " << endl;
2218 rtgraph->SetTitle(
"r(t) fit (whole TRT)");
2219 }
2220 else
2221 {
2222 cout <<
" found rtgraph for folder: " <<
folder << endl;
2223 rtgraph->SetTitle(titlemap[folder].c_str());
2224 }
2225 cout << " set rtgraph X title t-T0/ns and Y title |r|_{track}/mm" << endl;
2226
2227 rtgraph->GetXaxis()->SetTitle(
"t-T0/ns");
2228 rtgraph->GetYaxis()->SetTitle(
"|r|_{track}/mm");
2229
2230 rtgraph->GetXaxis()->SetTitleSize(0.06);
2231 rtgraph->GetXaxis()->SetLabelSize(0.06);
2232
2233
2236 rtgraph->GetYaxis()->SetRangeUser(-0.05, 2.6);
2237 cout << " Draw rtgraph " << endl;
2239 TF1 *newRT;
2240 if (
rtgraph->GetFunction(
"rtfunc"))
2241 newRT =
rtgraph->GetFunction(
"rtfunc");
2242 else
2243 newRT =
rtgraph->GetFunction(
"rtfunc2");
2244 if (newRT)
2245 {
2246 cout << " Draw new fit " << endl;
2247 newRT->SetLineWidth(1);
2248 newRT->Draw("same");
2249 }
2251 {
2255 cout << " Draw old fit " << endl;
2257 }
2258
2259
2260 TLegend *
leg =
new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373,
nullptr,
"brNDC");
2262 leg->AddEntry(newRT,
"Fit",
"l");
2264 leg->SetTextSize(0.03);
2266
2267
2269 {
2272 TPad *c1_4 = new TPad("c1_4", "newpad", 0.01, 0, 0.99, 0.32);
2273 c1_4->Draw();
2274 c1_4->cd();
2275 c1_4->SetTopMargin(0.01);
2276 c1_4->SetBottomMargin(0.3);
2277 c1_4->SetRightMargin(0.1);
2278 c1_4->SetFillStyle(0);
2279 c1_4->SetGrid();
2280
2281 Double_t Xmax =
rtgraph->GetXaxis()->GetXmax();
2283
2284 const Int_t
n = 300;
2287
2288 Double_t Ymax = -10;
2289 Double_t Ymin = 10;
2290
2291 for (Int_t i = 0;
i <
n;
i++)
2292 {
2299 }
2300
2301 TGraph *
gr1 =
new TGraph(n,
x,
y);
2302
2304 gr1->GetXaxis()->SetTitle(
"t-T0/ns");
2305 gr1->GetXaxis()->SetRangeUser(Xmin, Xmax);
2306 gr1->GetYaxis()->SetTitle(
"Old r(t) - New r(t) /mm");
2307 gr1->GetYaxis()->SetRangeUser(-0.1, 0.1);
2308
2309 gr1->GetYaxis()->SetNdivisions(5);
2310 gr1->GetXaxis()->SetTitleSize(0.06);
2311 gr1->GetXaxis()->SetLabelSize(0.06);
2312 gr1->GetYaxis()->SetLabelSize(0.08);
2313 gr1->GetYaxis()->SetTitleOffset(0.8);
2314 gr1->GetYaxis()->SetTitleSize(0.06);
2315 gr1->SetLineStyle(2);
2316
2317
2318
2320 std::vector<Double_t>
x1(n1, 0),
y1(n1, 0),
ex1(n1, 0), ey1(n1, 0);
2322
2323 for (Int_t i = 0;
i <
n1;
i++)
2324 {
2329 y1.at(i) =
Y - newRT->Eval(X);
2331 ey1.at(i) =
rtgraph->GetErrorY(i);
2332 if (
y1.at(i) > Ymax)
2333 {
2335 }
2336 if (
y1.at(i) < Ymin)
2337 {
2339 }
2340 }
2341
2342 TGraphErrors *
gr2 =
new TGraphErrors(n1, &
x1.at(0), &
y1.at(0), &
ex1.at(0), &ey1.at(0));
2343 gr2->SetMarkerColor(2);
2344 gr2->SetMarkerStyle(20);
2346 gr2->GetYaxis()->SetTitle(
"Old r(t) - New r(t) /mm");
2347
2348 gr2->GetYaxis()->SetRangeUser(-0.2, 0.2);
2349 gr2->GetXaxis()->SetRangeUser(-5, 50);
2350 cout << " Draw difference " << endl;
2353
2354 TLine *line0 = new TLine(Xmin, 0, Xmax, 0);
2355 line0->SetLineColor(4);
2356 line0->Draw();
2357 }
2358 }
2359 else
2360 {
2361 cout << " nullptr rtgraph " << endl;
2362 }
2363
2366 {
2367
2368 if (folder == "")
2369 trgraph->SetTitle(
"t(r) fit (whole TRT)");
2370 else
2371 {
2373
2374 sprintf(name, "t(r) fit (%s)", titlemap[string(folder)].c_str());
2376 }
2377
2378 trgraph->GetYaxis()->SetTitle(
"t-T0/ns");
2379 trgraph->GetXaxis()->SetTitle(
"|r|_{track}/mm");
2380
2383 cout << " Draw trgraph " << endl;
2385 }
2386 else
2387 {
2388 cout << " nullptr trgraph " << endl;
2389 }
2390
2391 gStyle->SetOptStat(1);
2392}
TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)