All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Histograms.h
Go to the documentation of this file.
1 #ifndef __sbnanalysis_HISTOGRAM_HH
2 #define __sbnanalysis_HISTOGRAM_HH
3 
4 #include <vector>
5 #include <string>
6 #include <tuple>
7 
10 
12 
13 #include "../Histograms/HistoList.h"
14 #include "../Histograms/TrackHisto.h"
15 #include "../Histograms/Profile.h"
16 #include "../Histograms/InteractionHisto.h"
17 #include "../Histograms/CosmicHisto.h"
18 #include "../Histograms/CRTHisto.h"
19 #include "../Histograms/DynamicSelector.h"
20 
21 #include "Cuts.h"
22 
23 namespace ana {
24  namespace SBNOsc {
25 
26  // boilerplate to constexpr-append two arrays
27  template <typename T, std::size_t N1, std::size_t N2>
28  constexpr std::array<T, N1+N2> concat(std::array<T, N1> lhs, std::array<T, N2> rhs) {
29  std::array<T,N1+N2> result{};
30  size_t index = 0;
31  for (auto &el : lhs) {
32  result[index] = std::move(el);
33  index ++;
34  }
35  for (auto &el : rhs) {
36  result[index] = std::move(el);
37  index ++;
38  }
39  return result;
40  }
41  // std::array<const char *, Cuts::nTruthCuts+Cuts::nCuts> concat<const char *, Cuts::nTruthCuts, Cuts::nCuts>();
42 
43 /**
44  * Set of Track and Interaction histos for all modes/cuts/sub-types
45  */
46 struct Histograms : public HistoList {
47 
48  void Initialize(
50  const sbnd::CRTGeoAlg &crt_geo,
51  const Cuts &cuts,
52  const std::string &prefix,
53  const std::vector<std::string> &track_histo_types,
54  const std::vector<std::string> &track_profile_types,
55  const std::vector<std::tuple<unsigned, float, float>> &track_profile_xranges);
56 
57  /**
58  * Fill all of the histograms with an event
59  * \param event The reconstructed event information
60  * \param core The sbncode core event information
61  * \param cuts The configured Cuts classes
62  * \param fill_all_tracks Whether to fill all track histograms or just the primary track histograms
63  */
64  void Fill(
65  const numu::RecoEvent &event,
66  const event::Event &core,
67  const Cuts &cutmaker,
68  const std::vector<numu::TrackSelector> &selectors,
69  const std::vector<numu::TrackFunction> &xfunctions,
70  bool fill_all_tracks=true);
71 
72  /**
73  * Turn the InteractionMode enum into a string for (e.g.) histogram names.
74  *
75  * \param mode The interaction mode to be converted
76  * \return String representaiton of that mode
77  */
78  static std::string mode2Str(const numu::InteractionMode &mode) {
79  switch (mode) {
80  case numu::mCC: return "CC";
81  case numu::mCCNonPrimary: return "CC-Other";
82  case numu::mNC: return "NC";
83  case numu::mNCNonPrimary: return "NC-Other";
84  case numu::mCosmic: return "Cosmic";
85  case numu::mIntimeCosmic: return "IntimeCosmic";
86  case numu::mOther: return "Other";
87  case numu::mAll: return "All";
88  }
89  return "";
90  }
91  static const unsigned nHistos = Cuts::nCuts + Cuts::nTruthCuts;
92  static const unsigned nModes = 8; //!< number of interaction modes
93  static constexpr numu::InteractionMode allModes[nModes] =
97  numu::mOther, numu::mAll }; //!< List of all interaction modes
98 
99  // static constexpr const char* histoNames[nHistos] = {"Truth", "Reco", "R_track", "R_vmatch", "R_tmatch", "R_match", "R_contained"}; //!< List of all cut names
100 
101 
102  static constexpr std::array<const char *, nHistos> histoNames = concat(Cuts::truthCutNames, Cuts::cutNames); //!< Names of histograms
103 
104  InteractionHistos fInteraction[nHistos][nModes]; //!< all the interaction histograms
105  std::vector<TrackHistos> fAllTracks; //!< Track histograms for all tracks
106  std::vector<std::array<TrackHistos, Cuts::nCuts>> fPrimaryTracks; //!< Track histograms for priamry tracks in a candidate neutrino interaction
107  std::vector<std::vector<std::array<TrackProfiles, Cuts::nCuts>>> fPrimaryTrackProfiles; //!< Profile histograms for primary tracks
108  std::array<CosmicHistos, 4> fCosmic;
109 
110  std::array<CRTHistos, Cuts::nCuts> fCRTs;
111 
112 };
113 
114  } // namespace SBNOSc
115 } // namespace ana
116 
117 #endif
Definition: Mode.h:11
const geo::GeometryCore * geometry
static std::string mode2Str(const numu::InteractionMode &mode)
Definition: Histograms.h:78
std::vector< std::vector< std::array< TrackProfiles, Cuts::nCuts > > > fPrimaryTrackProfiles
Profile histograms for primary tracks.
Definition: Histograms.h:107
std::array< CosmicHistos, 4 > fCosmic
Definition: Histograms.h:108
std::array< CRTHistos, Cuts::nCuts > fCRTs
Definition: Histograms.h:110
InteractionHistos fInteraction[nHistos][nModes]
all the interaction histograms
Definition: Histograms.h:104
InteractionMode
Definition: Mode.h:8
static const unsigned nHistos
Definition: Histograms.h:91
process_name opflashCryoW ana
constexpr std::array< T, N1+N2 > concat(std::array< T, N1 > lhs, std::array< T, N2 > rhs)
Definition: Histograms.h:28
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
Access the description of detector geometry.
static const unsigned nCuts
total number of cuts
Definition: Mode.h:9
void Fill(const numu::RecoEvent &event, const event::Event &core, const Cuts &cutmaker, const std::vector< numu::TrackSelector > &selectors, const std::vector< numu::TrackFunction > &xfunctions, bool fill_all_tracks=true)
Definition: Histograms.cc:14
static constexpr std::array< const char *, nHistos > histoNames
Names of histograms.
Definition: Histograms.h:102
static constexpr numu::InteractionMode allModes[nModes]
List of all interaction modes.
Definition: Histograms.h:93
const char mode
Definition: noise_ana.cxx:20
Description of geometry of one entire detector.
void Initialize(const geo::GeometryCore *geometry, const sbnd::CRTGeoAlg &crt_geo, const Cuts &cuts, const std::string &prefix, const std::vector< std::string > &track_histo_types, const std::vector< std::string > &track_profile_types, const std::vector< std::tuple< unsigned, float, float >> &track_profile_xranges)
Definition: Histograms.cc:111
std::vector< std::array< TrackHistos, Cuts::nCuts > > fPrimaryTracks
Track histograms for priamry tracks in a candidate neutrino interaction.
Definition: Histograms.h:106
Provides a base class aware of world box coordinates.
std::vector< TrackHistos > fAllTracks
Track histograms for all tracks.
Definition: Histograms.h:105
The standard event data definition.
Definition: Event.hh:228
static const unsigned nTruthCuts
Total number of truth cuts.
static const unsigned nModes
number of interaction modes
Definition: Histograms.h:92
static constexpr std::array< const char *, nTruthCuts > truthCutNames
static constexpr std::array< const char *, nCuts > cutNames