Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_b1pi_hists.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DEventProcessor_b1pi_hists.cc
4 // Created: Thu Sep 28 11:38:03 EDT 2011
5 // Creator: pmatt (on Darwin swire-b241.jlab.org 8.4.0 powerpc)
6 //
7 
9 
10 // The executable should define the ROOTfile global variable. It will
11 // be automatically linked when dlopen is called.
12 extern TFile *ROOTfile;
13 
14 // Routine used to create our DEventProcessor
15 extern "C"
16 {
17  void InitPlugin(JApplication *app)
18  {
19  InitJANAPlugin(app);
20  app->AddProcessor(new DEventProcessor_b1pi_hists());
21  app->AddFactoryGenerator(new DFactoryGenerator_b1pi_hists());
22  }
23 } // "C"
24 
25 //------------------
26 // init
27 //------------------
29 {
30  return NOERROR;
31 }
32 
33 //------------------
34 // brun
35 //------------------
36 jerror_t DEventProcessor_b1pi_hists::brun(JEventLoop *locEventLoop, int32_t runnumber)
37 {
38  return NOERROR;
39 }
40 
41 //------------------
42 // evnt
43 //------------------
44 jerror_t DEventProcessor_b1pi_hists::evnt(JEventLoop *locEventLoop, uint64_t eventnumber)
45 {
46  //Triggers the analysis (is also automatically called by DEventWriterROOT::Fill_Trees())
47  vector<const DAnalysisResults*> locAnalysisResultsVector;
48  locEventLoop->Get(locAnalysisResultsVector);
49 
50  //Output TTree
51  const DEventWriterROOT* locEventWriterROOT = NULL;
52  locEventLoop->GetSingle(locEventWriterROOT);
53  locEventWriterROOT->Fill_DataTrees(locEventLoop, "b1pi_hists");
54 
55  //Do Miscellaneous Cuts
56  bool locSaveEventFlag = false;
57  for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i)
58  {
59  const DAnalysisResults* locAnalysisResults = locAnalysisResultsVector[loc_i];
60  if(locAnalysisResults->Get_Reaction()->Get_ReactionName() != "b1pi")
61  continue;
62  if(locAnalysisResults->Get_NumPassedParticleCombos() == 0)
63  continue;
64  locSaveEventFlag = true;
65  break;
66  }
67 
68  //Output REST File
69  if(locSaveEventFlag)
70  {
71  vector<const DEventWriterREST*> locEventWriterRESTVector;
72  locEventLoop->Get(locEventWriterRESTVector);
73  locEventWriterRESTVector[0]->Write_RESTEvent(locEventLoop, "b1pi");
74  }
75 
76  return NOERROR;
77 }
78 
79 //------------------
80 // erun
81 //------------------
83 {
84  // Any final calculations on histograms (like dividing them)
85  // should be done here. This may get called more than once.
86  return NOERROR;
87 }
88 
89 //------------------
90 // fini
91 //------------------
93 {
94  return NOERROR;
95 }
96 
jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
TFile * ROOTfile
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t evnt(JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
InitPlugin_t InitPlugin
string Get_ReactionName(void) const
Definition: DReaction.h:75
void Fill_DataTrees(JEventLoop *locEventLoop, string locDReactionTag) const
const DReaction * Get_Reaction(void) const
size_t Get_NumPassedParticleCombos(void) const
jerror_t fini(void)
Called after last event of last event source has been processed.