ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TPCFEETestRecov1.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TPCFEETestRecov1.h
1 /*
2  * TPCFEETestRecov1.h
3  *
4  * Created on: Sep 19, 2018
5  * Author: jinhuang
6  */
7 
8 #ifndef CORESOFTWARE_OFFLINE_PACKAGES_TPCDAQ_TPCFEETESTRECOV1_H_
9 #define CORESOFTWARE_OFFLINE_PACKAGES_TPCDAQ_TPCFEETESTRECOV1_H_
10 
11 #include <fun4all/SubsysReco.h>
12 
13 #include <TObject.h>
14 
15 #include <stdint.h>
16 #include <cmath>
17 #include <map>
18 #include <set>
19 #include <string>
20 #include <vector>
21 
22 class PHCompositeNode;
24 class TTree;
25 class TClonesArray;
26 class Event;
27 
28 namespace TPCDaqDefs
29 {
30 namespace FEEv1
31 {
32 class SampleFit_PowerLawDoubleExp_PDFMaker;
33 }
34 } // namespace TPCDaqDefs
35 
37 {
38  public:
39  TPCFEETestRecov1(const std::string &outputfilename =
40  "TPCFEETestRecov1.root");
41  virtual ~TPCFEETestRecov1();
42 
43  int Init(PHCompositeNode *topNode);
44  int InitRun(PHCompositeNode *topNode);
45  int process_event(PHCompositeNode *topNode);
46  int ResetEvent(PHCompositeNode *topNode);
47  int End(PHCompositeNode *topNode);
48 
49  void setClusteringZeroSuppression(int threshold)
50  {
51  m_clusteringZeroSuppression = threshold;
52  }
53 
54  void setNPostSample(int nPostSample)
55  {
56  m_nPostSample = nPostSample;
57  }
58 
59  void setNPreSample(int nPreSample)
60  {
61  m_nPreSample = nPreSample;
62  }
63 
65  class EventHeader : public TObject
66  {
67  public:
68  int run;
69  int event;
70 
71  uint32_t bx_counter;
73 
74  int xray_x;
75  int xray_y;
76 
78  : run(-1)
79  , event(-1)
80  , bx_counter(0)
82  , xray_x(-1)
83  , xray_y(-1)
84  {
85  }
86 
87  ClassDefOverride(TPCFEETestRecov1::EventHeader, 1)
88  };
89 
92  {
93  public:
94  PadPlaneData();
95  void Reset();
96 
97  struct SampleID
98  {
99  int pady;
100  int padx;
101  int sample;
102 
103  void adjust(const SampleID &adjustment)
104  {
105  pady += adjustment.pady;
106  padx += adjustment.padx;
107  sample += adjustment.sample;
108  }
109  };
110 
111  static bool IsValidPad(const int pad_x, const int pad_y);
112  std::vector<int> &getPad(const int pad_x, const int pad_y);
113  int getSample(const SampleID &id);
114 
116  void Clustering(int zero_suppression, bool verbosity = false);
117 
118 #if !defined(__CINT__) || defined(__CLING__)
119 
120  const std::vector<std::vector<std::vector<int>>> &getData() const
121  {
122  return m_data;
123  }
124 
125  const std::multimap<int, SampleID> &getGroups() const
126  {
127  return m_groups;
128  }
129 
130  private:
132  std::vector<std::vector<std::vector<int>>> m_data;
133 
134  std::multimap<int, SampleID> m_groups;
135 
136 #endif // #if !defined(__CINT__) || defined(__CLING__)
137  };
138 
140  class ClusterData : public TObject
141  {
142  public:
144  : min_sample(-1)
145  , max_sample(-1)
146  , peak(NAN)
147  , peak_sample(NAN)
148  , pedstal(NAN)
149  , avg_padx(NAN)
150  , avg_pady(NAN)
151  , size_pad_x(-1)
152  , size_pad_y(-1)
153  {
154  }
155 
156  std::set<int> padxs;
157  std::set<int> padys;
158  std::set<int> samples;
159 
160 #if !defined(__CINT__) || defined(__CLING__)
161  std::map<int, std::vector<double>> padx_samples;
162  std::map<int, std::vector<double>> pady_samples;
163  std::vector<double> sum_samples;
164 #endif // #if !defined(__CINT__) || defined(__CLING__)
165 
168 
169  double peak;
170  double peak_sample;
171  double pedstal;
172 
173  std::map<int, double> padx_peaks;
174  std::map<int, double> pady_peaks;
175 
177  double avg_padx;
178  double avg_pady;
179 
183 
185  };
186 
188  class ChannelHeader : public TObject
189  {
190  public:
191  int size;
193  uint8_t packet_type;
195  uint32_t bx_counter;
197  uint8_t sampa_address;
199  uint16_t sampa_channel;
201  uint16_t fee_channel;
202 
204  int pad_x;
205  int pad_y;
206 
207  int pedestal;
208  int max;
209 
211  : size(0)
212  , packet_type(0)
213  , bx_counter(0)
214  , sampa_address(0)
215  , sampa_channel(0)
216  , fee_channel(0)
217  , pad_x(-1)
218  , pad_y(-1)
219  , pedestal(-1)
220  , max(-1)
221  {
222  }
223 
224  ClassDefOverride(TPCFEETestRecov1::ChannelHeader, 1)
225  };
226 
227  private:
228 #if !defined(__CINT__) || defined(__CLING__)
229 
230  // IO stuff
231 
233 
234  std::string m_outputFileName;
235 
236  TTree *m_eventT;
237 
240 
242  TClonesArray *m_IOClusters;
243 
244  TTree *m_chanT;
245 
248  std::vector<uint32_t> m_chanData;
249 
250  // clustering stuff
252  std::map<int, ClusterData> m_clusters;
253 
256  static std::pair<int, int> roughZeroSuppression(std::vector<int> &data);
257 
259  void Clustering(void);
260 
261 #endif // #if !defined(__CINT__) || defined(__CLING__)
262 
266 
267  void get_motor_loc(Event *evt);
268 
271 
273 };
274 
276 
277 #endif /* CORESOFTWARE_OFFLINE_PACKAGES_TPCDAQ_TPCFEETESTRECOV1_H_ */