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

Public Member Functions

 RresTbin (TFile *, const string &, int)
 

Public Attributes

vector< TH1D * > reshists
 
map< double, double > resmap
 

Private Attributes

TGraphErrors m_thegraph
 
std::vector< double > m_rdata
 
std::vector< double > m_erdata
 
std::vector< double > m_tdata
 
std::vector< double > m_etdata
 

Detailed Description

Definition at line 3324 of file TRTCalib_makeplots.cxx.

Constructor & Destructor Documentation

◆ RresTbin()

RresTbin::RresTbin ( TFile *  file,
const string &  detname,
int  det 
)

Definition at line 3339 of file TRTCalib_makeplots.cxx.

3340 {
3341 
3342  TF1 ff("fitfunc", "gaus");
3343  TF1 *ff2 = new TF1("fitfunc2", "pol3");
3344 
3345  TDirectory *trt = nullptr;
3346  TDirectory *detdir = nullptr;
3347  TDirectory *binhist = nullptr;
3348  string resname;
3349  bool isAr = false;
3350  if (detname.find("Ar") != string::npos)
3351  isAr = true;
3352  bool allTRT = false;
3353  if (detname == "WholeBarrel_1")
3354  {
3355  resname = "reshists5";
3356  }
3357  else if (detname == "Detector_-1")
3358  {
3359  resname = "reshists2";
3360  }
3361  else if (detname == "Detector_1")
3362  {
3363  resname = "reshists3";
3364  }
3365  else if (detname == "Detector_-2")
3366  {
3367  resname = "reshists1";
3368  }
3369  else if (detname == "Detector_2")
3370  {
3371  resname = "reshists4";
3372  }
3373  else if (!isAr)
3374  {
3375  resname = "reshists";
3376  allTRT = true;
3377  }
3378  else if (detname == "WholeBarrel_Ar_1")
3379  {
3380  resname = "reshists_Ar5";
3381  }
3382  else if (detname == "Detector_Ar_-1")
3383  {
3384  resname = "reshists_Ar2";
3385  }
3386  else if (detname == "Detector_Ar_1")
3387  {
3388  resname = "reshists_Ar3";
3389  }
3390  else if (detname == "Detector_Ar_-2")
3391  {
3392  resname = "reshists_Ar1";
3393  }
3394  else if (detname == "Detector_Ar_2")
3395  {
3396  resname = "reshists_Ar4";
3397  }
3398  else
3399  {
3400  resname = "reshists_Ar";
3401  allTRT = true;
3402  }
3403 
3404  if (!isAr)
3405  trt = (TDirectory *)file->FindKey("TRT_all")->ReadObj();
3406  else
3407  trt = (TDirectory *)file->FindKey("TRT_Ar_all")->ReadObj();
3408 
3409  if (!isAr)
3410  cout << "In RresTbin Xenon" << endl;
3411  if (isAr)
3412  cout << "In RresTbin Argon" << endl;
3413  if (trt)
3414  {
3415  cout << " found TRT_all directory " << endl;
3416  detdir = (TDirectory *)trt->FindKey(detname.c_str())->ReadObj();
3417  if (detdir)
3418  {
3419  cout << " found binhist directory for detector name " << detname << endl;
3420  if (!allTRT)
3421  {
3422  binhist = (TDirectory *)detdir->FindKey(resname.c_str())->ReadObj();
3423  }
3424  else
3425  {
3426  binhist = (TDirectory *)trt->FindKey(resname.c_str())->ReadObj();
3427  }
3428 
3429  if (binhist)
3430  {
3431  cout << " found reshists directory for detector number: " << det << endl;
3432  }
3433  else
3434  {
3435  cout << " did not find reshists directory for detector number " << det << endl;
3436  }
3437  }
3438  else
3439  {
3440  cout << " did not find binhist directory for detector name " << detname << endl;
3441  }
3442  }
3443  else
3444  {
3445  cout << " did not find TRT_all directory " << endl;
3446  }
3447 
3448  if (binhist)
3449  {
3450 
3451  TVectorD *tbins = (TVectorD *)file->FindKey("tbins")->ReadObj();
3452 
3453  if (tbins)
3454  {
3455  const size_t nElements = tbins->GetNoElements();
3456  cout << " found tbins vector with length " << nElements << endl;
3457  m_rdata = std::vector<double>(nElements,0.);
3458  m_erdata = std::vector<double>(nElements,0.);
3459  m_tdata = std::vector<double>(nElements,0.);
3460  m_etdata = std::vector<double>(nElements,0.);
3461  m_thegraph = TGraphErrors(nElements);
3462 
3463  int ipoint = 0;
3464  for (int ihist = 0; ihist < tbins->GetNoElements(); ihist++)
3465  {
3466 
3467  TH1D *reshist = nullptr;
3468 
3469  if (det == 4)
3470  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_bar", ihist));
3471  else if (det == 5)
3472  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_trt", ihist));
3473  else
3474  reshist = (TH1D *)binhist->Get(Form("res_tbin%i_%i", ihist, det));
3475 
3476  if (reshist != nullptr)
3477  {
3478  double lolim = -0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()-10);
3479  double hilim = 0.1; // reshist->GetBinCenter(reshist->GetMaximumBin()+10);
3480 
3481  if (reshist->Fit(&ff, "Q", "", lolim, hilim) + 1)
3482  {
3483  m_rdata[ipoint] = ff.GetParameter(1);
3484  m_erdata[ipoint] = ff.GetParError(1);
3485  m_tdata[ipoint] = (*tbins)[ihist];
3486 
3487  m_etdata[ipoint] = 0;
3488  // printf("%f %f\n",ff.GetParameter(1),ff.GetParError(1));
3489  ipoint++;
3490  }
3491 
3492  reshists.push_back(reshist);
3493  }
3494  }
3495  cout << " succesfully fitted " << ipoint << " histograms " << endl;
3496  for (int ip = 0; ip < ipoint; ip++)
3497  {
3498  // cout << rdata[ip] << " ";
3499  resmap[m_tdata[ip]] = m_rdata[ip];
3500  }
3501  // cout << endl;
3502 
3503  if (ipoint > 10)
3504  {
3505  m_thegraph = TGraphErrors(ipoint, m_tdata.data(), m_rdata.data(), m_etdata.data(), m_erdata.data());
3506 
3507  cout << " draw t-binned residual graph " << endl;
3508  string detstr[8] = {"endcap A", "barrel A", "", "barrel C", "endcap C", "", "whole barrel", "whole TRT"};
3509 
3510  m_thegraph.SetMarkerStyle(20);
3511  m_thegraph.SetTitle(Form("t-binned absolute residual (%s)", detstr[det + 2].c_str()));
3512  m_thegraph.Draw("ap");
3513  m_thegraph.GetYaxis()->SetTitle("|r|-|r_{track}| /mm");
3514  m_thegraph.GetYaxis()->SetRangeUser(-0.150, 0.150);
3515  m_thegraph.GetXaxis()->SetRangeUser(0, 50);
3516  m_thegraph.GetXaxis()->SetTitle("t-t0 /ns");
3517 
3518  printf("RPOLDIFF %i %e %e %e %e\n", det, ff2->GetParameter(0), ff2->GetParameter(1), ff2->GetParameter(2), ff2->GetParameter(3));
3519 
3520  this->SetGrid();
3521  }
3522  }
3523  }
3524 }

Member Data Documentation

◆ m_erdata

std::vector<double> RresTbin::m_erdata
private

Definition at line 3334 of file TRTCalib_makeplots.cxx.

◆ m_etdata

std::vector<double> RresTbin::m_etdata
private

Definition at line 3336 of file TRTCalib_makeplots.cxx.

◆ m_rdata

std::vector<double> RresTbin::m_rdata
private

Definition at line 3333 of file TRTCalib_makeplots.cxx.

◆ m_tdata

std::vector<double> RresTbin::m_tdata
private

Definition at line 3335 of file TRTCalib_makeplots.cxx.

◆ m_thegraph

TGraphErrors RresTbin::m_thegraph
private

Definition at line 3332 of file TRTCalib_makeplots.cxx.

◆ reshists

vector<TH1D *> RresTbin::reshists

Definition at line 3328 of file TRTCalib_makeplots.cxx.

◆ resmap

map<double, double> RresTbin::resmap

Definition at line 3329 of file TRTCalib_makeplots.cxx.


The documentation for this class was generated from the following file:
RresTbin::m_etdata
std::vector< double > m_etdata
Definition: TRTCalib_makeplots.cxx:3336
RresTbin::m_thegraph
TGraphErrors m_thegraph
Definition: TRTCalib_makeplots.cxx:3332
RresTbin::m_erdata
std::vector< double > m_erdata
Definition: TRTCalib_makeplots.cxx:3334
TRTCalib_Extractor.det
det
Definition: TRTCalib_Extractor.py:36
RresTbin::resmap
map< double, double > resmap
Definition: TRTCalib_makeplots.cxx:3329
RresTbin::reshists
vector< TH1D * > reshists
Definition: TRTCalib_makeplots.cxx:3328
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
file
TFile * file
Definition: tile_monitor.h:29
find_tgc_unfilled_channelids.ip
ip
Definition: find_tgc_unfilled_channelids.py:3
RresTbin::m_tdata
std::vector< double > m_tdata
Definition: TRTCalib_makeplots.cxx:3335
RresTbin::m_rdata
std::vector< double > m_rdata
Definition: TRTCalib_makeplots.cxx:3333