Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DTranslationTable_factory.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DTranslationTable_factory.h
4 // Created: Thu Jun 27 15:33:38 EDT 2013
5 // Creator: davidl (on Darwin harriet.jlab.org 11.4.2 i386)
6 //
7 
8 #ifndef _DTranslationTable_factory_
9 #define _DTranslationTable_factory_
10 
11 #include <JANA/JFactory.h>
12 #include "DTranslationTable.h"
13 
14 #include <mutex>
15 
16 class DTranslationTable_factory:public jana::JFactory<DTranslationTable>{
17 
18  public:
21 
22  DTranslationTable *tt = nullptr;
23 
24  //------------------
25  // brun
26  //------------------
27  jerror_t brun(JEventLoop *loop, int32_t runnumber)
28  {
29  // Print message about table, but only once for each run
30  static std::mutex mtx;
31  mtx.lock();
32  static set<int32_t> runs_announced;
33  if( runs_announced.count(runnumber)==0 ){
34  jout << "Creating DTranslationTable for run " << runnumber << endl;
35  runs_announced.insert(runnumber);
36  }
37  mtx.unlock();
38 
39  // (See DTAGHGeometry_factory.h)
40  SetFactoryFlag(NOT_OBJECT_OWNER);
41  ClearFactoryFlag(WRITE_TO_OUTPUT);
42 
43  if( tt ) delete tt;
44 
45  tt = new DTranslationTable(loop);
46 
47  // If restricting parsing, make sure it is set for this source
48  tt->SetSystemsToParse(loop->GetJEvent().GetJEventSource());
49 
50  return NOERROR;
51  }
52 
53  //------------------
54  // evnt
55  //------------------
56  jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)
57  {
58  // Reuse existing DTranslationTable object.
59  if( tt ) _data.push_back( tt );
60 
61  return NOERROR;
62  }
63 
64  //------------------
65  // erun
66  //------------------
67  jerror_t erun(void)
68  {
69  if( tt ) delete tt;
70  tt = NULL;
71 
72  return NOERROR;
73  }
74 };
75 
76 #endif // _DTranslationTable_factory_
77 
jerror_t brun(JEventLoop *loop, int32_t runnumber)
jerror_t evnt(JEventLoop *loop, uint64_t eventnumber)
static void SetSystemsToParse(string systems, JEventSource *eventsource)