FdEventSelector.cc
Go to the documentation of this file.
1 #include "FdEventSelector.h"
2 #include <utl/ErrorLogger.h>
3 
4 #include <det/Detector.h>
5 
6 #include <fdet/Pixel.h>
7 #include <fdet/Channel.h>
8 
9 #include <utl/TimeStamp.h>
10 #include <utl/Reader.h>
11 #include <utl/TabulatedFunctionErrors.h>
12 
13 #include <evt/Event.h>
14 #include <evt/ShowerRecData.h>
15 #include <evt/ShowerFRecData.h>
16 
17 #include <fevt/FEvent.h>
18 #include <fevt/Header.h>
19 #include <fevt/Eye.h>
20 #include <fevt/Telescope.h>
21 #include <fevt/EyeHeader.h>
22 #include <fevt/EyeRecData.h>
23 #include <fevt/Pixel.h>
24 #include <fevt/PixelRecData.h>
25 
26 #include <fwk/CentralConfig.h>
27 
28 #include <AugerEvent.h>
29 
30 // FDEvent stuff
31 
32 #include "EyeEventHeader.hh"
33 #include <EyePixelData.hh>
34 #include <EyePixelList.hh>
35 #include <FdNumbering.hh>
36 #include <MiEvent.hh>
37 #include <EyeEvent.hh>
38 #include <FdNumbering.hh>
39 #include <TTimeStamp.hh>
40 
41 // SD stuff
42 
43 #include <sevt/SEvent.h>
44 #include <sevt/Station.h>
45 #include <sevt/StationTriggerData.h>
46 
47 
48 using namespace FdUtil;
49 using namespace det;
50 using namespace evt;
51 using namespace fevt;
52 using namespace std;
53 using namespace utl;
54 using namespace fwk;
55 using namespace sevt;
56 
57 using namespace FdEventSelectorKG;
58 
59 
60 FdEventSelector::FdEventSelector() {}
61 FdEventSelector::~FdEventSelector() {}
62 
65 {
66  // get data cards
67  Branch topB =
68  CentralConfig::GetInstance()->GetTopBranch ("FdEventSelector");
69 
70  if (!topB) {
71  ERROR ("Could not find branch FdEventSelector");
72  return eFailure;
73  }
74 
75  topB.GetChild("verbosity").GetData(fVerbosity);
76  topB.GetChild("minEyes").GetData(fMinEyes);
77  topB.GetChild("minTOTs").GetData(fMinTOTs);
78  topB.GetChild("minimumTrigPix").GetData(fMinFdTrigPix);
79  topB.GetChild("maximumTrigPix").GetData(fMaxFdTrigPix);
80 
81  for (Branch cB = topB.GetFirstChild(); cB; cB = cB.GetNextSibling()) {
82  if (cB.GetName() == "deselectLaser") {
83  double mean=0, width=0;
84  cB.GetChild("mean").GetData(mean);
85  cB.GetChild("width").GetData(width);
86  fDeselectLaser.push_back(deselectLaser(mean, width));
87  }
88  else if (cB.GetName() == "selectFdId") {
89  int run=0, event=0;
90  cB.GetChild("run").GetData(run);
91  cB.GetChild("event").GetData(event);
92  fSelectFdId.push_back(selectFdId(run, event));
93  }
94  else if (cB.GetName() == "deselectEye") {
95  unsigned int eyeId = 0;
96  cB.GetChild("eyeId").GetData(eyeId);
97  fDeselectEyes.insert(eyeId);
98  }
99  }
100 
101  // info output
102  ostringstream info;
103  info << " Version: "
104  << GetVersionInfo(VModule::eRevisionNumber) << "\n";
105  if (fVerbosity >= 0) {
106  info << " Parameters:\n"
107  " minimumTrigPix: " << fMinFdTrigPix << "\n"
108  " maximumTrigPix: " << fMaxFdTrigPix << "\n"
109  " minEyes: " << fMinEyes << "\n"
110  " minTOTs: " << fMinTOTs << "\n";
111  for(vector<deselectLaser>::const_iterator i=fDeselectLaser.begin();
112  i!=fDeselectLaser.end(); ++i) {
113  info << " deselectLaser: mean=" << int(i->mean) << "ns, width=" << int(i->width) << "ns \n";
114  }
115  for(vector<selectFdId>::const_iterator i=fSelectFdId.begin();
116  i!=fSelectFdId.end(); ++i) {
117  info << " pick event by Fd Id: run=" << int(i->run) << ", event=" << int(i->event) << "\n";
118  }
119  info << " deselected eyes:";
120  if (fDeselectEyes.empty())
121  info << " (none)\n";
122  else {
123  for (set<unsigned int>::const_iterator i = fDeselectEyes.begin();
124  i != fDeselectEyes.end(); ++i)
125  info << " " << *i;
126  info << "\n";
127  }
128  }
129  INFO(info);
130 
131  return eSuccess;
132 }
133 
134 
136 FdEventSelector::Run (Event& event)
137 {
138  if(!event.HasFEvent()) return eContinueLoop;
139 
140  int nGood=0;
141  const fevt::FEvent& fevent = event.GetFEvent();
142 
143  int countEyes = 0;
144 
145  // iterate eyes
146  for (FEvent::ConstEyeIterator iEye = fevent.EyesBegin(ComponentSelector::eHasData);
147  iEye != fevent.EyesEnd(ComponentSelector::eHasData);
148  ++iEye) {
149 
150  countEyes++;
151 
152  const unsigned int EyeId = iEye->GetId();
153  int nTrigPix=0;
154 
155  // check ioAuger:
156  if (!event.HasRawEvent()) {
157  if (fVerbosity>-1) INFO(" no raw FD event - skipping ...");
158  return eContinueLoop;
159  }
160 
161 
162  // check TEyeEvent
163  AugerEvent::EyeIterator iRawEye;
164  for (iRawEye = event.GetRawEvent().EyesBegin();
165  iRawEye != event.GetRawEvent().EyesEnd();
166  iRawEye++) {
167 
168  if (EyeId == iRawEye->GetEventHeader()->GetEyeNo()) {
169  break;
170  }
171  }
172 
173 
174  if (iRawEye == event.GetRawEvent().EyesEnd()) {
175  if (fVerbosity>-1) INFO(" raw EyeEvent not found - skipping ...");
176  return eContinueLoop;
177  }
178 
179  TEyeEventHeader* fdEyeEventHeader = iRawEye->GetEventHeader();
180  int RunNo = fdEyeEventHeader->GetRunNo();
181  int EventNo = fdEyeEventHeader->GetEventNo();
182  int EyeID = fdEyeEventHeader->GetEyeNo();
183 
184  if (fVerbosity > -1) {
185  ostringstream info;
186  info << " eye " << EyeID
187  << " run " << RunNo
188  << " event " << EventNo;
189  INFO(info);
190  }
191 
192  if (fDeselectEyes.find(EyeId) != fDeselectEyes.end()) {
193  if (fVerbosity > -1)
194  INFO("found deselected eye - skipping...");
195  continue;
196  }
197 
198  if (fSelectFdId.size() > 0) {
199  bool found = false;
200  for(vector<selectFdId>::const_iterator i=fSelectFdId.begin();
201  i!=fSelectFdId.end(); ++i) {
202  if (RunNo==i->run && EventNo==i->event) {
203  found = true;
204  }
205  }
206  if (!found) {
207  INFO("Event not selected. Skipping.");
208  continue;
209  //return eContinueLoop;
210  }
211  }
212 
213  // check pixel data
214  TEyePixelList* eye_pixel_list = iRawEye->GetPixelList();
215  TEyePixelData* eye_pixel_data = iRawEye->GetPixelData();
216  TMirrorPixelData * mipixeldata = 0;
217 
218  UInt_t NumPix = eye_pixel_list->GetNumPixels();
219  int last_miID = -1;
220 
221  for (UInt_t i = 0; i < NumPix; i++) {
222 
223  Fd::FdPixelNumber fdpixel = eye_pixel_list->GetPixel (i);
224  UInt_t pixel_no = Fd::GetMirrorPixelNo (fdpixel);
225  Bool_t isv = (pixel_no >= 441);
226 
227  if (!isv) { // discard virtual pixels
228  int miID = Fd::GetEyeMirrorNo (fdpixel);
229  if (last_miID!=miID){
230  mipixeldata = eye_pixel_data->GetPixelData (miID);
231  last_miID = miID;
232  }
233 
234  int firsttrigd = mipixeldata-> GetFirstTriggeredTimeBin (fdpixel);
235  if (firsttrigd>-1) {
236  nTrigPix++;
237  }
238  }
239  }
240 
241  if (fVerbosity>-1) {
242  ostringstream info;
243  info << " number of triggered pixels: " << nTrigPix;
244  INFO(info);
245  }
246 
247  if (nTrigPix<fMinFdTrigPix) continue;
248  if (nTrigPix>fMaxFdTrigPix) {
249  if (fVerbosity>-1) {
250  ostringstream info;
251  info << " skipping too large event : nPix= " << nTrigPix;
252  INFO(info);
253  }
254  return eContinueLoop; // break event for stereo if one event is too large
255  }
256 
257 
258  if (fDeselectLaser.size()>0) {
259  const FdRoot::TTimeStamp * timeStamp = fdEyeEventHeader->GetTimeStamp();
260  unsigned int NanoTime = timeStamp->GetNanoSec();
261  for(vector<deselectLaser>::const_iterator i=fDeselectLaser.begin();
262  i!=fDeselectLaser.end(); ++i) {
263  if (std::fabs(i->mean-NanoTime) < i->width) {
264  if (fVerbosity>-1) {
265  ostringstream info;
266  info << " laser check: " << NanoTime << " " << i->mean
267  << " " << i->width;
268  INFO(info);
269  }
270  continue;
271  }
272  }
273  }
274  nGood++;
275  }
276 
277  if (countEyes<fMinEyes) {
278  if (fVerbosity>-1) INFO(" not enough eyes in event - skipping ");
279  return eContinueLoop;
280  }
281 
282  // search for TOTs
283 
284  int nTOT=0;
285  if ( nGood > 0 && fMinTOTs > 0 ) {
286  if (event.HasSEvent()) {
287  const sevt::SEvent& sevent = event.GetSEvent();
289  for(sditer=sevent.StationsBegin(); sditer != sevent.StationsEnd(); ++sditer) {
290  if (sditer->HasTriggerData()) {
291  const sevt::StationTriggerData& trigStation = sditer->GetTriggerData();
292  if (trigStation.IsTimeOverThreshold())
293  nTOT++;
294  }
295  }
296  } // has sevent
297 
298  if (fVerbosity>-1) {
299  ostringstream info;
300  info << " number of TOT stations: " << nTOT;
301  INFO(info);
302  }
303  }
304 
305  if(nGood>0 && nTOT>=fMinTOTs) {
306  return eSuccess;
307  } else {
308  if (fVerbosity>-1) INFO(" skipping event ...");
309  return eContinueLoop;
310  }
311 }
312 
313 
315 FdEventSelector::Finish()
316 {
317  return eSuccess;
318 }
319 
Branch GetTopBranch() const
Definition: Branch.cc:63
StationIterator StationsEnd()
End of all stations.
Definition: SEvent.h:59
boost::filter_iterator< ComponentSelector, ConstAllEyeIterator > ConstEyeIterator
Definition: FEvent.h:56
bool HasFEvent() const
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
EyeIterator EyesEnd(const ComponentSelector::Status status)
Definition: FEvent.h:66
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
AugerEvent & GetRawEvent()
Branch GetNextSibling() const
Get next sibling of this branch.
Definition: Branch.cc:284
Class representing a document branch.
Definition: Branch.h:107
EyeIterator EyesBegin(const ComponentSelector::Status status)
Definition: FEvent.h:58
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
Top of Fluorescence Detector event hierarchy.
Definition: FEvent.h:33
fwk::VModule::ResultFlag(fwk::VModule::* run)(evt::Event &)
Definition: fwkPython.cc:59
bool IsTimeOverThreshold() const
T1 TOT is always promoted to T2 TOT.
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
Station Trigger Data description
StationIterator StationsBegin()
Beginning of all stations.
Definition: SEvent.h:57
bool HasRawEvent() const
Branch GetFirstChild() const
Get first child of this Branch.
Definition: Branch.cc:98
boost::indirect_iterator< InternalConstStationIterator, const Station & > ConstStationIterator
Definition: SEvent.h:54
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const

, generated on Tue Sep 26 2023.