VirtualChannelCalibrator.cc
Go to the documentation of this file.
1 
11 
12 #include <fwk/CentralConfig.h>
13 #include <fwk/RunController.h>
14 
15 #include <utl/config.h>
16 #include <utl/Reader.h>
17 #include <utl/ErrorLogger.h>
18 #include <utl/AugerUnits.h>
19 
20 #include <evt/Event.h>
21 
22 #include <fevt/FEvent.h>
23 #include <fevt/Eye.h>
24 #include <fevt/Header.h>
25 #include <fevt/EyeHeader.h>
26 #include <fevt/EyeTriggerData.h>
27 #include <fevt/Telescope.h>
28 #include <fevt/Channel.h>
29 #include <fevt/ChannelRecData.h>
30 #include <fevt/Pixel.h>
31 #include <fevt/PixelRecData.h>
32 #include <fevt/PixelTriggerData.h>
33 #include <fevt/TelescopeTriggerData.h>
34 #include <fevt/SLTData.h>
35 
36 #include <det/Detector.h>
37 
38 #include <fdet/Eye.h>
39 #include <fdet/Telescope.h>
40 #include <fdet/Camera.h>
41 #include <fdet/Channel.h>
42 #include <fdet/Pixel.h>
43 #include <fdet/FDetector.h>
44 
45 #include <utl/Trace.h>
46 #include <utl/TraceAlgorithm.h>
47 
48 #include <AugerEvent.h>
49 #include <EyeEvent.hh>
50 #include <EyeEventHeader.hh>
51 #include <EyeT3Data.hh>
52 #include <FadcData.hh>
53 #include <FdNumbering.hh>
54 #include <FDEventLibVersion.hh>
55 
56 #include <sstream>
57 #include <cmath>
58 #include <iomanip>
59 
60 using namespace VirtualChannelCalibratorKG;
61 using namespace fevt;
62 using namespace fdet;
63 using namespace utl;
64 using namespace fwk;
65 using namespace std;
66 
67 
70 {
71  Branch topB = CentralConfig::GetInstance()->GetTopBranch("VirtualChannelCalibrator");
72 
73  if (!topB) {
74  ERROR("Could not find branch VirtualChannelCalibrator");
75  return eFailure;
76  }
77  topB.GetChild("verbosity").GetData(fVerbosity);
78  return eSuccess;
79 }
80 
81 struct CameraData {
82 
83  // map<unsigned int> channelSignal;
84 
85 };
86 
87 
90 {
91  if (!event.HasFEvent()) {
92  WARNING("No FD Event");
93  return eContinueLoop;
94  }
95 
96  bool saturatedEvent = false;
97 
98  const fevt::FEvent& fdEvent = event.GetFEvent();
99  const fdet::FDetector& detFD = det::Detector::GetInstance().GetFDetector();
100 
101  for (fevt::FEvent::ConstEyeIterator eyeIter = fdEvent.EyesBegin();
102  eyeIter != fdEvent.EyesEnd(); ++eyeIter) {
103 
104  //const fdet::Eye& detEye = detFD.GetEye(*eyeIter);
105  const fevt::Eye& eyeEvent = *eyeIter;
106 
107  for (fevt::Eye::ConstTelescopeIterator telescopeIter = eyeEvent.TelescopesBegin();
108  telescopeIter != eyeEvent.TelescopesEnd(); ++telescopeIter) {
109 
110  const fdet::Telescope& detTel = detFD.GetTelescope(*telescopeIter);
111  const fevt::Telescope& telEvent = *telescopeIter;
112 
113  const fdet::Camera& detCamera = detTel.GetCamera();
114  const unsigned int fadcDynamicRange = (unsigned int) detCamera.GetADCDynamicRange();
115  //const int adcOverFlow = (1 << fadcDynamicRange) - 1;
116 
117  map<unsigned int, TraceD> saturatedPixelList;
118 
119  for (fevt::Telescope::ConstChannelIterator chanIter = telEvent.ChannelsBegin();
120  chanIter != telEvent.ChannelsEnd(); ++chanIter) {
121 
122  const fdet::Channel& detChannel = detFD.GetChannel(*chanIter);
123  //const fevt::Channel& chEvent = *chanIter;
124 
125  //const unsigned int thisChannelId = chanIter->GetId();
126  if (!chanIter->HasRecData())
127  continue;
128 
129  const ChannelRecData& recData = chanIter->GetRecData();
130 
131  if (recData.ChannelIsSaturated()) {
132  saturatedEvent = true;
133  }
134 
135  if (detChannel.IsVirtual()) {
136  }
137 
138 
139  //const TraceI& virtualTrace = recData.GetFADCTrace(FdConstants::eTotal);
140 
141  // correct trace according to Eq. (1) in GAP-2006-104
142 
143  /*
144  for (unsigned int pos = startBin; pos <= endBin; ++pos) {
145  const int adcValue = rawFADCTrace[pos];
146  }
147  */
148 
149 
150  //const double channelGain = detChannel.GetElectronicsGain();
151  const unsigned int virtualChannelId = detChannel.GetVirtualChannelId();
152  //const double virtualChannelGain = detTel.GetChannel(virtualChannelId).GetElectronicsGain();
153 
154  } // channel iterator
155 
156 
157  /*
158  if (thisChannelId == virtualChannelId) { // virtual channel for de-saturation
159  if (recData.ChannelIsSaturated()) {
160  const unsigned int t1 = recData.GetFirstSatBin();
161  const unsigned int t2 = recData.GetLastSatBin();
162  if ((startBin <= t1 && t1 <= endBin) ||
163  (startBin <= t2 && t2 <= endBin)) {
164  WARNING("trace recovery failed because virtual channel"
165  " is saturated!");
166  pixel.SetLowGainSaturation();
167  return;
168  }
169  }
170  vChannelRecData = &recData;
171  }
172 
173  } else if (thisChannelId != channelId) {
174 
175  const unsigned int thisVirtualChannelId =
176  detTel.GetChannel(thisChannelId).GetVirtualChannelId();
177 
178  if (thisVirtualChannelId == virtualChannelId) { // other pixels in same virtual channel
179  if (recData.ChannelIsSaturated()) {
180  const unsigned int t1 = recData.GetFirstSatBin();
181  const unsigned int t2 = recData.GetLastSatBin();
182  if ((startBin <= t1 && t1 <= endBin) ||
183  (startBin <= t2 && t2 <= endBin)) {
184  WARNING("more than one saturated channels in same time range!!");
185  return;
186  }
187  }
188  otherChannels.push_back(&recData);
189  electronicGains.push_back(thisDetChannel.GetElectronicsGain());
190  }
191  }
192  */
193 
194  /*
195  if (!vChannelRecData) {
196  ERROR("Missing virtual channel data!!");
197  pixel.SetLowGainSaturation();
198  return;
199  }
200 
201  const TraceI& virtualTrace = vChannelRecData->GetFADCTrace(FdConstants::eTotal);
202 
203  // correct trace according to Eq. (1) in GAP-2006-104
204 
205  for (unsigned int pos = startBin; pos <= endBin; ++pos) {
206  const int adcValue = rawFADCTrace[pos];
207  if (adcValue >= adcOverFlow) {
208  double otherChannelADCSum = 0.;
209  for (unsigned int i = 0; i < otherChannels.size(); ++i) {
210  const TraceI& thisTrace = otherChannels[i]->GetFADCTrace(FdConstants::eTotal);
211  const double adcValue = thisTrace[pos] - otherChannels[i]->GetBaseLine();
212  otherChannelADCSum += adcValue/electronicGains[i];
213  }
214  const double vADCBaseLineSub = virtualTrace[pos] - vChannelRecData->GetBaseLine();
215  const double recoveredSignal =
216  (vADCBaseLineSub/virtualChannelGain - otherChannelADCSum) * channelGain;
217  rawFADCTrace[pos] = int(recoveredSignal + 0.5);
218  channelRecData.AddDeSaturatedBin(pos);
219  }
220  }
221  pixel.SetSaturationRecovered()
222 
223  */
224  } // telescope iter
225  } // eye iter
226 
227  return eSuccess;
228 }
229 
230 
233 {
234  return eSuccess;
235 }
236 
237 
238 
239 
240 // Configure (x)emacs for this file ...
241 // Local Variables:
242 // mode: c++
243 // compile-command: "make -C .. VirtualChannelCalibratorKG/VirtualChannelCalibrator.o -k"
244 // End:
Branch GetTopBranch() const
Definition: Branch.cc:63
ChannelIterator ChannelsBegin()
fwk::VModule::ResultFlag Init()
Initialize: invoked at beginning of run (NOT beginning of event)
Description of the electronic channel for the 480 channels of the crate.
Fluorescence Detector Eye Event.
Definition: FEvent/Eye.h:29
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
bool HasFEvent() const
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
bool IsVirtual() const
ChannelIterator ChannelsEnd()
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
const Camera & GetCamera() const
Get the Camera object that belongs to the telescope.
Detector description interface for FDetector-related data.
Definition: FDetector.h:44
fwk::VModule::ResultFlag Run(evt::Event &event)
Run: invoked once per event.
Class representing a document branch.
Definition: Branch.h:107
TelescopeIterator TelescopesEnd()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:230
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
const Channel & GetChannel(const fevt::Channel &eventChannel) const
Get fdet::Channel from fevt::Channel.
Definition: FDetector.cc:161
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
bool ChannelIsSaturated() const
check saturation flag for this channel
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
TelescopeIterator TelescopesBegin()
first available tel of status eHasData (DEPRECATED)
Definition: FEvent/Eye.cc:207
Fluorescence Detector Channel Reconstructed Data Event.
Detector description interface for Telescope-related data.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
const Telescope & GetTelescope(const fevt::Telescope &eventTel) const
Get fdet::Telescope from fevt::Telescope.
Definition: FDetector.cc:150
fwk::VModule::ResultFlag Finish()
Finish: invoked at end of the run (NOT end of the event)
boost::indirect_iterator< InternalConstChannelIterator, const Channel & > ConstChannelIterator
An iterator over available channles for read.
unsigned int GetVirtualChannelId() const
Fluorescence Detector Telescope Event.
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
boost::filter_iterator< ComponentSelector, ConstAllTelescopeIterator > ConstTelescopeIterator
Definition: FEvent/Eye.h:73
Description of a camera.

, generated on Tue Sep 26 2023.