All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CaloPrinter.cc
Go to the documentation of this file.
1 /**
2  * \file CaloPrinter.cc
3  *
4  *
5  * Author:
6  */
7 
8 #include <iostream>
9 #include <array>
10 
11 #include "canvas/Utilities/InputTag.h"
12 #include "core/SelectionBase.hh"
13 #include "core/Event.hh"
14 #include "core/Experiment.hh"
15 #include "core/ProviderManager.hh"
16 
18 #include "canvas/Persistency/Common/FindManyP.h"
19 #include "fhiclcpp/ParameterSet.h"
20 
21 #include "TH1D.h"
22 #include "TGraph.h"
23 
24 namespace ana {
25  namespace SBNOsc {
26 
27 /**
28  * \class CaloPrinter
29  * \brief Electron neutrino event selection
30  */
32 public:
33  /** Constructor. */
35 
36  /**
37  * Initialization.
38  *
39  * \param config A configuration, as a FHiCL ParameterSet object
40  */
41  void Initialize(fhicl::ParameterSet* config=NULL) {
42  fTag = config ? config->get<std::string>("Tag", "pandoraCalo") : "pandoraCalo";
43  event_ind = 0;
44  z = new TH1D("calo point z", "calo point z", 1000, -1000, 1000);
45  }
46 
47  /** Finalize and write objects to the output file. */
48  void Finalize() {
49  fOutputFile->cd();
50  z->Write();
51  }
52 
53  /**
54  * Process one event.
55  *
56  * \param ev A single event, as a gallery::Event
57  * \param Reconstructed interactions
58  * \return True to keep event
59  */
60  bool ProcessEvent(const gallery::Event& ev, const std::vector<event::Interaction> &truth, std::vector<event::RecoInteraction>& reco) {
61  const std::vector<anab::Calorimetry> calos = *ev.getValidHandle<std::vector<anab::Calorimetry>>(fTag);
62  std::cout << "New Event!\n";
63  for (const anab::Calorimetry& calo: calos) {
64  std::cout << "New Calo!\n";
65  for (recob::tracking::Point_t xyz: calo.XYZ()) {
66  std::cout << xyz.X() << " " << xyz.Y() << " " << xyz.Z() << std::endl;
67  if (xyz.Z() < -100.) std::cout << "Low!\n";
68  z->Fill(xyz.Z());
69  }
70  }
71  return false;
72  }
73 
74 protected:
75  std::string fTag;
76  TH1D *z;
77  unsigned event_ind;
78 };
79 
80  } // namespace SBNOsc
81 } // namespace ana
83 
TFile * fOutputFile
The output ROOT file.
process_name opflashCryoW ana
Electron neutrino event selection.
Definition: CaloPrinter.cc:31
process_name can override from command line with o or output calo
Definition: pid.fcl:40
process_name standard_reco_uboone reco
#define DECLARE_SBN_PROCESSOR(classname)
Base class for event selections.
bool ProcessEvent(const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
Definition: CaloPrinter.cc:60
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
BEGIN_PROLOG could also be cout
void Initialize(fhicl::ParameterSet *config=NULL)
Definition: CaloPrinter.cc:41