R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandTamexReader.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "R3BLogger.h"
17
18#include <FairLogger.h>
19#include <FairRootManager.h>
20
21#include <TClonesArray.h>
22#include <ext_data_struct_info.hh>
23
28
29extern "C"
30{
31#include "ext_data_client.h"
33}
34
36 : R3BReader("R3BNeulandTamexReader")
37 , fData(data)
38 , fOffset(offset)
39 , fOnline(kFALSE)
40 , fSkiptriggertimes(kFALSE)
41 , fArray(new TClonesArray("R3BPaddleTamexMappedData"))
42 , fArrayTrigger(new TClonesArray("R3BPaddleTamexMappedData"))
43 , fNofPlanes(sizeof(fData->NN_P) / sizeof(fData->NN_P[0]))
44{
45}
46
48{
49 R3BLOG(debug1, "");
50 if (fArray)
51 {
52 delete fArray;
53 }
54 if (fArrayTrigger)
55 {
56 delete fArrayTrigger;
57 }
58}
59
60Bool_t R3BNeulandTamexReader::Init(ext_data_struct_info* a_struct_info)
61{
62 Int_t ok;
63 R3BLOG(info, "");
65
66 if (!ok)
67 {
68 R3BLOG(error, "Failed to setup structure information.");
69 return kFALSE;
70 }
71
72 R3BLOG(info, "Number of planes " << fNofPlanes);
73
74 // Register output arrays in tree
75 FairRootManager::Instance()->Register("NeulandMappedData", "Neuland", fArray, !fOnline);
76 if (!fSkiptriggertimes)
77 {
78 FairRootManager::Instance()->Register("NeulandTrigMappedData", "Neuland", fArrayTrigger, !fOnline);
79 }
80 else
81 {
82 fArrayTrigger = NULL;
83 }
84 Reset();
85 memset(fData, 0, sizeof *fData);
86
87 return kTRUE;
88}
89
91{
92 const auto data = fData;
93
94 for (int plane = 0; plane < fNofPlanes; ++plane)
95 {
96 for (int pm = 0; pm < 2; ++pm)
97 {
98 int idx = 0;
99 int start = 0;
100 int stop = 0;
101 int bar;
102 int cLE, fLE, cTE, fTE;
103
104 // the counter for coarse time and fine time should be always the same:
105 if (data->NN_P[plane].tcl_T[pm].BM != data->NN_P[plane].tfl_T[pm].BM ||
106 data->NN_P[plane].tcl_T[pm].B != data->NN_P[plane].tfl_T[pm].B ||
107 data->NN_P[plane].tct_T[pm].BM != data->NN_P[plane].tft_T[pm].BM ||
108 data->NN_P[plane].tct_T[pm].B != data->NN_P[plane].tft_T[pm].B)
109 {
110 // fLogger->Info(MESSAGE_ORIGIN, " Bad event, counter of coarse times and fine times do not match \n");
111 return kFALSE;
112 }
113
114 // the counter for leading and trailing edge should be always the same:
115 if (data->NN_P[plane].tcl_T[pm].B != data->NN_P[plane].tct_T[pm].B ||
116 data->NN_P[plane].tfl_T[pm].B != data->NN_P[plane].tft_T[pm].B)
117 {
118 // fLogger->Info(MESSAGE_ORIGIN, " Bad event, mismatch of trailing and leading edges \n");
119 return kFALSE;
120 }
121
122 for (int hit = 0; hit < data->NN_P[plane].tcl_T[pm].BM; hit++)
123 {
124 bar = data->NN_P[plane].tcl_T[pm].BMI[hit];
125 stop = data->NN_P[plane].tcl_T[pm].BME[hit];
126 // fLogger->Info(MESSAGE_ORIGIN, " bar %d, multihit %d \n", bar, stop-start);
127
128 for (int multi = start; multi < stop; multi++)
129 {
130 cLE = data->NN_P[plane].tcl_T[pm].Bv[multi];
131 fLE = data->NN_P[plane].tfl_T[pm].Bv[multi];
132 cTE = data->NN_P[plane].tct_T[pm].Bv[multi];
133 fTE = data->NN_P[plane].tft_T[pm].Bv[multi];
134
135 // fLogger->Info(MESSAGE_ORIGIN, " leading coarse time %d, fine time %d \n", cLE, fLE);
136 // fLogger->Info(MESSAGE_ORIGIN, " trailing coarse time %d, fine time %d \n",cTE, fTE);
137
138 auto mapped = new ((*fArray)[fArray->GetEntriesFast()]) R3BPaddleTamexMappedData(plane + 1, bar);
139 if (0 == pm)
140 {
141 mapped->fCoarseTime1LE = cLE;
142 mapped->fFineTime1LE = fLE;
143 mapped->fCoarseTime1TE = cTE;
144 mapped->fFineTime1TE = fTE;
145 }
146 else
147 {
148 mapped->fCoarseTime2LE = cLE;
149 mapped->fFineTime2LE = fLE;
150 mapped->fCoarseTime2TE = cTE;
151 mapped->fFineTime2TE = fTE;
152 }
153 }
154 start = stop;
155 }
156 }
157 }
158
159 // Cards' trigger.
160 // NOLINTBEGIN
161 if (fArrayTrigger != nullptr)
162 {
163 int v_i = 0;
164 for (int i_i = 0; i_i < fData->NN_TRIGCM; ++i_i)
165 {
166 auto channel_id = fData->NN_TRIGCMI[i_i];
167 for (; v_i < fData->NN_TRIGCME[i_i]; ++v_i)
168 {
169 auto coarse = fData->NN_TRIGCv[v_i];
170 auto fine = fData->NN_TRIGFv[v_i];
171 auto mapped =
172 new ((*fArrayTrigger)[fArrayTrigger->GetEntriesFast()]) R3BPaddleTamexMappedData(0, channel_id);
173 mapped->fCoarseTime1LE = coarse;
174 mapped->fFineTime1LE = fine;
175 }
176 }
177 }
178 // NOLINTEND
179
180 return kTRUE;
181}
182
184{
185 fArray->Clear();
186 if (fArrayTrigger != nullptr)
187 {
188 fArrayTrigger->Clear();
189 }
190}
191
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
ClassImp(R3B::Neuland::Cal2HitPar)
R3BNeulandTamexReader(EXT_STR_h101_raw_nnp_tamex_onion *, size_t)
ext_h101_raw_nnp_tamex.h was created by running $unpacker –ntuple=STRUCT_HH,RAW:NN,...
auto R3BRead() -> Bool_t override
auto Init(ext_data_struct_info *) -> Bool_t override
virtual ~R3BNeulandTamexReader() override
R3BReader(TString const &)
Definition R3BReader.cxx:16
struct EXT_STR_h101_raw_nnp_tamex_onion_t EXT_STR_h101_raw_nnp_tamex_onion
struct EXT_STR_h101_raw_nnp_tamex_t EXT_STR_h101_raw_nnp_tamex
#define EXT_STR_h101_raw_nnp_tamex_ITEMS_INFO(ok, si, offset, struct_t, printerr)