AttenHists.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 /// \brief Histograms used by attenuation calibration
3 /// \author Christopher Backhouse - bckhouse@caltech.edu
4 /// \date Apr 2013
5 ///////////////////////////////////////////////////////////////////////////
6 #ifndef CALDP_ATTENHISTS_H
7 #define CALDP_ATTENHISTS_H
8 
9 #include "TH2.h"
10 
12 
13 #include <map>
14 
15 namespace caldp
16 {
17  typedef enum _path_type{
24  } PathType_t;
25 
26  /// Histograms used by attenuation calibration
27  class AttenHists
28  {
29  public:
31  : WPE(nullptr)
32  , WPE_corr(nullptr)
33  , WPE_corr_xy(nullptr)
34  , WPE_corr_z(nullptr)
35  , WPE_corr_traj(nullptr)
36  , WPE_corr_xy_truth(nullptr)
37  {}
38 
39 #ifndef __GCCXML__
41  {
42  Add(WPE, rhs.WPE);
43  Add(WPE_corr, rhs.WPE_corr);
48 
49  return *this;
50  }
51 
53  {
54  switch (pt){
55  case kCalXY: return WPE_corr_xy;
56  case kCalAvg: return WPE_corr;
57  case kCalXYTruth: return WPE_corr_xy_truth;
58  case kCalZ: return WPE_corr_z;
59  case kCalTraj: return WPE_corr_traj;
60  default: return WPE;
61  }
62  return WPE_corr;
63  }
64 
65 #endif
66 
68 
69  protected:
70  void Add(TH2F*& lhs, TH2F* rhs)
71  {
72  if(lhs) lhs->Add(rhs); else lhs = new TH2F(*rhs);
73  }
74  };
75 
76  /// AttenHists for many channels
78  {
79  public:
80 #ifndef __GCCXML__
82  {
83  return fMap[c];
84  }
85 
87  {
88  return fMap[geo::OfflineChan(plane, cell)];
89  }
90 
91  /// Intended for writing out/drawing all the histograms
92  std::map<int, std::vector<TH2F*>> GetAllHistsByPlane()
93  {
94  std::map<int, std::vector<TH2F*>> ret;
95  for(auto& it: fMap){
96  const int plane = it.first.Plane();
97  const AttenHists& hs = it.second;
98 
99  ret[plane].push_back(hs.WPE);
100  ret[plane].push_back(hs.WPE_corr);
101  ret[plane].push_back(hs.WPE_corr_xy);
102  ret[plane].push_back(hs.WPE_corr_z);
103  ret[plane].push_back(hs.WPE_corr_traj);
104  ret[plane].push_back(hs.WPE_corr_xy_truth);
105  }
106  return ret;
107  }
108 
110  {
111  for(auto& it: rhs.fMap) fMap[it.first] += it.second;
112  return *this;
113  }
114 
115  void Clear()
116  {
117  fMap.clear();
118  }
119 #endif
120  protected:
121  std::map<geo::OfflineChan, AttenHists> fMap;
122  };
123 }
124 
125 #endif
AttenHists & GetHists(int plane, int cell)
Definition: AttenHists.h:86
std::map< int, std::vector< TH2F * > > GetAllHistsByPlane()
Intended for writing out/drawing all the histograms.
Definition: AttenHists.h:92
set< int >::iterator it
TH2F * WPE_corr_xy_truth
Definition: AttenHists.h:67
void Add(TH2F *&lhs, TH2F *rhs)
Definition: AttenHists.h:70
std::map< geo::OfflineChan, AttenHists > fMap
Definition: AttenHists.h:121
enum caldp::_path_type PathType_t
AttenHists & GetHists(const geo::OfflineChan &c)
Definition: AttenHists.h:81
Histograms used by attenuation calibration.
Definition: AttenHists.h:27
TH2F * HistogramByPathType(caldp::PathType_t const &pt)
Definition: AttenHists.h:52
_path_type
Definition: AttenHists.h:17
AttenHists for many channels.
Definition: AttenHists.h:77
Histograms used by attenuation calibration.
AttenHistsMap & operator+=(const AttenHistsMap &rhs)
Definition: AttenHists.h:109
AttenHists & operator+=(const AttenHists &rhs)
Definition: AttenHists.h:40
A (plane, cell) pair.
Definition: OfflineChan.h:17
TH2F * WPE_corr_traj
Definition: AttenHists.h:67
Simple object representing a (plane, cell) pair.
TH2F * WPE_corr_xy
Definition: AttenHists.h:67