TPCCondData
ExtendedAltroParameters.cc
Go to the documentation of this file.
1 /*
2  * ExtendedAltroParameters.cc
3  *
4  * Created on: Jul 13, 2012
5  * Author: caiazza
6  */
7 
8 #include <iostream>
9 #include <string>
10 #include <sstream>
11 
13 #include "TPCCondDataExeptions.h"
14 
15 namespace tpcconddata
16 {
17 
19 {
20  SetData(Data);
21 }
22 
25 {
26 
27 }
28 
30 {
31 
32 }
33 
34 void
36 {
38  SetGainSettings(Data.Gain);
40  SetShutdown(Data.Shutdown);
53 }
54 
57 {
58  ExtendedAltroData result;
59  result.PreampEnable = GetPreampEnable();
60  result.Gain = GetGainSettings();
61  result.ShapingTime = GetShapingTime();
62  result.Shutdown = GetShutdown();
63  result.ZSThreshold = GetZSThreshold();
65  result.PreSamples = GetPreSamples();
66  result.PostSamples = GetPostSamples();
68  result.RCUAddress = GetRCUAddress();
69  result.RCUFWVersion = GetRCUFWVersion();
75 
76  return result;
77 }
78 
79 void
81 {
82  obj()->setIntVal(0, Enable);
83 }
84 
85 void
87 {
88  obj()->setIntVal(1, Gain);
89 }
90 
91 void
93 {
94  obj()->setIntVal(2, ShapingTime);
95 }
96 
97 void
99 {
100  obj()->setIntVal(3, Shutdown);
101 }
102 
103 void
105 {
106  if(Threshold > 1024)
107  {
108  std::stringstream message;
109  message << "The Zero Suppression Threshold for the ALTRO electronics has to be between "
110  << "0 and 1023 and is being set at " << Threshold << std::endl;
111  throw InvalidDataException("ExtendedAltroParameters", message.str());
112  }
113 
114  obj()->setIntVal(4, Threshold);
115 }
116 
117 void
119 {
120  if( (MinSamples < 0) | (MinSamples > 3))
121  {
122  std::stringstream message;
123  message << "The Glith Filter minimum samples for the ALTRO electronics has to be between "
124  << "0 and 3 and is being set at " << MinSamples << std::endl;
125  throw InvalidDataException("ExtendedAltroParameters", message.str());
126  }
127 
128  obj()->setIntVal(5, MinSamples);
129 }
130 
131 void
133 {
134  if( (PreSamples < 0) | (PreSamples > 3) )
135  {
136  std::stringstream message;
137  message << "The Number of PreSamples for the ALTRO electronics has to be between "
138  << "0 and 3 and is being set at " << PreSamples << std::endl;
139  throw InvalidDataException("ExtendedAltroParameters", message.str());
140  }
141 
142  obj()->setIntVal(6, PreSamples);
143 }
144 
145 void
147 {
148  if( (PostSamples < 0) | (PostSamples > 7) )
149  {
150  std::stringstream message;
151  message << "The Number of PostSamples for the ALTRO electronics has to be between "
152  << "0 and 7 and is being set at " << PostSamples << std::endl;
153  throw InvalidDataException("ExtendedAltroParameters", message.str());
154  }
155 
156  obj()->setIntVal(7, PostSamples);
157 }
158 
159 void
161 {
162  if( (PreTriggerSamples < 0) | (PreTriggerSamples > 15) )
163  {
164  std::stringstream message;
165  message << "The Number of PostSamples for the ALTRO electronics has to be between "
166  << "0 and 15 and is being set at " << PreTriggerSamples << std::endl;
167  throw InvalidDataException("ExtendedAltroParameters", message.str());
168  }
169 
170  obj()->setIntVal(8, PreTriggerSamples);
171 }
172 
173 void
175 {
176  obj()->setIntVal(9, RCUAddress);
177 }
178 
179 void
181 {
182  obj()->setIntVal(10, RCUFWVersion);
183 }
184 
185 void
187 {
188  obj()->setIntVal(11, RCUActiveFECA);
189 }
190 
191 void
193 {
194  obj()->setIntVal(12, RCUActiveFECB);
195 }
196 
197 void
199 {
200  obj()->setIntVal(13, RCUConfigRegister1);
201 }
202 
203 void
205 {
206  obj()->setIntVal(14, RCUConfigRegister2);
207 }
208 
209 void
211 {
212  obj()->setIntVal(15, RCUStatusErrors);
213 }
214 
215 bool
217 {
218  return static_cast<bool>(getIntVal(0));
219 }
220 
223 {
224  return ExtendedAltroParameters::GainSettings(getIntVal(1));
225 }
226 
229 {
230  return ExtendedAltroParameters::ShapingSettings(getIntVal(2));
231 }
232 
233 bool
235 {
236  return static_cast<bool>(getIntVal(3));
237 }
238 
239 int
241 {
242  return getIntVal(4);
243 }
244 
245 int
247 {
248  return getIntVal(5);
249 }
250 
251 int
253 {
254  return getIntVal(6);
255 }
256 
257 int
259 {
260  return getIntVal(7);
261 }
262 
263 int
265 {
266  return getIntVal(8);
267 }
268 
269 int
271 {
272  return getIntVal(9);
273 }
274 
275 int
277 {
278  return getIntVal(10);
279 }
280 
281 int
283 {
284  return getIntVal(11);
285 }
286 
287 int
289 {
290  return getIntVal(12);
291 }
292 
293 int
295 {
296  return getIntVal(13);
297 }
298 
299 int
301 {
302  return getIntVal(14);
303 }
304 
305 int
307 {
308  return getIntVal(15);
309 }
310 
311 std::string
313 {
314  return std::string("$Rev: 3117 $");
315 }
316 
317 std::string
319 {
320  return std::string("ExtendedAltroElectronicsParameters");
321 }
322 
323 void
324 ExtendedAltroParameters::print( std::ostream& os ) const
325 {
326  std::streamsize PrecisionBefore = os.precision();
327  std::streamsize WidthBefore = os.width();
328  os.precision(4);
329  os.setf(std::ios_base::fixed);
330  os << "Extended Electronics Parameters: " << std::endl
331  << "PreampEnable: " << GetPreampEnable() << "\t Gain: " << static_cast<int>(GetGainSettings()) <<std::endl
332  << "Shaping Time: " << static_cast<int>(GetShapingTime()) << "\t Shutdown: " << GetShutdown() << std::endl
333  << "Zero Suppression Threshold: " << GetZSThreshold() << "\t PreSamples: " << GetPreSamples() << std::endl
334  << "PostSamples: " << GetPostSamples() << "\t PreTrigger Samples: " << GetPreTriggerSamples() << std::endl
335  << "RCU Address: " << std::hex << GetRCUAddress() << std::dec << "\t RCU Firmware Version: " << GetRCUFWVersion() << std::endl
336  << "Active FEC A: " <<std::hex << GetRCUActiveFECA() << "\t Active FEC B: " << GetRCUActiveFECB() << std::endl
337  << "RCU Configuration Reg 1: " << GetRCUConfigRegister1() << "\t RCU Configuration Reg 2: " << GetRCUConfigRegister2() << std::endl
338  << "RCU Status/Errors: " << GetRCUStatusErrors() << std::dec << std::endl;
339 
340  os.precision( PrecisionBefore );
341  os.width( WidthBefore );
342 }
343 
344 const std::string
346 {
347  return std::string("ExtendedAltroParameters");
348 }
349 
350 const std::string
352 {
353  std::string Description = "i:PreampEnable,Gain,ShapingTime,Shutdown,ZSThreshold,PreSamples,";
354  Description += "PostSamples,PreTriggerSamples,RCUAddress,RCUFWVersion,RCUActiveFECA,";
355  Description += "RCUActiveFECB,RCUConfigRegister1,RCUConfigRegister2,RCUStatusErrors";
356  return Description;
357 }
358 
359 std::ostream &operator<<(std::ostream &os, const ExtendedAltroParameters &p)
360 {
361  p.print(os);
362  return os;
363 }
364 
366 {
367  bool result = first.GetPreampEnable() == second.GetPreampEnable() &&
368  first.GetGainSettings() == second.GetGainSettings() &&
369  first.GetShapingTime() == second.GetShapingTime() &&
370  first.GetShutdown() == second.GetShutdown() &&
371  first.GetZSThreshold() == second.GetZSThreshold() &&
372  first.GetPreSamples() == second.GetPreSamples() &&
373  first.GetPostSamples() == second.GetPostSamples() &&
374  first.GetPreTriggerSamples() == second.GetPreTriggerSamples() &&
375  first.GetRCUAddress() == second.GetRCUAddress() &&
376  first.GetRCUFWVersion() == second.GetRCUFWVersion() &&
377  first.GetRCUActiveFECA() == second.GetRCUActiveFECA() &&
378  first.GetRCUActiveFECB() == second.GetRCUActiveFECB() &&
379  first.GetRCUConfigRegister1() == second.GetRCUConfigRegister1() &&
380  first.GetRCUConfigRegister2() == second.GetRCUConfigRegister2() &&
381  first.GetRCUStatusErrors() == second.GetRCUStatusErrors();
382  return result;
383 }
384 
386 {
387  return !(first == second);
388 }
389 
390 
391 
392 }//end namespace
393 
394 
void SetPreTriggerSamples(int &PreTriggerSamples)
bool operator==(const ExtendedAltroParameters &first, const ExtendedAltroParameters &second)
Comparison operator that compares 1-1 all the internal data.
bool operator!=(const ExtendedAltroParameters &first, const ExtendedAltroParameters &second)
void SetShapingTime(ShapingSettings &ShapingTime)
static std::string getDefaultColName()
Default name for the collection of this type.
ShapingSettings
Enumerator to store the available settings of the Shaping Time and match them with an human readable ...
std::ostream & operator<<(std::ostream &os, const ADCChannelMapping &acm)
Base exception for error involving some data having an invalid value.
void SetData(ExtendedAltroData &Data)
Sets all the data at the same time.
void SetRCUConfigRegister2(int &RCUConfigRegister2)
const std::string getDataDescription() const
Defines the data description in the standard condDB format.
void print(std::ostream &os=std::cout) const
Prints a summary of the data.
void SetRCUConfigRegister1(int &RCUConfigRegister1)
ExtendedAltroParameters(ExtendedAltroData &Data)
Convenient constructor to set all the data using the ExtendedAltroData structure to collect the data...
GainSettings
Enumerator to store the available settings of the gain and match them with an human readable name...
void SetPreampEnable(bool &Enable)
Single element setters.
static const int EXTENDEDALTROPARSNINT
Class storing to the condDB additional electronics information specific to the ALTRO electronics Prea...
bool GetPreampEnable() const
Single element Getters.
ExtendedAltroData GetData() const
Retrieves all the data in a single structure.
static std::string getRevision()
Retrieves the version of this condition object.
const std::string getTypeName() const
Defines the type name used for the Condition Database.
static const int EXTENDEDALTROPARSNDOUBLE
static const int EXTENDEDALTROPARSNFLOAT