FdUpTimeFileManager.cc
Go to the documentation of this file.
1 
9 #include <utl/Reader.h>
10 #include <utl/TimeStamp.h>
11 #include <utl/ErrorLogger.h>
12 #include <utl/SaveCurrentTDirectory.h>
13 
14 #include <fwk/CentralConfig.h>
15 
16 #include <det/Detector.h>
17 #include <det/ValidityStamp.h>
18 
19 #include <fdet/FDetector.h>
20 #include <fdet/FdUpTimeFileManager.h>
21 
22 #include <sstream>
23 #include <string>
24 #include <set>
25 #include <map>
26 #include <utility>
27 #include <algorithm>
28 
29 #include <TFile.h>
30 #include <TTree.h>
31 
32 using namespace fwk;
33 using namespace det;
34 using namespace fdet;
35 using namespace utl;
36 using namespace std;
37 
38 
39 REGISTER_F_MANAGER("FdUpTimeFileManager", FdUpTimeFileManager);
40 
41 
42 const double FdUpTimeFileManager::fgSearchMapBinning = 10000; // .*s; // [s]
43 
44 
46 {
47  fRootFilePtr = file;
48  if (fRootFilePtr) {
49  fDataTree = (TTree*)(fRootFilePtr->Get("AugerUpTime"));
50  if (fDataTree) {
51  TBranch* const startB = fDataTree->GetBranch("uptime_gpsStart");
52  startB->SetAddress(&fGpsStart);
53  startB->GetEntry(0);
54  TBranch* const stopB = fDataTree->GetBranch("uptime_gpsStop");
55  stopB->SetAddress(&fGpsStop);
56  stopB->GetEntry(stopB->GetEntries() - 1);
57 
58  fHeaderTree = (TTree*)(fRootFilePtr->Get("Header"));
59  if (fHeaderTree) {
60  TBranch* const UpTimeVerB = fHeaderTree->GetBranch("SoftwareVersion");
61  UpTimeVerB->SetAddress(&fFileVersion);
62  UpTimeVerB->GetEntry(0);
63  } else
64  fFileVersion = 0;
65  } else {
66  ostringstream err;
67  err << " FdUpTimeFileManager input file=" << file->GetName()
68  << " is corrupt! Up times will not be available!";
69  ERROR(err);
70  fRootFilePtr = nullptr;
71  }
72  }
73 }
74 
75 
76 bool
78 {
79  return first < second;
80 }
81 
82 
83 void
84 FdUpTimeFileManager::Init(const std::string& configLink)
85 {
86  VManager::Init(configLink);
87 
88  fVerbosity = 0;
89 
90  fBranch.GetChild("file").GetData(fFileList);
91 
92  const SaveCurrentTDirectory save;
93  for (fRootFileIterator = fFileList.begin(); fRootFileIterator != fFileList.end(); ++fRootFileIterator) {
94  UpTimePeriod rootUpTime;
95  TFile* const rootFile = TFile::Open(fRootFileIterator->c_str(), "READ");
96  if (!rootFile || rootFile->IsZombie()) {
97  ostringstream err;
98  err << fRootFileIterator->c_str()
99  << " is an UpTime file corrupted or inexistent!";
100  ERROR(err);
101  continue;
102  } else {
103  rootUpTime = UpTimePeriod(rootFile);
104  if (rootUpTime.fRootFilePtr)
105  fUpTimeVector.push_back(rootUpTime);
106  }
107  }
108 
109  if (fUpTimeVector.size() != fFileList.size()) {
110  ostringstream err;
111  err << "UpTime file(s) unavailable!";
112  ERROR(err);
113  throw IOFailureException(err.str());
114  }
115  if (fFileList.empty())
116  WARNING("EMPTY FILE LIST!");
117  Initialize();
118 }
119 
120 
121 void
122 FdUpTimeFileManager::Initialize()
123 {
124  ostringstream msg;
125  msg << "Initializing FdUpTimeFileManager index map ...";
126  auto verbosityB = fBranch.GetChild("verbosity");
127  if (verbosityB) {
128  verbosityB.GetData(fVerbosity);
129  msg << "\n\tverbosity level: " << fVerbosity;
130  }
131  INFO(msg);
132 
133  // list of properties for telescope
134  fAvailableComponents.insert("has_fduptime");
135  fAvailableComponents.insert("uptime_gpsStart");
136  fAvailableComponents.insert("uptime_gpsStop");
137  fAvailableComponents.insert("uptime_fraction");
138  fAvailableComponents.insert("status");
139  fAvailableComponents.insert("veto_fraction"); // for eye
140  fAvailableComponents.insert("ADCVariance"); // for channel
141  fAvailableComponents.insert("Threshold"); // for channel
142  fAvailableComponents.insert("Baseline"); // for channel
143 
144  // build index
145  sort(fUpTimeVector.begin(), fUpTimeVector.end(), UpTimePeriodSortFunction);
146  for (fUpTimeVectorIterator = fUpTimeVector.begin(); fUpTimeVectorIterator != fUpTimeVector.end(); ++fUpTimeVectorIterator) {
147 
148  // create index map for fast lookup
149  TBranch* const startB = fUpTimeVectorIterator->fDataTree->GetBranch("uptime_gpsStart");
150  UInt_t gpsStart = 0;
151  startB->SetAddress(&gpsStart);
152  TBranch* const stopB = fUpTimeVectorIterator->fDataTree->GetBranch("uptime_gpsStop");
153  UInt_t gpsStop = 0;
154  stopB->SetAddress(&gpsStop);
155 
156  for (unsigned int i = 0; i < (unsigned int)startB->GetEntries(); ++i) {
157 
158  startB->GetEntry(i);
159  stopB->GetEntry(i);
160 
161  unsigned int bin1 = (unsigned int)(gpsStart / fgSearchMapBinning);
162  unsigned int bin2 = (unsigned int)(gpsStop / fgSearchMapBinning);
163 
164  vector<unsigned int> iCurr;
165  iCurr.push_back(bin1);
166  if (bin1 != bin2)
167  iCurr.push_back(bin2);
168 
169  Index& refIndex = fUpTimeVectorIterator->fFileVersion ? fIndexHeadered : fIndexUnheadered;
170 
171  for (unsigned int j = 0; j < iCurr.size(); ++j) {
172  if (refIndex.find(iCurr[j]) == refIndex.end() || refIndex[iCurr[j]].back().second.fRootFilePtr != fUpTimeVectorIterator->fRootFilePtr)
173  refIndex[iCurr[j]].push_back(make_pair(make_pair(i, i), *fUpTimeVectorIterator));
174  else { // change bounds
175  if (i < refIndex[iCurr[j]].back().first.first)
176  refIndex[iCurr[j]].back().first.first = i;
177  if (i > refIndex[iCurr[j]].back().first.second)
178  refIndex[iCurr[j]].back().first.second = i;
179  }
180  }
181  }
182  }
183 
184  if (fVerbosity > 3) {
185  for (int j = 0; j < 2; ++j) {
186  Index& verbRefIndex = !j ? fIndexHeadered : fIndexUnheadered;
187  cerr << "\t == " << (!j ? "Headered" : "Unheadered") << " files ==\n";
188  for (auto iIndex = verbRefIndex.begin(); iIndex != verbRefIndex.end(); ++iIndex) {
189  cerr << " => index-maxp-entry: bin=" << iIndex->first << ":\n";
190  for (auto iVector = iIndex->second.begin(); iVector != iIndex->second.end(); ++iVector)
191  cerr << "\tstart=" << iVector->first.first
192  << " stop=" << iVector->first.second
193  << " TFile=" << iVector->second.fRootFilePtr->GetName() << '\n';
194  }
195  }
196  }
197 }
198 
199 
201 FdUpTimeFileManager::GetOkFlag(int& returnData,
202  const std::string& componentProperty,
203  const std::string& componentName,
204  const IndexMap& componentIndex)
205  const
206 {
207  if (fAvailableComponents.find(componentProperty) == fAvailableComponents.end())
208  return VManager::eNotFound;
209 
210  if (!fUpTimeVector.size())
211  return VManager::eNotFound;
212 
213  if (!ReadData())
214  return VManager::eNotFound;
215 
216  if (componentProperty == "has_fduptime") {
217  returnData = 1;//0xff;//cout << returnData << endl;
218  return VManager::eFound;
219  }
220 
221  if (componentProperty == "uptime_gpsStart") {
222  returnData = fDataValidity.GetStartTime().GetGPSSecond();
223  return VManager::eFound;
224  } else if (componentProperty == "uptime_gpsStop") {
225  returnData = fDataValidity.GetStopTime().GetGPSSecond();
226  return VManager::eFound;
227  }
228 
229  if (fVerbosity > 2) {
230  ostringstream info;
231  info << "called GetOkFlag for componentName=" << componentName
232  << " componentProperty=" << componentProperty << " and index map:\n";
233  for (auto imap = componentIndex.begin(); imap != componentIndex.end(); ++imap)
234  info << " index=\"" << imap->first << "\" -> \"" << imap->second << "\"\n";
235  INFO(info);
236  }
237 
238  if (componentProperty == "status") {
239 
240  if (componentName == "telescope") {
241 
242  const int dataId = GetTelIndex(componentIndex);
243  const auto iData = fTelescopeStatus.find(dataId);
244  if (iData == fTelescopeStatus.end()) {
245  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
246  return VManager::eNotFound;
247  }
248 
249  returnData = iData->second;
250  return VManager::eFound;
251 
252  } else if (componentName == "eye") {
253 
254  const int eyeId = GetEyeIndex(componentIndex);
255 
256  if (fVerbosity > 2) {
257  ostringstream info;
258  info << " eyeIndex=" << eyeId;
259  for (auto iI = fEyeStatus.begin(); iI != fEyeStatus.end(); ++iI) {
260  info << "\n eyeStatus[" << iI->first << "] = "
261  << iI->second;
262  }
263  INFO(info);
264  }
265 
266  const auto iData = fEyeStatus.find(eyeId);
267  if (iData == fEyeStatus.end()) {
268  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
269  return VManager::eNotFound;
270  }
271 
272  returnData = iData->second;
273  return VManager::eFound;
274 
275  } else if (componentName == "CDAS") {
276 
277  returnData = fCDASStatus;
278  return VManager::eFound;
279 
280  }
281  }
282 
283  return VManager::eNotFound;
284 }
285 
286 
288 FdUpTimeFileManager::GetData(double& returnData,
289  const std::string& componentProperty,
290  const std::string& componentName,
291  const IndexMap& componentIndex)
292  const
293 {
294  // check if property can be provided by manager
295  if (fAvailableComponents.find(componentProperty) == fAvailableComponents.end())
296  return VManager::eNotFound;
297 
298  // check if data available
299  if (!fUpTimeVector.size())
300  return VManager::eNotFound;
301 
302  if (!ReadData())
303  return VManager::eNotFound;
304 
305  if (fVerbosity > 2) {
306  ostringstream info;
307  info << "called GetData(double) for componentName=" << componentName
308  << " componentProperty=" << componentProperty << " and index map:";
309  for (auto imap = componentIndex.begin(); imap != componentIndex.end(); ++imap) {
310  info << "\n index=\"" << imap->first << "\" -> \"" << imap->second << '"';
311  }
312  INFO(info);
313  }
314 
315  if (componentProperty == "has_fduptime") {
316  returnData = 1;//0xff;// cout << returnData;
317  return VManager::eFound;
318  }
319  if (componentName == "channel") {
320  // channel property
321  return GetChannelData(returnData, componentProperty, componentName, componentIndex);
322  } else if (componentProperty == "veto_fraction") {
323  if (componentName == "eye" || componentName == "CDAS")
324  return GetVetoFraction(returnData, componentProperty, componentName, componentIndex);
325  } else if (componentName == "telescope" || componentName == "eye" || componentName == "CDAS") {
326  // eye, tel, cdas property
327  return GetUpTimeFraction(returnData, componentProperty, componentName, componentIndex);
328  }
329 
330  return VManager::eNotFound;
331 }
332 
333 
335 FdUpTimeFileManager::GetUpTimeFraction(double& returnData,
336  const std::string& componentProperty,
337  const std::string& componentName,
338  const IndexMap& componentIndex)
339  const
340 {
341  // check if data available
342  if (!fUpTimeVector.size())
343  return VManager::eNotFound;
344 
345  if (!ReadData())
346  return VManager::eNotFound;
347 
348  if (fVerbosity > 2) {
349  ostringstream info;
350  info << "called GetUpTimeFraction for componentName=" << componentName
351  << " componentProperty=" << componentProperty << " and index map:";
352  for (auto imap = componentIndex.begin(); imap != componentIndex.end(); ++imap) {
353  info << "\n index=\"" << imap->first << "\" -> \"" << imap->second << '"';
354  }
355  INFO(info);
356  }
357 
358  if (componentProperty == "uptime_fraction") {
359 
360  if (componentName == "telescope") {
361 
362  int dataId = GetTelIndex(componentIndex);
363  auto iData = fTelescopeUpTimeFraction.find(dataId);
364  if (iData == fTelescopeUpTimeFraction.end()) {
365  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
366  return VManager::eNotFound;
367  }
368 
369  returnData = iData->second;
370  return VManager::eFound;
371 
372  } else if (componentName == "eye") {
373 
374  int eyeId = GetEyeIndex(componentIndex);
375  auto iData = fEyeUpTimeFraction.find(eyeId);
376  if (iData == fEyeUpTimeFraction.end()) {
377  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
378  return VManager::eNotFound;
379  }
380 
381  returnData = iData->second;
382  return VManager::eFound;
383 
384  } else if (componentName == "CDAS") {
385 
386  returnData = fCDASUpTimeFraction;
387  return VManager::eFound;
388 
389  }
390 
391  }
392 
393  return VManager::eNotFound;
394 }
395 
396 
398 FdUpTimeFileManager::GetVetoFraction(double& returnData,
399  const std::string& componentProperty,
400  const std::string& componentName,
401  const IndexMap& componentIndex)
402  const
403 {
404  // check if data available
405  if (!fUpTimeVector.size())
406  return VManager::eNotFound;
407 
408  if (!ReadData())
409  return VManager::eNotFound;
410 
411  if (fVerbosity > 2) {
412  ostringstream info;
413  info << "called GetVetoFraction for componentName=" << componentName
414  << " componentProperty=" << componentProperty << " and index map:";
415  for (auto imap = componentIndex.begin(); imap != componentIndex.end(); ++imap) {
416  info << "\n index=\"" << imap->first << "\" -> \"" << imap->second << '"';
417  }
418  INFO(info);
419  }
420 
421  if (componentProperty == "veto_fraction") {
422 
423  if (componentName == "eye") {
424 
425  int eyeId = GetEyeIndex(componentIndex);
426  const auto iData = fFDASVetoFraction.find(eyeId);
427  if (iData == fFDASVetoFraction.end()) {
428  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
429  return VManager::eNotFound;
430  }
431 
432  returnData = iData->second;
433  return VManager::eFound;
434 
435  } else if (componentName == "CDAS") {
436 
437  int eyeId = GetEyeIndex(componentIndex);
438  const auto iDataSD = fCDASVetoFraction.find(eyeId);
439  if (iDataSD == fCDASVetoFraction.end()) {
440  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
441  return VManager::eNotFound;
442  }
443 
444  returnData = iDataSD->second;
445  return VManager::eFound;
446 
447  }
448 
449  }
450 
451  return VManager::eNotFound;
452 }
453 
454 
455 int
456 FdUpTimeFileManager::GetEyeIndex(const IndexMap& componentIndex)
457  const
458 {
459  const auto iEyeId = componentIndex.find("eyeId");
460  if (iEyeId == componentIndex.end()) {
461  cerr << "WRONG iEyeId = " << iEyeId->second << '\n';
462  INFO_TERSE("Called FdUpTimeFileManager with wrong number of arguments!");
463  return -1;
464  }
465 
466  return boost::lexical_cast<int>(iEyeId->second);
467 }
468 
469 
470 int
471 FdUpTimeFileManager::GetTelIndex(const IndexMap& componentIndex)
472  const
473 {
474  const auto iEyeId = componentIndex.find("eyeId");
475  const auto iTelId = componentIndex.find("telescopeId");
476  if (iEyeId == componentIndex.end() || iTelId == componentIndex.end()) {
477  INFO_TERSE("Called FdUpTimeFileManager with wrong number of arguments!");
478  return -1;
479  }
480 
481  const auto eyeId = boost::lexical_cast<int>(iEyeId->second);
482  const auto telId = boost::lexical_cast<int>(iTelId->second);
483  const int dataId = 6 * (eyeId - 1) + telId;
484  return dataId;
485 }
486 
487 
488 int
489 FdUpTimeFileManager::GetChannelIndex(const IndexMap& componentIndex)
490  const
491 {
492  const auto iChannelId = componentIndex.find("channelId");
493  if (iChannelId == componentIndex.end()) {
494  INFO_TERSE("Called FdUpTimeFileManager with wrong number of arguments!");
495  return -1;
496  }
497 
498  return boost::lexical_cast<int>(iChannelId->second);
499 }
500 
501 
503 FdUpTimeFileManager::GetChannelData(double& returnData,
504  const std::string& componentProperty,
505  const std::string&,
506  const IndexMap& componentIndex)
507  const
508 {
509  // index is linear --> ((eyeId-1) * 6 + telId) * 440 + channelId;
510  // int dataId = GetChannelIndex(componentIndex);
511 
512  if (fVerbosity > 2) {
513  ostringstream info;
514  info << "called GetChannelData with componentProperty=" << componentProperty << " and index map:";
515  for (auto imap = componentIndex.begin(); imap != componentIndex.end(); ++imap) {
516  info << "\n index=\"" << imap->first << "\" -> \"" << imap->second << '"';
517  }
518  INFO(info);
519  }
520 
521  const int dataId = GetTelIndex(componentIndex);
522  int channelId = GetChannelIndex(componentIndex);
523 
524  if (fVerbosity > 2) {
525  ostringstream info;
526  info << " (eye/tel) dataId=" << dataId << " channelId=" << channelId
527  << " fChannelInfo.size()=" << fChannelInfo.size() << " # tels";
528  INFO(info);
529  }
530 
531  const auto iData = fChannelInfo.find(dataId);
532  if (iData == fChannelInfo.end()) {
533  INFO_TERSE("Requested property of FdUpTimeFileManager not available!");
534  return VManager::eNotFound;
535  }
536 
537  const auto& info = iData->second;
538 
539  if (fVerbosity > 2)
540  cerr << " channel vector size=" << info.size() << '\n';
541 
542  channelId -= 1; // index starts at 0
543  returnData = 0;
544  if ((unsigned int)(channelId) < info.size()) {
545  if (componentProperty == "ADCVariance")
546  returnData = info[channelId].fVariance;
547  else if (componentProperty == "Threshold")
548  returnData = info[channelId].fThreshold;
549  else if (componentProperty == "Baseline")
550  returnData = info[channelId].fBaseline;
551  else
552  return VManager::eNotFound;
553  }
554 
555  if (fVerbosity > 2)
556  cerr << " VAR=" << returnData << '\n';
557 
558  return VManager::eFound;
559 }
560 
561 
562 bool
563 FdUpTimeFileManager::ReadData()
564  const
565 {
566  if (fVerbosity > 2)
567  INFO("enter ReadData");
568 
569  if (fDataValidity.IsValid()) {
570  if (fVerbosity > 2)
571  INFO("Data is still valid");
572  return true;
573  }
574 
575  unsigned int now = det::Detector::GetInstance().GetTime().GetGPSSecond();
576 
577  // really get the data from the TTree
578  fEyeUpTimeFraction.clear();
579  fFDASVetoFraction.clear();
580  fTelescopeUpTimeFraction.clear();
581  fEyeStatus.clear();
582  fTelescopeStatus.clear();
583  fCDASStatus = 0;
584  fCDASUpTimeFraction = 0.;
585  fCDASVetoFraction.clear();
586  fChannelInfo.clear();
587 
588  // using the index map to get first bounds ...
589  unsigned int iBin = (unsigned int)(now / fgSearchMapBinning);
590  const ConstIndexIterator iIndex[2] = { fIndexHeadered.find(iBin), fIndexUnheadered.find(iBin) };
591 
592  if (iIndex[0] == fIndexHeadered.end() && iIndex[1] == fIndexUnheadered.end())
593  return false;
594 
595  unsigned int lower = 0;
596  unsigned int upper = 0;
597  string fileName;
598  bool foundLimits = false;
599  TTree* actualDataTree = nullptr;
600  double upTimeVer = 0;
601 
602  for (int j = 0; j < 2; ++j) {
603 
604  if (iIndex[j] == (!j ? fIndexHeadered.end() : fIndexUnheadered.end()))
605  continue;
606 
607  for (auto iVector = iIndex[j]->second.begin(); iVector != iIndex[j]->second.end(); ++iVector) {
608  if (iVector->second.fGpsStart <= now && now < iVector->second.fGpsStop) {
609  lower = iVector->first.first;
610  upper = iVector->first.second;
611  fileName = iVector->second.fRootFilePtr->GetName();
612  actualDataTree = iVector->second.fDataTree;
613  upTimeVer = iVector->second.fFileVersion;
614  foundLimits = true;
615  break;
616  }
617  }
618  if (foundLimits)
619  break;
620  }
621  if (!foundLimits)
622  return false;
623 
624  if (fVerbosity > 2) {
625  ostringstream info;
626  info << " index: now=" << now
627  << " index=" << iBin
628  << " lower=" << lower
629  << " upper=" << upper
630  << " TFile=" << fileName;
631  INFO(info);
632  }
633 
634  // start looking into TTree
635  TBranch* const startB = actualDataTree->GetBranch("uptime_gpsStart");
636  UInt_t gpsStart = 0;
637  startB->SetAddress(&gpsStart);
638  TBranch* const stopB = actualDataTree->GetBranch("uptime_gpsStop");
639  UInt_t gpsStop = 0;
640  stopB->SetAddress(&gpsStop);
641 
642  int nSearch = 0;
643  int index = 0 ;
644  bool foundit = false;
645  while (!foundit && upper >= lower) {
646 
647  index = lower + (upper - lower)/2;
648  startB->GetEntry(index);
649  stopB->GetEntry(index);
650 
651  if (gpsStart <= now && now < gpsStop) {
652  foundit = true;
653  } else {
654  if (now < gpsStart)
655  upper = index - 1;
656  else
657  lower = index + 1;
658  }
659  ++nSearch;
660 
661  if (fVerbosity > 2) {
662  cerr << " search loop: nSearch=" << nSearch
663  << " gpsStart=" << gpsStart
664  << " gpsStop=" << gpsStop
665  << " foundit=" << foundit
666  << " index=" << index << '\n';
667  }
668 
669  }
670 
671  if (fVerbosity > 2) {
672  cerr << " END search loop: "
673  << " index=" << index << '\n';
674  }
675 
676  if (foundit) {
677  Double_t tel_up_time_fraction[27] = { 0 };
678  UInt_t tel_status[27] = { 0 };
679  Double_t eye_up_time_fraction[5] = { 0 };
680  UInt_t eye_status[5] = { 0 };
681  Double_t cDAS_up_time_fraction = 0;
682  Double_t fDAS_veto_fraction[5] = { 0 };
683  Double_t cDAS_conn_fraction[5] = { 0 };
684  Double_t cDAS_veto_fraction[5] = { 0 };
685  UInt_t cDAS_status = 0;
686  UInt_t time_start = 0;
687  UInt_t time_stop = 0;
688  UShort_t channel_var[27][kNPixelPerTel] = { { 0 } };
689  UShort_t channel_threshold[27][kNPixelPerTel] = { { 0 } };
690  UShort_t channel_baseline[27][kNPixelPerTel] = { { 0 } };
691 
692  actualDataTree->SetBranchAddress("uptime_gpsStart", &time_start);
693  actualDataTree->SetBranchAddress("uptime_gpsStop", &time_stop);
694  actualDataTree->SetBranchAddress("TelescopeUpFraction", &tel_up_time_fraction);
695  actualDataTree->SetBranchAddress("EyeUpFraction", &eye_up_time_fraction);
696  if (fVerbosity > 2)
697  cerr << "UpTimeFile Version is " << upTimeVer << '\n';
698  if (upTimeVer < 3) {
699  actualDataTree->SetBranchAddress("TelescopeStatus", &tel_status);
700  actualDataTree->SetBranchAddress("EyeStatus",eye_status);
701  actualDataTree->SetBranchAddress("CDASUpFraction", &cDAS_up_time_fraction);
702  } else {
703  actualDataTree->SetBranchAddress("FDASVetoFraction", &fDAS_veto_fraction);
704  actualDataTree->SetBranchAddress("CDASConnFraction", &cDAS_conn_fraction);
705  actualDataTree->SetBranchAddress("CDASVetoFraction", &cDAS_veto_fraction);
706  }
707  actualDataTree->SetBranchAddress("CDASStatus", &cDAS_status);
708  actualDataTree->SetBranchAddress("ADCVariance", &channel_var);
709  actualDataTree->SetBranchAddress("ADCThreshold", &channel_threshold);
710  actualDataTree->SetBranchAddress("ADCBaseline", &channel_baseline);
711 
712  actualDataTree->GetEntry(index);
713 
714  for (int iEye = 1; iEye <= 5; ++iEye) {
715 
716  int nTel = 6;
717  if (iEye == 5)
718  nTel = 3;
719 
720  for (int iTel = 1; iTel <= nTel; ++iTel) {
721 
722  const int telIndex = 6*(iEye - 1) + iTel;
723  const int telIndex1 = telIndex - 1;
724 
725  fTelescopeUpTimeFraction[telIndex] = tel_up_time_fraction[telIndex1];
726  if (upTimeVer < 3)
727  fTelescopeStatus[telIndex] = tel_status[telIndex1];
728  else if (fTelescopeUpTimeFraction[telIndex] > 0)
729  fTelescopeStatus[telIndex] = 1;
730  else
731  fTelescopeStatus[telIndex] = 0;
732  fChannelInfo[telIndex].clear();
733  for (unsigned int channel = 0; channel < kNPixelPerTel; ++channel) {
734  fChannelInfo[telIndex].push_back(
735  ChannelInfo(
736  channel_var[telIndex1][channel], // VAR
737  channel_threshold[telIndex1][channel], // threshold
738  channel_baseline[telIndex1][channel] // baseline
739  )
740  );
741  }
742  }
743 
744  const int iEye1 = iEye - 1;
745  if (upTimeVer < 3) {
746  fEyeStatus[iEye] = eye_status[iEye1];
747  fEyeUpTimeFraction[iEye] = eye_up_time_fraction[iEye1];
748  fFDASVetoFraction[iEye] = 1;
749  fCDASVetoFraction[iEye] = 1;
750  } else {
751  fFDASVetoFraction[iEye] = fDAS_veto_fraction[iEye1];
752  fEyeUpTimeFraction[iEye] = eye_up_time_fraction[iEye1];
753  if (fEyeUpTimeFraction[iEye] > 0)
754  fEyeStatus[iEye] = 1;
755  fCDASVetoFraction[iEye] = cDAS_veto_fraction[iEye1];
756  }
757 
758  } // end for eye
759 
760  fCDASStatus = cDAS_status;
761 
762  if (upTimeVer < 3)
763  fCDASUpTimeFraction = cDAS_up_time_fraction;
764  else
765  fCDASUpTimeFraction = 1;
766 
767  fDataValidity.SetValidityInterval(TimeStamp(time_start), TimeStamp(time_stop));
768 
769  }
770 
771  if (fVerbosity > 2) {
772  cerr << " ReadData result is valid from start: "
773  << fDataValidity.GetStartTime().GetGPSSecond()
774  << " end: " << fDataValidity.GetStopTime().GetGPSSecond() << '\n';
775  }
776 
777  return foundit;
778 }
#define INFO_TERSE(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:175
bool UpTimePeriodSortFunction(const UpTimePeriod &first, const UpTimePeriod &second)
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
void Init()
Initialise the registry.
std::map< unsigned int, IndexVector > Index
A TimeStamp holds GPS second and nanosecond for some event.
Definition: TimeStamp.h:110
Base class to report exceptions in IO.
UpTimePeriod()=default
const double second
Definition: GalacticUnits.h:32
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
Class to manage Fd UpTime ROOT files.
const string file
Index::const_iterator ConstIndexIterator
#define REGISTER_F_MANAGER(_name_, _Type_)
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127

, generated on Tue Sep 26 2023.