|
ATLAS Offline Software
|
Go to the documentation of this file.
11 #include "GaudiKernel/MsgStream.h"
14 #include "TDirectory.h"
18 #include "boost/thread/tss.hpp"
25 TRandom3* random = rnd.get();
27 random =
new TRandom3();
36 const Double_t &
t(
x[0]);
40 return (back + A / (1 +
std::exp(-(
t - t_0) / T)));
69 snprintf(buf, 100,
"t_spec_%d",
id);
71 snprintf(buf, 100,
"t_spec_%s",
hname);
82 snprintf(buf, 100,
"t0_tmax_dir_%d",
id);
105 snprintf(
buffer, 100,
"t0_tmax_dir_%d",
id);
115 if (
m_time->GetEntries() < 1000) {
120 if (
m_time->GetEntries() < 10000) {
147 log << MSG::WARNING <<
"T0MTHistos::FitTmax: Class is not initialized!" <<
endmsg;
155 log << MSG::WARNING <<
"T0MTHistos::FitTmax for tube " <<
m_id <<
": No valid t0-value!" <<
endmsg;
165 log << MSG::WARNING <<
"T0MTHistos::FitTmax for tube " <<
m_id <<
": Pattern recognition failed!" <<
endmsg;
172 snprintf(
buffer, 100,
"mt_tmax_fermi");
191 if (
m_dir !=
nullptr) {
196 std::string fitopt(
"LR");
224 log << MSG::WARNING <<
"T0MTHistos::FitT0: Class is not initialized!" <<
endmsg;
238 log << MSG::WARNING <<
"T0MTHistos::FitT0 for tube " <<
m_id <<
": Pattern recognition failed!" <<
endmsg;
247 snprintf(
buffer, 100,
"mt_t0_fermi");
262 if (
m_dir !=
nullptr) {
264 ln->Write(
"t0_range_min");
266 ln->Write(
"t0_range_max");
271 std::string fitopt(
"BLR");
282 m_chi2 =
m_time->GetFunction(
"mt_t0_fermi")->GetChisquare() /
m_time->GetFunction(
"mt_t0_fermi")->GetNDF();
297 std::string fitopt(
"BLR");
305 char scramhistname[100];
306 snprintf(scramhistname, 100,
"%s_scram",
m_time->GetName());
307 std::unique_ptr<TH1F> scramhist = std::make_unique<TH1F>(scramhistname,
"scrambled histogram",
m_time->GetSize() - 2,
308 m_time->GetXaxis()->GetXmin(),
m_time->GetXaxis()->GetXmax());
310 for (
int binnr = 0; binnr <
m_time->GetSize(); binnr++) {
312 scramhist->SetBinError(binnr,
m_time->GetBinError(binnr) * 1.41421356);
323 log << MSG::WARNING <<
"T0MTHistos::FitT0 for tube " <<
m_id <<
": Scrambed pattern recognition failed!" <<
endmsg;
327 char scrambuffer[100];
328 snprintf(scrambuffer, 100,
"scrammt_t0_fermi");
329 std::unique_ptr<TF1> scramm_t0_fermi = std::make_unique<TF1>();
331 scramm_t0_fermi->SetName(scrambuffer);
348 m_time->GetListOfFunctions()->Clear();
356 m_time->GetListOfFunctions()->Clear();
361 m_chi2 =
m_time->GetFunction(
"mt_t0_fermi")->GetChisquare() /
m_time->GetFunction(
"mt_t0_fermi")->GetNDF();
370 TF1 *t0_fermi =
m_time->GetFunction(
"mt_t0_fermi");
372 t0_fermi->GetRange(
min,
max);
375 for (
int bin = startbin;
bin < endbin;
bin++) {
376 float measval =
m_time->GetBinContent(
bin);
377 float funcval = t0_fermi->Eval(
m_time->GetBinCenter(
bin));
380 if (measval < 10 && funcval < 10 &&
384 m_chi2 += (measval - funcval) * (measval - funcval);
386 m_chi2 += (measval - funcval) * (measval - funcval) / (errval * errval);
398 std::list<Slice> slice_chi2;
402 TF1 *t0_fermi =
m_time->GetFunction(
"mt_t0_fermi");
405 t0_fermi->GetRange(
min,
max);
421 double measval =
m_time->GetBinContent(
bin);
422 double funcval = t0_fermi->Eval(
m_time->GetBinCenter(
bin));
423 double errval =
m_time->GetBinError(
bin);
436 if (
it == slice_chi2.begin()) {
442 }
while (
it->chi_2 /
static_cast<double>(
it->n_bins) > 3);
444 m_time->GetListOfFunctions()->Clear();
445 std::string fitopt(
"BLR");
452 m_time->Fit(
"mt_t0_fermi", fitopt.c_str(),
"",
min,
max);
456 m_chi2 =
m_time->GetFunction(
"mt_t0_fermi")->GetChisquare() /
m_time->GetFunction(
"mt_t0_fermi")->GetNDF();
JetConstituentVector::iterator iterator
const double & ScrambleThreshold() const
the chi2 threshold at which the scrambling method is used
void FillT(double t)
fill drift time spectrum
double GetFitRangeMin() const
get fit range
std::unique_ptr< TF1 > m_t0_fermi
function fitted to the riding edghe of the spectrum
double GetBinContent(int) const
TDirectory * m_dir
TDirectory where debug and result histograms are stored.
singleton-like access to IMessageSvc via open function and helper
void TopChi2()
top chi2 calculation
double GetBackground() const
get the background level
static constexpr int N_T0_FIT_PAR
number of parameters in t0 fit
Double_t mt_t0_fermi(Double_t *x, Double_t *par)
The fermi function to be fitted at the rising edge of the spectrum.
const bool & UseTopChi2() const
If true use only the top part of the function for the chi2 calculation.
Int_t FindBin(const TAxis *axis, const double x)
TRandom3 * getTLSRandomGen()
const int & NBinsTime() const
Number of bins for time histogram and range.
double GetEstimatedT0() const
get estimated t0
double m_chi2
chi2/NDF value
const T0MTSettingsT0 * T0Settings() const
get settings for the t0-fit
double GetHeight() const
get height
const double & SlicingThreshold() const
the chi2 threshold at which the slicing method is used
IMessageSvc * getMessageSvc(bool quiet=false)
static constexpr int T0_PAR_NR_T
std::unique_ptr< TF1 > m_tmax_fermi
function fitted to the falling edge of the spectrum
bool FitTmax()
Performs tmax-fit Returns true if fit is successfull.
double GetBackground() const
get the background level
static constexpr int T0_PAR_NR_BACK
int m_status_code
status code for t0 fit (0 ok, 1 not fitted, 2 low statistics, 3 failed)
void SetTSpec(int id, TH1F *spec, const T0MTSettings *settings, bool copy_spec=true)
set the pointer of the drift-time spectrum to an existing spectrum.
const int & VerboseLevel() const
verbose level 0: no output 1: Fitter output
double GetFitRangeMin() const
get fit range
const double & TimeMin() const
bool m_t0_ok
is true if t0 fit was successful
static constexpr int TMAX_PAR_NR_A
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
void Initialize(int id, const T0MTSettings *settings, const char *hname=nullptr)
Initialize class.
void SetBinContent(int, double)
static constexpr int TMAX_PAR_NR_B
static constexpr int TMAX_PAR_NR_T0
double GetFitRangeMax() const
get fit range
static constexpr int T0_PAR_NR_T0
parameter numbers in t0 fit
double GetA() const
get parameter a in exp-function representing the end of the spectrum
const T0MTSettings * m_settings
Pointer to settings class.
bool Initialize(TH1F *hist, const T0MTSettings *settings)
Initialize class - returns true if pattern recognition was successfull.
bool T0Scramble()
try to get better start values from a scrambled histogram
bool FitT0()
Perform t0-fit Returns true if fit is successfull.
double m_tmax_ok
is true if tmax fit was successful
std::unique_ptr< TH1F > m_time
time spectrum
const bool & AddFitfun() const
If set to true the fitted functions are added to the histograms.
static constexpr int T0_PAR_NR_A
static constexpr int TMAX_PAR_NR_T
const double & TimeMax() const
static constexpr int N_TMAX_FIT_PAR
number of parameters for tmax fit
Double_t mt_tmax_fermi(Double_t *x, Double_t *par)
The fermi function to be fitted at the trailing slope of the spectrum.
bool Initialize(TH1F *hist, double t0, const T0MTSettings *settings)
Initialize class.
static constexpr int TMAX_PAR_NR_TMAX
parameters numbers for tmax fit
void TopSlicing()
top slicing metyhod
const bool & DrawDebugGraphs() const
If set to true for every tube a TDirectory will be created.
double GetEstimatedTMax() const
get estimated t0
static constexpr int TMAX_PAR_NR_BACK
#define ATLAS_THREAD_SAFE
Define macros for attributes used to control the static checker.
double GetFitRangeMax() const
get fit range
double GetB() const
get parameter a in exp-function representing the end of the spectrum
bool NormalFit()
normal t0 fit