ATLAS Offline Software
Loading...
Searching...
No Matches
T0Fit.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <TString.h> // for Form
6
8#include "TClass.h"
9#include "TDirectory.h"
10#include "TFile.h"
11#include "TH1.h"
12#include "TKey.h"
13#include "TObject.h"
14#include "TROOT.h"
15#include "cstdlib"
16#include "iostream"
17#include "string"
18
19using namespace MuonCalib;
20
21int main(int argc, char *argv[]) {
22 // check command line arguments
23 if (argc != 3) {
24 throw std::runtime_error(
25 Form("File: %s, Line: %d\nT0Fit::main() - Usage: %s <input file> <output file>!", __FILE__, __LINE__, argv[0]));
26 }
27
28 TROOT wurscht("wurscht", "wurscht");
29 TFile infile(argv[1]);
30 TDirectory *dir = &infile;
31 TFile outfile(argv[2], "RECREATE");
32 T0MTSettings settings;
33 settings.AddFitfun() = true;
34 settings.DrawDebugGraphs() = true;
35 if (!dir) {
36 throw std::runtime_error(
37 Form("File: %s, Line: %d\nT0Fit::main() - Cannot find TDirectory 'MT_t0_fitter' in file %s!", __FILE__, __LINE__, argv[1]));
38 }
39 // loop on all histograms
40 TIter nextkey(dir->GetListOfKeys());
41 TKey *key;
42 int n = 0;
43 while ((key = (TKey *)nextkey())) {
44 TObject *obj = key->ReadObj();
45 if (obj->IsA()->InheritsFrom("TH1F")) {
46 TH1F *hist = dynamic_cast<TH1F *>(obj);
47 if (hist == NULL) continue;
48 string hname = hist->GetName();
49 if (hname == "t_spec_Summary") continue;
50 hist->GetListOfFunctions()->Clear();
51 T0MTHistos fitter;
52 fitter.SetTSpec(n, hist, &settings);
53 n++;
54 if (fitter.FitT0()) { fitter.FitTmax(); }
55 }
56 }
57 outfile.Write();
58}
Histogram and fitter class for drift time and pulsehight spectra The rising slope is fitted by a ferm...
Definition T0MTHistos.h:40
Settings for the T0 calibration (histogram booking and fitting parameters) Parameters for pattern rec...
const bool & AddFitfun() const
If set to true the fitted functions are added to the histograms.
const bool & DrawDebugGraphs() const
If set to true for every tube a TDirectory will be created.
int main()
Definition hello.cxx:18
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.