Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 09:39:17

0001 #pragma once
0002 
0003 #include "event_aligner.h"
0004 #include "waveform_builder.h"
0005 
0006 #include <cstdint>
0007 #include <vector>
0008 #include <list>
0009 #include <string>
0010 
0011 #include <TROOT.h>
0012 #include <TFile.h>
0013 #include <TTree.h>
0014 
0015 class event_writer {
0016 private:
0017     // Tree variables
0018     struct tree_vars {
0019         uint event_number;
0020         uint *timestamps;   // The four timestamps for the first sample of each event
0021 
0022         // Raw waveform
0023         uint *adc_block;
0024         uint *toa_block;
0025         uint *tot_block;
0026 
0027         uint **samples_adc;
0028         uint **samples_toa;
0029         uint **samples_tot;
0030 
0031         // Hit location
0032         uint *hit_x;
0033         uint *hit_y;
0034         uint *hit_z;
0035         bool *good_channel;
0036 
0037         // Some processing to quickly draw results
0038         uint *hit_max;
0039         uint *hit_pedestal;
0040     };
0041     tree_vars event_values;
0042 
0043     int num_kcu;
0044     int num_samples;
0045     int num_channels;
0046     int event_number;
0047 
0048     std::string file_name;
0049     TFile *file;
0050     TTree *tree;
0051 
0052     bool decode_position(int channel, int &x, int &y, int &z);
0053 
0054 public:
0055     event_writer(const std::string &file_name);
0056     ~event_writer();
0057 
0058     void write_event(aligned_event *event);
0059     void close();
0060 };