All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
ana::SBNOsc::Histograms Struct Reference

#include <Histograms.h>

Inheritance diagram for ana::SBNOsc::Histograms:
ana::SBNOsc::HistoList

Public Member Functions

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)
 
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)
 
- Public Member Functions inherited from ana::SBNOsc::HistoList
void Scale (double scale)
 
void Add (const HistoList &other)
 
void Write ()
 
void StoreHisto (TH1 *histo)
 
void Merge (const HistoList &merge)
 

Static Public Member Functions

static std::string mode2Str (const numu::InteractionMode &mode)
 

Public Attributes

InteractionHistos fInteraction [nHistos][nModes]
 all the interaction histograms More...
 
std::vector< TrackHistosfAllTracks
 Track histograms for all tracks. More...
 
std::vector< std::array
< TrackHistos, Cuts::nCuts > > 
fPrimaryTracks
 Track histograms for priamry tracks in a candidate neutrino interaction. More...
 
std::vector< std::vector
< std::array< TrackProfiles,
Cuts::nCuts > > > 
fPrimaryTrackProfiles
 Profile histograms for primary tracks. More...
 
std::array< CosmicHistos, 4 > fCosmic
 
std::array< CRTHistos,
Cuts::nCuts
fCRTs
 
- Public Attributes inherited from ana::SBNOsc::HistoList
std::vector< TH1 * > fAllHistos
 
std::vector< TDirectory * > fLocations
 

Static Public Attributes

static const unsigned nHistos = Cuts::nCuts + Cuts::nTruthCuts
 
static const unsigned nModes = 8
 number of interaction modes More...
 
static constexpr
numu::InteractionMode 
allModes [nModes]
 List of all interaction modes. More...
 
static constexpr std::array
< const char *, nHistos
histoNames = concat(Cuts::truthCutNames, Cuts::cutNames)
 Names of histograms. More...
 

Detailed Description

Set of Track and Interaction histos for all modes/cuts/sub-types

Definition at line 46 of file Histograms.h.

Member Function Documentation

void ana::SBNOsc::Histograms::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 
)

Fill all of the histograms with an event

Parameters
eventThe reconstructed event information
coreThe sbncode core event information
cutsThe configured Cuts classes
fill_all_tracksWhether to fill all track histograms or just the primary track histograms

Definition at line 14 of file Histograms.cc.

19  {
20 
21  if (event.type == numu::fOverlay) {
22  fCosmic[0].Fill(event.particles);
23  if (cutmaker.PassFlashTrigger(event)) {
24  fCosmic[1].Fill(event.particles);
25  }
26  }
27  else {
28  std::cout << "Filling Cosmic!\n";
29  fCosmic[2].Fill(event.particles);
30  if (cutmaker.PassFlashTrigger(event)) {
31  fCosmic[3].Fill(event.particles);
32  }
33  }
34 
36 
37  if (fill_all_tracks) {
38  for (const auto &track_pair: event.tracks) {
39  const numu::RecoTrack &track = track_pair.second;
40  for (unsigned i = 0; i < fAllTracks.size(); i++) {
41  const numu::TrueParticle &part = (track.match.has_match) ? event.particles.at(track.match.mcparticle_id) : bad;
42  bool select = selectors[i](track, part, event.type);
43  if (select) {
44  fAllTracks[i].Fill(track, event.particles);
45  }
46  }
47  }
48  }
49 
50  for (unsigned i = 0; i < event.reco.size(); i++) {
51  std::array<bool, Cuts::nCuts> cuts = cutmaker.ProcessRecoCuts(event, i);
52  const numu::RecoInteraction &interaction = event.reco[i];
53 
54 
55  if (event.tracks.size() > (unsigned)interaction.slice.primary_track_index) {
56  const numu::RecoTrack &track = event.tracks.at(interaction.slice.primary_track_index);
57 
58  for (unsigned cut_i = 0; cut_i < Cuts::nCuts; cut_i++) {
59  if (cuts[cut_i] && cutmaker.HasCRTHitMatch(track)) {
60  std::cout << "Filling CRT Histo!\n";
61  fCRTs[cut_i].Fill(track.crt_match.hit);
62  }
63  }
64 
65  for (unsigned j = 0; j < fPrimaryTracks.size(); j++) {
66  const numu::TrueParticle &part = (track.match.has_match) ? event.particles.at(track.match.mcparticle_id) : bad;
67  bool select = selectors[i](track, part, event.type);
68  if (select) {
69  for (unsigned cut_i = 0; cut_i < Cuts::nCuts; cut_i++) {
70  if (cuts[cut_i]) {
71  fPrimaryTracks[j][cut_i].Fill(track, event.particles);
72  for (unsigned k = 0; k < xfunctions.size(); k++) {
73  const numu::TrueParticle &part = (track.match.has_match) ? event.particles.at(track.match.mcparticle_id) : bad;
74  uscript::Value x = xfunctions[k](&track, &part, (unsigned*)&event.type);
75  assert(IS_NUMBER(x));
76  fPrimaryTrackProfiles[j][k][cut_i].Fill(AS_NUMBER(x),
77  track, event);
78  }
79  }
80  }
81  }
82  }
83  }
84 
85  // fill histos
86  for (size_t cut_i=0; cut_i < Cuts::nCuts; cut_i++) {
87  int mode = interaction.match.mode;
88  if (cuts[cut_i]) {
89  fInteraction[cut_i+Cuts::nTruthCuts][mode].Fill(event.reco[i],
90  event,
91  core.truth);
93  event,
94  core.truth);
95  }
96  }
97  }
98 
99  for (unsigned i = 0; i < core.truth.size(); i++) {
100  std::array<bool, Cuts::nTruthCuts> cuts = cutmaker.ProcessTruthCuts(event, core, i);
101  for (int cut_i = 0; cut_i < Cuts::nTruthCuts; cut_i++) {
102  int mode = numu::GetMode(core.truth[i]);
103  if (cuts[cut_i]) {
104  fInteraction[cut_i][mode].Fill(core.truth[i], i, event);
105  fInteraction[cut_i][numu::mAll].Fill(core.truth[i], i, event);
106  }
107  }
108  }
109 }
InteractionMode mode
Mode of the interaction.
InteractionMode GetMode(const event::Interaction &truth)
Definition: TruthMatch.cc:5
process_name opflash particleana ie x
CRTMatch crt_match
CRTMatch.
Definition: RecoTrack.h:59
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
TruthMatch match
Info for mathing to truth.
Definition: RecoEvent.h:42
std::array< CRTHistos, Cuts::nCuts > fCRTs
Definition: Histograms.h:110
int mcparticle_id
MCParticle ID of the particle this track matches to (same as the ID of the RecoTrack of that particle...
int primary_track_index
Index of the primary track.
Definition: RecoEvent.h:27
InteractionHistos fInteraction[nHistos][nModes]
all the interaction histograms
Definition: Histograms.h:104
process_name use argoneut_mc_hitfinder track
std::map< size_t, TrueParticle > particles
Map of indices to True particle information.
Definition: RecoEvent.h:49
std::vector< RecoInteraction > reco
List of reconstructed vertices.
Definition: RecoEvent.h:50
static const unsigned nCuts
total number of cuts
std::map< size_t, RecoTrack > tracks
Map of track indices to Track information.
Definition: RecoEvent.h:48
#define AS_NUMBER(value)
Definition: value.h:53
#define IS_NUMBER(value)
Definition: value.h:61
const char mode
Definition: noise_ana.cxx:20
bool has_match
Whether a track match exists.
std::vector< std::array< TrackHistos, Cuts::nCuts > > fPrimaryTracks
Track histograms for priamry tracks in a candidate neutrino interaction.
Definition: Histograms.h:106
std::vector< TrackHistos > fAllTracks
Track histograms for all tracks.
Definition: Histograms.h:105
TrackTruthMatch match
Truth matching information.
Definition: RecoTrack.h:57
static const unsigned nTruthCuts
Total number of truth cuts.
RecoSlice slice
Particle content of the interaction.
Definition: RecoEvent.h:39
CRTHit hit
Definition: CRTMatch.h:32
pdgs k
Definition: selectors.fcl:22
void Fill(const numu::RecoInteraction &vertex, const numu::RecoEvent &event, const std::vector< event::Interaction > &core_truth)
BEGIN_PROLOG could also be cout
std::vector< Interaction > truth
All truth interactions.
Definition: Event.hh:232
void ana::SBNOsc::Histograms::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 at line 111 of file Histograms.cc.

118  {
119 
120  double max_length = SBNRecoUtils::MaxLength(geometry);
122  std::vector<double> tagger_volume = crt_geo.CRTLimits();
123 
124  std::cout << "Limits: " << tagger_volume[0] << " " << tagger_volume[3] << " " << tagger_volume[1] << " " << tagger_volume[4] << " " << tagger_volume[2] << " " << tagger_volume[5] << std::endl;
125 
126  // make new directory for histograms
127  TDirectory *d_top = gDirectory->mkdir("histograms");
128 
129  if (prefix.size() != 0) {
130  d_top = d_top->mkdir(prefix.c_str());
131  d_top->cd();
132  }
133 
134  d_top->mkdir("cosmic");
135 
136  d_top->mkdir("cosmic/outtime");
137  d_top->cd("cosmic/outtime");
138  fCosmic[0].Initialize("", detector);
139  d_top->cd();
140 
141  d_top->mkdir("cosmic/outtime_trig");
142  d_top->cd("cosmic/outtime_trig");
143  fCosmic[1].Initialize("", detector);
144  d_top->cd();
145 
146  d_top->mkdir("cosmic/intime");
147  d_top->cd("cosmic/intime");
148  fCosmic[2].Initialize("", detector);
149  d_top->cd();
150 
151  d_top->mkdir("cosmic/intime_trig");
152  d_top->cd("cosmic/intime_trig");
153  fCosmic[3].Initialize("", detector);
154  d_top->cd();
155 
156  std::vector<std::string> cut_order = cuts.CutOrder();
157  std::vector<std::string> truth_cut_order = cuts.TruthCutOrder();
158 
159  d_top->mkdir("interaction");
160  for (unsigned i = 0; i < Histograms::nHistos; i++) {
161  for (const auto mode: Histograms::allModes) {
162  std::string cut_name = (i < truth_cut_order.size()) ? truth_cut_order[i] : cut_order[i - truth_cut_order.size()];
163  std::string postfix = mode2Str(mode) + prefix + cut_name;
164  std::string dirname = "interaction/" + mode2Str(mode) + "/" + cut_name;
165  d_top->mkdir(dirname.c_str());
166  d_top->cd(dirname.c_str());
167  fInteraction[i][mode].Initialize("", detector, tagger_volume);
168  d_top->cd();
169  }
170  }
171 
172  d_top->mkdir("crt");
173  for (unsigned cut_i = 0; cut_i < Cuts::nCuts; cut_i++) {
174  std::string dirname = "crt/" + cut_order[cut_i];
175  d_top->mkdir(dirname.c_str());
176  d_top->cd(dirname.c_str());
177  fCRTs[cut_i].Initialize("", tagger_volume);
178  d_top->cd();
179  }
180 
181  fAllTracks.reserve(track_histo_types.size());
182  fPrimaryTracks.reserve(track_histo_types.size());
183 
184  d_top->mkdir("ptrack");
185  d_top->mkdir("alltrack");
186  for (unsigned i = 0; i < track_histo_types.size(); i++) {
187  fAllTracks.emplace_back();
188  fPrimaryTracks.emplace_back();
189  fPrimaryTrackProfiles.emplace_back();
190 
191  std::string dirname = track_histo_types[i];
192  std::string all_dirname = "alltrack/" + dirname;
193 
194  d_top->mkdir(all_dirname.c_str());
195  d_top->cd(all_dirname.c_str());
196  fAllTracks[i].Initialize("", detector, max_length);
197  d_top->cd();
198  for (unsigned j = 0; j < Cuts::nCuts; j++) {
199  std::string p_dirname = "ptrack/" + dirname + cut_order[j];
200  d_top->mkdir(p_dirname.c_str());
201  d_top->cd(p_dirname.c_str());
202  fPrimaryTracks[i][j].Initialize("", detector, max_length);
203  d_top->cd();
204 
205  for (unsigned k = 0; k < track_profile_types.size(); k++) {
206  if (j == 0) fPrimaryTrackProfiles[i].emplace_back();
207  unsigned n_bin;
208  float xlo, xhi;
209  std::tie(n_bin, xlo, xhi) = track_profile_xranges[k];
210  std::string p_profile_dirname = "ptrack/" + dirname + cut_order[j] + "/profile_" + track_profile_types[k];
211  d_top->mkdir(p_profile_dirname.c_str());
212  d_top->cd(p_profile_dirname.c_str());
213  fPrimaryTrackProfiles[i][k][j].Initialize("", n_bin, xlo, xhi);
214  d_top->cd();
215  }
216 
217  }
218  }
219 
220 
221  for (unsigned i = 0; i < 4; i++) {
222  Merge(fCosmic[i]);
223  }
224  for (unsigned i = 0; i < Histograms::nHistos; i++) {
225  for (const auto mode: Histograms::allModes) {
226  Merge(fInteraction[i][mode]);
227  }
228  }
229 
230  for (unsigned i = 0; i < Cuts::nCuts; i++) {
231  Merge(fCRTs[i]);
232  }
233 
234  for (unsigned i = 0; i < fAllTracks.size(); i++) {
235  Merge(fAllTracks[i]);
236  for (unsigned j = 0; j < Cuts::nCuts; j++) {
237  Merge(fPrimaryTracks[i][j]);
238  for (unsigned k = 0; k < track_profile_types.size(); k++) {
239  Merge(fPrimaryTrackProfiles[i][k][j]);
240  }
241  }
242  }
243 
244 }
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
timings intime T_reco cut_order
Definition: selectors.fcl:126
std::array< CRTHistos, Cuts::nCuts > fCRTs
Definition: Histograms.h:110
InteractionHistos fInteraction[nHistos][nModes]
all the interaction histograms
Definition: Histograms.h:104
geo::BoxBoundedGeo DetectorVolume(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:35
static const unsigned nHistos
Definition: Histograms.h:91
double MaxLength(const geo::GeometryCore *geometry)
Definition: GeoUtil.cc:22
timings intime truth_cut_order
Definition: selectors.fcl:126
static const unsigned nCuts
total number of cuts
void Initialize(const std::string &prefix, const geo::BoxBoundedGeo &detector_volume, const std::vector< double > &tagger_volume)
static constexpr numu::InteractionMode allModes[nModes]
List of all interaction modes.
Definition: Histograms.h:93
const char mode
Definition: noise_ana.cxx:20
void Merge(const HistoList &merge)
Definition: HistoList.cc:31
std::vector< std::array< TrackHistos, Cuts::nCuts > > fPrimaryTracks
Track histograms for priamry tracks in a candidate neutrino interaction.
Definition: Histograms.h:106
std::vector< TrackHistos > fAllTracks
Track histograms for all tracks.
Definition: Histograms.h:105
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
Definition: BoxBoundedGeo.h:33
pdgs k
Definition: selectors.fcl:22
BEGIN_PROLOG could also be cout
static std::string ana::SBNOsc::Histograms::mode2Str ( const numu::InteractionMode mode)
inlinestatic

Turn the InteractionMode enum into a string for (e.g.) histogram names.

Parameters
modeThe interaction mode to be converted
Returns
String representaiton of that mode

Definition at line 78 of file Histograms.h.

78  {
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  }
Definition: Mode.h:11
Definition: Mode.h:9
const char mode
Definition: noise_ana.cxx:20

Member Data Documentation

constexpr numu::InteractionMode ana::SBNOsc::Histograms::allModes[nModes]
static
Initial value:

List of all interaction modes.

Definition at line 93 of file Histograms.h.

std::vector<TrackHistos> ana::SBNOsc::Histograms::fAllTracks

Track histograms for all tracks.

Definition at line 105 of file Histograms.h.

std::array<CosmicHistos, 4> ana::SBNOsc::Histograms::fCosmic

Definition at line 108 of file Histograms.h.

std::array<CRTHistos, Cuts::nCuts> ana::SBNOsc::Histograms::fCRTs

Definition at line 110 of file Histograms.h.

InteractionHistos ana::SBNOsc::Histograms::fInteraction[nHistos][nModes]

all the interaction histograms

Definition at line 104 of file Histograms.h.

std::vector<std::vector<std::array<TrackProfiles, Cuts::nCuts> > > ana::SBNOsc::Histograms::fPrimaryTrackProfiles

Profile histograms for primary tracks.

Definition at line 107 of file Histograms.h.

std::vector<std::array<TrackHistos, Cuts::nCuts> > ana::SBNOsc::Histograms::fPrimaryTracks

Track histograms for priamry tracks in a candidate neutrino interaction.

Definition at line 106 of file Histograms.h.

constexpr std::array<const char *, nHistos> ana::SBNOsc::Histograms::histoNames = concat(Cuts::truthCutNames, Cuts::cutNames)
static

Names of histograms.

Definition at line 102 of file Histograms.h.

const unsigned ana::SBNOsc::Histograms::nHistos = Cuts::nCuts + Cuts::nTruthCuts
static

Definition at line 91 of file Histograms.h.

const unsigned ana::SBNOsc::Histograms::nModes = 8
static

number of interaction modes

Definition at line 92 of file Histograms.h.


The documentation for this struct was generated from the following files: