AmpGen 2.1
Loading...
Searching...
No Matches
Projection.h
Go to the documentation of this file.
1#ifndef AMPGEN_PROJECTION_H
2#define AMPGEN_PROJECTION_H
3
4#include <stddef.h>
5#include <functional>
6#include <string>
7#include <utility>
8
9#include <TH1D.h>
10#include <TH2D.h>
11#include <THStack.h>
12
13#include "AmpGen/ArgumentPack.h"
14#include "AmpGen/Types.h"
16
17namespace AmpGen
18{
19 class Projection2D;
20 class Event;
21 class EventList;
22
24 {
25 using keyedFunctors = KeyedFunctors<double(Event)>;
26 public:
28 template <class FCN>
29 Projection( const FCN& fcn, const std::string& name,
30 const std::string& xAxisTitle, const size_t& nBins, const double& min, const double& max,
31 const std::string& units = "" ) : Projection( std::function< double( const Event& )>( fcn ), name, xAxisTitle, nBins, min, max, units ) {}
32 Projection( const std::function<double( const Event& )>& fcn, const std::string& name,
33 const std::string& xAxisTitle, const size_t& nBins, const double& min, const double& max,
34 const std::string& units = "" );
35 const std::string name() const;
36 template <class eventlist_type, class... ARGS> TH1D* operator()(const eventlist_type& evts, const ARGS... args) const
37 {
38 return projInternal(evts, ArgumentPack(args...) );
39 }
40 template <class eventlist_type, class... ARGS> std::tuple<std::vector<TH1D*>, THStack*> operator()(const eventlist_type& evts,
41 const keyedFunctors& weightFunction, const ARGS... args ) const
42 {
43 return projInternal(evts, weightFunction, ArgumentPack(args...) );
44 }
45
46 double operator()( const Event& evt ) const;
47
48 TH1D* plot(const std::string& prefix="") const;
49
50 std::function<int( const Event& evt )> binFunctor() const;
51 void setRange( const double& min, const double& max )
52 {
53 m_min = min;
54 m_max = max;
55 m_width = (m_max-m_min)/double(m_nBins);
56 }
57
58 friend class Projection2D;
60 template <class eventlist_type>
61 TH1D* projInternal(const eventlist_type&, const ArgumentPack&) const;
62 template <class eventlist_type>
63 std::tuple<std::vector<TH1D*>, THStack*> projInternal(const eventlist_type&, const keyedFunctors&, const ArgumentPack&) const;
64 std::function<double( const Event& )> m_func;
65 std::string m_name = {""};
66 std::string m_xAxisTitle = {""};
67 std::string m_units = {""};
68 size_t m_nBins = {0};
69 double m_min = {0};
70 double m_max = {0};
71 double m_width = {0};
72 };
73
75 {
76 friend class Projection;
77 Projection xAxis;
78 Projection yAxis;
79 template <typename eventlist_type> TH2D* projInternal(const eventlist_type&, const ArgumentPack&) const;
80
81 public:
82 Projection2D( const Projection& _xAxis, const Projection& _yAxis ) : xAxis( _xAxis ), yAxis( _yAxis ) {}
83
84 TH2D* plot(const std::string& prefix="") const;
85 template <class eventlist_type, class... ARGS> TH2D* operator()(const eventlist_type& evts, const ARGS... args) const
86 {
87 return projInternal(evts, ArgumentPack(args...) );
88 }
89
90 std::pair<double, double> operator()( const Event& evt ) const;
91 };
92 namespace PlotOptions {
93 DECLARE_ARGUMENT(LineColor , int);
94 DECLARE_ARGUMENT(DrawStyle , std::string);
95 DECLARE_ARGUMENT(Selection , std::function<bool( const Event& )>);
96 DECLARE_ARGUMENT(Prefix , std::string);
98 DECLARE_ARGUMENT(AddTo , THStack*);
99 DECLARE_ARGUMENT(AutoWrite , bool);
100 }
101} // namespace AmpGen
102
103#endif
#define DECLARE_ARGUMENT(X, Y)
Container for a set of arguments Contains a set of arguments packed from a variadic constructor,...
Encapsulates the final state particles of a single event.
Definition Event.h:18
Unary expression that returns .
Definition Expression.h:393
Projection2D(const Projection &_xAxis, const Projection &_yAxis)
Definition Projection.h:82
TH2D * plot(const std::string &prefix="") const
std::pair< double, double > operator()(const Event &evt) const
friend class Projection
Definition Projection.h:76
TH2D * operator()(const eventlist_type &evts, const ARGS... args) const
Definition Projection.h:85
Projection(const std::function< double(const Event &)> &fcn, const std::string &name, const std::string &xAxisTitle, const size_t &nBins, const double &min, const double &max, const std::string &units="")
std::tuple< std::vector< TH1D * >, THStack * > operator()(const eventlist_type &evts, const keyedFunctors &weightFunction, const ARGS... args) const
Definition Projection.h:40
std::string m_xAxisTitle
Definition Projection.h:66
void setRange(const double &min, const double &max)
Definition Projection.h:51
std::string m_units
Definition Projection.h:67
std::function< double(const Event &)> m_func
Definition Projection.h:64
std::function< int(const Event &evt)> binFunctor() const
TH1D * operator()(const eventlist_type &evts, const ARGS... args) const
Definition Projection.h:36
Projection(const FCN &fcn, const std::string &name, const std::string &xAxisTitle, const size_t &nBins, const double &min, const double &max, const std::string &units="")
Definition Projection.h:29
friend class Projection2D
Definition Projection.h:58
const std::string name() const
TH1D * projInternal(const eventlist_type &, const ArgumentPack &) const
private:
TH1D * plot(const std::string &prefix="") const
std::string m_name
Definition Projection.h:65
std::tuple< std::vector< TH1D * >, THStack * > projInternal(const eventlist_type &, const keyedFunctors &, const ArgumentPack &) const
double operator()(const Event &evt) const