CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
src/datafile/vEvent.cc
Go to the documentation of this file.
1 
9 #include "vEvent.hh"
10 #include "vDataFile.hh"
11 #include "sOutputManager.hh"
12 
13 // =====================================================================
14 // ---------------------------------------------------------------------
15 // ---------------------------------------------------------------------
16 // =====================================================================
17 
19 {
20  m_timeInMs = 0;
21  m_nbLines = 0;
22  mp_ID1 = NULL;
23  mp_ID2 = NULL;
26  m_verbose = -1;
27  m_eventValue = 0.;
28  m_eventIndex = -1;
29  m_nbCustomINTData = -1;
30  m_nbCustomFLTData = -1;
31  mp_customINTData = NULL;
32  mp_customFLTData = NULL;
33 }
34 
35 // =====================================================================
36 // ---------------------------------------------------------------------
37 // ---------------------------------------------------------------------
38 // =====================================================================
39 
41 {
42  if (mp_ID1 != NULL) free(mp_ID1);
43  if (mp_ID1 != NULL) free(mp_ID2);
44  if (mp_customINTData != NULL) free(mp_customINTData);
45  if (mp_customFLTData != NULL) free(mp_customFLTData);
46 }
47 
48 // =====================================================================
49 // ---------------------------------------------------------------------
50 // ---------------------------------------------------------------------
51 // =====================================================================
52 
53 int vEvent::AllocateID()
54 {
55  // Verbose
57  if (m_verbose>=VERBOSE_DETAIL) Cout("vEvent::AllocateID() -> Allocate buffers for indices" << endl);
58  // Check number of lines
59  if (m_nbLines<1)
60  {
61  Cerr("***** vEvent::AllocateID() -> Error, number of lines has not been initialized (<1) !" << endl);
62  return 1;
63  }
64  else
65  {
66  // Allocate buffer indices
67  mp_ID1 = (uint32_t*)malloc(m_nbLines*sizeof(uint32_t));
68  mp_ID2 = (uint32_t*)malloc(m_nbLines*sizeof(uint32_t));
69  }
70  // Call the pure virtual function implemented in child classes for the allocation of data specific to child classes
72  {
73  Cerr("***** vEvent::AllocateID() -> Error when trying to allocated specific data for the Event !" << endl);
74  return 1;
75  }
76  // End
77  return 0;
78 }
79 
80 // =====================================================================
81 // ---------------------------------------------------------------------
82 // ---------------------------------------------------------------------
83 // =====================================================================
85 {
86  if(m_nbCustomINTData < 1)
87  {
88  Cerr("***** vEvent::AllocateCustomINTData() -> Error, number of custom EVTINTDATA data has not been initialized (<1) !" << endl);
89  return 1;
90  }
91  else
93 
94  return 0;
95 }
96 
97 // =====================================================================
98 // ---------------------------------------------------------------------
99 // ---------------------------------------------------------------------
100 // =====================================================================
102 {
103  if(m_nbCustomFLTData < 1)
104  {
105  Cerr("***** vEvent::AllocateCustomFLTData() -> Error, number of custom EVTFLTDATA data has not been initialized (<1) !" << endl);
106  return 1;
107  }
108  else
110 
111  return 0;
112 }
113 
114 // =====================================================================
115 // ---------------------------------------------------------------------
116 // ---------------------------------------------------------------------
117 // =====================================================================
119 {
120  if(a_idx >= m_nbCustomFLTData || mp_customFLTData==NULL)
121  {
122  Cerr("***** vEvent::GetCustomFLTdata() -> Error when trying to recover custom EVTFLTDATA data #"<< a_idx+1 << "!" << endl);
123 
124  if(mp_customFLTData==NULL)
125  Cerr("***** 'mp_customFLTData' has not been initialized!" << endl);
126  else
127  Cerr("***** the number of custom data is initialized to " << m_nbCustomFLTData << endl);
128  }
129 
130  return mp_customFLTData[ a_idx ];
131 }
132 
133 
134 // =====================================================================
135 // ---------------------------------------------------------------------
136 // ---------------------------------------------------------------------
137 // =====================================================================
139 {
140  if(a_idx >= m_nbCustomINTData || mp_customINTData==NULL)
141  {
142  Cerr("***** vEvent::GetCustomINTdata() -> Error when trying to recover custom EVTINTDATA data #"<< a_idx+1 << "!" << endl);
143 
144  if(mp_customINTData==NULL)
145  Cerr("***** 'mp_customINTData' has not been initialized!" << endl);
146  else
147  Cerr("***** the number of custom data is initialized to " << m_nbCustomINTData << endl);
148  }
149 
150  return mp_customINTData[ a_idx ];
151 }
152 
153 // =====================================================================
154 // ---------------------------------------------------------------------
155 // ---------------------------------------------------------------------
156 // =====================================================================
157 int vEvent::SetCustomFLTData(int a_idx, EVTFLTDATA a_value)
158 {
159  if(a_idx >= m_nbCustomFLTData || mp_customFLTData==NULL)
160  {
161  Cerr("***** vEvent::SetCustomFLTData() -> Error when trying to set custom EVTFLTDATA data #"<< a_idx+1 << "!" << endl);
162 
163  if(mp_customFLTData==NULL)
164  Cerr("***** 'mp_customFLTData' has not been initialized!" << endl);
165  else
166  Cerr("***** the number of custom data is initialized to " << m_nbCustomFLTData << endl);
167 
168  return 1;
169  }
170 
171  mp_customFLTData[ a_idx ] = a_value;
172  return 0;
173 }
174 
175 // =====================================================================
176 // ---------------------------------------------------------------------
177 // ---------------------------------------------------------------------
178 // =====================================================================
179 int vEvent::SetCustomINTData(int a_idx, EVTINTDATA a_value)
180 {
181  if(a_idx >= m_nbCustomINTData || mp_customINTData==NULL)
182  {
183  Cerr("***** vEvent::SetCustomINTData() -> Error when trying to set custom EVTINTDATA data #"<< a_idx+1 << "!" << endl);
184 
185  if(mp_customINTData==NULL)
186  Cerr("***** 'mp_customINTData' has not been initialized!" << endl);
187  else
188  Cerr("***** the number of custom data is initialized to " << m_nbCustomINTData << endl);
189 
190  return 1;
191  }
192 
193  mp_customINTData[ a_idx ] = a_value;
194  return 0;
195 }
196 
197 
virtual EVTFLTDATA * GetCustomFLTData()
#define EVTINTDATA
#define Cerr(MESSAGE)
int AllocateCustomINTData()
Instantiate the m_nbCustomINTData array.
virtual int SetCustomINTData(int a_idx, EVTINTDATA a_value)
EVTFLTDATA * mp_customFLTData
EVTINTDATA * mp_customINTData
#define DEBUG_VERBOSE(IGNORED1, IGNORED2)
vEvent()
vEvent constructor. Initialize the member variables to their default values.
virtual int SetCustomFLTData(int a_idx, EVTFLTDATA a_value)
int AllocateID()
Instantiate the mp_ID1 and mp_ID2 indices arrays.
#define EVTFLTDATA
virtual int AllocateSpecificData()=0
Pure virtual function implemented in the child classes, dedicated to the allocation of specific data ...
int AllocateCustomFLTData()
Instantiate the m_nbCustomFLTData array.
virtual EVTINTDATA * GetCustomINTData()
#define Cout(MESSAGE)
virtual ~vEvent()
vEvent destructor