Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
duneprototypes
duneprototypes
Coldbox
vd
ChannelMap
VDColdboxChannelMapService_service.cc
Go to the documentation of this file.
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Class: VDColdboxChannelMapService
3
// Module type: service
4
// File: VDColdboxChannelMapService.h
5
// Author: Tom Junk, October 2021
6
//
7
// Implementation of hardware-offline channel mapping reading from a file.
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9
10
#include "
VDColdboxChannelMapService.h
"
11
#include "
messagefacility/MessageLogger/MessageLogger.h
"
12
13
14
dune::VDColdboxChannelMapService::VDColdboxChannelMapService
(
fhicl::ParameterSet
const
& pset) {
15
16
std::string
channelMapFile = pset.
get
<
std::string
>(
"FileName"
);
17
std::string
fullname;
18
cet::search_path
sp(
"FW_SEARCH_PATH"
);
19
sp.
find_file
(channelMapFile, fullname);
20
21
if
(fullname.empty()) {
22
std::cout <<
"Input file "
<< channelMapFile <<
" not found"
<<
std::endl
;
23
throw
cet::exception
(
"File not found"
);
24
}
25
else
26
std::cout <<
"VD Coldbox Channel Map: Building TPC wiremap from file "
<< channelMapFile <<
std::endl
;
27
28
std::ifstream
inFile
(fullname, std::ios::in);
29
std::string
line
;
30
while
(std::getline(inFile,line)) {
31
VDCBChanInfo
chinfo;
32
std::stringstream linestream(line);
33
linestream >>
34
chinfo.
offlchan
>>
35
chinfo.
wib
>>
36
chinfo.
wibconnector
>>
37
chinfo.
cebchan
>>
38
chinfo.
femb
>>
39
chinfo.
asic
>>
40
chinfo.
asicchan
>>
41
chinfo.
connector
>>
42
chinfo.
stripid
;
43
chinfo.
valid
=
true
;
44
chantoinfomap
[chinfo.
offlchan
] = chinfo;
45
infotochanmap
[chinfo.
wib
][chinfo.
wibconnector
][chinfo.
cebchan
] = chinfo.
offlchan
;
46
}
47
inFile.close();
48
}
49
50
dune::VDColdboxChannelMapService::VDColdboxChannelMapService
(
fhicl::ParameterSet
const
& pset,
art::ActivityRegistry
&) :
VDColdboxChannelMapService
(pset) {
51
}
52
53
// The function below gets cold electronics info from offline channel number. Sets valid to be false if
54
// there is no corresponding cold electronics channel
55
// if not found in the map, return a chan info struct filled with -1's and set the valid flag to false.
56
57
dune::VDColdboxChannelMapService::VDCBChanInfo
dune::VDColdboxChannelMapService::getChanInfoFromOfflChan
(
int
offlchan)
58
{
59
VDCBChanInfo
r
;
60
auto
fm
=
chantoinfomap
.find(offlchan);
61
if
(
fm
==
chantoinfomap
.end())
62
{
63
r.
offlchan
= -1;
64
r.
wib
= -1;
65
r.
wibconnector
= -1;
66
r.
cebchan
= -1;
67
r.
femb
= -1;
68
r.
asic
= -1;
69
r.
asicchan
= -1;
70
r.
connector
= -1;
71
r.
stripid
=
"INVALID"
;
72
r.
valid
=
false
;
73
}
74
else
75
{
76
r =
fm
->second;
77
}
78
return
r
;
79
}
80
81
82
// The function below uses conventions from Nitish's spreadsheet. WIB: 1-3, wibconnector: 1-4, cechan: 0-127
83
// It returns an offline channel number of -1 if the wib, wibconnector, and cechan are not in the map
84
85
int
dune::VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
(
int
wib,
int
wibconnector,
int
cechan)
86
{
87
int
r
= -1;
88
auto
fm1 =
infotochanmap
.find(wib);
89
if
(fm1 ==
infotochanmap
.end())
return
r;
90
auto
& m1 = fm1->second;
91
auto
fm2
= m1.find(wibconnector);
92
if
(
fm2
== m1.end())
return
r;
93
auto
&
m2
=
fm2
->second;
94
auto
fm3
=
m2
.find(cechan);
95
if
(
fm3
==
m2
.end())
return
r;
96
r =
fm3
->second;
97
return
r
;
98
}
99
100
// For convenience, the function below uses conventions from the DAQ WIB header, with two FEMBs per fiber
101
// on FELIX readout: slot: 0-2, fiber=1 or 2, cehcan: 0-255
102
// it returns a channel number of -1 if the slot, fiber, chan combination is not in the map
103
104
int
dune::VDColdboxChannelMapService::getOfflChanFromSlotFiberChan
(
int
slot,
int
fiber,
int
chan)
105
{
106
int
wc
= fiber*2 - 1;
107
if
(chan>127)
108
{
109
chan -= 128;
110
wc++;
111
}
112
return
getOfflChanFromWIBConnectorInfo
(slot+1,wc,chan);
113
}
114
115
116
DEFINE_ART_SERVICE
(
dune::VDColdboxChannelMapService
)
dune::VDColdboxChannelMapService::chantoinfomap
std::unordered_map< int, VDCBChanInfo > chantoinfomap
Definition:
VDColdboxChannelMapService.h:68
dune::VDColdboxChannelMapService::VDCBChanInfo::asicchan
int asicchan
Definition:
VDColdboxChannelMapService.h:40
dune::VDColdboxChannelMapService::infotochanmap
std::unordered_map< int, std::unordered_map< int, std::unordered_map< int, int > > > infotochanmap
Definition:
VDColdboxChannelMapService.h:72
string
std::string string
Definition:
nybbler.cc:12
VDColdboxChannelMapService.h
dune::VDColdboxChannelMapService::VDCBChanInfo::femb
int femb
Definition:
VDColdboxChannelMapService.h:38
dune::VDColdboxChannelMapService::VDCBChanInfo::stripid
std::string stripid
Definition:
VDColdboxChannelMapService.h:42
dune::VDColdboxChannelMapService::VDCBChanInfo::offlchan
int offlchan
Definition:
VDColdboxChannelMapService.h:34
dune::VDColdboxChannelMapService::VDCBChanInfo::connector
int connector
Definition:
VDColdboxChannelMapService.h:41
dune::VDColdboxChannelMapService::VDCBChanInfo::wib
int wib
Definition:
VDColdboxChannelMapService.h:35
wc
Definition:
CellTree_module.cc:53
MessageLogger.h
genie::units::fm3
static constexpr double fm3
Definition:
Units.h:77
dune::VDColdboxChannelMapService::VDColdboxChannelMapService
VDColdboxChannelMapService(fhicl::ParameterSet const &pset)
Definition:
VDColdboxChannelMapService_service.cc:14
dune::VDColdboxChannelMapService::VDCBChanInfo::asic
int asic
Definition:
VDColdboxChannelMapService.h:39
genie::units::m2
static constexpr double m2
Definition:
Units.h:72
dune::VDColdboxChannelMapService::VDCBChanInfo::wibconnector
int wibconnector
Definition:
VDColdboxChannelMapService.h:36
dune::VDColdboxChannelMapService
Definition:
VDColdboxChannelMapService.h:26
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
dune::VDColdboxChannelMapService::getChanInfoFromOfflChan
VDCBChanInfo getChanInfoFromOfflChan(int offlchan)
Definition:
VDColdboxChannelMapService_service.cc:57
genie::units::fm2
static constexpr double fm2
Definition:
Units.h:76
inFile
TFile * inFile
Definition:
makeDST.cxx:36
DEFINE_ART_SERVICE
#define DEFINE_ART_SERVICE(svc)
Definition:
ServiceDefinitionMacros.h:36
art::ActivityRegistry
Definition:
ActivityRegistry.h:52
dune::VDColdboxChannelMapService::getOfflChanFromSlotFiberChan
int getOfflChanFromSlotFiberChan(int slot, int fiber, int chan)
Definition:
VDColdboxChannelMapService_service.cc:104
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
cet::search_path::find_file
std::string find_file(std::string const &filename) const
Definition:
search_path.cc:96
dune::VDColdboxChannelMapService::VDCBChanInfo::valid
bool valid
Definition:
VDColdboxChannelMapService.h:43
genie::units::fm
static constexpr double fm
Definition:
Units.h:75
cet::search_path
Definition:
search_path.h:36
fhicl::exception
cet::coded_exception< error, detail::translate > exception
Definition:
exception.h:33
dune::VDColdboxChannelMapService::VDCBChanInfo::cebchan
int cebchan
Definition:
VDColdboxChannelMapService.h:37
plot_model.r
r
Definition:
plot_model.py:57
dune::VDColdboxChannelMapService::VDCBChanInfo
Definition:
VDColdboxChannelMapService.h:33
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
dune::VDColdboxChannelMapService::getOfflChanFromWIBConnectorInfo
int getOfflChanFromWIBConnectorInfo(int wib, int wibconnector, int cechan)
Definition:
VDColdboxChannelMapService_service.cc:85
Generated by
1.8.11