BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Analysis.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef ANALYSIS_H
19#define ANALYSIS_H
20
21#include "TH1D.h"
22#include "TH2D.h"
23#include "TH3D.h"
24#include "BDSBH4DBase.hh"
25
26#include <map>
27#include <string>
28#include <vector>
29
30class HistogramDef;
33class TChain;
34class TFile;
35
43{
44public:
49 Analysis(const std::string& treeNameIn,
50 TChain* chainIn,
51 const std::string& mergedHistogramNameIn,
52 bool perEntryAnalysis = true,
53 bool debugIn = false);
54 virtual ~Analysis();
55
57 virtual void Execute();
58
62 virtual void Process() = 0;
63
65 virtual void UserProcess();
66
68 virtual void SimpleHistograms();
69
72
74 void AccumulatePerEntryHistograms(long int entryNumber);
75
78
81 virtual void Terminate();
82
84 virtual void Write(TFile* outputFile);
85
86protected:
88 void FillHistogram(HistogramDef* definition,
89 std::vector<TH1*>* outputHistograms = nullptr);
90
91 std::string treeName;
92 TChain* chain;
93 std::string mergedHistogramName;
94 std::vector<TH1*> simpleHistograms;
95 std::vector<PerEntryHistogram*> perEntryHistograms;
97 bool debug;
98 long int entries;
99 bool perEntry;
100
101private:
103 Analysis() = delete;
104};
105
106#endif
Base class for any TTree analysis.
Definition Analysis.hh:43
virtual void Execute()
Method which calls all other methods in order.
Definition Analysis.cc:63
virtual void Terminate()
Definition Analysis.cc:122
virtual void SimpleHistograms()
Process histogram definitions from configuration instance.
Definition Analysis.cc:85
void PreparePerEntryHistograms()
Create structures necessary for per entry histograms.
Definition Analysis.cc:99
long int entries
Number of entries in the chain.
Definition Analysis.hh:98
bool debug
Whether debug print out is used or not.
Definition Analysis.hh:97
HistogramMeanFromFile * histoSum
Merge of per event stored histograms.
Definition Analysis.hh:96
void AccumulatePerEntryHistograms(long int entryNumber)
Accumulate means and variances for per entry histograms.
Definition Analysis.cc:110
virtual void Write(TFile *outputFile)
Write rebdsim histograms.
Definition Analysis.cc:130
Analysis()=delete
No default constructor for this base class.
void TerminatePerEntryHistograms()
Prepare result of per entry histogram accumulation.
Definition Analysis.cc:116
std::string mergedHistogramName
Name of directory for merged histograms.
Definition Analysis.hh:93
virtual void UserProcess()
Virtual function for user to overload and use. Does nothing by default.
Definition Analysis.cc:82
bool perEntry
Whether to analyse each entry in the tree in a for loop or not.
Definition Analysis.hh:99
void FillHistogram(HistogramDef *definition, std::vector< TH1 * > *outputHistograms=nullptr)
Create an individual histogram based on a definition.
Definition Analysis.cc:165
virtual void Process()=0
Common specification for a histogram.
Accumulator to merge pre-made per-entry histograms.
Holder for information to calculate per entry histograms.