All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
ana::ExampleAnalysis::ExampleSelection Class Reference

An example selection analysis. More...

#include <ExampleSelection.h>

Inheritance diagram for ana::ExampleAnalysis::ExampleSelection:
core::SelectionBase core::ProcessorBase

Public Member Functions

 ExampleSelection ()
 
void Initialize (fhicl::ParameterSet *config=NULL)
 
void Finalize ()
 
bool ProcessEvent (const gallery::Event &ev, const std::vector< event::Interaction > &truth, std::vector< event::RecoInteraction > &reco)
 
- Public Member Functions inherited from core::SelectionBase
 SelectionBase ()
 
virtual ~SelectionBase ()
 
- Public Member Functions inherited from core::ProcessorBase
 ProcessorBase ()
 
virtual ~ProcessorBase ()
 
virtual void FillTree ()
 
virtual void FillRecoTree ()
 
virtual void EventCleanup ()
 
template<class T >
TBranch * AddBranch (std::string name, T *obj)
 
template<class T >
TBranch * AddRecoBranch (std::string name, T *obj)
 

Protected Attributes

unsigned fEventCounter
 Count processed events. More...
 
art::InputTag fTruthTag
 art tag for MCTruth information More...
 
int fMyParam
 A parameter from the configuration file. More...
 
int fNuCount
 Number of neutrino interactions in the event. More...
 
int fMyVar
 Another variable of interest. More...
 
TH2D * fNuVertexXZHist
 Neutrino vertex XZ projection. More...
 
- Protected Attributes inherited from core::ProcessorBase
unsigned long fEventIndex
 An incrementing index. More...
 
Experiment fExperimentID
 Experiment identifier. More...
 
ProviderManagerfProviderManager
 Interface for provider access. More...
 
std::string fOutputFilename
 The output filename. More...
 
std::string fProviderConfig
 A custom provider config fcl file. More...
 
std::vector< geo::BoxBoundedGeofActiveVolumes
 List of active volumes in configured detector. More...
 
bool fWriteTree
 Enable writing of the main tree. More...
 
TFile * fOutputFile
 The output ROOT file. More...
 
TTree * fTree
 The output ROOT tree. More...
 
event::EventfEvent
 The standard output event data structure. More...
 
bool fWriteRecoTree
 Enable writing of the reco tree. More...
 
TTree * fRecoTree
 The output reco ROOT tree. More...
 
event::RecoEventfRecoEvent
 The standard output reco event data structure. More...
 
TTree * fSubRunTree
 Subrun output tree. More...
 
SubRunfSubRun
 Standard output subrun structure. More...
 
TTree * fFileMetaTree
 File metadata output tree. More...
 
FileMetafFileMeta
 standard output file metadata structure More...
 
TParameter< int > * fExperimentParameter
 Saves value of experiment enum. More...
 
std::set< std::pair< int, int > > fSubRunCache
 Cache stored subruns. More...
 
art::InputTag fTruthTag
 art tag for MCTruth information More...
 
art::InputTag fFluxTag
 art tag for MCFlux information More...
 
std::vector< art::InputTag > fWeightTags
 art tag(s) for MCEventWeight information More...
 
art::InputTag fMCTrackTag
 art tag for MCTrack More...
 
art::InputTag fMCShowerTag
 art tag for MCShower More...
 
art::InputTag fMCParticleTag
 art tag for MCParticle More...
 
std::string fGeneratorProcess
 process_name of process used to run genie. Used to extract subrun/POT information More...
 

Additional Inherited Members

- Public Attributes inherited from core::ProcessorBase
std::vector
< event::RecoInteraction > * 
fReco
 Reco interaction list. More...
 
- Protected Member Functions inherited from core::ProcessorBase
virtual void Initialize (char *config=NULL)
 
virtual void Setup (char *config=NULL)
 
virtual void Setup (fhicl::ParameterSet *config=NULL)
 
virtual void Teardown ()
 
void BuildEventTree (gallery::Event &ev)
 
void SetupServices (gallery::Event &ev)
 
void UpdateSubRuns (gallery::Event &ev)
 
void UpdateFileMeta (gallery::Event &ev)
 

Detailed Description

An example selection analysis.

This selection analysis doesn't actually select events, it just demonstrates the framework!

Definition at line 38 of file ExampleSelection.h.

Constructor & Destructor Documentation

ana::ExampleAnalysis::ExampleSelection::ExampleSelection ( )

Constructor.

Definition at line 19 of file ExampleSelection.cxx.

20  : SelectionBase(), fNuCount(0), fEventCounter(0) {}
unsigned fEventCounter
Count processed events.
int fNuCount
Number of neutrino interactions in the event.

Member Function Documentation

void ana::ExampleAnalysis::ExampleSelection::Finalize ( )
virtual

Finalize and write objects to the output file.

Implements core::ProcessorBase.

Definition at line 58 of file ExampleSelection.cxx.

58  {
59  // Output our histograms to the ROOT file
60  fOutputFile->cd();
61  fNuVertexXZHist->Write();
62 }
TH2D * fNuVertexXZHist
Neutrino vertex XZ projection.
TFile * fOutputFile
The output ROOT file.
void ana::ExampleAnalysis::ExampleSelection::Initialize ( fhicl::ParameterSet *  config = NULL)
virtual

Initialization.

Here we load configuration parameters, set up histograms for output, and add our own branches to the output tree.

Parameters
configA configuration, as FHiCL ParameterSet object

Implements core::ProcessorBase.

Definition at line 23 of file ExampleSelection.cxx.

23  {
24  // Make a histogram
25  fNuVertexXZHist = new TH2D("nu_vtx_XZ", "",
26  100, -1000, 1000, 100, -1000, 1000);
27 
28  // Load configuration parameters
29  fMyParam = 0;
30  fTruthTag = { "generator" };
31 
32  if (config) {
33  fhicl::ParameterSet pconfig = \
34  config->get<fhicl::ParameterSet>("ExampleAnalysis");
35 
36  fMyParam = pconfig.get<int>("parameter", 0);
37 
38  fTruthTag = \
39  { pconfig.get<std::string>("MCTruthTag", "generator") };
40  }
41 
42  // Add custom branches
43  AddBranch("nucount", &fNuCount);
44  AddBranch("myvar", &fMyVar);
45 
46  // Use LArSoft service functions via the ProviderManager
47  if (fProviderManager) {
48  std::cout << "Detector: "
50  << std::endl;
51  }
52 
53  // Use some library code
54  hello();
55 }
TH2D * fNuVertexXZHist
Neutrino vertex XZ projection.
const geo::GeometryCore * GetGeometryProvider() const
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
int fMyParam
A parameter from the configuration file.
ProviderManager * fProviderManager
Interface for provider access.
int fNuCount
Number of neutrino interactions in the event.
TBranch * AddBranch(std::string name, T *obj)
int fMyVar
Another variable of interest.
art::InputTag fTruthTag
art tag for MCTruth information
BEGIN_PROLOG could also be cout
bool ana::ExampleAnalysis::ExampleSelection::ProcessEvent ( const gallery::Event &  ev,
const std::vector< event::Interaction > &  truth,
std::vector< event::RecoInteraction > &  reco 
)
virtual

Process one event.

Parameters
evA single event, as a gallery::Event
recoReconstructed interactions
Returns
True to keep event

Implements core::ProcessorBase.

Definition at line 65 of file ExampleSelection.cxx.

68  {
69  if (fEventCounter % 10 == 0) {
70  std::cout << "ExampleSelection: Processing event "
71  << fEventCounter << std::endl;
72  }
73  fEventCounter++;
74 
75  // Grab a data product from the event
76  auto const& mctruths = \
77  *ev.getValidHandle<std::vector<simb::MCTruth>>(fTruthTag);
78 
79  // Fill in the custom branches
80  fNuCount = mctruths.size(); // Number of neutrinos in this event
81  fMyVar = fMyParam;
82 
83  // Iterate through the neutrinos
84  for (size_t i=0; i<mctruths.size(); i++) {
85  auto const& mctruth = mctruths.at(i);
86 
87  // Fill neutrino vertex position histogram
88  if (mctruth.NeutrinoSet()) {
89  fNuVertexXZHist->Fill(mctruth.GetNeutrino().Nu().Vx(),
90  mctruth.GetNeutrino().Nu().Vz());
91  }
92  // Add in the "reconstructed" interaction
93  //
94  // Contruct truth information from the provided vector
95  event::RecoInteraction interaction(i);
96  // get "reconstructed" energy
97  interaction.reco_energy = util::ECCQE(mctruth.GetNeutrino().Nu().Momentum().Vect(), mctruth.GetNeutrino().Lepton().E());
98  reco.push_back(interaction);
99  }
100 
101  return true;
102 }
TH2D * fNuVertexXZHist
Neutrino vertex XZ projection.
double ECCQE(const TVector3 &l_momentum, double l_energy)
Definition: Interaction.cxx:7
Contains truth level information and additional fields for selection-defined reconstruction informati...
Definition: Event.hh:178
unsigned fEventCounter
Count processed events.
int fMyParam
A parameter from the configuration file.
int fNuCount
Number of neutrino interactions in the event.
int fMyVar
Another variable of interest.
art::InputTag fTruthTag
art tag for MCTruth information
BEGIN_PROLOG could also be cout

Member Data Documentation

unsigned ana::ExampleAnalysis::ExampleSelection::fEventCounter
protected

Count processed events.

Definition at line 68 of file ExampleSelection.h.

int ana::ExampleAnalysis::ExampleSelection::fMyParam
protected

A parameter from the configuration file.

Definition at line 72 of file ExampleSelection.h.

int ana::ExampleAnalysis::ExampleSelection::fMyVar
protected

Another variable of interest.

Definition at line 76 of file ExampleSelection.h.

int ana::ExampleAnalysis::ExampleSelection::fNuCount
protected

Number of neutrino interactions in the event.

Custom data branches

Definition at line 75 of file ExampleSelection.h.

TH2D* ana::ExampleAnalysis::ExampleSelection::fNuVertexXZHist
protected

Neutrino vertex XZ projection.

Histograms

Definition at line 79 of file ExampleSelection.h.

art::InputTag ana::ExampleAnalysis::ExampleSelection::fTruthTag
protected

art tag for MCTruth information

Configuration parameters

Definition at line 71 of file ExampleSelection.h.


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