Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_bigevents_skim.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_bigevents_skim.cc
4 // Created: Thu May 12 08:01:59 EDT 2016
5 // Creator: zihlmann (on Linux ifarm1401 2.6.32-431.el6.x86_64 x86_64)
6 //
7 
9 using namespace jana;
10 
11 
12 // Routine used to create our JEventProcessor
13 #include <JANA/JApplication.h>
14 #include <JANA/JFactory.h>
15 extern "C"{
16  void InitPlugin(JApplication *app){
17  InitJANAPlugin(app);
18  app->AddProcessor(new JEventProcessor_bigevents_skim());
19  }
20 } // "C"
21 
22 
23 //------------------
24 // JEventProcessor_bigevents_skim (Constructor)
25 //------------------
27 {
28 
29 }
30 
31 //------------------
32 // ~JEventProcessor_bigevents_skim (Destructor)
33 //------------------
35 {
36 
37 }
38 
39 //------------------
40 // init
41 //------------------
43 {
44  // This is called once at program startup. If you are creating
45  // and filling historgrams in this plugin, you should lock the
46  // ROOT mutex like this:
47  //
48  // japp->RootWriteLock();
49  // ... fill historgrams or trees ...
50  // japp->RootUnLock();
51  //
52 
53  return NOERROR;
54 }
55 
56 //------------------
57 // brun
58 //------------------
59 jerror_t JEventProcessor_bigevents_skim::brun(JEventLoop *eventLoop, int32_t runnumber)
60 {
61  // This is called whenever the run number changes
62  return NOERROR;
63 }
64 
65 //------------------
66 // evnt
67 //------------------
68 jerror_t JEventProcessor_bigevents_skim::evnt(JEventLoop *loop, uint64_t eventnumber)
69 {
70  // This is called for every event. Use of common resources like writing
71  // to a file or filling a histogram should be mutex protected. Using
72  // loop->Get(...) to get reconstructed objects (and thereby activating the
73  // reconstruction algorithm) should be done outside of any mutex lock
74  // since multiple threads may call this method at the same time.
75  // Here's an example:
76  //
77  // vector<const MyDataClass*> mydataclasses;
78  // loop->Get(mydataclasses);
79  //
80  // japp->RootWriteLock();
81  // ... fill historgrams or trees ...
82  // japp->RootUnLock();
83 
84  const DEventWriterEVIO* locEventWriterEVIO = NULL;
85  loop->GetSingle(locEventWriterEVIO);
86  // write out BOR events
87  if(loop->GetJEvent().GetStatusBit(kSTATUS_BOR_EVENT)) {
88  locEventWriterEVIO->Write_EVIOEvent(loop, "bigevents");
89  return NOERROR;
90  }
91  // write out EPICS events
92  if(loop->GetJEvent().GetStatusBit(kSTATUS_EPICS_EVENT)) {
93  locEventWriterEVIO->Write_EVIOEvent(loop, "bigevents");
94  return NOERROR;
95  }
96 
97  // get trigger types
98  const DL1Trigger *trig_words = NULL;
99  uint32_t trig_mask;
100  //uint32_t fp_trig_mask;
101  try {
102  loop->GetSingle(trig_words);
103  } catch(...) {};
104  if (trig_words) {
105  trig_mask = trig_words->trig_mask;
106  //fp_trig_mask = trig_words->fp_trig_mask;
107  }
108  else {
109  trig_mask = 0;
110  //fp_trig_mask = 0;
111  }
112 
113  if (!(trig_mask & 0x4)){
114  return NOERROR;
115  }
116 
117  vector <const DCDCDigiHit*> CDCHits;
118  loop->Get(CDCHits);
119 
120  if (CDCHits.size() > 2000) { // huge event lets keep it!
121 
122  locEventWriterEVIO->Write_EVIOEvent(loop, "bigevents");
123 
124  }
125 
126 
127 
128  return NOERROR;
129 }
130 
131 //------------------
132 // erun
133 //------------------
135 {
136  // This is called whenever the run number changes, before it is
137  // changed to give you a chance to clean up before processing
138  // events from the next run number.
139  return NOERROR;
140 }
141 
142 //------------------
143 // fini
144 //------------------
146 {
147  // Called before program exit after event processing is finished.
148  return NOERROR;
149 }
uint32_t trig_mask
Definition: DL1Trigger.h:18
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
jerror_t fini(void)
Called after last event of last event source has been processed.
InitPlugin_t InitPlugin
jerror_t init(void)
Called once at program start.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
bool Write_EVIOEvent(JEventLoop *locEventLoop, string locOutputFileNameSubString) const