FDetector/Channel.cc
Go to the documentation of this file.
1 #include <string>
2 #include <sstream>
3 
4 #include <boost/lexical_cast.hpp>
5 
6 #include <det/VManager.h>
7 #include <det/Detector.h>
8 
9 #include <fdet/FDetector.h>
10 #include <fdet/Eye.h>
11 #include <fdet/Telescope.h>
12 #include <fdet/Camera.h>
13 #include <fdet/Channel.h>
14 
15 #include <utl/ErrorLogger.h>
16 
17 using namespace fdet;
18 using namespace det;
19 using namespace utl;
20 using namespace std;
21 
22 
23 Channel::Channel(const unsigned int eyeId,
24  const unsigned int telescopeId,
25  const unsigned int channelId,
26  const std::string& physEyeIdString,
27  const std::string& physTelIdString) :
28  fChannelId(channelId),
29  fTelescopeId(telescopeId),
30  fEyeId(eyeId),
31  fPhysicalEyeIdString(physEyeIdString),
32  fPhysicalTelescopeIdString(physTelIdString),
33  fADCVariance(0),
34  fThreshold(0),
35  fBaseline(0)
36 {
37  fChannelIdStr = boost::lexical_cast<string>(channelId);
38 }
39 
40 
42 {
43  delete fADCVariance;
44  delete fThreshold;
45  delete fBaseline;
46 }
47 
48 void Channel::Update() const {
49 
50  // reset time dependent parameters
51  delete fADCVariance;
52  delete fThreshold;
53  delete fBaseline;
54  fADCVariance = 0;
55  fThreshold = 0;
56  fBaseline = 0;
57 }
58 
59 
60 bool
62  const
63 {
64  const fdet::Telescope& detTel =
65  det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId);
66  return fChannelId > detTel.GetLastPixelId();
67 }
68 
69 
70 unsigned int Channel::GetVirtualChannelId() const {
71  const fdet::Telescope& detTel =
72  det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId);
73 
74  const int row = (fChannelId - detTel.GetFirstPixelId()) %
75  detTel.GetLastRow() + detTel.GetFirstRow();
76 
77  const int col = (fChannelId - detTel.GetFirstPixelId()) /
78  detTel.GetLastRow() + detTel.GetFirstColumn();
79 
80  if( (row % 2) == 0 ) { // even row
81  return (detTel.GetLastPixelId() + 2) + (col - detTel.GetFirstColumn()) * 2;
82  } else { // odd row
83  return (detTel.GetLastPixelId() + 1) + (col - detTel.GetFirstColumn()) * 2;
84  }
85 }
86 
87 
88 // properties of the camera
89 
90 unsigned int
92  const
93 {
94  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetPixelId(fChannelId);
95 }
96 
97 
98 int
100  const
101 {
102  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetFLTBoxcarSumLength();
103 }
104 
105 
106 int
108  const
109 {
110  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetFLTProlongation();
111 }
112 
113 
114 int
116  const
117 {
118  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetSLTTriggerBin();
119 }
120 
121 
122 double Channel::GetGainVariance() const {
123  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetGainVariance();
124 }
125 
127  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetElectronicNoiseVariance();
128 }
129 
130 int
132  const
133 {
134  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetFADCTraceLength();
135 }
136 
137 
138 double
140  const
141 {
142  return det::Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera().GetFADCBinSize();
143 }
144 
145 
146 
147 double
149  const
150 {
151  const fdet::Camera& dCamera =
152  Detector::GetInstance().GetFDetector().GetEye(fEyeId).GetTelescope(fTelescopeId).GetCamera();
153  if (IsVirtual())
154  return dCamera.GetElectronicsGain() / dCamera.GetVirtualChannelGainRatio();
155  else
156  return dCamera.GetElectronicsGain();
157 }
158 
159 
160 
161 // real properties of the channel
162 
163 double
165  const
166 {
167  return GetChannelData(fADCVariance, "ADCVariance", "channel", "ADC variance");
168 }
169 
170 double
172  const
173 {
174  return GetChannelData(fThreshold, "Threshold", "channel", "pixel threshold");
175 }
176 
177 double
179  const
180 {
181  return GetChannelData(fBaseline, "Baseline", "channel", "pixel baseline");
182 }
183 
184 
185 
186 template<typename T>
187 inline
188 const T&
189 Channel::GetChannelData(T*& requestedData,
190  const std::string& property,
191  const std::string& component,
192  const std::string& errorMsg)
193  const
194 {
195  if (!requestedData) {
196  requestedData = new T;
197  GetChannelData(*requestedData, property, component, errorMsg);
198  }
199  return *requestedData;
200 }
201 
202 
203 template<typename T>
204 inline
205 void
206 Channel::GetChannelData(T& requestedData,
207  const std::string& property,
208  const std::string& component,
209  const std::string& errorMsg)
210  const
211 {
212  const VManager& manager = Detector::GetInstance().GetFManagerRegister();
213 
214  VManager::IndexMap indexMap;
215  indexMap["channelId"] = fChannelIdStr;
216  indexMap["telescopeId"] = fPhysicalTelescopeIdString;
217  indexMap["eyeId"] = fPhysicalEyeIdString;
218 
219  const VManager::Status foundFlag = manager.GetData(requestedData, property, component, indexMap);
220 
221  if (foundFlag == VManager::eNotFound) {
222  ostringstream err;
223  err << "Did not find requested component for " << errorMsg << "; "
224  << VManager::QueryInfoMessage(property, component, indexMap);
225  ERROR(err);
226  throw NonExistentComponentException(err.str());
227  }
228 }
double GetThreshold() const
int GetSLTTriggerBin() const
double GetBaseline() const
std::string fPhysicalTelescopeIdString
Channel(const unsigned int eyeId, const unsigned int telescopeId, const unsigned int channelId, const std::string &physEyeIdString, const std::string &physTelIdString)
std::string fChannelIdStr
double GetElectronicsGain() const
void Update() const
unsigned int GetFirstPixelId() const
double GetElectronicNoiseVariance() const
bool IsVirtual() const
Base class for exceptions trying to access non-existing components.
Interface for detector managers.
Definition: VManager.h:115
double GetElectronicsGain() const
unsigned int GetFirstColumn() const
unsigned int fChannelId
virtual Status GetData(double &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const =0
unsigned int GetLastPixelId() const
double * fADCVariance
int GetFLTBoxcarSumLength() const
double GetVirtualChannelGainRatio() const
int GetFADCTraceLength() const
unsigned int GetLastRow() const
double GetGainVariance() const
fTelescopeId(t.GetTelescopeId())
unsigned int fTelescopeId
int GetFLTProlongation() const
Detector description interface for Telescope-related data.
double GetFADCBinSize() const
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
unsigned int GetVirtualChannelId() const
unsigned int fEyeId
std::string fPhysicalEyeIdString
double GetADCVariance() const
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
const T & GetChannelData(T *&requestedData, const std::string &property, const std::string &component, const std::string &errorMsg) const
unsigned int GetFirstRow() const
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
Description of a camera.
unsigned int GetPixelId() const

, generated on Tue Sep 26 2023.