Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_p2pi0_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DEventProcessor_p2pi0_hists.cc
4 // Created: Tue May 19 07:56:16 EDT 2015
5 // Creator: jrsteven (on Linux ifarm1401 2.6.32-431.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_p2pi0_hists()); //register this plugin
18  locApplication->AddFactoryGenerator(new DFactoryGenerator_p2pi0_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_p2pi0_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_p2pi0_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  /*********************************************************** REQUIRED ***********************************************************/
73 
74  //REQUIRED: To run an analysis, You MUST call one at least of the below code fragments.
75  //JANA is on-demand, so if you don't call one of these, then your analysis won't run.
76 
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, "p2pi0_hists");
85  */
86 
87  //Optional: Get the analysis results for all DReactions.
88  //Getting these objects triggers the analysis, if it wasn't performed already.
89  //These objects contain the DParticleCombo objects that survived the DAnalysisAction cuts that were added to the DReactions
90  vector<const DAnalysisResults*> locAnalysisResultsVector;
91  locEventLoop->Get(locAnalysisResultsVector);
92 
93  return NOERROR;
94 }
95 
96 //------------------
97 // erun
98 //------------------
100 {
101  // This is called whenever the run number changes, before it is
102  // changed to give you a chance to clean up before processing
103  // events from the next run number.
104  return NOERROR;
105 }
106 
107 //------------------
108 // fini
109 //------------------
111 {
112  // Called before program exit after event processing is finished.
113  return NOERROR;
114 }
115 
jerror_t erun(void)
Called every time run number changes, provided brun has been called.
InitPlugin_t InitPlugin
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.