Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
tstfadc_main.cxx
Go to the documentation of this file.
1#include <iostream>
2#include <fstream>
3#include <cstdlib>
4#include <cstdio>
5#include <numeric>
6#include <vector>
7#include <ctime>
8#include "THaCodaFile.h"
9#include "CodaDecoder.h"
10#include "Fadc250Module.h"
11#include "TString.h"
12#include "TROOT.h"
13#include "TFile.h"
14#include "TH1.h"
15#include "TH2.h"
16#include "TDirectory.h"
17#include "TGraph.h"
18#include "TMultiGraph.h"
19#include "TRandom3.h"
20#include "TCanvas.h"
21
22//#define DEBUG
23//#define WITH_DEBUG
24
25static const uint32_t SLOTMIN = 1;
26static const uint32_t NUMSLOTS = 22;
27static const uint32_t NADCCHAN = 16;
28static const uint32_t NUMRAWEVENTS = 1000;
29static const uint32_t NPED = 4;
30static const uint32_t NPEAK = 4;
31
32using namespace std;
33using namespace Decoder;
34
46
47static int fadc_mode_const;
48
49void GeneratePlots(Int_t mode, uint32_t islot, uint32_t chan) {
50 // Mode Directory
51 mode_dir = dynamic_cast <TDirectory*> (hfile->Get(Form("mode_%d_data", mode)));
52 if( !mode_dir ) {
53 mode_dir = hfile->mkdir(Form("mode_%d_data", mode));
54 mode_dir->cd();
55 } else
56 hfile->cd(Form("/mode_%d_data", mode));
57 // Slot directory
58 slot_dir[islot] = dynamic_cast <TDirectory*> (mode_dir->Get(Form("slot_%u", islot)));
59 if( !slot_dir[islot] ) {
60 slot_dir[islot] = mode_dir->mkdir(Form("slot_%u", islot));
61 slot_dir[islot]->cd();
62 } else
63 hfile->cd(Form("/mode_%d_data/slot_%u", mode, islot));
64 if (mode != 1) {
65 if( !h2_pinteg[islot] )
66 h2_pinteg[islot] = new TH2I("h2_pinteg", Form(
67 "FADC Mode %d Pulse Integral Data Slot %u; Channel Number; FADC Units (Channels)", mode, islot), 16, -0.5, 15.5,
68 4096, 0, 40095);
69 if( !h2_ptime[islot] )
70 h2_ptime[islot] = new TH2I("h2_ptime", Form(
71 "FADC Mode %d Pulse Time Data Slot %u; Channel Number; FADC Units (Channels)", mode, islot), 16, -0.5, 15.5,
72 40096, 0, 40095);
73 if( !h2_pped[islot] )
74 h2_pped[islot] = new TH2I("h2_pped", Form(
75 "FADC Mode %d Pulse Pedestal Data Slot %u; Channel Number; FADC Units (Channels)", mode, islot), 16, -0.5, 15.5,
76 4096, 0, 4095);
77 if( !h2_ppeak[islot] )
78 h2_ppeak[islot] = new TH2I("h2_ppeak", Form(
79 "FADC Mode %d Pulse Peak Data Slot %u; Channel Number; FADC Units (Channels)", mode, islot), 16, -0.5, 15.5,
80 4096, 0, 4095);
81 }
82 // Channel directory
83 chan_dir[chan] = dynamic_cast <TDirectory*> (slot_dir[islot]->Get(Form("chan_%u", chan)));
84 if( !chan_dir[chan] ) {
85 chan_dir[chan] = slot_dir[islot]->mkdir(Form("chan_%u", chan));
86 chan_dir[chan]->cd();
87 } else
88 hfile->cd(Form("/mode_%d_data/slot_%u/chan_%u", mode, islot, chan));
89 // Histos
90 if( !h_pinteg[islot][chan] ) h_pinteg[islot][chan] = new TH1I("h_pinteg", Form(
91 "FADC Mode %d Pulse Integral Data Slot %u Channel %u; FADC Units (Channels); Counts / 10 Channels", mode, islot,
92 chan), 4096, 0, 40095);
93 if( mode != 1 ) {
94 if( !h_ptime[islot][chan] )
95 h_ptime[islot][chan] = new TH1I("h_ptime", Form(
96 "FADC Mode %d Pulse Time Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel", mode, islot, chan),
97 40096, 0, 40095);
98 if( !h_pped[islot][chan] )
99 h_pped[islot][chan] = new TH1I("h_pped", Form(
100 "FADC Mode %d Pulse Pedestal Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel", mode, islot,
101 chan), 4096, 0, 4095);
102 if( !h_ppeak[islot][chan] )
103 h_ppeak[islot][chan] = new TH1I("h_ppeak", Form(
104 "FADC Mode %d Pulse Peak Data Slot %u Channel %u; FADC Units (Channels); Counts / Channel", mode, islot, chan),
105 4096, 0, 4095);
106 }
107 // Graphs
108 if( !mg_psamp[islot][chan] && ((mode == 1) || (mode == 8) || (mode == 10)) ) {
109 mg_psamp[islot][chan] = new TMultiGraph("samples", "samples");
110 for( uint32_t ipeak = 0; ipeak < NPEAK; ipeak++ )
111 mg_psamp_npeak[islot][chan][ipeak] = new TMultiGraph(Form("samples_npeak_%u", ipeak + 1),
112 Form("samples_npeak_%u", ipeak + 1));
113 }
114 // Canvas'
115 if( !c_psamp[islot][chan] && ((mode == 1) || (mode == 8) || (mode == 10)) ) {
116 c_psamp[islot][chan] = new TCanvas(Form("c_psamp_slot_%u_chan_%u", islot, chan),
117 Form("c_psamp_slot_%u_chan_%u", islot, chan), 800, 800);
118 c_psamp[islot][chan]->Divide(5, 5);
119 for( uint32_t ipeak = 0; ipeak < NPEAK; ipeak++ ) {
120 c_psamp_npeak[islot][chan][ipeak] = new TCanvas(Form("c_psamp_npeak_%u_slot_%u_chan_%u", ipeak + 1, islot, chan),
121 Form("c_psamp_npeak_%u_slot_%u_chan_%u", ipeak + 1, islot, chan),
122 800, 800);
123 c_psamp_npeak[islot][chan][ipeak]->Divide(5, 5);
124 }
125 }
126 // Raw samples directories & graphs
127 if( (mode == 1) || (mode == 8) || (mode == 10) ) {
128 raw_samples_dir[chan] = dynamic_cast <TDirectory*> (chan_dir[chan]->Get("raw_samples"));
129 if( !raw_samples_dir[chan] ) {
130 raw_samples_dir[chan] = chan_dir[chan]->mkdir("raw_samples");
132 } else
133 hfile->cd(Form("/mode_%d_data/slot_%u/chan_%u/raw_samples", mode, islot, chan));
134 for( uint32_t raw_index = 0; raw_index < NUMRAWEVENTS; raw_index++ ) {
135 if( !g_psamp_event[islot][chan][raw_index] ) {
136 g_psamp_event[islot][chan][raw_index] = new TGraph();
137 g_psamp_event[islot][chan][raw_index]->SetName(Form("g_psamp_event_%u", raw_index));
138 }
139 }
140 for( uint32_t ipeak = 0; ipeak < NPEAK; ipeak++ ) {
141 raw_samples_npeak_dir[chan][ipeak] = dynamic_cast <TDirectory*> (chan_dir[chan]->Get(
142 Form("raw_samples_npeak_%u", ipeak + 1)));
143 if( !raw_samples_npeak_dir[chan][ipeak] ) {
144 raw_samples_npeak_dir[chan][ipeak] = chan_dir[chan]->mkdir(Form("raw_samples_npeak_%u", ipeak + 1));
145 raw_samples_npeak_dir[chan][ipeak]->cd();
146 } else
147 hfile->cd(Form("/mode_%d_data/slot_%u/chan_%u/raw_samples_npeak_%u", mode, islot, chan, ipeak + 1));
148 for( uint32_t raw_index = 0; raw_index < NUMRAWEVENTS; raw_index++ ) {
149 if( !g_psamp_npeak_event[islot][chan][ipeak][raw_index] ) {
150 g_psamp_npeak_event[islot][chan][ipeak][raw_index] = new TGraph();
151 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetName(
152 Form("g_psamp_npeak_%u_event_%u", ipeak + 1, raw_index));
153 }
154 }
155 }
156 }
157}
158
159UInt_t SumVectorElements(const vector<uint32_t>& data_vector) {
160 UInt_t sum_of_elements = accumulate(data_vector.begin(), data_vector.end(), 0U);
161 return sum_of_elements;
162}
163
164int main(int /* argc */, char** /* argv */)
165{
166
167 Int_t runNumber = 0;
168 Int_t maxEvent = 0;
169 Int_t crateNumber = 0;
170 TString spectrometer = "";
171 TString fileLocation = "";
172 TString runFile, rootFile;
173
174 // Acquire run number, max number of events, spectrometer name, and crate number
175 if (fileLocation == "") {
176 cout << "\nEnter the location of the raw CODA file (raw or cache): ";
177 cin >> fileLocation;
178 if (fileLocation != "raw" && fileLocation != "cache") {
179 cerr << "...Invalid entry\n";
180 return 1;
181 }
182 }
183 if (runNumber == 0) {
184 cout << "\nEnter a Run Number (-1 to exit): ";
185 cin >> runNumber;
186 if (runNumber <= 0) {
187 cerr << "...Invalid entry\n" << endl;
188 return 1;
189 }
190 }
191 if (maxEvent == 0) {
192 cout << "\nEnter Number of Events to Analyze (-1 = All): ";
193 cin >> maxEvent;
194 if (maxEvent <= 0 && maxEvent != -1) {
195 cerr << "...Invalid entry\n" << endl;
196 return 1;
197 }
198 if (maxEvent == -1)
199 cout << "\nAll Events in Run " << runNumber << " Will be Analyzed" << endl;
200 }
201 if (spectrometer == "") {
202 cout << "\nEnter the Spectrometer Name (hms or shms): ";
203 cin >> spectrometer;
204 if (spectrometer != "hms" && spectrometer != "shms") {
205 cerr << "...Invalid entry\n";
206 return 1;
207 }
208 }
209 if (crateNumber == 0) {
210 cout << "\nEnter the Crate Number to be Analyzed: ";
211 cin >> crateNumber;
212 if (crateNumber <= 0) {
213 cerr << "...Invalid entry\n";
214 return 1;
215 }
216 }
217
218 // Create file name patterns
219 if (fileLocation == "raw")
220 runFile = fileLocation+"/";
221 if (fileLocation == "cache")
222 runFile = fileLocation+"/";
223 if (spectrometer == "hms")
224 runFile += Form("hms_all_%05d.dat", runNumber);
225 if (spectrometer == "shms")
226 runFile += Form("shms_all_%05d.dat", runNumber);
227 rootFile = Form("ROOTfiles/raw_fadc_%d.root", runNumber);
228
229 // Initialize raw samples index array
230 memset(raw_samp_index, 0, sizeof(raw_samp_index));
231 memset(raw_samp_npeak_index, 0, sizeof(raw_samp_npeak_index));
232
233 // Initialize the analysis clock
234 clock_t t = clock();
235
236 // Define the data file to be analyzed
237 TString filename(runFile);
238
239 // Define the analysis debug output
240 auto *debugfile = new ofstream;
241 // debugfile->open ("tstfadc_main_debug.txt");
242
243 // Initialize the CODA decoder
244 THaCodaFile datafile;
245 if (datafile.codaOpen(filename) != CODA_OK) {
246 cerr << "ERROR: Cannot open CODA data" << endl;
247 cerr << "Perhaps you mistyped it" << endl;
248 cerr << "... exiting." << endl;
249 exit(2);
250 }
251 auto *evdata = new CodaDecoder();
252 evdata->SetCodaVersion(datafile.getCodaVersion());
253
254 // Initialize the evdata debug output
255 evdata->SetDebug(1);
256 evdata->SetDebugFile(debugfile);
257
258 // Initialize root and output
259 TROOT fadcana("tstfadcroot", "Hall C analysis");
260 hfile = new TFile("fadc_data.root", "RECREATE", "fadc module data");
261
262 // Set the number of event to be analyzed
263 uint32_t iievent = (maxEvent == -1) ? 1 : maxEvent;
264 // Loop over events
265 for(uint32_t ievent = 0; ievent < iievent; ievent++) {
266 // Read in data file
267 Int_t status = datafile.codaRead();
268 if (status == CODA_OK) {
269 status = evdata->LoadEvent(datafile.getEvBuffer());
270 if( status != CodaDecoder::HED_OK && status != CodaDecoder::HED_WARN ) {
271 cerr << "ERROR " << status << " while decoding event " << ievent
272 << ". Exiting." << endl;
273 break;
274 }
275 // Loop over slots
276 for(uint32_t islot = SLOTMIN; islot < NUMSLOTS; islot++) {
277 if (evdata->GetNumRaw(crateNumber, islot) != 0) {
278 auto *fadc =
279 dynamic_cast <Fadc250Module*> (evdata->GetModule(crateNumber, islot));
280 if (fadc != nullptr) {
281 //fadc->CheckDecoderStatus();
282 // Loop over channels
283 for (uint32_t chan = 0; chan < NADCCHAN; chan++) {
284 // Acquire the FADC mode
285 Int_t fadc_mode = fadc->GetFadcMode(); fadc_mode_const = fadc_mode;
286 if (debugfile) *debugfile << "Channel " << chan << " is in FADC Mode " << fadc_mode << endl;
287 Bool_t raw_mode = ((fadc_mode == 1) || (fadc_mode == 8) || (fadc_mode == 10));
288
289 // Acquire the number of FADC events
290 UInt_t num_fadc_events = fadc->GetNumFadcEvents(chan);
291 // If in raw mode, acquire the number of FADC samples
292 UInt_t num_fadc_samples = 0;
293 if (raw_mode) {
294 num_fadc_samples = fadc->GetNumFadcSamples(chan, ievent);
295 }
296 if (num_fadc_events > 0) {
297 // Generate FADC plots
298 GeneratePlots(fadc_mode, islot, chan);
299 for (UInt_t jevent = 0; jevent < num_fadc_events; jevent++) {
300 // Debug output
301 if (debugfile) {
302 if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0)
303 *debugfile << "FADC EMULATED PI DATA = " << fadc->GetEmulatedPulseIntegralData(chan) << endl;
304 if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
305 if( fadc_mode != 8 )
306 *debugfile << "FADC PI DATA = " << fadc->GetPulseIntegralData(chan, jevent) << endl;
307 *debugfile << "FADC PT DATA = " << fadc->GetPulseTimeData(chan, jevent) << endl;
308 *debugfile << "FADC PPED DATA = " << fadc->GetPulsePedestalData(chan, jevent) / NPED << endl;
309 *debugfile << "FADC PPEAK DATA = " << fadc->GetPulsePeakData(chan, jevent) << endl;
310 }
311 }
312 // Fill histos
313 if ((fadc_mode == 1 || fadc_mode == 8) && num_fadc_samples > 0)
314 h_pinteg[islot][chan]->Fill(fadc->GetEmulatedPulseIntegralData(chan));
315 else if (fadc_mode == 7 || fadc_mode == 8 || fadc_mode == 9 || fadc_mode == 10) {
316 if (fadc_mode != 8) {
317 h_pinteg[islot][chan]->Fill(fadc->GetPulseIntegralData(chan, jevent));
318 } else {
319 h_pinteg[islot][chan]->Fill(fadc->GetEmulatedPulseIntegralData(chan));
320 }
321 h_ptime[islot][chan]->Fill(fadc->GetPulseTimeData(chan, jevent));
322 h_pped[islot][chan]->Fill(fadc->GetPulsePedestalData(chan, jevent) / NPED);
323 h_ppeak[islot][chan]->Fill(fadc->GetPulsePeakData(chan, jevent));
324 // 2D Histos
325 if (fadc_mode != 8) {
326 h2_pinteg[islot]->Fill(chan, fadc->GetPulseIntegralData(chan, jevent));
327 } else {
328 h2_pinteg[islot]->Fill(chan, fadc->GetEmulatedPulseIntegralData(chan));
329 }
330 h2_ptime[islot]->Fill(chan, fadc->GetPulseTimeData(chan, jevent));
331 h2_pped[islot]->Fill(chan, fadc->GetPulsePedestalData(chan, jevent) / NPED);
332 h2_ppeak[islot]->Fill(chan, fadc->GetPulsePeakData(chan, jevent));
333 }
334 // Raw sample events
335 if (raw_mode && num_fadc_samples > 0) {
336 // Debug output
337 if (debugfile) *debugfile << "NUM FADC SAMPLES = " << num_fadc_samples << endl;
338 // Acquire the raw samples vector and populate graphs
339 raw_samples_vector[islot][chan] = fadc->GetPulseSamplesVector(chan);
340 for (uint32_t ipeak = 0; ipeak < NPEAK; ipeak++) {
341 if (uint32_t (num_fadc_events) == ipeak+1)
342 raw_samples_npeak_vector[islot][chan][ipeak] = fadc->GetPulseSamplesVector(chan);
343 }
344 if (raw_samp_index[islot][chan] < NUMRAWEVENTS) {
345 for (uint32_t sample_num = 0; sample_num < raw_samples_vector[islot][chan].size(); sample_num++) {
347 static_cast<Int_t>(sample_num), sample_num + 1,
348 raw_samples_vector[islot][chan][sample_num]);
349 }
350 mg_psamp[islot][chan]->Add(g_psamp_event[islot][chan][raw_samp_index[islot][chan]], "ACP");
351 raw_samp_index[islot][chan] += 1;
352 } // NUMRAWEVENTS condition
353 for (uint32_t ipeak = 0; ipeak < NPEAK; ipeak++) {
354 if (num_fadc_events == ipeak+1) {
355 if (raw_samp_npeak_index[islot][chan][ipeak] < NUMRAWEVENTS) {
356 for (uint32_t sample_num = 0; sample_num < raw_samples_npeak_vector[islot][chan][ipeak].size(); sample_num++) {
357 g_psamp_npeak_event[islot][chan][ipeak][raw_samp_npeak_index[islot][chan][ipeak]]->SetPoint(
358 static_cast<Int_t>(sample_num), sample_num + 1,
359 raw_samples_npeak_vector[islot][chan][ipeak][sample_num]);
360 }
361 mg_psamp_npeak[islot][chan][ipeak]->Add(g_psamp_npeak_event[islot][chan][ipeak][raw_samp_npeak_index[islot][chan][ipeak]], "ACP");
362 raw_samp_npeak_index[islot][chan][ipeak] += 1;
363 } // NUMRAWEVENTS condition
364 } // npeak condition
365 } // npeak loop
366 } // Raw mode condition
367 } // FADC event loop
368 } // Number of FADC events condition
369 } // FADC channel loop
370 } // FADC module found condition
371 else
372 if (debugfile) *debugfile << "FADC MODULE NOT FOUND!!!" << endl;
373 } // Number raw words condition
374 } // Slot loop
375 } else if( status != EOF ) {
376 cerr << "ERROR " << status << " while reading CODA event " << ievent
377 << ". Twonk." << endl;
378 break;
379 } // CODA file read status condition
380 if (ievent % 1000 == 0 && ievent != 0)
381 cout << ievent << " events have been processed" << endl;
382 if (maxEvent == -1) iievent++;
383 if (status == EOF) break;
384 } // Event loop
385
386 // Populate waveform graphs and multigraphs and write to root file
387 auto *rand = new TRandom3();
388 for(uint32_t islot = 3; islot < NUMSLOTS; islot++) {
389 for (uint32_t chan = 0; chan < NADCCHAN; chan++) {
390 for( uint32_t raw_index = 0; raw_index < NUMRAWEVENTS; raw_index++) {
391 // Raw sample plots
392 if (g_psamp_event[islot][chan][raw_index] != nullptr) {
393 Color_t rand_int = 1 + rand->Integer(9);
394 hfile->cd(Form("/mode_%d_data/slot_%u/chan_%u/raw_samples", fadc_mode_const, islot, chan));
395 c_psamp[islot][chan]->cd(raw_index + 1);
396 g_psamp_event[islot][chan][raw_index]->Draw("ACP");
397 g_psamp_event[islot][chan][raw_index]->SetTitle(Form("FADC Mode %d Pulse Peak Data Slot %d Channel %d Event %d", fadc_mode_const, islot, chan, raw_index+1));
398 g_psamp_event[islot][chan][raw_index]->GetXaxis()->SetTitle("Sample Number");
399 g_psamp_event[islot][chan][raw_index]->GetYaxis()->SetTitle("Sample Value");
400 g_psamp_event[islot][chan][raw_index]->SetLineColor(rand_int);
401 g_psamp_event[islot][chan][raw_index]->SetMarkerColor(rand_int);
402 g_psamp_event[islot][chan][raw_index]->SetMarkerStyle(20);
403 g_psamp_event[islot][chan][raw_index]->SetDrawOption("ACP");
404 } // Graph condition
405 } // Raw event loop
406 // Write the canvas to file
407 if (c_psamp[islot][chan] != nullptr) c_psamp[islot][chan]->Write();
408 // Write the multigraphs to file
409 if (mg_psamp[islot][chan] != nullptr) {
410 hfile->cd(Form("/mode_%d_data/slot_%d/chan_%d/raw_samples", fadc_mode_const, islot, chan));
411 mg_psamp[islot][chan]->Draw("ACP");
412 mg_psamp[islot][chan]->SetTitle(Form("%d Raw Events of FADC Mode %d Sample Data Slot %d Channel %d; Sample Number; Sample Value", raw_samp_index[islot][chan], fadc_mode_const, islot, chan));
413 mg_psamp[islot][chan]->Write();
414 } // Mulitgraph condition
415 for (uint32_t ipeak = 0; ipeak < NPEAK; ipeak++) {
416 for( uint32_t raw_index = 0; raw_index < NUMRAWEVENTS; raw_index++) {
417 // Raw sample plots
418 if (g_psamp_npeak_event[islot][chan][ipeak][raw_index] != nullptr) {
419 Color_t rand_int = 1 + rand->Integer(9);
420 hfile->cd(Form("/mode_%d_data/slot_%d/chan_%d/raw_samples_npeak_%d", fadc_mode_const, islot, chan, ipeak+1));
421 c_psamp_npeak[islot][chan][ipeak]->cd(raw_index + 1);
422 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->Draw("ACP");
423 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetTitle(Form("FADC Mode %d Pulse Peak Data Slot %d Channel %d nPeak = %d Event %d", fadc_mode_const, islot, chan, ipeak+1, raw_index+1));
424 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->GetXaxis()->SetTitle("Sample Number");
425 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->GetYaxis()->SetTitle("Sample Value");
426 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetLineColor(rand_int);
427 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetMarkerColor(rand_int);
428 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetMarkerStyle(20);
429 g_psamp_npeak_event[islot][chan][ipeak][raw_index]->SetDrawOption("ACP");
430 } // Graph condition
431 } // Raw event loop
432 // Write the canvas to file
433 if (c_psamp_npeak[islot][chan][ipeak] != nullptr) c_psamp_npeak[islot][chan][ipeak]->Write();
434 // Write the multigraphs to file
435 if (mg_psamp_npeak[islot][chan][ipeak] != nullptr) {
436 hfile->cd(Form("/mode_%d_data/slot_%d/chan_%d/raw_samples_npeak_%d", fadc_mode_const, islot, chan, ipeak+1));
437 mg_psamp_npeak[islot][chan][ipeak]->Draw("ACP");
438 mg_psamp_npeak[islot][chan][ipeak]->SetTitle(Form("%d Raw Events of FADC Mode %d Sample Data Slot %d Channel %d nPeak = %d; Sample Number; Sample Value", raw_samp_npeak_index[islot][chan][ipeak], fadc_mode_const, islot, chan, ipeak+1));
439 mg_psamp_npeak[islot][chan][ipeak]->Write();
440 } // Mulitgraph condition
441 } // npeak loop
442 } // Channel loop
443 } // Slot loop
444
445 // Write and close the data file
446 hfile->Write();
447 hfile->Close();
448 datafile.codaClose();
449
450 // Calculate the analysis rate
451 t = clock() - t;
452 printf ("The analysis took %.1f seconds \n", ((float) t) / CLOCKS_PER_SEC);
453 printf ("The analysis event rate is %.1f Hz \n", (iievent - 1) / (((float) t) / CLOCKS_PER_SEC));
454
455} // main()
int Int_t
unsigned int UInt_t
uint32_t chan
bool Bool_t
short Color_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char mode
#define CODA_OK
Definition THaCodaData.h:28
char * Form(const char *fmt,...)
virtual Int_t GetFadcMode() const
UInt_t * getEvBuffer()
Definition THaCodaData.h:76
virtual Int_t getCodaVersion()
virtual Int_t codaOpen(const char *filename, Int_t mode=1)
virtual Int_t codaClose()
virtual Int_t codaRead()
virtual void SetLineColor(Color_t lcolor)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
TVirtualPad * cd(Int_t subpadnumber=0) override
Bool_t cd() override
T * Get(const char *namecycle)
TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE) override
virtual TObject * Get(const char *namecycle)
virtual Bool_t cd()
virtual TDirectory * mkdir(const char *name, const char *title="", Bool_t returnExistingDirectory=kFALSE)
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsiz=0) const override
void Close(Option_t *option="") override
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
void SetName(const char *name="") override
void Draw(Option_t *chopt="") override
TAxis * GetXaxis() const
TAxis * GetYaxis() const
void SetTitle(const char *title="") override
virtual Int_t Fill(const char *name, Double_t w)
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
virtual void Add(TGraph *graph, Option_t *chopt="")
void Draw(Option_t *chopt="") override
virtual void SetTitle(const char *title="")
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
virtual void SetDrawOption(Option_t *option="")
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
int main()
double sum_of_elements(const LASymMatrix &)
STL namespace.
TH1I * h_pped[NUMSLOTS][NADCCHAN]
TH2I * h2_pped[NUMSLOTS]
TH2I * h2_ppeak[NUMSLOTS]
TMultiGraph * mg_psamp[NUMSLOTS][NADCCHAN]
TGraph * g_psamp_event[NUMSLOTS][NADCCHAN][NUMRAWEVENTS]
TH2I * h2_ptime[NUMSLOTS]
UInt_t SumVectorElements(const vector< uint32_t > &data_vector)
static const uint32_t NPED
TH1I * h_ppeak[NUMSLOTS][NADCCHAN]
TGraph * g_psamp_npeak_event[NUMSLOTS][NADCCHAN][NPEAK][NUMRAWEVENTS]
uint32_t raw_samp_npeak_index[NUMSLOTS][NADCCHAN][NPEAK]
static const uint32_t NPEAK
TH1I * h_ptime[NUMSLOTS][NADCCHAN]
TCanvas * c_psamp_npeak[NUMSLOTS][NADCCHAN][NPEAK]
uint32_t raw_samp_index[NUMSLOTS][NADCCHAN]
TDirectory * chan_dir[NADCCHAN]
void GeneratePlots(Int_t mode, uint32_t islot, uint32_t chan)
TDirectory * slot_dir[NUMSLOTS]
static const uint32_t NUMSLOTS
TH1I * h_pinteg[NUMSLOTS][NADCCHAN]
TDirectory * raw_samples_dir[NADCCHAN]
TCanvas * c_psamp[NUMSLOTS][NADCCHAN]
TDirectory * mode_dir
static const uint32_t NADCCHAN
TFile * hfile
TH2I * h2_pinteg[NUMSLOTS]
TDirectory * raw_samples_npeak_dir[NADCCHAN][NPEAK]
static const uint32_t SLOTMIN
TMultiGraph * mg_psamp_npeak[NUMSLOTS][NADCCHAN][NPEAK]
vector< uint32_t > raw_samples_npeak_vector[NUMSLOTS][NADCCHAN][NPEAK]
static int fadc_mode_const
static const uint32_t NUMRAWEVENTS
vector< uint32_t > raw_samples_vector[NUMSLOTS][NADCCHAN]