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_tDetToChanInfo
 
std::unordered_map< unsigned int, TPCChanInfo_tOfflToChanInfo
 

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.

17 {
19 fNChans = 0;
20}
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 76 of file TPCChannelMapSP.cpp.

82{
83 size_t h = make_hash(detid,crate,slot,stream,streamchan);
84 auto ret = DetToChanInfo.find(h);
85 if (ret == DetToChanInfo.end())
86 {
87 h = make_hash(detid,fSubstituteCrate,slot,stream,streamchan);
88 ret = DetToChanInfo.find(h);
89 if (ret == DetToChanInfo.end())
90 {
91 TPCChanInfo_t badInfo = {};
92 badInfo.valid = false;
93 return badInfo;
94 }
95 }
96 return ret->second;
97}
struct dune::TPCChannelMapSP::TPCChanInfo TPCChanInfo_t
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

◆ GetChanInfoFromOfflChan()

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

Definition at line 99 of file TPCChannelMapSP.cpp.

101{
102 auto ci = OfflToChanInfo.find(offlineChannel);
103 if (ci == OfflToChanInfo.end()) {
104 TPCChanInfo_t badInfo = {};
105 badInfo.valid = false;
106 return badInfo;
107 }
108 return ci->second;
109}
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 111 of file TPCChannelMapSP.cpp.

117{
118 size_t hashval = (((size_t)detid & 0x3f)<<34);
119 hashval ^=((crate & 0x3ff)<<24);
120 hashval ^=((slot & 0xf)<<20);
121 hashval ^=((stream & 0xff)<<12);
122 hashval ^=(streamch & 0xfff);
123 return hashval;
124}

◆ ReadMapFromFile()

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

Definition at line 22 of file TPCChannelMapSP.cpp.

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