Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_ppi0gamma_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DEventProcessor_ppi0gamma_hists.cc
4 // Created: Wed Mar 11 20:34:22 EDT 2015
5 // Creator: jrsteven (on Linux halldw1.jlab.org 2.6.32-504.8.1.el6.x86_64 x86_64)
6 //
7 
9 
10 // Routine used to create our DEventProcessor
11 
12 extern "C"
13 {
14  void InitPlugin(JApplication *locApplication)
15  {
16  InitJANAPlugin(locApplication);
17  locApplication->AddProcessor(new DEventProcessor_ppi0gamma_hists()); //register this plugin
18  locApplication->AddFactoryGenerator(new DFactoryGenerator_ppi0gamma_hists()); //register the factory generator
19  }
20 } // "C"
21 
22 //------------------
23 // init
24 //------------------
26 {
27  // This is called once at program startup. If you are creating
28  // and filling historgrams in this plugin, you should lock the
29  // ROOT mutex like this:
30  //
31  // japp->RootWriteLock();
32  // ... create historgrams or trees ...
33  // japp->RootUnLock();
34  //
35 
36  return NOERROR;
37 }
38 
39 //------------------
40 // brun
41 //------------------
42 jerror_t DEventProcessor_ppi0gamma_hists::brun(jana::JEventLoop* locEventLoop, int locRunNumber)
43 {
44  // This is called whenever the run number changes
45 
46  return NOERROR;
47 }
48 
49 //------------------
50 // evnt
51 //------------------
52 jerror_t DEventProcessor_ppi0gamma_hists::evnt(jana::JEventLoop* locEventLoop, uint64_t locEventNumber)
53 {
54  // This is called for every event. Use of common resources like writing
55  // to a file or filling a histogram should be mutex protected. Using
56  // locEventLoop->Get(...) to get reconstructed objects (and thereby activating the
57  // reconstruction algorithm) should be done outside of any mutex lock
58  // since multiple threads may call this method at the same time.
59  //
60  // Here's an example:
61  //
62  // vector<const MyDataClass*> mydataclasses;
63  // locEventLoop->Get(mydataclasses);
64  //
65  // japp->RootWriteLock();
66  // ... fill historgrams or trees ...
67  // japp->RootUnLock();
68 
69  // DOCUMENTATION:
70  // ANALYSIS library: https://halldweb1.jlab.org/wiki/index.php/GlueX_Analysis_Software
71 
72  // Get the analysis results for all DReactions.
73  //Getting these objects triggers the analysis, if it wasn't performed already.
74  //These objects contain the DParticleCombo objects that survived the DAnalysisAction cuts that were added to the DReactions
75  vector<const DAnalysisResults*> locAnalysisResultsVector;
76  locEventLoop->Get(locAnalysisResultsVector);
77 
78  //Recommended: Write surviving particle combinations (if any) to output ROOT TTree
79  //If no cuts are performed by the analysis actions added to a DReaction, then this saves all of its particle combinations.
80  //The event writer gets the DAnalysisResults objects from JANA, performing the analysis.
81  // string is DReaction factory tag: will fill trees for all DReactions that are defined in the specified factory
82  const DEventWriterROOT* locEventWriterROOT = NULL;
83  locEventLoop->GetSingle(locEventWriterROOT);
84  //locEventWriterROOT->Fill_DataTrees(locEventLoop, "ppi0gamma_hists");
85 
86  return NOERROR;
87 }
88 
89 //------------------
90 // erun
91 //------------------
93 {
94  // This is called whenever the run number changes, before it is
95  // changed to give you a chance to clean up before processing
96  // events from the next run number.
97  return NOERROR;
98 }
99 
100 //------------------
101 // fini
102 //------------------
104 {
105  // Called before program exit after event processing is finished.
106  return NOERROR;
107 }
108 
jerror_t init(void)
Called once at program start.
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t brun(jana::JEventLoop *locEventLoop, int locRunNumber)
Called every time a new run number is detected.
jerror_t evnt(jana::JEventLoop *locEventLoop, uint64_t locEventNumber)
Called every event.
InitPlugin_t InitPlugin
jerror_t erun(void)
Called every time run number changes, provided brun has been called.