ATLAS Offline Software
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 
19 using namespace MuonCalib;
20 
21 int 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();
52  fitter.SetTSpec(n, hist, &settings);
53  n++;
54  if (fitter.FitT0()) { fitter.FitTmax(); }
55  }
56  }
57  outfile.Write();
58 }
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
run.infile
string infile
Definition: run.py:13
T0MTHistos.h
dqt_zlumi_pandas.hname
string hname
Definition: dqt_zlumi_pandas.py:279
plotmaker.hist
hist
Definition: plotmaker.py:148
MuonCalib::T0MTHistos
Definition: T0MTHistos.h:40
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
beamspotman.n
n
Definition: beamspotman.py:731
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
beamspotman.dir
string dir
Definition: beamspotman.py:623
MuonCalib::T0MTSettings::AddFitfun
const bool & AddFitfun() const
If set to true the fitted functions are added to the histograms.
Definition: T0MTSettings.h:63
MuonCalib::T0MTSettings::DrawDebugGraphs
const bool & DrawDebugGraphs() const
If set to true for every tube a TDirectory will be created.
Definition: T0MTSettings.h:60
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.PyAthena.obj
obj
Definition: PyAthena.py:132
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
MuonCalib::T0MTSettings
Definition: T0MTSettings.h:28
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
main
int main(int argc, char *argv[])
Definition: T0Fit.cxx:21