MaCh3  2.2.3
Reference Guide
Functions
FitterBase.cpp File Reference
#include "FitterBase.h"
#include "Samples/SampleHandlerFD.h"
#include "TRandom.h"
#include "TStopwatch.h"
#include "TTree.h"
#include "TGraphAsymmErrors.h"
Include dependency graph for FitterBase.cpp:

Go to the source code of this file.

Functions

void WriteHistograms (TH1 *hist, const std::string &baseName)
 Helper to write histograms. More...
 
void WriteHistogramsByMode (SampleHandlerFD *sample, const std::string &suffix, const bool by_mode, const bool by_channel, const std::vector< TDirectory * > &SampleDir)
 Generic histogram writer - should make main code more palatable. More...
 

Function Documentation

◆ WriteHistograms()

void WriteHistograms ( TH1 *  hist,
const std::string &  baseName 
)

Helper to write histograms.

Definition at line 1348 of file FitterBase.cpp.

1348  {
1349 // *************************
1350  if (!hist) return;
1351  hist->SetTitle(baseName.c_str());
1352  hist->GetYaxis()->SetTitle("Events");
1353  hist->SetDirectory(nullptr);
1354  hist->Write(baseName.c_str());
1355 }

◆ WriteHistogramsByMode()

void WriteHistogramsByMode ( SampleHandlerFD sample,
const std::string &  suffix,
const bool  by_mode,
const bool  by_channel,
const std::vector< TDirectory * > &  SampleDir 
)

Generic histogram writer - should make main code more palatable.

Definition at line 1359 of file FitterBase.cpp.

1363  {
1364 // *************************
1365  MaCh3Modes *modes = sample->GetMaCh3Modes();
1366  for (int subSampleIndex = 0; subSampleIndex < sample->GetNsamples(); ++subSampleIndex) {
1367  SampleDir[subSampleIndex]->cd();
1368  std::string sampleName = sample->GetTitle();
1369  // Probably a better way of handling this logic
1370  if (by_mode) {
1371  for (int iMode = 0; iMode < modes->GetNModes(); ++iMode) {
1372  auto modeHist = sample->Get1DVarHistByModeAndChannel(sample->GetXBinVarName(), iMode);
1373  WriteHistograms(modeHist, sampleName + "_" + modes->GetMaCh3ModeName(iMode) + suffix);
1374  delete modeHist;
1375  }
1376  }
1377 
1378  if (by_channel) {
1379  for (int iChan = 0; iChan < sample->GetNOscChannels(); ++iChan) {
1380  auto chanHist = sample->Get1DVarHistByModeAndChannel(sample->GetXBinVarName(), -1, iChan); // -1 skips over mode plotting
1381  WriteHistograms(chanHist, sampleName + "_" + sample->GetFlavourName(iChan) + suffix);
1382  delete chanHist;
1383  }
1384  }
1385 
1386  if (by_mode && by_channel) {
1387  for (int iMode = 0; iMode < modes->GetNModes(); ++iMode) {
1388  for (int iChan = 0; iChan < sample->GetNOscChannels(); ++iChan) {
1389  auto hist = sample->Get1DVarHistByModeAndChannel(sample->GetXBinVarName(), iMode, iChan);
1390  WriteHistograms(hist, sampleName + "_" + modes->GetMaCh3ModeName(iMode) + "_" + sample->GetFlavourName(iChan) + suffix);
1391  delete hist;
1392  }
1393  }
1394  }
1395 
1396  if (!by_mode && !by_channel) {
1397  auto hist = sample->Get1DVarHistByModeAndChannel(sample->GetXBinVarName());
1398  WriteHistograms(hist, sampleName + suffix);
1399  delete hist;
1400  }
1401  }
1402 }
void WriteHistograms(TH1 *hist, const std::string &baseName)
Helper to write histograms.
KS: Class describing MaCh3 modes used in the analysis, it is being initialised from config.
Definition: MaCh3Modes.h:41
int GetNModes() const
KS: Get number of modes, keep in mind actual number is +1 greater due to unknown category.
Definition: MaCh3Modes.h:54
std::string GetMaCh3ModeName(const int Index) const
KS: Get normal name of mode, if mode not known you will get UNKNOWN_BAD.
Definition: MaCh3Modes.cpp:156
std::string GetXBinVarName() const
MaCh3Modes * GetMaCh3Modes() const
Return pointer to MaCh3 modes.
std::string GetTitle() const override
std::string GetFlavourName(const int iChannel)
int GetNOscChannels() override
TH1 * Get1DVarHistByModeAndChannel(const std::string &ProjectionVar_Str, int kModeToFill=-1, int kChannelToFill=-1, int WeightStyle=0, TAxis *Axis=nullptr)
virtual M3::int_t GetNsamples()