Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_ps_skim.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_ps_skim.cc
4 // Created: Mon May 18 09:52:08 EDT 2015
5 // Creator: nsparks (on Linux cua2.jlab.org 2.6.32-431.5.1.el6.x86_64 x86_64)
6 //
7 
9 using namespace jana;
10 
12 #include <TRIGGER/DL1Trigger.h>
13 
14 // Routine used to create our JEventProcessor
15 #include <JANA/JApplication.h>
16 #include <JANA/JFactory.h>
17 extern "C"{
18  void InitPlugin(JApplication *app){
19  InitJANAPlugin(app);
20  app->AddProcessor(new JEventProcessor_ps_skim());
21  }
22 } // "C"
23 
24 
25 //------------------
26 // JEventProcessor_ps_skim (Constructor)
27 //------------------
29 {
30 
31 }
32 
33 //------------------
34 // ~JEventProcessor_ps_skim (Destructor)
35 //------------------
37 {
38 
39 }
40 
41 //------------------
42 // init
43 //------------------
45 {
46 
47  return NOERROR;
48 }
49 
50 //------------------
51 // brun
52 //------------------
53 jerror_t JEventProcessor_ps_skim::brun(JEventLoop *eventLoop, int32_t runnumber)
54 {
55  // This is called whenever the run number changes
56  return NOERROR;
57 }
58 
59 //------------------
60 // evnt
61 //------------------
62 jerror_t JEventProcessor_ps_skim::evnt(JEventLoop *loop, uint64_t eventnumber)
63 {
64  const DEventWriterEVIO* locEventWriterEVIO = NULL;
65  loop->GetSingle(locEventWriterEVIO);
66  // write out BOR events
67  if(loop->GetJEvent().GetStatusBit(kSTATUS_BOR_EVENT)) {
68  locEventWriterEVIO->Write_EVIOEvent(loop, "ps");
69  return NOERROR;
70  }
71  // write out EPICS events
72  if(loop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT)) {
73  locEventWriterEVIO->Write_EVIOEvent(loop, "ps");
74  return NOERROR;
75  }
76  // get trigger types
77  const DL1Trigger *trig_words = NULL;
78  uint32_t trig_mask, fp_trig_mask;
79  try {
80  loop->GetSingle(trig_words);
81  } catch(...) {};
82  if (trig_words) {
83  trig_mask = trig_words->trig_mask;
84  fp_trig_mask = trig_words->fp_trig_mask;
85  }
86  else {
87  trig_mask = 0;
88  fp_trig_mask = 0;
89  }
90  int trig_bits = fp_trig_mask > 0 ? 10 + fp_trig_mask:trig_mask;
91  // skim PS triggers
92  if (trig_bits==8) {
93  locEventWriterEVIO->Write_EVIOEvent(loop, "ps");
94  return NOERROR;
95  }
96  return NOERROR;
97 }
98 
99 //------------------
100 // erun
101 //------------------
103 {
104  // This is called whenever the run number changes, before it is
105  // changed to give you a chance to clean up before processing
106  // events from the next run number.
107  return NOERROR;
108 }
109 
110 //------------------
111 // fini
112 //------------------
114 {
115  // Called before program exit after event processing is finished.
116  return NOERROR;
117 }
118 
uint32_t trig_mask
Definition: DL1Trigger.h:18
uint32_t fp_trig_mask
Definition: DL1Trigger.h:19
jerror_t fini(void)
Called after last event of last event source has been processed.
InitPlugin_t InitPlugin
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t init(void)
Called once at program start.
bool Write_EVIOEvent(JEventLoop *locEventLoop, string locOutputFileNameSubString) const
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.