AttenProfiles.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_ATTENPROFILES_H
7 #define CALDP_ATTENPROFILES_H
8 #if defined G__DICTIONARY && ! defined ATTENPROFILES_DEFAULT_CONSTRUCTORS
9 #define ATTENPROFILES_DEFAULT_CONSTRUCTORS
10 #endif
11 
12 #include "TH2.h"
13 
16 
17 #include <cassert>
18 #include <cmath>
19 #include <map>
20 
21 namespace caldp
22 {
23  /// Lightweight TProfile equivalent
25  {
26  public:
27 
28  // No-one in Calibration wants default constructors, they just lead to
29  // things accidentally getting the wrong binning, much better to be
30  // explicit. But generating reflex dictionaries relies on them, so control
31  // them with this #define
33  : fMinW(-1)
34  , fMaxW(-1)
35  {}
36 
37 #ifndef __GCCXML__
38  LiteProfile(float w0, float w1);
39 
40  void Fill(float x, float y);
41  LiteProfile& operator+=(LiteProfile const& rhs);
42  TH1F* ToTH1F() const;
43  int TotalHits() const;
44  int TotalEntries() const;
45  std::vector<int> const& Count() const;
46  std::vector<float> const& Sum() const;
47  std::vector<float> const& SqSum() const;
48 
49 #endif
50  protected:
51  float fMinW, fMaxW;
52 
53  static const size_t kNumBins = 100;
54 
55  std::vector<int> fCount;
56  std::vector<float> fSum;
57  std::vector<float> fSqSum;
58  };
59 
60  /// Profiles used by attenuation calibration
62  {
63  public:
65 
66 #ifndef __GCCXML__
67  AttenProfiles(float minW, float maxW);
68 
70 
72  {
73  switch (pt){
74  case kCalXY: return WPE_corr_xy;
75  case kCalAvg: return WPE_corr;
76  case kCalXYTruth: return WPE_corr_xy_truth;
77  case kCalZ: return WPE_corr_z;
78  case kCalTraj: return WPE_corr_traj;
79  default: return WPE;
80  }
81  return WPE_corr;
82  }
83 #endif
84 
85  LiteProfile WPE, WPE_corr, WPE_corr_xy, WPE_corr_z, WPE_corr_traj, WPE_corr_xy_truth;
86  };
87 
88  /// AttenProfiles for many channels
90  {
91  public:
92 
93  AttenProfilesMap() : fMinW(-1), fMaxW(-1) {}
94 
95 #ifndef __GCCXML__
96  AttenProfilesMap(float w0, float w1);
97 
98  AttenProfilesMap(const AttenProfiles&) = delete; // uncopyable
99 
100  bool HasProfiles(const geo::OfflineChan& c) const;
101  bool HasProfiles(int plane, int cell) const;
102 
103  AttenProfiles & GetProfiles(const geo::OfflineChan& c);
104  AttenProfiles & GetProfiles(int plane, int cell);
105 
106  /// List of channels with profiles on
107  std::vector<geo::OfflineChan> Channels() const;
108 
109  /// Intended for writing out/drawing all the histograms
110  std::map<int, std::map<int, std::vector<TH1F*>>> GetAllProfilesByPlaneAndCell();
111 
113 
114  void Clear();
115 
116  double MinW() const {return fMinW;}
117  double MaxW() const {return fMaxW;}
118 #endif
119  protected:
120  float fMinW, fMaxW;
121 
122  std::map<geo::OfflineChan, AttenProfiles> fMap;
123  };
124 
125 }
126 
127 #endif
double MinW() const
int TotalEntries() const
TH1F * ToTH1F() const
std::vector< int > fCount
Definition: AttenProfiles.h:55
void Fill(float x, float y)
std::vector< int > const & Count() const
AttenProfiles for many channels.
Definition: AttenProfiles.h:89
int TotalHits() const
std::vector< float > const & Sum() const
enum caldp::_path_type PathType_t
LiteProfile & operator+=(LiteProfile const &rhs)
std::map< geo::OfflineChan, AttenProfiles > fMap
static const size_t kNumBins
Definition: AttenProfiles.h:53
std::vector< float > fSum
Definition: AttenProfiles.h:56
Profiles used by attenuation calibration.
Definition: AttenProfiles.h:61
Histograms used by attenuation calibration.
Lightweight TProfile equivalent.
Definition: AttenProfiles.h:24
std::vector< float > fSqSum
Definition: AttenProfiles.h:57
LiteProfile & LiteProfileByPathType(caldp::PathType_t const &pt)
Definition: AttenProfiles.h:71
LiteProfile WPE_corr_z
Definition: AttenProfiles.h:85
A (plane, cell) pair.
Definition: OfflineChan.h:17
Simple object representing a (plane, cell) pair.
std::vector< float > const & SqSum() const
double MaxW() const