LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
lariov::SIOVChannelStatusProvider Class Reference

Class providing information about the quality of channels. More...

#include "SIOVChannelStatusProvider.h"

Inheritance diagram for lariov::SIOVChannelStatusProvider:
lariov::DatabaseRetrievalAlg

Public Member Functions

 SIOVChannelStatusProvider (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~SIOVChannelStatusProvider ()=default
 Default destructor. More...
 
const ChannelStatus & GetChannelStatus (raw::ChannelID_t channel) const
 Returns Channel Status. More...
 
Status_t Status (raw::ChannelID_t channel) const override
 
virtual void Reconfigure (fhicl::ParameterSet const &p)
 Configure using fhicl::ParameterSet. More...
 
bool UpdateFolder (DBTimeStamp_t ts)
 Return true if fFolder is successfully updated. More...
 
const std::string & URL () const
 Get connection information. More...
 
const std::string & FolderName () const
 
const std::string & Tag () const
 
const IOVTimeStamp & Begin () const
 Get Timestamp information. More...
 
const IOVTimeStamp & End () const
 
Single channel queries

Returns whether the specified channel is physical and connected to wire

bool IsPresent (raw::ChannelID_t channel) const override
 Returns whether the specified channel is bad in the current run. More...
 
bool IsBad (raw::ChannelID_t channel) const override
 Returns whether the specified channel is bad in the current run. More...
 
bool IsNoisy (raw::ChannelID_t channel) const override
 Returns whether the specified channel is noisy in the current run. More...
 
bool IsGood (raw::ChannelID_t channel) const override
 Returns whether the specified channel is physical and good. More...
 
Global channel queries

Returns a copy of set of good channel IDs for the current run

ChannelSet_t GoodChannels () const override
 Returns a copy of set of bad channel IDs for the current run. More...
 
ChannelSet_t BadChannels () const override
 Returns a copy of set of bad channel IDs for the current run. More...
 
ChannelSet_t NoisyChannels () const override
 Returns a copy of set of noisy channel IDs for the current run. More...
 
Configuration functions

Prepares the object to provide information about the specified time

bool Update (DBTimeStamp_t)
 Allows a service to add to the list of noisy channels. More...
 
void AddNoisyChannel (raw::ChannelID_t ch)
 Allows a service to add to the list of noisy channels. More...
 

Static Public Member Functions

static DBChannelID_t rawToDBChannel (raw::ChannelID_t channel)
 Converts LArSoft channel ID in the one proper for the DB. More...
 

Protected Attributes

std::unique_ptr< DBFolderfFolder
 

Private Member Functions

ChannelSet_t GetChannelsWithStatus (chStatus status) const
 

Private Attributes

DataSource::ds fDataSource
 
Snapshot< ChannelStatus > fData
 
Snapshot< ChannelStatus > fNewNoisy
 
ChannelStatus fDefault
 

Detailed Description

Class providing information about the quality of channels.


This class serves information read from a FHiCL configuration file and/or a database.

LArSoft interface to this class is through the service SIOVChannelStatusService.

Definition at line 35 of file SIOVChannelStatusProvider.h.

Constructor & Destructor Documentation

lariov::SIOVChannelStatusProvider::SIOVChannelStatusProvider ( fhicl::ParameterSet const &  pset)

Constructor.

Definition at line 33 of file SIOVChannelStatusProvider.cxx.

References fData, fDataSource, fDefault, file, and fhicl::ParameterSet::get().

34  : DatabaseRetrievalAlg(pset.get<fhicl::ParameterSet>("DatabaseRetrievalAlg"))
35  , fDefault(0)
36  {
37 
38  bool UseDB = pset.get<bool>("UseDB", false);
39  bool UseFile = pset.get<bool>("UseFile", false);
40  std::string fileName = pset.get<std::string>("FileName", "");
41 
42  //priority: (1) use db, (2) use table, (3) use defaults
43  //If none are specified, use defaults
44  if ( UseDB ) fDataSource = DataSource::Database;
45  else if (UseFile) fDataSource = DataSource::File;
46  else fDataSource = DataSource::Default;
47 
48  if (fDataSource == DataSource::Default) {
49  std::cout << "Using default channel status value: "<<kGOOD<<"\n";
50  fDefault.SetStatus(kGOOD);
51  }
52  else if (fDataSource == DataSource::File) {
53  cet::search_path sp("FW_SEARCH_PATH");
54  std::string abs_fp = sp.find_file(fileName);
55  std::cout << "Using channel statuses from local file: "<<abs_fp<<"\n";
56  std::ifstream file(abs_fp);
57  if (!file) {
58  throw cet::exception("SIOVChannelStatusProvider")
59  << "File "<<abs_fp<<" is not found.";
60  }
61 
62  std::string line;
63  ChannelStatus cs(0);
64  while (std::getline(file, line)) {
65  DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, line.find(',')));
66  int status = std::stoi(line.substr(line.find(',')+1));
67 
68  cs.SetChannel(ch);
69  cs.SetStatus( ChannelStatus::GetStatusFromInt(status) );
70  fData.AddOrReplaceRow(cs);
71  }
72  } // if source from file
73  else {
74  std::cout << "Using channel statuses from conditions database\n";
75  }
76  }
TFile * file
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &tag="")
Constructors.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
virtual lariov::SIOVChannelStatusProvider::~SIOVChannelStatusProvider ( )
virtualdefault

Default destructor.

Member Function Documentation

void lariov::SIOVChannelStatusProvider::AddNoisyChannel ( raw::ChannelID_t  ch)

Allows a service to add to the list of noisy channels.

Definition at line 172 of file SIOVChannelStatusProvider.cxx.

References fNewNoisy, IsBad(), IsPresent(), and rawToDBChannel().

Referenced by Status().

172  {
173 
174  // for c2: ISO C++17 does not allow 'register' storage class specifier
175  //register DBChannelID_t const dbch = rawToDBChannel(ch);
176  DBChannelID_t const dbch = rawToDBChannel(ch);
177  if (!this->IsBad(dbch) && this->IsPresent(dbch)) {
178  ChannelStatus cs(dbch);
179  cs.SetStatus(kNOISY);
180  fNewNoisy.AddOrReplaceRow(cs);
181  }
182  }
bool IsPresent(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
static DBChannelID_t rawToDBChannel(raw::ChannelID_t channel)
Converts LArSoft channel ID in the one proper for the DB.
bool IsBad(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::BadChannels ( ) const
override

Returns a copy of set of bad channel IDs for the current run.

Definition at line 156 of file SIOVChannelStatusProvider.cxx.

References GetChannelsWithStatus().

Referenced by Status().

156  {
157  ChannelSet_t dead = GetChannelsWithStatus(kDEAD);
158  ChannelSet_t ln = GetChannelsWithStatus(kLOWNOISE);
159  dead.insert(ln.begin(),ln.end());
160  return dead;
161  }
ChannelSet_t GetChannelsWithStatus(chStatus status) const
const IOVTimeStamp& lariov::DatabaseRetrievalAlg::Begin ( ) const
inlineinherited
const IOVTimeStamp& lariov::DatabaseRetrievalAlg::End ( ) const
inlineinherited
const std::string& lariov::DatabaseRetrievalAlg::FolderName ( ) const
inlineinherited

Definition at line 55 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

55 {return fFolder->FolderName();}
std::unique_ptr< DBFolder > fFolder
const ChannelStatus & lariov::SIOVChannelStatusProvider::GetChannelStatus ( raw::ChannelID_t  channel) const

Returns Channel Status.

Definition at line 105 of file SIOVChannelStatusProvider.cxx.

References fData, fDataSource, fDefault, fNewNoisy, and rawToDBChannel().

Referenced by GetChannelsWithStatus(), IsBad(), IsGood(), IsNoisy(), IsPresent(), and Status().

105  {
106  if (fDataSource == DataSource::Default) {
107  return fDefault;
108  }
109 
110  if (fNewNoisy.HasChannel(rawToDBChannel(ch))) {
111  return fNewNoisy.GetRow(rawToDBChannel(ch));
112  }
113  else {
114  return fData.GetRow(rawToDBChannel(ch));
115  }
116  }
static DBChannelID_t rawToDBChannel(raw::ChannelID_t channel)
Converts LArSoft channel ID in the one proper for the DB.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::GetChannelsWithStatus ( chStatus  status) const
private

Definition at line 121 of file SIOVChannelStatusProvider.cxx.

References fDataSource, fDefault, and GetChannelStatus().

Referenced by BadChannels(), GoodChannels(), and NoisyChannels().

121  {
122 
123  ChannelSet_t retSet;
124  retSet.clear();
125  DBChannelID_t maxChannel = art::ServiceHandle<geo::Geometry>()->Nchannels() - 1;
126  if (fDataSource == DataSource::Default) {
127  if (fDefault.Status() == status) {
128  std::vector<DBChannelID_t> chs;
129  for (DBChannelID_t ch=0; ch != maxChannel; ++ch) {
130  chs.push_back(ch);
131  }
132  retSet.insert(chs.begin(), chs.end());
133  }
134  }
135  else {
136  std::vector<DBChannelID_t> chs;
137  for (DBChannelID_t ch=0; ch != maxChannel; ++ch) {
138  if (this->GetChannelStatus(ch).Status() == status) chs.push_back(ch);
139  }
140 
141  retSet.insert(chs.begin(), chs.end());
142  }
143  return retSet;
144  }
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::GoodChannels ( ) const
override

Returns a copy of set of bad channel IDs for the current run.

Definition at line 149 of file SIOVChannelStatusProvider.cxx.

References GetChannelsWithStatus().

Referenced by Status().

149  {
150  return GetChannelsWithStatus(kGOOD);
151  }
ChannelSet_t GetChannelsWithStatus(chStatus status) const
bool lariov::SIOVChannelStatusProvider::IsBad ( raw::ChannelID_t  channel) const
inlineoverride

Returns whether the specified channel is bad in the current run.

Definition at line 63 of file SIOVChannelStatusProvider.h.

References GetChannelStatus(), and IsPresent().

Referenced by AddNoisyChannel().

63  {
64  return GetChannelStatus(channel).IsDead() || GetChannelStatus(channel).IsLowNoise() || !IsPresent(channel);
65  }
bool IsPresent(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsGood ( raw::ChannelID_t  channel) const
inlineoverride

Returns whether the specified channel is physical and good.

Definition at line 73 of file SIOVChannelStatusProvider.h.

References GetChannelStatus().

73  {
74  return GetChannelStatus(channel).IsGood();
75  }
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsNoisy ( raw::ChannelID_t  channel) const
inlineoverride

Returns whether the specified channel is noisy in the current run.

Definition at line 68 of file SIOVChannelStatusProvider.h.

References GetChannelStatus().

68  {
69  return GetChannelStatus(channel).IsNoisy();
70  }
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsPresent ( raw::ChannelID_t  channel) const
inlineoverride

Returns whether the specified channel is bad in the current run.

Definition at line 58 of file SIOVChannelStatusProvider.h.

References GetChannelStatus().

Referenced by AddNoisyChannel(), and IsBad().

58  {
59  return GetChannelStatus(channel).IsPresent();
60  }
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::NoisyChannels ( ) const
override

Returns a copy of set of noisy channel IDs for the current run.

Definition at line 166 of file SIOVChannelStatusProvider.cxx.

References GetChannelsWithStatus().

Referenced by Status().

166  {
167  return GetChannelsWithStatus(kNOISY);
168  }
ChannelSet_t GetChannelsWithStatus(chStatus status) const
static DBChannelID_t lariov::SIOVChannelStatusProvider::rawToDBChannel ( raw::ChannelID_t  channel)
inlinestatic

Converts LArSoft channel ID in the one proper for the DB.

Definition at line 107 of file SIOVChannelStatusProvider.h.

Referenced by AddNoisyChannel(), and GetChannelStatus().

108  { return DBChannelID_t(channel); }
void lariov::DatabaseRetrievalAlg::Reconfigure ( fhicl::ParameterSet const &  p)
virtualinherited

Configure using fhicl::ParameterSet.

Reimplemented in lariov::DetPedestalRetrievalAlg, lariov::SIOVElectronicsCalibProvider, and lariov::SIOVPmtGainProvider.

Definition at line 9 of file DatabaseRetrievalAlg.cxx.

References lariov::DatabaseRetrievalAlg::fFolder, and fhicl::ParameterSet::get().

Referenced by lariov::DatabaseRetrievalAlg::DatabaseRetrievalAlg(), lariov::SIOVPmtGainProvider::Reconfigure(), lariov::SIOVElectronicsCalibProvider::Reconfigure(), lariov::DetPedestalRetrievalAlg::Reconfigure(), and lariov::DatabaseRetrievalAlg::~DatabaseRetrievalAlg().

9  {
10 
11  std::string foldername = p.get<std::string>("DBFolderName");
12  std::string url = p.get<std::string>("DBUrl");
13  std::string tag = p.get<std::string>("DBTag", "");
14  fFolder.reset(new DBFolder(foldername, url, tag));
15  }
std::unique_ptr< DBFolder > fFolder
Status_t lariov::SIOVChannelStatusProvider::Status ( raw::ChannelID_t  channel) const
inlineoverride

Definition at line 78 of file SIOVChannelStatusProvider.h.

References AddNoisyChannel(), BadChannels(), GetChannelStatus(), GoodChannels(), NoisyChannels(), and Update().

78  {
79  return (Status_t) this->GetChannelStatus(channel).Status();
80  }
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
const std::string& lariov::DatabaseRetrievalAlg::Tag ( ) const
inlineinherited

Definition at line 56 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

56 {return fFolder->Tag();}
std::unique_ptr< DBFolder > fFolder
bool lariov::SIOVChannelStatusProvider::Update ( DBTimeStamp_t  ts)

Allows a service to add to the list of noisy channels.

Definition at line 78 of file SIOVChannelStatusProvider.cxx.

References lariov::DatabaseRetrievalAlg::Begin(), lariov::DatabaseRetrievalAlg::End(), fData, fDataSource, lariov::DatabaseRetrievalAlg::fFolder, fNewNoisy, and lariov::DatabaseRetrievalAlg::UpdateFolder().

Referenced by lariov::SIOVChannelStatusService::PreProcessEvent(), and Status().

78  {
79 
80  fNewNoisy.Clear();
81  if (fDataSource != DataSource::Database) return false;
82  if (!this->UpdateFolder(ts)) return false;
83 
84  //DBFolder was updated, so now update the Snapshot
85  fData.Clear();
86  fData.SetIoV(this->Begin(), this->End());
87 
88  std::vector<DBChannelID_t> channels;
89  fFolder->GetChannelList(channels);
90  for (auto it = channels.begin(); it != channels.end(); ++it) {
91 
92  long status;
93  fFolder->GetNamedChannelData(*it, "status", status);
94 
95  ChannelStatus cs(*it);
96  cs.SetStatus( ChannelStatus::GetStatusFromInt((int)status) );
97 
98  fData.AddOrReplaceRow(cs);
99  }
100  return true;
101  }
std::unique_ptr< DBFolder > fFolder
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
const IOVTimeStamp & End() const
const IOVTimeStamp & Begin() const
Get Timestamp information.
bool lariov::DatabaseRetrievalAlg::UpdateFolder ( DBTimeStamp_t  ts)
inlineinherited

Return true if fFolder is successfully updated.

Definition at line 49 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

Referenced by lariov::SIOVPmtGainProvider::Update(), lariov::SIOVElectronicsCalibProvider::Update(), lariov::DetPedestalRetrievalAlg::Update(), and Update().

49  {
50  return fFolder->UpdateData(ts);
51  }
std::unique_ptr< DBFolder > fFolder
const std::string& lariov::DatabaseRetrievalAlg::URL ( ) const
inlineinherited

Get connection information.

Definition at line 54 of file DatabaseRetrievalAlg.h.

References lariov::DatabaseRetrievalAlg::fFolder.

54 {return fFolder->URL();}
std::unique_ptr< DBFolder > fFolder

Member Data Documentation

Snapshot<ChannelStatus> lariov::SIOVChannelStatusProvider::fData
private
DataSource::ds lariov::SIOVChannelStatusProvider::fDataSource
private
ChannelStatus lariov::SIOVChannelStatusProvider::fDefault
private
Snapshot<ChannelStatus> lariov::SIOVChannelStatusProvider::fNewNoisy
private

Definition at line 114 of file SIOVChannelStatusProvider.h.

Referenced by AddNoisyChannel(), GetChannelStatus(), and Update().


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