ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
RtGraphs Class Reference
Inheritance diagram for RtGraphs:
Collaboration diagram for RtGraphs:

Public Member Functions

 RtGraphs (char *, const string &, bool)
 

Public Attributes

TH2F * rthist {}
 
TGraphErrors * rtgraph {}
 
TGraphErrors * trgraph {}
 
TF1 * oldrtfunc {}
 

Detailed Description

Definition at line 2052 of file TRTCalib_makeplots.cxx.

Constructor & Destructor Documentation

◆ RtGraphs()

RtGraphs::RtGraphs ( char *  infile,
const string &  folder,
bool  isAr = false 
)

Definition at line 2063 of file TRTCalib_makeplots.cxx.

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

Member Data Documentation

◆ oldrtfunc

TF1* RtGraphs::oldrtfunc {}

Definition at line 2060 of file TRTCalib_makeplots.cxx.

◆ rtgraph

TGraphErrors* RtGraphs::rtgraph {}

Definition at line 2058 of file TRTCalib_makeplots.cxx.

◆ rthist

TH2F* RtGraphs::rthist {}

Definition at line 2057 of file TRTCalib_makeplots.cxx.

◆ trgraph

TGraphErrors* RtGraphs::trgraph {}

Definition at line 2059 of file TRTCalib_makeplots.cxx.


The documentation for this class was generated from the following file:
plotBeamSpotCompare.ex1
ex1
Definition: plotBeamSpotCompare.py:217
plotBeamSpotCompare.gr1
gr1
Definition: plotBeamSpotCompare.py:391
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
run.infile
string infile
Definition: run.py:13
VertexShift::Xmin
const float Xmin
Definition: VertexShift.h:25
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
x
#define x
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
file
TFile * file
Definition: tile_monitor.h:29
compute_lumi.leg
leg
Definition: compute_lumi.py:95
Monitored::Y
@ Y
Definition: HistogramFillerUtils.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
RtGraphs::rtgraph
TGraphErrors * rtgraph
Definition: TRTCalib_makeplots.cxx:2058
RtGraphs::oldrtfunc
TF1 * oldrtfunc
Definition: TRTCalib_makeplots.cxx:2060
Rtt_histogram.n1
n1
Definition: Rtt_histogram.py:21
dqt_zlumi_display_z_rate.gr2
gr2
Definition: dqt_zlumi_display_z_rate.py:81
y
#define y
RtGraphs::trgraph
TGraphErrors * trgraph
Definition: TRTCalib_makeplots.cxx:2059
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:56
calibdata.cd
cd
Definition: calibdata.py:51
RtGraphs::rthist
TH2F * rthist
Definition: TRTCalib_makeplots.cxx:2057