ATLAS Offline Software
T0CalibrationClassic.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef T0CALIBRATIONCLASSIC_H
6 #define T0CALIBRATIONCLASSIC_H
7 
8 #include <TF1.h>
9 #include <TFile.h>
10 #include <TH1.h>
11 #include <TH2.h>
12 
13 #include <iostream>
14 #include <vector>
15 
17 #include "GaudiKernel/MsgStream.h"
21 
22 namespace MuonCalib {
23 
24  class MuonCalibSegment;
25  class IMdtCalibrationOutput;
26 
31  public:
33  T0ClassicSettings(double minAdc, double maxAdc, int adcBins, double minTime, double maxTime, int timeBins, bool fitTime,
34  int minEntries, int initParam, int numParams, std::array<double, 8> fitParams, double chiMax, int printLevel) :
37  m_binAdc(adcBins),
40  m_binTime(timeBins),
42  m_entries(minEntries),
43  m_initParamFlag(initParam),
45  m_params(fitParams),
46  m_chi2max(chiMax),
50  double minAdc() const { return m_minAdc; };
52  double maxAdc() const { return m_maxAdc; };
54  int binAdc() const { return m_binAdc; };
56  double minTime() const { return m_minTime; };
58  double maxTime() const { return m_maxTime; };
60  int binTime() const { return m_binTime; };
62  bool fitTime() const { return m_fitTime; };
64  int entries() const { return m_entries; };
67  int initParamFlag() const { return m_initParamFlag; };
69  int numParams() const { return m_numParams; };
71  const std::array<double, 8>& params() const { return m_params; };
73  double chi2max() const { return m_chi2max; };
75  int printLevel() const { return m_printLevel; };
77  void print() const {
78  MsgStream log(Athena::getMessageSvc(), "T0ClassicSettings");
79  log << MSG::INFO << "T0ClassicSettings: " << endmsg;
80  log << MSG::INFO << "booking of Adc histos: min max bins " << minAdc() << " " << maxAdc() << " " << binAdc() << endmsg;
81  log << MSG::INFO << "booking of Time histos: min max bins " << minTime() << " " << maxTime() << " " << binTime() << endmsg;
82  log << MSG::INFO << "fitting of Time histos: active minentries paramflag chi2cut nparams" << fitTime() << " " << entries()
83  << " " << initParamFlag() << " " << chi2max() << " " << numParams() << endmsg;
84  log << MSG::INFO << "Parameters: " << endmsg;
85  for (int i = 0; i < numParams(); i++) { log << MSG::INFO << m_params[i] << endmsg; }
86  };
87 
88  private:
90  double m_minAdc;
91  double m_maxAdc;
92  int m_binAdc;
93  double m_minTime;
94  double m_maxTime;
95  int m_binTime;
96  bool m_fitTime;
97  int m_entries;
100  std::array<double, 8> m_params;
101  double m_chi2max;
103  }; // end class T0ClassicSettings
104 
109  public:
110  std::unique_ptr<TH1> time{nullptr};
111  std::unique_ptr<TH1> adc{nullptr};
112  // TH2* adc_vs_time;
113  int id;
114  };
115 
120  public:
125  T0CalibrationClassic(const std::string& name, const T0ClassicSettings* settings);
128 
129  bool handleSegment(MuonCalibSegment& seg);
130  void setInput(const IMdtCalibrationOutput* input) override;
131  bool analyse();
132  bool converged() const;
133 
135  virtual MdtCalibOutputPtr getResults() const override;
136  virtual MdtCalibOutputPtr analyseSegments(const MuonSegVec& segs) override;
137 
138  private:
139  T0ClassicHistos* bookHistos(unsigned int idtube);
140  T0ClassicHistos* getHistos(unsigned int idtube);
144  void searchParams(TH1* h, double* p, int np);
146  bool m_converged;
147  std::string m_name;
149  std::unique_ptr<TFile> m_file{};
150  TDirectory* m_regiondir;
151 
152  std::vector<std::unique_ptr<T0ClassicHistos>> m_histos;
153  std::unique_ptr<MdtTubeFitContainer> m_result;
155 
156  // hidden assignment operator and copy constructor
159  }; // end class T0CalibrationClassic
160 } // namespace MuonCalib
161 
162 #endif
MuonCalib::T0CalibrationClassic
Definition: T0CalibrationClassic.h:119
MuonCalib::T0CalibrationClassic::bookHistos
T0ClassicHistos * bookHistos(unsigned int idtube)
booking of histograms
Definition: T0CalibrationClassic.cxx:581
MuonCalib::T0ClassicSettings::numParams
int numParams() const
Definition: T0CalibrationClassic.h:69
MuonCalib::T0CalibrationClassic::m_currentItnum
int m_currentItnum
current iteration (always 1?)
Definition: T0CalibrationClassic.h:148
MuonCalib::IMdtCalibration::MdtCalibOutputPtr
std::shared_ptr< IMdtCalibrationOutput > MdtCalibOutputPtr
Definition: IMdtCalibration.h:30
MuonCalib::T0ClassicSettings::m_fitTime
bool m_fitTime
flag to select or deselect the fit to Time Spectra
Definition: T0CalibrationClassic.h:96
MuonCalib::T0ClassicSettings::T0ClassicSettings
T0ClassicSettings(double minAdc, double maxAdc, int adcBins, double minTime, double maxTime, int timeBins, bool fitTime, int minEntries, int initParam, int numParams, std::array< double, 8 > fitParams, double chiMax, int printLevel)
constructor
Definition: T0CalibrationClassic.h:33
MuonCalib::T0CalibrationClassic::m_result
std::unique_ptr< MdtTubeFitContainer > m_result
tube constants
Definition: T0CalibrationClassic.h:153
MuonCalib::T0ClassicSettings::m_initParamFlag
int m_initParamFlag
fix or search initial parameters for spectrum fit
Definition: T0CalibrationClassic.h:98
MuonCalib::T0ClassicSettings::m_chi2max
double m_chi2max
normalized chi2 cut
Definition: T0CalibrationClassic.h:101
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MuonCalib::T0CalibrationClassic::m_file
std::unique_ptr< TFile > m_file
pointer to the histogram file
Definition: T0CalibrationClassic.h:149
MuonCalib::MdtTubeFitContainer::SingleTubeFit
Definition: MdtTubeFitContainer.h:18
MuonCalib::T0CalibrationClassic::m_name
std::string m_name
calibration region name
Definition: T0CalibrationClassic.h:147
MuonCalib::T0ClassicSettings::m_entries
int m_entries
minimum number of entries per spectrum fitting
Definition: T0CalibrationClassic.h:97
MuonCalib::T0CalibrationClassic::setInput
void setInput(const IMdtCalibrationOutput *input) override
unused
Definition: T0CalibrationClassic.cxx:640
MuonCalib::T0CalibrationClassic::getResults
virtual MdtCalibOutputPtr getResults() const override
Definition: T0CalibrationClassic.cxx:526
MuonCalib::IMdtCalibration
Definition: IMdtCalibration.h:25
MuonCalib::MuonCalibSegment
Definition: MuonCalibSegment.h:39
MdtTubeFitContainer.h
MuonCalib::T0ClassicSettings::binAdc
int binAdc() const
Definition: T0CalibrationClassic.h:54
MuonCalib::T0CalibrationClassic::m_regiondir
TDirectory * m_regiondir
pointer to the ROOT directory
Definition: T0CalibrationClassic.h:150
PlotPulseshapeFromCool.np
np
Definition: PlotPulseshapeFromCool.py:64
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MuonCalib::T0ClassicSettings::maxAdc
double maxAdc() const
Definition: T0CalibrationClassic.h:52
MuonCalib::T0CalibrationClassic::m_delete_settings
bool m_delete_settings
Definition: T0CalibrationClassic.h:154
MuonCalib::T0ClassicSettings::printLevel
int printLevel() const
Definition: T0CalibrationClassic.h:75
MuonCalib::T0ClassicHistos
Definition: T0CalibrationClassic.h:108
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MuonCalib::T0CalibrationClassic::handleSegment
bool handleSegment(MuonCalibSegment &seg)
fill tube spectra
Definition: T0CalibrationClassic.cxx:62
MuonCalib::T0ClassicHistos::time
std::unique_ptr< TH1 > time
time spectrum
Definition: T0CalibrationClassic.h:110
lumiFormat.i
int i
Definition: lumiFormat.py:85
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
MuonCalib::T0CalibrationClassic::T0CalibrationClassic
T0CalibrationClassic(const std::string &name, const T0ClassicSettings *settings)
constructor
Definition: T0CalibrationClassic.cxx:30
MuonCalib::T0ClassicSettings::entries
int entries() const
Definition: T0CalibrationClassic.h:64
MuonCalib::T0CalibrationClassic::T0CalibrationClassic
T0CalibrationClassic(const T0CalibrationClassic &)=delete
MuonCalib
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
Definition: CscCalcPed.cxx:22
MuonCalib::T0ClassicSettings::print
void print() const
a method to dump all the settings
Definition: T0CalibrationClassic.h:77
MuonCalib::T0ClassicSettings::minTime
double minTime() const
Definition: T0CalibrationClassic.h:56
MuonCalib::T0CalibrationClassic::m_settings
const T0ClassicSettings * m_settings
pointer to the settings
Definition: T0CalibrationClassic.h:145
MuonCalib::T0ClassicSettings::m_minTime
double m_minTime
Time spectrum low edge.
Definition: T0CalibrationClassic.h:93
MuonCalib::T0CalibrationClassic::converged
bool converged() const
return m_converged (always false?)
Definition: T0CalibrationClassic.cxx:654
MuonCalib::T0ClassicSettings::m_maxAdc
double m_maxAdc
Adc spectrum high edge.
Definition: T0CalibrationClassic.h:91
MuonCalib::T0ClassicSettings::initParamFlag
int initParamFlag() const
Definition: T0CalibrationClassic.h:67
MuonCalib::T0CalibrationClassic::m_converged
bool m_converged
convergence status
Definition: T0CalibrationClassic.h:146
MuonCalib::IMdtCalibration::name
virtual std::string name() const
returns name (region) of instance
Definition: IMdtCalibration.h:49
MuonCalib::T0ClassicSettings::m_numParams
int m_numParams
number of paramaters for spectrum fit
Definition: T0CalibrationClassic.h:99
MuonCalib::T0ClassicSettings::params
const std::array< double, 8 > & params() const
Definition: T0CalibrationClassic.h:71
IMdtCalibration.h
MuonCalib::T0CalibrationClassic::operator=
T0CalibrationClassic & operator=(const T0CalibrationClassic &right)=delete
MuonCalib::IMdtCalibrationOutput
Definition: IMdtCalibrationOutput.h:28
MuonCalib::T0ClassicSettings::m_minAdc
double m_minAdc
Private settings.
Definition: T0CalibrationClassic.h:86
MuonCalib::T0ClassicSettings::maxTime
double maxTime() const
Definition: T0CalibrationClassic.h:58
MuonCalib::T0ClassicSettings::m_params
std::array< double, 8 > m_params
initial parameters for spectrum fit
Definition: T0CalibrationClassic.h:100
h
MdtTubeFullInfoContainer.h
MuonCalib::T0ClassicSettings::chi2max
double chi2max() const
Definition: T0CalibrationClassic.h:73
MuonCalib::T0ClassicSettings::m_printLevel
int m_printLevel
output level flag (1 for verbose)
Definition: T0CalibrationClassic.h:102
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonCalib::T0ClassicSettings
Definition: T0CalibrationClassic.h:30
MuonCalib::T0CalibrationClassic::getHistos
T0ClassicHistos * getHistos(unsigned int idtube)
retrieve pointer for tube idtube histograms
Definition: T0CalibrationClassic.cxx:530
MuonCalib::T0CalibrationClassic::doTimeFit
void doTimeFit(T0ClassicHistos &, MdtTubeFitContainer::SingleTubeFit &, MdtTubeFitContainer::SingleTubeCalib &)
fit time spectrum
Definition: T0CalibrationClassic.cxx:159
MuonCalib::MdtTubeCalibContainer::SingleTubeCalib
Definition: MdtTubeCalibContainer.h:18
MuonCalib::IMdtCalibration::MuonSegVec
std::vector< std::shared_ptr< MuonCalibSegment > > MuonSegVec
Definition: IMdtCalibration.h:27
MuonCalib::T0ClassicSettings::binTime
int binTime() const
Definition: T0CalibrationClassic.h:60
MuonCalib::T0ClassicSettings::m_maxTime
double m_maxTime
Time spectrum high edge.
Definition: T0CalibrationClassic.h:94
MuonCalib::T0ClassicSettings::fitTime
bool fitTime() const
Definition: T0CalibrationClassic.h:62
MuonCalib::T0ClassicSettings::m_binTime
int m_binTime
Time spectrum number of bins.
Definition: T0CalibrationClassic.h:95
MuonCalib::T0CalibrationClassic::analyse
bool analyse()
extract parameters from spectra
Definition: T0CalibrationClassic.cxx:119
MuonCalib::T0ClassicHistos::adc
std::unique_ptr< TH1 > adc
adc spectrum
Definition: T0CalibrationClassic.h:111
MuonCalib::T0CalibrationClassic::m_histos
std::vector< std::unique_ptr< T0ClassicHistos > > m_histos
vector of pointers to tube histograms
Definition: T0CalibrationClassic.h:152
MuonCalib::T0CalibrationClassic::~T0CalibrationClassic
~T0CalibrationClassic()
destructor
Definition: T0CalibrationClassic.cxx:56
MuonCalib::T0CalibrationClassic::searchParams
void searchParams(TH1 *h, double *p, int np)
estimate initial parameters for time spectrum fit from the spectrum itself
Definition: T0CalibrationClassic.cxx:433
MuonCalib::T0CalibrationClassic::analyseSegments
virtual MdtCalibOutputPtr analyseSegments(const MuonSegVec &segs) override
new interface function
Definition: T0CalibrationClassic.cxx:153
MuonCalib::T0ClassicSettings::minAdc
double minAdc() const
Access functions to values of private settings.
Definition: T0CalibrationClassic.h:50
MuonCalib::T0ClassicSettings::m_binAdc
int m_binAdc
Adc spectrum number of bins.
Definition: T0CalibrationClassic.h:92
MuonCalib::T0ClassicHistos::id
int id
tube identifier
Definition: T0CalibrationClassic.h:113
MuonCalib::T0CalibrationClassic::doAdcFit
void doAdcFit(T0ClassicHistos &, MdtTubeFitContainer::SingleTubeFit &, MdtTubeFitContainer::SingleTubeCalib &)
fit adc spectrum
Definition: T0CalibrationClassic.cxx:327