All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
opdet::sbndPDMapAlg Class Reference

#include <sbndPDMapAlg.hh>

Inheritance diagram for opdet::sbndPDMapAlg:
opdet::PDMapAlg

Public Member Functions

 sbndPDMapAlg (const fhicl::ParameterSet &pset)
 
 sbndPDMapAlg ()
 
 ~sbndPDMapAlg ()
 
nlohmann::json getCollectionWithProperty (std::string property)
 
template<typename T >
nlohmann::json getCollectionWithProperty (std::string property, T property_value)
 
template<typename Func >
nlohmann::json getCollectionFromCondition (Func condition)
 
bool isPDType (size_t ch, std::string pdname) const override
 
bool isElectronics (size_t ch, std::string pdname) const
 
std::string pdType (size_t ch) const override
 
std::string electronicsType (size_t ch) const
 
std::vector< int > getChannelsOfType (std::string pdname) const
 
std::vector< int > getChannelsOfType (std::string pdname, std::string elname) const
 
size_t size () const
 
auto getChannelEntry (size_t ch) const
 

Private Attributes

nlohmann::json PDmap
 

Additional Inherited Members

- Private Member Functions inherited from opdet::PDMapAlg
virtual ~PDMapAlg () noexcept=default
 

Detailed Description

Definition at line 41 of file sbndPDMapAlg.hh.

Constructor & Destructor Documentation

opdet::sbndPDMapAlg::sbndPDMapAlg ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 12 of file sbndPDMapAlg_tool.cc.

13  {
14  std::string fname;
15  cet::search_path sp("FW_SEARCH_PATH");
16  sp.find_file("sbnd_pds_mapping.json", fname);
17  std::ifstream i(fname, std::ifstream::in);
18  i >> PDmap;
19  i.close();
20  }
string fname
Definition: demo.py:5
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
opdet::sbndPDMapAlg::sbndPDMapAlg ( )
inline

Definition at line 46 of file sbndPDMapAlg.hh.

46 : sbndPDMapAlg(fhicl::ParameterSet()) {}
opdet::sbndPDMapAlg::~sbndPDMapAlg ( )

Definition at line 22 of file sbndPDMapAlg_tool.cc.

23  { }

Member Function Documentation

std::string opdet::sbndPDMapAlg::electronicsType ( size_t  ch) const

Definition at line 42 of file sbndPDMapAlg_tool.cc.

43  {
44  return PDmap.at(ch)["electronics"];
45  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
auto opdet::sbndPDMapAlg::getChannelEntry ( size_t  ch) const

Definition at line 70 of file sbndPDMapAlg_tool.cc.

71  {
72  return PDmap.at(ch);
73  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
std::vector< int > opdet::sbndPDMapAlg::getChannelsOfType ( std::string  pdname) const

Definition at line 47 of file sbndPDMapAlg_tool.cc.

48  {
49  std::vector<int> out_ch_v;
50  for (size_t ch = 0; ch < PDmap.size(); ch++) {
51  if (PDmap.at(ch)["pd_type"] == pdname) out_ch_v.push_back(ch);
52  }
53  return out_ch_v;
54  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:19195
std::vector< int > opdet::sbndPDMapAlg::getChannelsOfType ( std::string  pdname,
std::string  elname 
) const

Definition at line 56 of file sbndPDMapAlg_tool.cc.

57  {//overload to select channels by pdtype AND electronics type ~rodrigoa
58  std::vector<int> out_ch_v;
59  for (size_t ch = 0; ch < PDmap.size(); ch++) {
60  if ((PDmap.at(ch)["pd_type"] == pdname) && (PDmap.at(ch)["electronics"] == elname))out_ch_v.push_back(ch);
61  }
62  return out_ch_v;
63  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:19195
template<typename Func >
nlohmann::json opdet::sbndPDMapAlg::getCollectionFromCondition ( Func  condition)

Definition at line 85 of file sbndPDMapAlg.hh.

86  {
87  nlohmann::json subSetPDmap;
88  std::copy_if (PDmap.begin(), PDmap.end(), std::back_inserter(subSetPDmap),
89  condition);
90  return subSetPDmap;
91  }
a class to store JSON values
Definition: json.hpp:2421
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:18745
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:18674
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
nlohmann::json opdet::sbndPDMapAlg::getCollectionWithProperty ( std::string  property)

Definition at line 76 of file sbndPDMapAlg_tool.cc.

77  {
78  nlohmann::json subSetPDmap;
79  std::copy_if (PDmap.begin(), PDmap.end(), std::back_inserter(subSetPDmap),
80  [property](const nlohmann::json e)->bool
81  {return e[property];} );
82  return subSetPDmap;
83  }
a class to store JSON values
Definition: json.hpp:2421
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:18745
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:18674
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
do i e
template<typename T >
nlohmann::json opdet::sbndPDMapAlg::getCollectionWithProperty ( std::string  property,
property_value 
)

Definition at line 75 of file sbndPDMapAlg.hh.

76  {
77  nlohmann::json subSetPDmap;
78  std::copy_if (PDmap.begin(), PDmap.end(), std::back_inserter(subSetPDmap),
79  [property, property_value](auto const& e)->bool
80  {return e[property] == property_value;} );
81  return subSetPDmap;
82  }
a class to store JSON values
Definition: json.hpp:2421
iterator end() noexcept
returns an iterator to one past the last element
Definition: json.hpp:18745
iterator begin() noexcept
returns an iterator to the first element
Definition: json.hpp:18674
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
do i e
bool opdet::sbndPDMapAlg::isElectronics ( size_t  ch,
std::string  pdname 
) const

Definition at line 31 of file sbndPDMapAlg_tool.cc.

32  {
33  if(PDmap.at(ch)["electronics"] == std::string(pdname)) return true; // TODO: add number of electronics, daphne01, daphne02, .... ~rodrigoa
34  return false;
35  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
bool opdet::sbndPDMapAlg::isPDType ( size_t  ch,
std::string  pdname 
) const
overridevirtual

Reimplemented from opdet::PDMapAlg.

Definition at line 25 of file sbndPDMapAlg_tool.cc.

26  {
27  if(PDmap.at(ch)["pd_type"] == std::string(pdname)) return true;
28  return false;
29  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
std::string opdet::sbndPDMapAlg::pdType ( size_t  ch) const
overridevirtual

Implements opdet::PDMapAlg.

Definition at line 37 of file sbndPDMapAlg_tool.cc.

38  {
39  return PDmap.at(ch)["pd_type"];
40  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
reference at(size_type idx)
access specified array element with bounds checking
Definition: json.hpp:17519
size_t opdet::sbndPDMapAlg::size ( void  ) const

Definition at line 65 of file sbndPDMapAlg_tool.cc.

66  {
67  return PDmap.size();
68  }
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
size_type size() const noexcept
returns the number of elements
Definition: json.hpp:19195

Member Data Documentation

nlohmann::json opdet::sbndPDMapAlg::PDmap
private

Definition at line 70 of file sbndPDMapAlg.hh.


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