BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
EventAnalysis.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 EVENTANALYSIS_H
19#define EVENTANALYSIS_H
20
21#include <vector>
22
23#include "Analysis.hh"
24
25#include "Rtypes.h" // for classdef
26
27class Event;
28class HistogramDefSet;
30class SamplerAnalysis;
31class TChain;
32class TFile;
33
41{
42public:
47
49 EventAnalysis(Event* eventIn,
50 TChain* chain,
51 bool perEntryAnalysis = true,
52 bool processSamplersIn = true,
53 bool debugIn = false,
54 bool printOutIn = true,
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
106 Event* eventIn,
107 TChain* chainIn) const;
108
109 bool printOut;
113 long int eventStart;
114 long int eventEnd;
116
119
122
123 ClassDef(EventAnalysis,2);
124};
125
126#endif
Base class for any TTree analysis.
Definition Analysis.hh:43
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.
bool printOut
Whether to print out at all per-event.
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.
PerEntryHistogramSet * ConstructPerEntryHistogramSet(const HistogramDefSet *definitionIn, Event *eventIn, TChain *chainIn) const
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.
long int nEventsToProcess
Difference between start and stop.
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:49
Specification for a set of histograms.
Histogram over a set of integers not number line.
Analysis routines for an individual sampler.
STL namespace.