RndmLocator.cxx
Go to the documentation of this file.
2 
3 #include <cassert>
4 #include <cmath>
5 #include <iostream>
6 
7 #include "NovaTimingUtilities/TimingUtilities.h"
8 
9 #include "TFile.h"
10 #include "TTree.h"
11 
12 namespace locator
13 {
15  {
16 
17  TFile f(fname.c_str());
18  assert(!f.IsZombie());
19 
20  TTree* tr = (TTree*)f.Get("ntp");
21  assert(tr);
22 
23  const int N = tr->GetEntries();
24 
25  ULong64_t t, t2, t3, t4;
26  tr->SetBranchAddress("Night_Twilight", &t);
27  tr->SetBranchAddress("Twilight_Day", &t2);
28  tr->SetBranchAddress("Day_Twilight", &t3);
29  tr->SetBranchAddress("Twilight_Night", &t4);
30 
31  for(int n = 0; n < N; ++n){
32  tr->GetEntry(n);
33  vNight_Twilight.push_back(t);
34  vTwilight_Day.push_back(t2);
35  vDay_Twilight.push_back(t3);
36  vTwilight_Night.push_back(t4);
37  }
38  }
39 
40 
42  {
43  }
44 
45  //......................................................................
46  void RndmLocatorTable::TNS(struct timespec ts, time_t &tRU) const
47  {
48 
49  uint64_t t;
50  time_t tR;
51  struct timespec tR_new;
52 
54  long long tickperday = 64000000L * 60L * 60L * 24L;
55  lldiv_t tmp = lldiv(t, tickperday);
56 
57  // moon_position_table_new3.py -d 2009/12/31 -n 2600
58  // The file is located at Eval/tools
59  int day_index = tmp.quot;
60 
61  if ( t>=vTwilight_Day[day_index] && t<=vDay_Twilight[day_index] ){
62 
63  TRandom3 rGen(0);
64  double rand = rGen.Uniform(0.0, 1.0);
65 
66  tR = rand *
67  (vNight_Twilight[day_index+1] - vTwilight_Night[day_index])
68  + vTwilight_Night[day_index];
69 
71  tRU = tR_new.tv_sec;
72  }
73  else{
74  tRU = ts.tv_sec;
75  }
76  }
77 
78 }
void TNS(struct timespec ts, time_t &tRU) const
Definition: RndmLocator.cxx:46
Float_t tmp
Definition: plot.C:36
bool convertNovaTimeToUnixTime(uint64_t const &inputNovaTime, struct timespec &outputUnixTime)
std::vector< ULong64_t > vDay_Twilight
Definition: RndmLocator.h:34
std::vector< ULong64_t > vNight_Twilight
Definition: RndmLocator.h:32
static constexpr double L
std::vector< ULong64_t > vTwilight_Night
Definition: RndmLocator.h:35
double t2
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::vector< ULong64_t > vTwilight_Day
Definition: RndmLocator.h:33
RndmLocatorTable(const std::string &fname)
Definition: RndmLocator.cxx:14
Detector geometry information.
assert(nhit_max >=nhit_nbins)
bool convertUnixTimeToNovaTime(struct timespec const &inputUnixTime, uint64_t &outputNovaTime)