Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
calib::DriftCache Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-10-28/Calibrator/func/DriftCache.h"

Public Member Functions

 DriftCache ()
 
virtual ~DriftCache ()
 
double GetFactor (int plane, int cell)
 
void SetRun (int detector, int run)
 
void SetCSVFile (std::string f)
 
void SetTag (const std::string &tag)
 
std::string GetTag ()
 
void SetUseEpochs (bool b)
 
bool UseEpochs ()
 
void SetEpoch (const std::string &epoch)
 
std::string Epoch ()
 
void SetEpochTag (const std::string &tag)
 
std::string EpochTag ()
 
void GetEpochFromDB ()
 
void UseCSVsFromUPS (bool use=true)
 
void SetCSVSource (const std::string &path)
 

Protected Member Functions

void Load ()
 
std::string GetCSVPath ()
 

Protected Attributes

bool fTableLoaded
 
bool fUseEpochs
 
bool fUseCSVsFromUPS
 
int fDet
 
int fFactorIdx
 
int fRun
 
std::string fCSVFile
 
std::string fCSVSourceDir
 
std::string fTag
 
std::string fEpochTag
 
std::string fEpoch
 
nova::dbi::TablefTbl
 

Detailed Description

Definition at line 21 of file DriftCache.h.

Constructor & Destructor Documentation

calib::DriftCache::DriftCache ( )

Definition at line 22 of file DriftCache.cxx.

23  : fTableLoaded(false),
24  fUseEpochs(false),
25  fDet(0),
26  fFactorIdx(-1),
27  fRun(0),
28  fCSVFile(""),
29  fTag(""),
30  fEpochTag(""),
31  fEpoch(""),
32  fTbl(0)
33  {
34  }
nova::dbi::Table * fTbl
Definition: DriftCache.h:68
std::string fEpoch
Definition: DriftCache.h:66
std::string fTag
Definition: DriftCache.h:64
std::string fEpochTag
Definition: DriftCache.h:65
std::string fCSVFile
Definition: DriftCache.h:62
calib::DriftCache::~DriftCache ( )
virtual

Definition at line 37 of file DriftCache.cxx.

References fTbl.

38  {
39  if (fTbl) delete fTbl;
40  }
nova::dbi::Table * fTbl
Definition: DriftCache.h:68

Member Function Documentation

std::string calib::DriftCache::Epoch ( )
inline

Definition at line 40 of file DriftCache.h.

40 { return fEpoch; }
std::string fEpoch
Definition: DriftCache.h:66
std::string calib::DriftCache::EpochTag ( )
inline

Definition at line 43 of file DriftCache.h.

43 { return fEpochTag; }
std::string fEpochTag
Definition: DriftCache.h:65
std::string calib::DriftCache::GetCSVPath ( )
protected

Definition at line 103 of file DriftCache.cxx.

References ana::assert(), fCSVFile, fEpoch, fTag, fUseEpochs, cet::getenv(), and GetEpochFromDB().

Referenced by Load().

104  {
105 
106  // if configured to provide own file
107  if(!fCSVFile.empty()){
108  return fCSVFile.c_str();
109  }
110 
111  // necessary components of path
112  const char* ups_path = getenv("CALIBCSVS_CSV_PATH");
113  assert(ups_path);
114  const char* detStr = "fd";
115 
116  if (fUseEpochs) {
117  GetEpochFromDB();
118  assert(!fEpoch.empty());
119  }
120 
121  std::string fullPath = std::string(ups_path) + "/" + fTag + "/calib_drift." + detStr + "." + fTag + "." + fEpoch + ".csv";
122  // Return final path
123 
124  return fullPath;
125  }
std::string getenv(std::string const &name)
std::string fEpoch
Definition: DriftCache.h:66
std::string fTag
Definition: DriftCache.h:64
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::string fCSVFile
Definition: DriftCache.h:62
assert(nhit_max >=nhit_nbins)
void calib::DriftCache::GetEpochFromDB ( )

Definition at line 83 of file DriftCache.cxx.

References ana::assert(), nova::dbi::Row::Col(), fDet, fEpoch, fEpochTag, fRun, fUseEpochs, nova::dbi::Column::Get(), nova::dbi::Table::GetColIndex(), nova::dbi::Table::GetRow(), nova::dbi::kDataOnly, nova::dbi::Table::Load(), nova::dbi::Table::NRow(), nova::dbi::Table::SetDataTypeMask(), nova::dbi::Table::SetDetector(), nova::dbi::Table::SetMaxTSVld(), nova::dbi::Table::SetMinTSVld(), nova::dbi::Table::SetTag(), and nova::dbi::Table::SetVerbosity().

Referenced by GetCSVPath(), and Load().

84  {
85  // first get epoch
86  if (fUseEpochs) {
87  nova::dbi::Table tbl("Calibration/tables/CalibDriftEpochs.xml");
88  tbl.SetDataTypeMask(nova::dbi::kDataOnly);
89  tbl.SetTag(fEpochTag);
90  tbl.SetDetector(fDet);
91  tbl.SetMinTSVld(fRun);
92  tbl.SetMaxTSVld(fRun);
93  tbl.SetVerbosity(100);
94  assert(tbl.Load());
95  assert(tbl.NRow() == 1);
96 
97  int epochIdx = tbl.GetColIndex("epoch");
98  tbl.GetRow(0)->Col(epochIdx).Get(fEpoch);
99  }
100  }
std::string fEpoch
Definition: DriftCache.h:66
std::string fEpochTag
Definition: DriftCache.h:65
assert(nhit_max >=nhit_nbins)
double calib::DriftCache::GetFactor ( int  plane,
int  cell 
)

Definition at line 43 of file DriftCache.cxx.

References febshutoff_auto::chan, nova::dbi::Row::Col(), om::cout, allTimeWatchdog::endl, fFactorIdx, fRun, fTableLoaded, fTbl, nova::dbi::Column::Get(), nova::dbi::Table::GetVldRow(), makeTrainCVSamples::int, Load(), and check_grl::row.

Referenced by calib::Calibrator::GetDriftScale().

44  {
45  if (!fTableLoaded) Load();
46 
48  int tchan = 12*plane + int(cell/32) + 1;
49 
50  //**********
51  nova::dbi::Row* row = fTbl->GetVldRow(tchan, fRun);
52  if (!row) {
53  std::cout << "DriftCache no factor found for channel " << tchan << std::endl;
54  std::abort();
55  }
56  double factor;
57  if(!row->Col(fFactorIdx).Get(factor)) std::abort();
58  return factor;
59  }
Column & Col(int i)
Find index of column with name. Suitable for passing to Col.
Definition: Row.h:63
nova::dbi::Table * fTbl
Definition: DriftCache.h:68
bool Get(T &val) const
Definition: Column.h:85
OStream cout
Definition: OStream.cxx:6
nova::dbi::Row * GetVldRow(unsigned long long channel, time_t t)
Definition: Table.cpp:2399
A (plane, cell) pair.
Definition: OfflineChan.h:17
std::string calib::DriftCache::GetTag ( )
inline

Definition at line 34 of file DriftCache.h.

34 { return fTag; }
std::string fTag
Definition: DriftCache.h:64
void calib::DriftCache::Load ( )
protected

Definition at line 128 of file DriftCache.cxx.

References om::cout, allTimeWatchdog::endl, nova::dbi::Table::FillChanRowMap(), fTableLoaded, fTbl, GetCSVPath(), GetEpochFromDB(), nova::dbi::Table::LoadFromCSV(), and nova::dbi::Table::NRow().

Referenced by GetFactor().

129  {
130  if (fTableLoaded) return;
131 
132  mf::LogInfo("DriftCache")
133  << "Initializing drift cache ...\n";
134 
135  const std::string constsCSVSource = GetCSVPath();
136 
137  GetEpochFromDB(); // will access dB if configured to do so
138 
139  if (fTbl->LoadFromCSV(constsCSVSource) <= 0){
140  std::cout<< "DriftCache Load failed to read from CSV file " <<std::endl;
141  std::abort();
142  }
143  if (fTbl->NRow() == 0){
144  std::cout<< "DriftCache Load found 0 rows in CSV file " <<std::endl;
145  std::abort();
146  }
147 
148  fTableLoaded = true;
149  fTbl->FillChanRowMap();
150  }
int LoadFromCSV(std::string fname, int offset=0, int limit=-1)
Definition: Table.cpp:1703
void FillChanRowMap()
Definition: Table.cpp:2355
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
nova::dbi::Table * fTbl
Definition: DriftCache.h:68
std::string GetCSVPath()
Definition: DriftCache.cxx:103
OStream cout
Definition: OStream.cxx:6
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
int NRow()
Definition: Table.h:101
void calib::DriftCache::SetCSVFile ( std::string  f)
inline
void calib::DriftCache::SetCSVSource ( const std::string &  path)
inline

Definition at line 48 of file DriftCache.h.

References Load(), and path.

Referenced by calib::Calibrator::Calibrator().

48 { fCSVSourceDir = path; }
std::string fCSVSourceDir
Definition: DriftCache.h:63
const std::string path
Definition: plot_BEN.C:43
void calib::DriftCache::SetEpoch ( const std::string &  epoch)
inline

Definition at line 39 of file DriftCache.h.

39 { fEpoch = epoch; }
std::string fEpoch
Definition: DriftCache.h:66
void calib::DriftCache::SetEpochTag ( const std::string &  tag)
inline

Definition at line 42 of file DriftCache.h.

References getGoodRuns4SAM::tag.

Referenced by calib::Calibrator::Calibrator().

void calib::DriftCache::SetRun ( int  detector,
int  run 
)

Definition at line 62 of file DriftCache.cxx.

References fillBadChanDBTables::det, fDet, fFactorIdx, fRun, fTableLoaded, fTag, fTbl, nova::dbi::Table::GetColIndex(), nova::dbi::kDataOnly, updateRunHistoryTables::run, nova::dbi::Table::SetDataTypeMask(), nova::dbi::Table::SetDetector(), nova::dbi::Table::SetMaxTSVld(), nova::dbi::Table::SetMinTSVld(), nova::dbi::Table::SetTag(), and nova::dbi::Table::SetVerbosity().

Referenced by calib::Calibrator::postBeginRun().

63  {
64  fDet = det;
65 
66  fRun =run;
67 
68  if (fTbl) delete fTbl;
69 
70  fTbl = new nova::dbi::Table("Calibration/tables/DriftCorrVld.xml");
72  fTbl->SetVerbosity(100);
76  fTbl->SetTag(fTag);
77  fFactorIdx = fTbl->GetColIndex("corr");
78  fTableLoaded = false;
79 
80  }
void SetTag(std::string s)
Definition: Table.h:290
nova::dbi::Table * fTbl
Definition: DriftCache.h:68
int GetColIndex(std::string cname)
Definition: Table.cpp:952
void SetDataTypeMask(int mask)
Definition: Table.h:74
void SetMinTSVld(time_t t)
Definition: Table.h:284
std::string fTag
Definition: DriftCache.h:64
bool SetDetector(std::string det)
Definition: Table.cpp:839
struct Table Table
Definition: TexBuilder.h:2
void SetMaxTSVld(time_t t)
Definition: Table.h:285
void SetVerbosity(int i)
Definition: Table.h:98
void calib::DriftCache::SetTag ( const std::string &  tag)
inline

Definition at line 33 of file DriftCache.h.

References getGoodRuns4SAM::tag.

Referenced by calib::Calibrator::Calibrator().

33 { fTag = tag; }
std::string fTag
Definition: DriftCache.h:64
void calib::DriftCache::SetUseEpochs ( bool  b)
inline

Definition at line 36 of file DriftCache.h.

References b.

Referenced by calib::Calibrator::Calibrator().

36 { fUseEpochs = b; }
const hit & b
Definition: hits.cxx:21
void calib::DriftCache::UseCSVsFromUPS ( bool  use = true)
inline

Definition at line 47 of file DriftCache.h.

Referenced by calib::Calibrator::Calibrator().

47 {fUseCSVsFromUPS = use;}
bool calib::DriftCache::UseEpochs ( )
inline

Definition at line 37 of file DriftCache.h.

37 { return fUseEpochs; }

Member Data Documentation

std::string calib::DriftCache::fCSVFile
protected

Definition at line 62 of file DriftCache.h.

Referenced by GetCSVPath().

std::string calib::DriftCache::fCSVSourceDir
protected

Definition at line 63 of file DriftCache.h.

int calib::DriftCache::fDet
protected

Definition at line 58 of file DriftCache.h.

Referenced by GetEpochFromDB(), and SetRun().

std::string calib::DriftCache::fEpoch
protected

Definition at line 66 of file DriftCache.h.

Referenced by GetCSVPath(), and GetEpochFromDB().

std::string calib::DriftCache::fEpochTag
protected

Definition at line 65 of file DriftCache.h.

Referenced by GetEpochFromDB().

int calib::DriftCache::fFactorIdx
protected

Definition at line 59 of file DriftCache.h.

Referenced by GetFactor(), and SetRun().

int calib::DriftCache::fRun
protected

Definition at line 60 of file DriftCache.h.

Referenced by GetEpochFromDB(), GetFactor(), and SetRun().

bool calib::DriftCache::fTableLoaded
protected

Definition at line 54 of file DriftCache.h.

Referenced by GetFactor(), Load(), and SetRun().

std::string calib::DriftCache::fTag
protected

Definition at line 64 of file DriftCache.h.

Referenced by GetCSVPath(), and SetRun().

nova::dbi::Table* calib::DriftCache::fTbl
protected

Definition at line 68 of file DriftCache.h.

Referenced by GetFactor(), Load(), SetRun(), and ~DriftCache().

bool calib::DriftCache::fUseCSVsFromUPS
protected

Definition at line 56 of file DriftCache.h.

bool calib::DriftCache::fUseEpochs
protected

Definition at line 55 of file DriftCache.h.

Referenced by GetCSVPath(), and GetEpochFromDB().


The documentation for this class was generated from the following files: