All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OpSimHitPrinter.cc
Go to the documentation of this file.
1 /**
2  * \file OpSimHitPrinter.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 
20 #include "fhiclcpp/ParameterSet.h"
21 #include "../OpHitFinder/opHitFinderSBND.hh"
22 
23 #include "TH1D.h"
24 #include "TGraph.h"
25 
26 namespace ana {
27  namespace SBNOsc {
28 
29 /**
30  * \class OpSimHitPrinter
31  * \brief Electron neutrino event selection
32  */
34 public:
35  /** Constructor. */
37 
38  /**
39  * Initialization.
40  *
41  * \param config A configuration, as a FHiCL ParameterSet object
42  */
43  void Initialize(fhicl::ParameterSet* config=NULL) {
44  fOpDetHitTag = config ? config->get<std::string>("OpDetHitTag", "ophit") : "ophit";
45  MakeOpHits = config ? config->get<bool>("MakeOpHits", false) : false;
46  _op_hit_maker = (MakeOpHits) ? new opdet::opHitFinderSBND(config->get<fhicl::ParameterSet>("OpHitMaker"), fProviderManager->GetDetectorClocksProvider()) :
47  NULL;
48  event_ind = 0;
49  }
50 
51  /** Finalize and write objects to the output file. */
52  void Finalize() {
53  }
54 
55  /**
56  * Process one event.
57  *
58  * \param ev A single event, as a gallery::Event
59  * \param Reconstructed interactions
60  * \return True to keep event
61  */
62  bool ProcessEvent(const gallery::Event& ev, const std::vector<event::Interaction> &truth, std::vector<event::RecoInteraction>& reco) {
63  std::vector<recob::OpHit> op_hits;
64  if (MakeOpHits) {
65  const std::vector<raw::OpDetWaveform> &op_waveforms = *ev.getValidHandle<std::vector<raw::OpDetWaveform>>("opdaq");
66  op_hits = _op_hit_maker->MakeHits(op_waveforms);
67  }
68  else {
69  op_hits = *ev.getValidHandle<std::vector<recob::OpHit>>(fOpDetHitTag);
70  }
71 
72  std::cout << "New event!" << std::endl;
73  for (const recob::OpHit &hit: op_hits) {
74  std::cout << "Op hit:" << " channel: " << hit.OpChannel() << " time:" << hit.PeakTime() << std::endl;
75  }
76  return false;
77  }
78 
79 protected:
80  std::string fOpDetHitTag;
82  bool MakeOpHits;
83  unsigned event_ind;
84 };
85 
86  } // namespace SBNOsc
87 } // namespace ana
89 
opdet::opHitFinderSBND * _op_hit_maker
process_name hit
Definition: cheaterreco.fcl:51
process_name opflashCryoW ana
bool ProcessEvent(const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
process_name standard_reco_uboone reco
std::vector< recob::OpHit > MakeHits(const std::vector< raw::OpDetWaveform > &waveforms)
Electron neutrino event selection.
#define DECLARE_SBN_PROCESSOR(classname)
Base class for event selections.
const detinfo::DetectorClocksStandard * GetDetectorClocksProvider() const
ProviderManager * fProviderManager
Interface for provider access.
void Initialize(fhicl::ParameterSet *config=NULL)
BEGIN_PROLOG could also be cout