Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
lariov::SIOVChannelStatusProvider Class Reference

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

#include <SIOVChannelStatusProvider.h>

Inheritance diagram for lariov::SIOVChannelStatusProvider:
lariov::DatabaseRetrievalAlg lariov::ChannelStatusProvider lar::UncopiableAndUnmovableClass

Public Member Functions

 SIOVChannelStatusProvider (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~SIOVChannelStatusProvider ()=default
 Default destructor. More...
 
const ChannelStatusGetChannelStatus (raw::ChannelID_t channel) const
 Returns Channel Status. More...
 
Status_t Status (raw::ChannelID_t channel) const override
 Returns a status integer with arbitrary meaning. More...
 
void UpdateTimeStamp (DBTimeStamp_t ts)
 Update event time stamp. More...
 
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 physical and connected to wire. 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 good 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)
 
void AddNoisyChannel (raw::ChannelID_t ch)
 Allows a service to add to the list of noisy channels. More...
 
- Public Member Functions inherited from lariov::DatabaseRetrievalAlg
 DatabaseRetrievalAlg (const std::string &foldername, const std::string &url, const std::string &url2="", const std::string &tag="", bool usesqlite=false, bool testmode=false)
 Constructors. More...
 
 DatabaseRetrievalAlg (fhicl::ParameterSet const &p)
 
virtual ~DatabaseRetrievalAlg ()
 Default destructor. More...
 
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::stringURL () const
 Get connection information. More...
 
const std::stringFolderName () const
 
const std::stringTag () const
 
const IOVTimeStampBegin () const
 Get Timestamp information. More...
 
const IOVTimeStampEnd () const
 
- Public Member Functions inherited from lariov::ChannelStatusProvider
 ChannelStatusProvider ()=default
 Default constructor. More...
 
 ChannelStatusProvider (ChannelStatusProvider const &)=delete
 
 ChannelStatusProvider (ChannelStatusProvider &&)=delete
 
ChannelStatusProvideroperator= (ChannelStatusProvider const &)=delete
 
ChannelStatusProvideroperator= (ChannelStatusProvider &&)=delete
 
virtual ~ChannelStatusProvider ()=default
 Virtual destructor; destructs nothing. More...
 
virtual bool HasStatus (raw::ChannelID_t channel) const
 Returns whether the specified status is a valid one. 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...
 
- Static Public Member Functions inherited from lariov::ChannelStatusProvider
static bool IsValidStatus (Status_t status)
 Returns whether the specified status is a valid one. More...
 

Private Member Functions

bool DBUpdate () const
 Do actual database updates. More...
 
bool DBUpdate (DBTimeStamp_t ts) const
 
ChannelSet_t GetChannelsWithStatus (chStatus status) const
 

Private Attributes

DBTimeStamp_t fEventTimeStamp
 
DBTimeStamp_t fCurrentTimeStamp
 
DataSource::ds fDataSource
 
Snapshot< ChannelStatusfData
 
Snapshot< ChannelStatusfNewNoisy
 
ChannelStatus fDefault
 

Additional Inherited Members

- Public Types inherited from lariov::ChannelStatusProvider
using Status_t = unsigned short
 type representing channel status More...
 
using ChannelSet_t = std::set< raw::ChannelID_t >
 Type of set of channel IDs. More...
 
- Static Public Attributes inherited from lariov::ChannelStatusProvider
static constexpr Status_t InvalidStatus = std::numeric_limits<Status_t>::max()
 Value or invalid status. More...
 
- Protected Attributes inherited from lariov::DatabaseRetrievalAlg
std::unique_ptr< DBFolderfFolder
 

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 37 of file SIOVChannelStatusProvider.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 27 of file SIOVChannelStatusProvider.cxx.

28  : DatabaseRetrievalAlg(pset.get<fhicl::ParameterSet>("DatabaseRetrievalAlg"))
29  , fEventTimeStamp(0)
31  , fDefault(0)
32  {
33 
34  bool UseDB = pset.get<bool>("UseDB", false);
35  bool UseFile = pset.get<bool>("UseFile", false);
36  std::string fileName = pset.get<std::string>("FileName", "");
37 
38  //priority: (1) use db, (2) use table, (3) use defaults
39  //If none are specified, use defaults
40  if ( UseDB ) fDataSource = DataSource::Database;
41  else if (UseFile) fDataSource = DataSource::File;
43 
45  std::cout << "Using default channel status value: "<<kGOOD<<"\n";
46  fDefault.SetStatus(kGOOD);
47  }
48  else if (fDataSource == DataSource::File) {
49  cet::search_path sp("FW_SEARCH_PATH");
50  std::string abs_fp = sp.find_file(fileName);
51  std::cout << "Using channel statuses from local file: "<<abs_fp<<"\n";
52  std::ifstream file(abs_fp);
53  if (!file) {
54  throw cet::exception("SIOVChannelStatusProvider")
55  << "File "<<abs_fp<<" is not found.";
56  }
57 
59  ChannelStatus cs(0);
60  while (std::getline(file, line)) {
61  DBChannelID_t ch = (DBChannelID_t)std::stoi(line.substr(0, line.find(',')));
62  int status = std::stoi(line.substr(line.find(',')+1));
63 
64  cs.SetChannel(ch);
65  cs.SetStatus( ChannelStatus::GetStatusFromInt(status) );
66  fData.AddOrReplaceRow(cs);
67  }
68  } // if source from file
69  else {
70  std::cout << "Using channel statuses from conditions database\n";
71  }
72  }
std::string string
Definition: nybbler.cc:12
std::uint32_t DBChannelID_t
DatabaseRetrievalAlg(const std::string &foldername, const std::string &url, const std::string &url2="", const std::string &tag="", bool usesqlite=false, bool testmode=false)
Constructors.
static chStatus GetStatusFromInt(int status)
Definition: ChannelStatus.h:45
fileName
Definition: dumpTree.py:9
void line(double t, double *p, double &x, double &y, double &z)
const char * cs
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void SetStatus(chStatus status)
Definition: ChannelStatus.h:43
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 203 of file SIOVChannelStatusProvider.cxx.

203  {
204 
205  // for c2: ISO C++17 does not allow 'register' storage class specifier
206  //register DBChannelID_t const dbch = rawToDBChannel(ch);
207  DBChannelID_t const dbch = rawToDBChannel(ch);
208  if (!this->IsBad(dbch) && this->IsPresent(dbch)) {
209  ChannelStatus cs(dbch);
210  cs.SetStatus(kNOISY);
211  fNewNoisy.AddOrReplaceRow(cs);
212  }
213  }
bool IsPresent(raw::ChannelID_t channel) const override
Returns whether the specified channel is physical and connected to wire.
static DBChannelID_t rawToDBChannel(raw::ChannelID_t channel)
Converts LArSoft channel ID in the one proper for the DB.
std::uint32_t DBChannelID_t
bool IsBad(raw::ChannelID_t channel) const override
Returns whether the specified channel is bad in the current run.
const char * cs
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::BadChannels ( ) const
overridevirtual

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

Implements lariov::ChannelStatusProvider.

Definition at line 187 of file SIOVChannelStatusProvider.cxx.

187  {
190  dead.insert(ln.begin(),ln.end());
191  return dead;
192  }
std::set< raw::ChannelID_t > ChannelSet_t
Type of set of channel IDs.
ChannelSet_t GetChannelsWithStatus(chStatus status) const
bool lariov::SIOVChannelStatusProvider::DBUpdate ( ) const
private

Do actual database updates.

Definition at line 93 of file SIOVChannelStatusProvider.cxx.

93  {
94  return DBUpdate(fEventTimeStamp);
95  }
bool DBUpdate() const
Do actual database updates.
bool lariov::SIOVChannelStatusProvider::DBUpdate ( DBTimeStamp_t  ts) const
private

Definition at line 100 of file SIOVChannelStatusProvider.cxx.

100  {
101 
102  bool result = false;
104 
105  mf::LogInfo("SIOVChannelStatusProvider") << "SIOVChannelStatusProvider::DBUpdate called with new timestamp.";
106 
107  fCurrentTimeStamp = ts;
108 
109  // Call non-const base class method.
110 
111  result = const_cast<SIOVChannelStatusProvider*>(this)->UpdateFolder(ts);
112  if(result) {
113  //DBFolder was updated, so now update the Snapshot
114  fData.Clear();
115  fData.SetIoV(this->Begin(), this->End());
116 
117  std::vector<DBChannelID_t> channels;
118  fFolder->GetChannelList(channels);
119  for (auto it = channels.begin(); it != channels.end(); ++it) {
120 
121  long status;
122  fFolder->GetNamedChannelData(*it, "status", status);
123 
124  ChannelStatus cs(*it);
125  cs.SetStatus( ChannelStatus::GetStatusFromInt((int)status) );
126 
127  fData.AddOrReplaceRow(cs);
128  }
129  }
130  }
131  return result;
132  }
std::unique_ptr< DBFolder > fFolder
static QCString result
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
static chStatus GetStatusFromInt(int status)
Definition: ChannelStatus.h:45
bool UpdateFolder(DBTimeStamp_t ts)
Return true if fFolder is successfully updated.
const IOVTimeStamp & End() const
const IOVTimeStamp & Begin() const
Get Timestamp information.
SIOVChannelStatusProvider(fhicl::ParameterSet const &pset)
Constructor.
const char * cs
const ChannelStatus & lariov::SIOVChannelStatusProvider::GetChannelStatus ( raw::ChannelID_t  channel) const

Returns Channel Status.

Definition at line 136 of file SIOVChannelStatusProvider.cxx.

136  {
138  return fDefault;
139  }
140  DBUpdate();
141  if (fNewNoisy.HasChannel(rawToDBChannel(ch))) {
142  return fNewNoisy.GetRow(rawToDBChannel(ch));
143  }
144  else {
145  return fData.GetRow(rawToDBChannel(ch));
146  }
147  }
static DBChannelID_t rawToDBChannel(raw::ChannelID_t channel)
Converts LArSoft channel ID in the one proper for the DB.
bool DBUpdate() const
Do actual database updates.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::GetChannelsWithStatus ( chStatus  status) const
private

Definition at line 152 of file SIOVChannelStatusProvider.cxx.

152  {
153 
154  ChannelSet_t retSet;
155  retSet.clear();
156  DBChannelID_t maxChannel = art::ServiceHandle<geo::Geometry const>()->Nchannels() - 1;
158  if (fDefault.Status() == status) {
159  std::vector<DBChannelID_t> chs;
160  for (DBChannelID_t ch=0; ch != maxChannel; ++ch) {
161  chs.push_back(ch);
162  }
163  retSet.insert(chs.begin(), chs.end());
164  }
165  }
166  else {
167  std::vector<DBChannelID_t> chs;
168  for (DBChannelID_t ch=0; ch != maxChannel; ++ch) {
169  if (this->GetChannelStatus(ch).Status() == status) chs.push_back(ch);
170  }
171 
172  retSet.insert(chs.begin(), chs.end());
173  }
174  return retSet;
175  }
std::set< raw::ChannelID_t > ChannelSet_t
Type of set of channel IDs.
chStatus Status() const
Definition: ChannelStatus.h:41
std::uint32_t DBChannelID_t
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::GoodChannels ( ) const
overridevirtual

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

Implements lariov::ChannelStatusProvider.

Definition at line 180 of file SIOVChannelStatusProvider.cxx.

180  {
182  }
ChannelSet_t GetChannelsWithStatus(chStatus status) const
bool lariov::SIOVChannelStatusProvider::IsBad ( raw::ChannelID_t  channel) const
inlineoverridevirtual

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

Implements lariov::ChannelStatusProvider.

Definition at line 65 of file SIOVChannelStatusProvider.h.

65  {
67  }
bool IsPresent(raw::ChannelID_t channel) const override
Returns whether the specified channel is physical and connected to wire.
bool IsLowNoise() const
Definition: ChannelStatus.h:37
uint8_t channel
Definition: CRTFragment.hh:201
bool IsDead() const
Definition: ChannelStatus.h:36
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsGood ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns whether the specified channel is physical and good.

Reimplemented from lariov::ChannelStatusProvider.

Definition at line 75 of file SIOVChannelStatusProvider.h.

75  {
77  }
uint8_t channel
Definition: CRTFragment.hh:201
bool IsGood() const
Definition: ChannelStatus.h:40
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsNoisy ( raw::ChannelID_t  channel) const
inlineoverridevirtual

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

Implements lariov::ChannelStatusProvider.

Definition at line 70 of file SIOVChannelStatusProvider.h.

70  {
72  }
bool IsNoisy() const
Definition: ChannelStatus.h:38
uint8_t channel
Definition: CRTFragment.hh:201
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::IsPresent ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns whether the specified channel is physical and connected to wire.

Implements lariov::ChannelStatusProvider.

Definition at line 60 of file SIOVChannelStatusProvider.h.

60  {
62  }
bool IsPresent() const
Definition: ChannelStatus.h:39
uint8_t channel
Definition: CRTFragment.hh:201
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
SIOVChannelStatusProvider::ChannelSet_t lariov::SIOVChannelStatusProvider::NoisyChannels ( ) const
overridevirtual

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

Implements lariov::ChannelStatusProvider.

Definition at line 197 of file SIOVChannelStatusProvider.cxx.

197  {
199  }
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 112 of file SIOVChannelStatusProvider.h.

113  { return DBChannelID_t(channel); }
std::uint32_t DBChannelID_t
uint8_t channel
Definition: CRTFragment.hh:201
Status_t lariov::SIOVChannelStatusProvider::Status ( raw::ChannelID_t  channel) const
inlineoverridevirtual

Returns a status integer with arbitrary meaning.

Reimplemented from lariov::ChannelStatusProvider.

Definition at line 80 of file SIOVChannelStatusProvider.h.

80  {
81  return (Status_t) this->GetChannelStatus(channel).Status();
82  }
chStatus Status() const
Definition: ChannelStatus.h:41
uint8_t channel
Definition: CRTFragment.hh:201
unsigned short Status_t
type representing channel status
const ChannelStatus & GetChannelStatus(raw::ChannelID_t channel) const
Returns Channel Status.
bool lariov::SIOVChannelStatusProvider::Update ( DBTimeStamp_t  ts)

Definition at line 84 of file SIOVChannelStatusProvider.cxx.

84  {
85 
86  fEventTimeStamp = ts;
87  fNewNoisy.Clear();
88  return DBUpdate(ts);
89  }
bool DBUpdate() const
Do actual database updates.
void lariov::SIOVChannelStatusProvider::UpdateTimeStamp ( DBTimeStamp_t  ts)

Update event time stamp.

Definition at line 76 of file SIOVChannelStatusProvider.cxx.

76  {
77  mf::LogInfo("SIOVChannelStatusProvider") << "SIOVChannelStatusProvider::UpdateTimeStamp called.";
78  fNewNoisy.Clear();
79  fEventTimeStamp = ts;
80  }
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo

Member Data Documentation

DBTimeStamp_t lariov::SIOVChannelStatusProvider::fCurrentTimeStamp
mutableprivate

Definition at line 125 of file SIOVChannelStatusProvider.h.

Snapshot<ChannelStatus> lariov::SIOVChannelStatusProvider::fData
mutableprivate

Definition at line 128 of file SIOVChannelStatusProvider.h.

DataSource::ds lariov::SIOVChannelStatusProvider::fDataSource
private

Definition at line 127 of file SIOVChannelStatusProvider.h.

ChannelStatus lariov::SIOVChannelStatusProvider::fDefault
private

Definition at line 130 of file SIOVChannelStatusProvider.h.

DBTimeStamp_t lariov::SIOVChannelStatusProvider::fEventTimeStamp
private

Definition at line 124 of file SIOVChannelStatusProvider.h.

Snapshot<ChannelStatus> lariov::SIOVChannelStatusProvider::fNewNoisy
private

Definition at line 129 of file SIOVChannelStatusProvider.h.


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