DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPCChannelMapSP.h
Go to the documentation of this file.
1
2// Class: TPCChannelMapSP
3// Module type: algorithm
4// File: TPCChannelMapSP.h
5// Author: Tom Junk, Jan 2025
6//
7// Meant to cover cases with HD and VD (BDE and TDE) which use the DUNE-DAQ v4.4.0 DAQEth header
8// detdataformats/DAQEthHeader.hpp
10
11#ifndef TPCChannelMapSP_H
12#define TPCChannelMapSP_H
13
14#include <stdexcept>
15#include <string>
16#include <unordered_map>
17#include <vector>
18
19namespace dune {
20 class TPCChannelMapSP;
21}
22
24
25public:
26 typedef struct TPCChanInfo {
27 unsigned int offlchan; // in gdml and channel sorting convention
28 unsigned int detid; // from detdatformats/DetID.hpp. Map key
29 unsigned int detelement; // CRP number for Vertical Drift or APA number for Horizontal Drift
30 unsigned int crate; // crate number Map key
31 unsigned int slot; // slot in crate (WIB for BDE and HD, card for TDE) Map key
32 unsigned int stream; // Hermes stream for BDE and HD, 0 for TDE Map key
33 unsigned int streamchan; // channel in the stream. Usually 0:63 Map key
34 unsigned int plane; // 0: U, 1: V, 2: X For info only
35 unsigned int chan_in_plane; // which channel this is in the plane For info only
36 unsigned int femb; // which FEMB For info only
37 unsigned int asic; // ASIC For info only
38 unsigned int asicchan; // ASIC channel For info only
39 bool valid; // true if valid, false if not -- if map lookup fails, this is false
41
42 TPCChannelMapSP(); // constructor
43
44 // initialize: read map from file
45
46 void ReadMapFromFile(std::string& fullname);
47
48 // TPC channel map accessors
49
50 // Map instrumentation numbers (detid:crate:slot:stream:streamchan) to offline channel number.
51
53 unsigned int crate,
54 unsigned int slot,
55 unsigned int stream,
56 unsigned int streamchan) const;
57
58 TPCChanInfo_t GetChanInfoFromOfflChan(unsigned int offlchan) const;
59
60 unsigned int GetNChannels() { return fNChans; };
61
62 // crate to substitute in case the crate number is not understood.
63
64 void SetSubstituteCrate(unsigned int sc) { fSubstituteCrate = sc; }
65
66 unsigned int GetSubstituteCrate() { return fSubstituteCrate; }
67
68private:
69 unsigned int fNChans; // summed over the detector
70 unsigned int fSubstituteCrate; // crate to substitute in case crate is not understood.
71 // this is meant for re-using a channel map for a coldbox for example
72
73 // map of detid, crate, slot, stream, streamchan to channel info struct
74
75 std::unordered_map<size_t, TPCChanInfo_t> DetToChanInfo; // just one key, a hash of the five keys (see make_hash)
76
77 // map of chan info indexed by offline channel number
78
79 std::unordered_map<unsigned int, TPCChanInfo_t> OfflToChanInfo;
80
81 //-----------------------------------------------
82
83 void check_offline_channel(unsigned int offlineChannel) const
84 {
85 // do nothing as channels may not be densely spaced in offline channel number.
86 };
87
88 size_t make_hash( unsigned int detid, //6 bits
89 unsigned int crate, //10 bits
90 unsigned int slot, //4 bits
91 unsigned int stream, //8 bits
92 unsigned int streamch //12 bits
93 ) const;
94};
95
96#endif
struct dune::TPCChannelMapSP::TPCChanInfo TPCChanInfo_t
unsigned int GetSubstituteCrate()
unsigned int GetNChannels()
size_t make_hash(unsigned int detid, unsigned int crate, unsigned int slot, unsigned int stream, unsigned int streamch) const
TPCChanInfo_t GetChanInfoFromOfflChan(unsigned int offlchan) const
std::unordered_map< unsigned int, TPCChanInfo_t > OfflToChanInfo
void ReadMapFromFile(std::string &fullname)
unsigned int fSubstituteCrate
std::unordered_map< size_t, TPCChanInfo_t > DetToChanInfo
void check_offline_channel(unsigned int offlineChannel) const
TPCChanInfo_t GetChanInfoFromElectronicsIDs(unsigned int detid, unsigned int crate, unsigned int slot, unsigned int stream, unsigned int streamchan) const
void SetSubstituteCrate(unsigned int sc)