ATLAS Offline Software
Loading...
Searching...
No Matches
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 3330 of file TRTCalib_makeplots.cxx.

Constructor & Destructor Documentation

◆ RresTbin()

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

Definition at line 3345 of file TRTCalib_makeplots.cxx.

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

Member Data Documentation

◆ m_erdata

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

Definition at line 3340 of file TRTCalib_makeplots.cxx.

◆ m_etdata

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

Definition at line 3342 of file TRTCalib_makeplots.cxx.

◆ m_rdata

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

Definition at line 3339 of file TRTCalib_makeplots.cxx.

◆ m_tdata

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

Definition at line 3341 of file TRTCalib_makeplots.cxx.

◆ m_thegraph

TGraphErrors RresTbin::m_thegraph
private

Definition at line 3338 of file TRTCalib_makeplots.cxx.

◆ reshists

vector<TH1D *> RresTbin::reshists

Definition at line 3334 of file TRTCalib_makeplots.cxx.

◆ resmap

map<double, double> RresTbin::resmap

Definition at line 3335 of file TRTCalib_makeplots.cxx.


The documentation for this class was generated from the following file: