BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
EventAnalysis.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef EVENTANALYSIS_H
20#define EVENTANALYSIS_H
21
22#include <vector>
23
24#include "Analysis.hh"
25
26#include "Rtypes.h" // for classdef
27
28class Event;
29class HistogramDefSet;
31class SamplerAnalysis;
32class TChain;
33class TFile;
34
42{
43public:
48
50 EventAnalysis(Event* eventIn,
51 TChain* chain,
52 bool perEntryAnalysis = true,
53 bool processSamplersIn = true,
54 bool debugIn = false,
55 double printModuloFraction = 0.01,
56 bool emittanceOnTheFlyIn = false,
57 long int eventStartIn = 0,
58 long int eventEndIn = -1,
59 const std::string& primaryParticleName = "");
60
61 virtual ~EventAnalysis() noexcept;
62
65 virtual void Execute();
66
68 virtual void Process();
69
70 virtual void SimpleHistograms();
71
73 virtual void Terminate();
74
76 virtual void Write(TFile* outputFileName);
77
78protected:
81 std::vector<std::vector<std::vector<double> > > opticalFunctions;
82
83 void PreparePerEntryHistogramSets();
84 void AccumulatePerEntryHistogramSets(long int entryNumber);
85 void TerminatePerEntryHistogramSets();
86
87 void CheckSpectraBranches();
88
90 void FillHistogram(HistogramDefSet* definition);
91
92private:
94 void SetPrintModuloFraction(double fraction);
95
97 void Initialise();
98
100 void ProcessSamplers(bool firstTime = false);
101
105 long int eventStart;
106 long int eventEnd;
107
110
112 std::map<HistogramDefSet*, std::vector<TH1*> > simpleSetHistogramOutputs;
113
114 ClassDef(EventAnalysis,1);
115};
116
117#endif
Base class for any TTree analysis.
Definition: Analysis.hh:44
Event level analysis.
std::vector< PerEntryHistogramSet * > perEntryHistogramSets
Cache of all per entry histogram sets.
void FillHistogram(HistogramDefSet *definition)
Fill a set of simple histograms across all events.
void Initialise()
Initialise each sampler analysis object in samplerAnalysis.
Event * event
Event object that data loaded from the file will be loaded into.
bool processSamplers
Whether to process samplers.
long int eventEnd
Event index to end analysis at.
virtual void Process()
Operate on each entry in the event tree.
virtual void SimpleHistograms()
Process histogram definitions from configuration instance.
int printModulo
Cache of print modulo fraction.
std::vector< std::vector< std::vector< double > > > opticalFunctions
Optical functions from all samplers.
void ProcessSamplers(bool firstTime=false)
Process each sampler analysis object.
std::vector< SamplerAnalysis * > samplerAnalyses
Holder for sampler analysis objects.
virtual void Execute()
std::map< HistogramDefSet *, std::vector< TH1 * > > simpleSetHistogramOutputs
Map of simple histograms created per histogram set for writing out.
virtual void Write(TFile *outputFileName)
Write analysis including optical functions to an output file.
virtual void Terminate()
Terminate each individual sampler analysis and append optical functions.
bool emittanceOnTheFly
Whether to calculate emittance fresh at each sampler.
long int eventStart
Event index to start analysis from.
void SetPrintModuloFraction(double fraction)
Set how often to print out information about the event.
Event loader.
Definition: Event.hh:50
Specification for a set of histograms.
Histogram over a set of integers not number line.
Analysis routines for an individual sampler.