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 2053 of file TRTCalib_makeplots.cxx.

Constructor & Destructor Documentation

◆ RtGraphs()

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

Definition at line 2064 of file TRTCalib_makeplots.cxx.

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;
2071  file->cd();
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;
2112  rthist = (TH2F *)det->FindKey("rt-relation")->ReadObj();
2113  this->cd();
2114  rthist->GetXaxis()->SetRangeUser(0, 40);
2115  char name[500];
2116  sprintf(name, "rt (%s)", titlemap[folder].c_str());
2117  rthist->SetTitle(name);
2118  if (det->FindKey("rtgraph"))
2119  {
2120  rtgraph = (TGraphErrors *)det->FindKey("rtgraph")->ReadObj();
2121  cout << " found also rtgraph " << endl;
2122  }
2123  else
2124  {
2125  rtgraph = nullptr;
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  {
2135  trgraph = nullptr;
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  {
2145  oldrtfunc = nullptr;
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();
2158  this->cd();
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  {
2168  rtgraph = nullptr;
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  {
2178  trgraph = nullptr;
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  {
2188  oldrtfunc = nullptr;
2189  cout << " did not find oldtrtfunc " << endl;
2190  }
2191  }
2192  else
2193  {
2194  cout << " No folder. No rt-relation." << endl;
2195  rthist = nullptr;
2196  rtgraph = nullptr;
2197  oldrtfunc = nullptr;
2198  }
2199 
2200  this->cd();
2201  this->Divide(2, 1, 0.01, 0.01);
2202  this->cd(1);
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 
2213  if (rtgraph)
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  // rtgraph->GetYaxis()->SetRangeUser(0,2.7);
2230  rtgraph->GetXaxis()->SetTitleSize(0.06);
2231  rtgraph->GetXaxis()->SetLabelSize(0.06);
2232 
2233  // Blue line too wide, extract and plot again:
2234  rtgraph->SetMarkerStyle(20);
2235  rtgraph->SetMarkerSize(0.5);
2236  rtgraph->GetYaxis()->SetRangeUser(-0.05, 2.6);
2237  cout << " Draw rtgraph " << endl;
2238  rtgraph->Draw("ap");
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  }
2250  if (oldrtfunc)
2251  {
2252  oldrtfunc->SetLineColor(1);
2253  oldrtfunc->SetLineWidth(1);
2254  oldrtfunc->SetLineStyle(2);
2255  cout << " Draw old fit " << endl;
2256  oldrtfunc->Draw("same");
2257  }
2258  // Legend
2259 
2260  TLegend *leg = new TLegend(0.7155172, 0.1038136, 0.8965517, 0.2542373, nullptr, "brNDC");
2261  leg->AddEntry(rtgraph, "Data", "p");
2262  leg->AddEntry(newRT, "Fit", "l");
2263  leg->AddEntry(oldrtfunc, "Fit old rt", "l");
2264  leg->SetTextSize(0.03);
2265  leg->Draw();
2266 
2267  // Plot the difference between old and new rt:
2268  if (oldrtfunc && newRT)
2269  {
2270  this->cd();
2271  this->cd(1);
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();
2282  Double_t Xmin = rtgraph->GetXaxis()->GetXmin();
2283 
2284  const Int_t n = 300;
2285  Double_t x[n], y[n], dx;
2286  dx = (Xmax - Xmin) / n;
2287 
2288  Double_t Ymax = -10;
2289  Double_t Ymin = 10;
2290 
2291  for (Int_t i = 0; i < n; i++)
2292  {
2293  x[i] = Xmin + i * dx;
2294  y[i] = (oldrtfunc->Eval(x[i]) - newRT->Eval(x[i]));
2295  if (y[i] > Ymax)
2296  Ymax = y[i];
2297  if (y[i] < Ymin)
2298  Ymin = y[i];
2299  }
2300 
2301  TGraph *gr1 = new TGraph(n, x, y);
2302 
2303  gr1->SetTitle("");
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  // gr1->GetYaxis()->SetRangeUser(1.1*Ymin,1.1*Ymax);
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  // Also add the difference between the fit and the points of the fit
2318 
2319  const Int_t n1 = rtgraph->GetN();
2320  std::vector<Double_t> x1(n1, 0), y1(n1, 0), ex1(n1, 0), ey1(n1, 0);
2321  Double_t X, Y;
2322 
2323  for (Int_t i = 0; i < n1; i++)
2324  {
2325  X = 0;
2326  Y = 0;
2327  rtgraph->GetPoint(i, X, Y);
2328  x1.at(i) = X;
2329  y1.at(i) = Y - newRT->Eval(X);
2330  ex1.at(i) = 0;
2331  ey1.at(i) = rtgraph->GetErrorY(i);
2332  if (y1.at(i) > Ymax)
2333  {
2334  Ymax = y1.at(i);
2335  }
2336  if (y1.at(i) < Ymin)
2337  {
2338  Ymin = y1.at(i);
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);
2345  gr2->SetTitle("");
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;
2351  gr2->Draw("ap");
2352  gr1->Draw("l");
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 
2364  this->cd(2);
2365  if (trgraph)
2366  {
2367 
2368  if (folder == "")
2369  trgraph->SetTitle("t(r) fit (whole TRT)");
2370  else
2371  {
2372  char name[500];
2373  //don't move 'folder'; it is passed by const ref
2374  sprintf(name, "t(r) fit (%s)", titlemap[string(folder)].c_str());
2375  trgraph->SetTitle(name);
2376  }
2377 
2378  trgraph->GetYaxis()->SetTitle("t-T0/ns");
2379  trgraph->GetXaxis()->SetTitle("|r|_{track}/mm");
2380  // trgraph->GetYaxis()->SetRangeUser(0,32);
2381  trgraph->SetMarkerStyle(20);
2382  trgraph->SetMarkerSize(0.5);
2383  cout << " Draw trgraph " << endl;
2384  trgraph->Draw("ap");
2385  }
2386  else
2387  {
2388  cout << " nullptr trgraph " << endl;
2389  }
2390 
2391  gStyle->SetOptStat(1);
2392 }

Member Data Documentation

◆ oldrtfunc

TF1* RtGraphs::oldrtfunc {}

Definition at line 2061 of file TRTCalib_makeplots.cxx.

◆ rtgraph

TGraphErrors* RtGraphs::rtgraph {}

Definition at line 2059 of file TRTCalib_makeplots.cxx.

◆ rthist

TH2F* RtGraphs::rthist {}

Definition at line 2058 of file TRTCalib_makeplots.cxx.

◆ trgraph

TGraphErrors* RtGraphs::trgraph {}

Definition at line 2060 of file TRTCalib_makeplots.cxx.


The documentation for this class was generated from the following file:
plotBeamSpotCompare.ex1
ex1
Definition: plotBeamSpotCompare.py:216
plotBeamSpotCompare.gr1
gr1
Definition: plotBeamSpotCompare.py:390
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:215
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:727
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:240
RtGraphs::rtgraph
TGraphErrors * rtgraph
Definition: TRTCalib_makeplots.cxx:2059
RtGraphs::oldrtfunc
TF1 * oldrtfunc
Definition: TRTCalib_makeplots.cxx:2061
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:2060
makeTRTBarrelCans.dx
tuple dx
Definition: makeTRTBarrelCans.py:20
CaloCondBlobAlgs_fillNoiseFromASCII.folder
folder
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:55
calibdata.cd
cd
Definition: calibdata.py:50
RtGraphs::rthist
TH2F * rthist
Definition: TRTCalib_makeplots.cxx:2058