Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
duneprototypes
duneprototypes
Protodune
singlephase
Tool
PdspOnlineChannel_tool.cc
Go to the documentation of this file.
1
// PdspOnlineChannel.cxx
2
3
#include "
PdspOnlineChannel.h
"
4
#include "
dune-raw-data/Services/ChannelMap/PdspChannelMapService.h
"
5
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
6
#include <iostream>
7
8
using
std::string
;
9
using
std::cout;
10
using
std::endl
;
11
using
Index
=
PdspOnlineChannel::Index
;
12
13
//**********************************************************************
14
15
PdspOnlineChannel::PdspOnlineChannel
(
const
fhicl::ParameterSet
& pset)
16
: m_LogLevel(pset.
get
<
Index
>(
"LogLevel"
)),
17
m_Ordering(pset.
get
<
Name
>(
"Ordering"
)),
18
m_orderByWib(m_Ordering ==
"WIB"
),
19
m_orderByConnector(m_Ordering ==
"connector"
),
20
m_orderByFemb(m_Ordering ==
"FEMB"
) {
21
const
string
myname =
"PdspOnlineChannel::ctor: "
;
22
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
23
cout << myname <<
" Ordering: "
<<
m_Ordering
<<
endl
;
24
if
( !
m_orderByWib
&& !
m_orderByConnector
&& !
m_orderByFemb
) {
25
cout << myname <<
"ERROR: Invalid ordering: "
<<
m_Ordering
<<
endl
;
26
}
27
}
28
29
//**********************************************************************
30
31
Index
PdspOnlineChannel::get
(
Index
chanOff)
const
{
32
const
string
myname =
"PdspOnlineChannel::get: "
;
33
if
( chanOff >= 15360 ) {
34
if
(
m_LogLevel
> 1 ) cout << myname <<
"Invalid offline channel: "
<< chanOff <<
endl
;
35
return
badIndex
();
36
}
37
art::ServiceHandle<dune::PdspChannelMapService>
pms;
38
// Fetch APA index.
39
Index
iapa = pms->
APAFromOfflineChannel
(chanOff);
40
if
( iapa > 5 ) {
41
if
(
m_LogLevel
> 1 ) cout << myname <<
"Invalid APA index: "
<< iapa <<
endl
;
42
return
badIndex
();
43
}
44
Index
kapa = iapa;
45
// Fetch WIB index.
46
Index
iwib = pms->
WIBFromOfflineChannel
(chanOff);
47
if
( iwib > 4 ) {
48
if
(
m_LogLevel
> 1 ) cout << myname <<
"Invalid WIB index: "
<< iwib <<
endl
;
49
return
badIndex
();
50
}
51
Index
kwib = iwib;
52
// Fetch connector index.
53
Index
icon = pms->
FEMBFromOfflineChannel
(chanOff);
54
if
( icon < 1 || icon > 4 ) {
55
if
(
m_LogLevel
> 1 ) cout << myname <<
"Invalid connector index: "
<< icon <<
endl
;
56
return
badIndex
();
57
}
58
Index
kcon = icon - 1;
59
// Fetch FEMB channel.
60
Index
ichf = pms->
FEMBChannelFromOfflineChannel
(chanOff);
61
if
( ichf > 127 ) {
62
if
(
m_LogLevel
> 1 ) cout << myname <<
"Invalid FEMB channel index: "
<< ichf <<
endl
;
63
return
badIndex
();
64
}
65
Index
kchf = ichf;
66
// Evauate online index.
67
Index
chanOn = 0;
68
if
(
m_orderByWib
) {
69
chanOn = 2560*kapa + 512*kwib + 128*kcon + kchf;
70
}
else
if
(
m_orderByConnector
) {
71
chanOn = 2560*kapa + 640*kcon + 128*kwib + kchf;
72
}
else
if
(
m_orderByFemb
) {
73
// FEMB index mapping.
74
static
Index
ifmb[20] = {10, 9, 8, 7, 6,
75
5, 4, 3, 2, 1,
76
20, 19, 18, 17, 16,
77
15, 14, 13, 12, 11};
78
Index
jfmb = 5*kcon + kwib;
79
Index
kfmb = ifmb[jfmb] - 1;
80
// Beam left, rotate FEMBs by 10.
81
bool
beamLeft = kapa/2 != (kapa+1)/2;
82
if
( beamLeft ) kfmb = (kfmb + 10) % 20;
83
chanOn = 2560*kapa + 128*kfmb + kchf;
84
}
85
return
chanOn;
86
}
87
88
//**********************************************************************
89
90
DEFINE_ART_CLASS_TOOL
(
PdspOnlineChannel
)
PdspOnlineChannel::m_LogLevel
Index m_LogLevel
Definition:
PdspOnlineChannel.h:65
PdspOnlineChannel::m_orderByFemb
bool m_orderByFemb
Definition:
PdspOnlineChannel.h:71
PdspOnlineChannel::PdspOnlineChannel
PdspOnlineChannel(const fhicl::ParameterSet &ps)
Definition:
PdspOnlineChannel_tool.cc:15
art::ServiceHandle< dune::PdspChannelMapService >
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
dune::PdspChannelMapService::FEMBChannelFromOfflineChannel
unsigned int FEMBChannelFromOfflineChannel(unsigned int offlineChannel) const
Returns FEMB channel.
Definition:
PdspChannelMapService_service.cc:336
string
std::string string
Definition:
nybbler.cc:12
PdspOnlineChannel::m_orderByWib
bool m_orderByWib
Definition:
PdspOnlineChannel.h:69
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
PdspOnlineChannel.h
dune::PdspChannelMapService::APAFromOfflineChannel
unsigned int APAFromOfflineChannel(unsigned int offlineChannel) const
Returns APA/crate.
Definition:
PdspChannelMapService_service.cc:302
PdspOnlineChannel
Definition:
PdspOnlineChannel.h:52
ServiceHandle.h
PdspOnlineChannel::m_Ordering
Name m_Ordering
Definition:
PdspOnlineChannel.h:66
PdspOnlineChannel::m_orderByConnector
bool m_orderByConnector
Definition:
PdspOnlineChannel.h:70
PdspOnlineChannel::get
Index get(Index chanOff) const override
Definition:
PdspOnlineChannel_tool.cc:31
dune::PdspChannelMapService::WIBFromOfflineChannel
unsigned int WIBFromOfflineChannel(unsigned int offlineChannel) const
Returns WIB/slot.
Definition:
PdspChannelMapService_service.cc:320
IndexMapTool::Index
unsigned int Index
Definition:
IndexMapTool.h:16
IndexMapTool::badIndex
static Index badIndex()
Definition:
IndexMapTool.h:18
PdspOnlineChannel::Name
std::string Name
Definition:
PdspOnlineChannel.h:56
dune::PdspChannelMapService::FEMBFromOfflineChannel
unsigned int FEMBFromOfflineChannel(unsigned int offlineChannel) const
Returns FEMB/fiber.
Definition:
PdspChannelMapService_service.cc:328
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
PdspChannelMapService.h
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11