Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DL1Trigger_factory.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 using namespace std;
4 
5 #include <JANA/JApplication.h>
6 #include <DAQ/DCODAROCInfo.h>
7 #include <DAQ/DL1Info.h>
8 
9 using namespace jana;
10 
11 #include "DL1Trigger_factory.h"
12 
13 //------------------
14 // init
15 //------------------
17 {
18 
19  return NOERROR;
20 }
21 
22 //------------------
23 // brun
24 //------------------
25 jerror_t DL1Trigger_factory::brun(jana::JEventLoop *eventLoop, int32_t runnumber)
26 {
27  return NOERROR;
28 }
29 
30 //------------------
31 // evnt
32 //------------------
33 jerror_t DL1Trigger_factory::evnt(JEventLoop *loop, uint64_t eventnumber)
34 {
35  // The L1 trigger latch words are added as "misc" words to the
36  // Physic's Event's Built Trigger Bank. These show up in the
37  // "misc" member of the DCODAROCInfo object corresponding to the
38  // Trigger Supervisor. The TS has rocid of "1" (which will hopefully
39  // never change!)
40 
41 
42  int l1_found = 0;
43 
44  vector<const DCODAROCInfo*> codarocinfos;
45  loop->Get(codarocinfos);
46 
47  vector<const DL1Info*> l1_info;
48  loop->Get(l1_info);
49 
50  DL1Trigger *l1trigger = new DL1Trigger;
51 
52  // Physics and possibly SYNC event
53  for(uint32_t i = 0; i < codarocinfos.size(); i++){
54  const DCODAROCInfo *cri = codarocinfos[i];
55 
56  // Only interested in Trigger Supervisor
57  if(cri->rocid != 1) continue;
58 
59  if(cri->misc.size()==2){
60  // Potentially, the TS can be configured to only
61  // add the GTP latch word or only the FP latch
62  // word (or neither or both). We have no way of
63  // knowing how it was configured, but if both are
64  // read out, then the GTP word comes first. (See
65  // e-mail sent by Bryan Moffit Dec. 15, 2015).
66  l1trigger->trig_mask = cri->misc[0]; // Global Trigger Processor latch word
67  l1trigger->fp_trig_mask = cri->misc[1]; // Front Panel latch word
68  l1trigger->event_type = 1;
69  l1_found++;
70  }
71 
72  l1trigger->timestamp = cri->timestamp;
73 
74  l1trigger->AddAssociatedObject(cri);
75 
76  break; // Should only be 1 with rocid=1
77  }
78 
79  // SYNC event
80  if(l1_info.size() == 1){
81  const DL1Info *l1_sc = l1_info[0];
82  l1trigger->event_type = 2;
83  l1trigger->nsync = l1_sc->nsync;
84  l1trigger->trig_number = l1_sc->trig_number;
85  l1trigger->live = l1_sc->live_time;
86  l1trigger->busy = l1_sc->busy_time;
87  l1trigger->live_inst = l1_sc->live_inst;
88  l1trigger->unix_time = l1_sc->unix_time;
89 
90  l1trigger->gtp_sc = l1_sc->gtp_sc;
91  l1trigger->fp_sc = l1_sc->fp_sc;
92  l1trigger->gtp_rate = l1_sc->gtp_rate;
93  l1trigger->fp_rate = l1_sc->fp_rate;
94 
95  l1_found++;
96  }
97 
98 
99  if(l1_found){
100  _data.push_back(l1trigger);
101  }else{
102  delete l1trigger; // prevent memory leak
103  }
104 
105 
106 
107  return NOERROR;
108 }
109 
110 //------------------
111 // erun
112 //------------------
114 {
115  return NOERROR;
116 }
117 
118 //------------------
119 // fini
120 //------------------
122 {
123  return NOERROR;
124 }
125 
uint32_t live_inst
Definition: DL1Info.h:24
vector< uint32_t > gtp_rate
Definition: DL1Trigger.h:31
uint32_t busy
Definition: DL1Trigger.h:25
int event_type
Definition: DL1Trigger.h:14
vector< uint32_t > fp_rate
Definition: DL1Trigger.h:32
uint64_t timestamp
Definition: DCODAROCInfo.h:22
uint32_t trig_mask
Definition: DL1Trigger.h:18
uint32_t fp_trig_mask
Definition: DL1Trigger.h:19
vector< uint32_t > fp_sc
Definition: DL1Info.h:28
jerror_t fini(void)
Called after last event of last event source has been processed.
uint32_t nsync
Definition: DL1Trigger.h:22
uint32_t live_inst
Definition: DL1Trigger.h:26
uint32_t rocid
Definition: DCODAROCInfo.h:21
uint32_t live
Definition: DL1Trigger.h:24
uint32_t nsync
Definition: DL1Info.h:20
uint64_t timestamp
Definition: DL1Trigger.h:17
vector< uint32_t > fp_sc
Definition: DL1Trigger.h:30
uint32_t unix_time
Definition: DL1Info.h:25
uint32_t busy_time
Definition: DL1Info.h:23
vector< uint32_t > gtp_sc
Definition: DL1Info.h:27
vector< uint32_t > gtp_sc
Definition: DL1Trigger.h:29
uint32_t live_time
Definition: DL1Info.h:22
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
uint32_t trig_number
Definition: DL1Info.h:21
vector< uint32_t > misc
Definition: DCODAROCInfo.h:23
vector< uint32_t > fp_rate
Definition: DL1Info.h:30
uint32_t trig_number
Definition: DL1Trigger.h:23
jerror_t init(void)
Called once at program start.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
vector< uint32_t > gtp_rate
Definition: DL1Info.h:29
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
uint32_t unix_time
Definition: DL1Trigger.h:27