DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dune::TPCChannelMapSP Class Reference

#include <TPCChannelMapSP.h>

Classes

struct  TPCChanInfo

Public Types

typedef struct dune::TPCChannelMapSP::TPCChanInfo TPCChanInfo_t

Public Member Functions

 TPCChannelMapSP ()
void ReadMapFromFile (std::string &fullname)
TPCChanInfo_t GetChanInfoFromElectronicsIDs (unsigned int detid, unsigned int crate, unsigned int slot, unsigned int stream, unsigned int streamchan) const
TPCChanInfo_t GetChanInfoFromOfflChan (unsigned int offlchan) const
unsigned int GetNChannels ()
void SetSubstituteCrate (unsigned int sc)
unsigned int GetSubstituteCrate ()

Private Member Functions

void check_offline_channel (unsigned int offlineChannel) const
size_t make_hash (unsigned int detid, unsigned int crate, unsigned int slot, unsigned int stream, unsigned int streamch) const

Private Attributes

unsigned int fNChans
unsigned int fSubstituteCrate
std::unordered_map< size_t, TPCChanInfo_t > DetToChanInfo
std::unordered_map< unsigned int, TPCChanInfo_t > OfflToChanInfo

Detailed Description

Definition at line 23 of file TPCChannelMapSP.h.

Member Typedef Documentation

◆ TPCChanInfo_t

Constructor & Destructor Documentation

◆ TPCChannelMapSP()

dune::TPCChannelMapSP::TPCChannelMapSP ( )

Definition at line 17 of file TPCChannelMapSP.cpp.

18{
20 fNChans = 0;
21}
unsigned int fSubstituteCrate

Member Function Documentation

◆ check_offline_channel()

void dune::TPCChannelMapSP::check_offline_channel ( unsigned int offlineChannel) const
inlineprivate

Definition at line 83 of file TPCChannelMapSP.h.

84 {
85 // do nothing as channels may not be densely spaced in offline channel number.
86 };

◆ GetChanInfoFromElectronicsIDs()

dune::TPCChannelMapSP::TPCChanInfo_t dune::TPCChannelMapSP::GetChanInfoFromElectronicsIDs ( unsigned int detid,
unsigned int crate,
unsigned int slot,
unsigned int stream,
unsigned int streamchan ) const

Definition at line 65 of file TPCChannelMapSP.cpp.

70{
71 size_t h = make_hash(detid, crate, slot, stream, streamchan);
72 auto ret = DetToChanInfo.find(h);
73 if (ret == DetToChanInfo.end()) {
74 h = make_hash(detid, fSubstituteCrate, slot, stream, streamchan);
75 ret = DetToChanInfo.find(h);
76 if (ret == DetToChanInfo.end()) {
77 TPCChanInfo_t badInfo = {};
78 badInfo.valid = false;
79 return badInfo;
80 }
81 }
82 return ret->second;
83}
size_t make_hash(unsigned int detid, unsigned int crate, unsigned int slot, unsigned int stream, unsigned int streamch) const
std::unordered_map< size_t, TPCChanInfo_t > DetToChanInfo
struct dune::TPCChannelMapSP::TPCChanInfo TPCChanInfo_t

◆ GetChanInfoFromOfflChan()

dune::TPCChannelMapSP::TPCChanInfo_t dune::TPCChannelMapSP::GetChanInfoFromOfflChan ( unsigned int offlchan) const

Definition at line 86 of file TPCChannelMapSP.cpp.

87{
88 auto ci = OfflToChanInfo.find(offlineChannel);
89 if (ci == OfflToChanInfo.end()) {
90 TPCChanInfo_t badInfo = {};
91 badInfo.valid = false;
92 return badInfo;
93 }
94 return ci->second;
95}
std::unordered_map< unsigned int, TPCChanInfo_t > OfflToChanInfo

◆ GetNChannels()

unsigned int dune::TPCChannelMapSP::GetNChannels ( )
inline

Definition at line 60 of file TPCChannelMapSP.h.

60{ return fNChans; };

◆ GetSubstituteCrate()

unsigned int dune::TPCChannelMapSP::GetSubstituteCrate ( )
inline

Definition at line 66 of file TPCChannelMapSP.h.

66{ return fSubstituteCrate; }

◆ make_hash()

size_t dune::TPCChannelMapSP::make_hash ( unsigned int detid,
unsigned int crate,
unsigned int slot,
unsigned int stream,
unsigned int streamch ) const
private

Definition at line 98 of file TPCChannelMapSP.cpp.

104{
105 size_t hashval = (((size_t)detid & 0x3f) << 34);
106 hashval ^= ((crate & 0x3ff) << 24);
107 hashval ^= ((slot & 0xf) << 20);
108 hashval ^= ((stream & 0xff) << 12);
109 hashval ^= (streamch & 0xfff);
110 return hashval;
111}

◆ ReadMapFromFile()

void dune::TPCChannelMapSP::ReadMapFromFile ( std::string & fullname)

Definition at line 24 of file TPCChannelMapSP.cpp.

25{
26 fNChans = 0;
27
28 std::ifstream inFile(fullname, std::ios::in);
29 std::string line;
30
31 while (std::getline(inFile, line)) {
32 std::stringstream linestream(line);
33
34 TPCChanInfo_t chanInfo;
35 linestream >> chanInfo.offlchan >> chanInfo.detid >> chanInfo.detelement >> chanInfo.crate >> chanInfo.slot >>
36 chanInfo.stream >> chanInfo.streamchan >> chanInfo.plane >> chanInfo.chan_in_plane >> chanInfo.femb >>
37 chanInfo.asic >> chanInfo.asicchan;
38
39 chanInfo.valid = true;
40 ++fNChans;
41
42 // fill maps.
43
44 check_offline_channel(chanInfo.offlchan);
45
46 auto hashval = make_hash(chanInfo.detid, chanInfo.crate, chanInfo.slot, chanInfo.stream, chanInfo.streamchan);
47 if (DetToChanInfo.find(hashval) != DetToChanInfo.end()) {
48 std::cout << "TPCChannelMapSP: duplicate electronics channel found. detid, crate, slot, stream, streamchan: "
49 << chanInfo.detid << " " << chanInfo.crate << " " << chanInfo.slot << " " << chanInfo.stream << " "
50 << chanInfo.streamchan << std::endl;
51 throw std::range_error("Duplicate Electronics ID");
52 }
53 DetToChanInfo[hashval] = chanInfo;
54
55 if (OfflToChanInfo.find(chanInfo.offlchan) != OfflToChanInfo.end()) {
56 std::cout << "TPCChannelMapSP: duplicate offline channel found: " << chanInfo.offlchan << std::endl;
57 throw std::range_error("Duplicate Offline TPC Channel ID");
58 }
59 OfflToChanInfo[chanInfo.offlchan] = chanInfo;
60 }
61 inFile.close();
62}
void check_offline_channel(unsigned int offlineChannel) const

◆ SetSubstituteCrate()

void dune::TPCChannelMapSP::SetSubstituteCrate ( unsigned int sc)
inline

Definition at line 64 of file TPCChannelMapSP.h.

64{ fSubstituteCrate = sc; }

Member Data Documentation

◆ DetToChanInfo

std::unordered_map<size_t, TPCChanInfo_t> dune::TPCChannelMapSP::DetToChanInfo
private

Definition at line 75 of file TPCChannelMapSP.h.

◆ fNChans

unsigned int dune::TPCChannelMapSP::fNChans
private

Definition at line 69 of file TPCChannelMapSP.h.

◆ fSubstituteCrate

unsigned int dune::TPCChannelMapSP::fSubstituteCrate
private

Definition at line 70 of file TPCChannelMapSP.h.

◆ OfflToChanInfo

std::unordered_map<unsigned int, TPCChanInfo_t> dune::TPCChannelMapSP::OfflToChanInfo
private

Definition at line 79 of file TPCChannelMapSP.h.


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