Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_OmegaSkim.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_OmegaSkim.cc
4 // Created: Wed May 24 13:46:12 EDT 2017
5 // Creator: mashephe (on Linux stanley.physics.indiana.edu 2.6.32-642.6.2.el6.x86_64 unknown)
6 //
7 
10 
11 using namespace jana;
12 
14 
17 
18 // Routine used to create our JEventProcessor
19 #include <JANA/JApplication.h>
20 #include <JANA/JFactory.h>
21 extern "C"{
22  void InitPlugin(JApplication *app){
23  InitJANAPlugin(app);
24  app->AddProcessor(new JEventProcessor_OmegaSkim());
25  app->AddFactoryGenerator( new DFactoryGenerator_OmegaSkim() );
26  }
27 } // "C"
28 
29 
30 //------------------
31 // JEventProcessor_OmegaSkim (Constructor)
32 //------------------
34 {
35 
36  WRITE_EVIO_FILE = 1;
37  gPARMS->SetDefaultParameter( "WRITE_EVIO_FILE", WRITE_EVIO_FILE );
38 
39  WRITE_ROOT_TREE = 0;
40  gPARMS->SetDefaultParameter( "WRITE_ROOT_TREE", WRITE_ROOT_TREE );
41 }
42 
43 //------------------
44 // ~JEventProcessor_OmegaSkim (Destructor)
45 //------------------
47 {
48 
49 }
50 
51 //------------------
52 // init
53 //------------------
55 {
56  // This is called once at program startup.
57 
58  return NOERROR;
59 }
60 
61 //------------------
62 // brun
63 //------------------
64 jerror_t JEventProcessor_OmegaSkim::brun(JEventLoop *eventLoop, int32_t runnumber)
65 {
66  // This is called whenever the run number changes
67  return NOERROR;
68 }
69 
70 //------------------
71 // evnt
72 //------------------
73 jerror_t JEventProcessor_OmegaSkim::evnt(JEventLoop *loop, uint64_t eventnumber)
74 {
75 
76  vector<const DAnalysisResults*> locAnalysisResultsVector;
77  loop->Get( locAnalysisResultsVector );
78 
79  const DEventWriterEVIO* eventWriterEVIO = NULL;
80  if( WRITE_EVIO_FILE ){
81 
82 
83  loop->GetSingle(eventWriterEVIO);
84 
85  // write out BOR events
86  if(loop->GetJEvent().GetStatusBit(kSTATUS_BOR_EVENT)) {
87  eventWriterEVIO->Write_EVIOEvent(loop, "omega");
88  return NOERROR;
89  }
90  }
91 
92  //Make sure that there are combos that survived for ****THIS**** CHANNEL!!!
93  bool locSuccessFlag = false;
94  for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i)
95  {
96  const DReaction* locReaction = locAnalysisResultsVector[loc_i]->Get_Reaction();
97  if(locReaction->Get_ReactionName() != "p3pi_excl")
98  continue;
99 
100  deque<const DParticleCombo*> locPassedParticleCombos;
101  locAnalysisResultsVector[loc_i]->Get_PassedParticleCombos(locPassedParticleCombos);
102  locSuccessFlag = !locPassedParticleCombos.empty();
103  break;
104  }
105  if(!locSuccessFlag)
106  return NOERROR;
107 
108  if( WRITE_EVIO_FILE ){
109  eventWriterEVIO->Write_EVIOEvent(loop, "omega");
110 
111  }
112 
113  if( WRITE_ROOT_TREE ){
114 
115  //Recommended: Write surviving particle combinations (if any) to output ROOT TTree
116  //If no cuts are performed by the analysis actions added to a DReaction, then this saves all of its particle combinations.
117  //The event writer gets the DAnalysisResults objects from JANA, performing the analysis.
118  // string is DReaction factory tag: will fill trees for all DReactions that are defined in the specified factory
119 
120  const DEventWriterROOT* eventWriterROOT = NULL;
121  loop->GetSingle(eventWriterROOT);
122  eventWriterROOT->Fill_DataTrees(loop, "OmegaSkim");
123  }
124 
125  return NOERROR;
126 }
127 
128 //------------------
129 // erun
130 //------------------
132 {
133  // This is called whenever the run number changes, before it is
134  // changed to give you a chance to clean up before processing
135  // events from the next run number.
136  return NOERROR;
137 }
138 
139 //------------------
140 // fini
141 //------------------
143 {
144  // Called before program exit after event processing is finished.
145  return NOERROR;
146 }
147 
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
InitPlugin_t InitPlugin
string Get_ReactionName(void) const
Definition: DReaction.h:75
jerror_t fini(void)
Called after last event of last event source has been processed.
void Fill_DataTrees(JEventLoop *locEventLoop, string locDReactionTag) const
bool Write_EVIOEvent(JEventLoop *locEventLoop, string locOutputFileNameSubString) const
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.