All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbndPDMapAlg.hh
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // File: sbndPDMapAlg.hh
3 // Authors: Laura Paulucci, Franciole Marinho, and Iker de Icaza
4 //
5 // Updates: 2020-03, v08_45_00. Iker de Icaza icaza@fnal.gov
6 // Added properties to PDS MAP and functions to access these.
7 //
8 // This class stores the SBND PDS Map and channel's properties;
9 // also implements functions to access these.
10 //
11 // As of version v09_24_01 each entry of the PDS Map
12 // has the following characteristics:
13 //
14 // channel: 0 to 311
15 // pd_type: pmt_coated, pmt_uncoated, xarapuca_vuv, xarapuca_vis
16 // pds_box: 0 to 23
17 // sensible_to_vis: true or false
18 // sensible_to_vuv: true or false
19 // tpc: 0, 1
20 // sampling: apsaia, daphne
21 ////////////////////////////////////////////////////////////////////////
22 
23 #ifndef SBND_OPDETSIM_SBNDPDMAPALG_HH
24 #define SBND_OPDETSIM_SBNDPDMAPALG_HH
25 
26 #include "sbncode/OpDet/PDMapAlg.h"
27 //#include "art/Utilities/ToolMacros.h"
28 //#include "art/Utilities/make_tool.h"
29 
30 #include <algorithm>
31 #include <fstream>
32 #include <map>
33 #include <string>
34 
35 #include "art_root_io/TFileService.h"
36 
37 #include "json.hpp"
38 
39 namespace opdet {
40 
42 
43  public:
44  //Default constructor
45  explicit sbndPDMapAlg(const fhicl::ParameterSet& pset);
46  sbndPDMapAlg() : sbndPDMapAlg(fhicl::ParameterSet()) {}
47  //Default destructor
48  ~sbndPDMapAlg();
49 
50  nlohmann::json getCollectionWithProperty(std::string property);
51  template<typename T> nlohmann::json getCollectionWithProperty(std::string property, T property_value);
52  template<typename Func> nlohmann::json getCollectionFromCondition(Func condition);
53 
54  // struct Config {};
55 
56  // sbndPDMapAlg(Config const&) {}
57 
58  // void setup() {}
59 
60  bool isPDType(size_t ch, std::string pdname) const override;
61  bool isElectronics(size_t ch, std::string pdname) const;
62  std::string pdType(size_t ch) const override;
63  std::string electronicsType(size_t ch) const;
64  std::vector<int> getChannelsOfType(std::string pdname) const;
65  std::vector<int> getChannelsOfType(std::string pdname,std::string elname) const;//overload
66  size_t size() const;
67  auto getChannelEntry(size_t ch) const;
68 
69  private:
71 
72  }; // class sbndPDMapAlg
73 
74  template<typename T>
75  nlohmann::json sbndPDMapAlg::getCollectionWithProperty(std::string property, T property_value)
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  }
83 
84  template<typename Func>
86  {
87  nlohmann::json subSetPDmap;
88  std::copy_if (PDmap.begin(), PDmap.end(), std::back_inserter(subSetPDmap),
89  condition);
90  return subSetPDmap;
91  }
92 
93 } // namespace
94 
95 #endif // SBND_OPDETSIM_SBNDPDMAPALG_HH
size_t size() const
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
bool isPDType(size_t ch, std::string pdname) const override
nlohmann::json PDmap
Definition: sbndPDMapAlg.hh:70
nlohmann::json getCollectionFromCondition(Func condition)
Definition: sbndPDMapAlg.hh:85
This is the interface class for a tool to handle PD mapping in SBN detectors, used for flash matching...
std::vector< int > getChannelsOfType(std::string pdname) const
bool isElectronics(size_t ch, std::string pdname) const
std::string electronicsType(size_t ch) const
do i e
auto getChannelEntry(size_t ch) const
nlohmann::json getCollectionWithProperty(std::string property)
std::string pdType(size_t ch) const override