Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaGenDetTest.cxx
Go to the documentation of this file.
1
2//
3// THaGenDetTest
4// General Detector Test of Decoder
5//
6// THaGenDetTest is an illustrative example of how to use
7// the Hall A C++ data I/O and decoder classes for
8// a detector class one might develop.
9// This is also used to measure the baseline speed
10// of I/O and decoder.
11// This is a "throw away" test code.
12//
13// author Robert Michaels (rom@jlab.org)
14//
16
17#include "THaGenDetTest.h"
18#include "THaEvData.h"
19
20//#define SIMPLELOOP
21
22#define PRINTOUT 1 // to printout or not
23
24using namespace std;
25
26THaGenDetTest::THaGenDetTest() : mycrates{}, myslots{}, chanlo{}, chanhi{}
27{
28}
29
31{
32// Set up my detector. I have to know what crate, slots, and
33// channels belong to my detector. Here "my detector" is
34// the scint and VDC on both arms.
35
36 for (auto& mycrate : mycrates) mycrate=0;
37
38 // E-arm Scintillators
39 mydevice[0] = "E-arm S1 ADCs on Left PMTs";
40 mycrates[0] = 1;
41 myslots[0] = 25;
42 chanlo[0] = 0; chanhi[0] = 5;
43 mydevice[1] = "E-arm S1 ADCs on Right PMTs";
44 mycrates[1] = 1;
45 myslots[1] = 25;
46 chanlo[1] = 48; chanhi[1] = 53;
47 mydevice[2] = "E-arm S2 ADCs on Left PMTs";
48 mycrates[2] = 1;
49 myslots[2] = 25;
50 chanlo[2] = 6; chanhi[2] = 11;
51 mydevice[3] = "E-arm S2 ADCs on Right PMTs";
52 mycrates[3] = 1;
53 myslots[3] = 25;
54 chanlo[3] = 54; chanhi[3] = 59;
55
56 mydevice[4] = "E-arm S1 TDCs on Left PMTs";
57 mycrates[4] = 1;
58 myslots[4] = 20;
59 chanlo[4] = 16; chanhi[4] = 21;
60 mydevice[5] = "E-arm S1 TDCs on Right PMTs";
61 mycrates[5] = 1;
62 myslots[5] = 20;
63 chanlo[5] = 32; chanhi[5] = 37;
64 mydevice[6] = "E-arm S2 TDCs on Left PMTs";
65 mycrates[6] = 1;
66 myslots[6] = 20;
67 chanlo[6] = 22; chanhi[6] = 27;
68 mydevice[7] = "E-arm S2 TDCs on Right PMTs";
69 mycrates[7] = 1;
70 myslots[7] = 20;
71 chanlo[7] = 38; chanhi[7] = 43;
72
73 // H-arm Scintillators
74 mydevice[8] = "H-arm S1 ADCs on Left PMTs";
75 mycrates[8] = 2;
76 myslots[8] = 25;
77 chanlo[8] = 0; chanhi[8] = 5;
78 mydevice[9] = "H-arm S1 ADCs on Right PMTs";
79 mycrates[9] = 2;
80 myslots[9] = 25;
81 chanlo[9] = 16; chanhi[9] = 21;
82 mydevice[10] = "H-arm S2 ADCs on Left PMTs";
83 mycrates[10] = 2;
84 myslots[10] = 25;
85 chanlo[10] = 6; chanhi[10] = 11;
86 mydevice[11] = "H-arm S2 ADCs on Right PMTs";
87 mycrates[11] = 2;
88 myslots[11] = 25;
89 chanlo[11] = 22; chanhi[11] = 27;
90
91 mydevice[12] = "H-arm S1 TDCs on Left PMTs";
92 mycrates[12] = 2;
93 myslots[12] = 23;
94 chanlo[12] = 0; chanhi[12] = 5;
95 mydevice[13] = "H-arm S1 TDCs on Right PMTs";
96 mycrates[13] = 2;
97 myslots[13] = 23;
98 chanlo[13] = 16; chanhi[13] = 21;
99 mydevice[14] = "H-arm S2 TDCs on Left PMTs";
100 mycrates[14] = 2;
101 myslots[14] = 23;
102 chanlo[14] = 6; chanhi[14] = 11;
103 mydevice[15] = "H-arm S2 TDCs on Right PMTs";
104 mycrates[15] = 2;
105 myslots[15] = 23;
106 chanlo[15] = 22; chanhi[15] = 27;
107
108 // E-arm VDCs
109 for (int i=0; i<16; i++) {
110 mydevice[i+16] = "E-arm VDCs";
111 mycrates[i+16] = 1;
112 myslots[i+16] = i+4;
113 chanlo[i+16] = 0;
114 chanhi[i+16] = 95;
115 if (((i+1)%4) == 0) chanhi[i+16]=79;
116 }
117
118 // H-arm VDCs
119 for (int i=0; i<16; i++) {
120 mydevice[i+33] = "H-arm VDCs";
121 mycrates[i+33] = 2;
122 myslots[i+33] = i+6;
123 chanlo[i+33] = 0;
124 chanhi[i+33] = 95;
125 if (((i+1)%4) == 0) chanhi[i+33]=79;
126 }
127
128 // mycrates[50] = 14;
129
130}
131
133{
134#ifdef PRINTOUT
135 cout << "\n\n------------------------------------------------"<<endl;
136 cout << "Event type " << dec << evdata->GetEvType() << endl;
137 cout << "Event length " << evdata->GetEvLength() << endl;
138 cout << "Event number " << evdata->GetEvNum() << endl;
139 cout << "Run number " << evdata->GetRunNum() << endl;
140 if (evdata->IsPhysicsTrigger()) cout << "Physics trigger" << endl;
141 if (evdata->IsScalerEvent()) cout << "Scaler event" << endl;
142 if (evdata->IsEpicsEvent()) cout << "Epics data" << endl;
143 if (evdata->IsPrescaleEvent()) {
144 cout << "Prescale data: \n Trig Prescale factor" << endl;
145 for (int trig = 1; trig<=8; trig++) {
146 cout << dec << " " << trig << " ";
147 cout << evdata->GetPrescaleFactor(trig) << endl;
148 }
149 }
150 if (evdata->IsScalerEvent()) {
151 cout << "Scaler data. (it will remain static until";
152 cout << " next scaler event): "<<endl;
153//FIXME: needs update for Podd 1.6+
154 cout << "Scaler handling not (yet) implemented in this example class" << endl;
155#if 0
156 for (unsigned sca = 0; sca < 3; sca++) { // 1st 3 scaler banks, left spectrom.
157 for (unsigned cha = 0; cha < 16; cha++) {
158 cout << "Scaler " << dec << sca << " channel " << cha;
159 cout << " data = (decimal) " << evdata->GetScaler("left",sca,cha);
160 cout << " data = (hex) "<<hex<<evdata->GetScaler("left",sca,cha)<<endl;
161 }
162 }
163#endif
164 }
165#endif // PRINTOUT
166 if (evdata->IsEpicsEvent()) {
167//FIXME: needs update for Podd 1.6+
168#ifdef PRINTOUT
169 cout << "EPICS data handling not (yet) implemented in this example class" << endl;
170#if 0
171 cout << "BPM 3A, X IPM1H03A.XPOS = ";
172 cout << evdata->GetEpicsData("IPM1H03A.XPOS")<<endl;
173 cout << "BPM 3A, Y IPM1H03A.YPOS = ";
174 cout << evdata->GetEpicsData("IPM1H03A.YPOS")<<endl;
175 cout << "BPM 3B, X IPM1H03B.XPOS = ";
176 cout << evdata->GetEpicsData("IPM1H03B.XPOS")<<endl;
177 cout << "BPM 3B, Y IPM1H03B.YPOS = ";
178 cout << evdata->GetEpicsData("IPM1H03B.YPOS")<<endl;
179 cout << "Avg of 2 BCM, hac_bcm_average = ";
180 cout << evdata->GetEpicsData("hac_bcm_average")<<endl;
181 cout << "Energy halla_MeV = ";
182 cout << evdata->GetEpicsData("halla_MeV")<<endl;
183#endif
184 }
185#endif
186 if (!evdata->IsPhysicsTrigger()) return;
187#if 0
188#ifdef PRINTOUT
189 unsigned crate = 16;
190 cout << "-------- Test of RICH raw data ---------"<<endl;
191 for (unsigned slot = 1; slot <= 16; slot++) { // Actually ADCs (2 ADCs per 8 VME slots)
192 cout << "Slot "<<slot<<endl;
193 for (unsigned chan = 0; chan < 500; chan++) { // channel numbers start at 0
194 cout<<"channel "<<chan<<" num hits "<<evdata->GetNumHits(crate,slot,chan)<<endl;
195 for (unsigned hit = 0; hit < evdata->GetNumHits(crate,slot,chan); hit++) {
196 cout << " ADC data = "<<evdata->GetData(crate,slot,chan,hit)<<endl;
197 }
198 }
199 }
200#endif
201#endif
202 unsigned long sum = 0;
203 for (unsigned j = 0; j < MAX; j++) {
204 if (!mycrates[j]) continue;
205 unsigned crate = mycrates[j];
206 unsigned slot = myslots[j];
207 // if (PRINTOUT) evdata->PrintSlotData(crate,slot);
208 bool firstone = true;
209
210// Two ways to retrieve the data: 1) simple loop over all channels,
211// and 2) loop over list of unique channels which were hit (faster).
212
213#ifdef SIMPLELOOP
214 for (unsigned chan = chanlo[j]; chan <= chanhi[j]; chan++) {
215#else
216 for (unsigned list = 0; list < evdata->GetNumChan(crate,slot); list++) {
217 unsigned chan = evdata->GetNextChan(crate,slot,list);
218#endif
219 if (( chan > chanhi[j]) || (chan < chanlo[j])) continue;
220 for (unsigned hit = 0; hit < evdata->GetNumHits(crate,slot,chan); hit++) {
221 unsigned data = evdata->GetData(crate,slot,chan,hit);
222#ifdef PRINTOUT
223 if(firstone) {
224 cout << "\n Data in " << mydevice[j]<<" / ";
225 cout << "crate "<<dec<<crate<<" / slot "<<slot<<endl;
226 firstone = false;
227 }
228 cout << "channel " << dec << chan << " hit # " << hit;
229 cout << " data (decimal) = " << data;
230 cout << " data (hex) = " << hex << data << endl;
231#endif
232 if (sum < 200000000) sum += data; // Do something with data...
233 }
234 }
235 }
236}
237
uint32_t chan
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
UInt_t GetEvType() const
Definition THaEvData.h:53
Bool_t IsEpicsEvent() const
Definition THaEvData.h:367
Bool_t IsPhysicsTrigger() const
Definition THaEvData.h:348
virtual UInt_t GetScaler(UInt_t, UInt_t, UInt_t) const
Definition THaEvData.h:110
Bool_t IsPrescaleEvent() const
Definition THaEvData.h:372
UInt_t GetNumHits(UInt_t crate, UInt_t slot, UInt_t chan) const
Definition THaEvData.h:264
virtual UInt_t GetPrescaleFactor(UInt_t) const
Definition THaEvData.h:105
UInt_t GetNextChan(UInt_t crate, UInt_t slot, UInt_t index) const
Definition THaEvData.h:339
UInt_t GetEvNum() const
Definition THaEvData.h:56
UInt_t GetNumChan(UInt_t crate, UInt_t slot) const
Definition THaEvData.h:331
UInt_t GetRunNum() const
Definition THaEvData.h:57
UInt_t GetEvLength() const
Definition THaEvData.h:54
Bool_t IsScalerEvent() const
Definition THaEvData.h:354
UInt_t GetData(UInt_t crate, UInt_t slot, UInt_t chan, UInt_t hit) const
Definition THaEvData.h:273
virtual double GetEpicsData(const char *tag, UInt_t event=0) const
Definition THaEvData.h:406
static const unsigned MAX
unsigned mycrates[MAX]
void process_event(THaEvData *evdata)
unsigned myslots[MAX]
TString mydevice[MAX]
unsigned chanlo[MAX]
unsigned chanhi[MAX]
STL namespace.