16 #include <boost/lexical_cast.hpp>
18 #include <utl/Reader.h>
19 #include <utl/TimeStamp.h>
20 #include <utl/ErrorLogger.h>
21 #include <utl/AugerException.h>
23 #include <fwk/CentralConfig.h>
25 #include <det/Detector.h>
26 #include <det/ValidityStamp.h>
28 #include <fdet/FDetector.h>
29 #include <fdet/FdChannelMappingManager.h>
33 #include <TDirectory.h>
45 FdChannelMappingManager::FdChannelMappingManager()
49 FdChannelMappingManager::~FdChannelMappingManager()
65 fPropertiesList.insert(
"channel_mapping");
66 fPropertiesList.insert(
"pixel_mapping");
71 FdChannelMappingManager::GetMapping(
int& returnData,
72 const string& componentProperty,
73 const string& componentName,
78 if (componentName !=
"electronics")
82 if (fPropertiesList.find(componentProperty) == fPropertiesList.end())
86 if (componentIndex.size() != 3)
90 const IndexMap::const_iterator iEyeId =
91 componentIndex.find(
"eyeId");
92 const IndexMap::const_iterator iTelId =
93 componentIndex.find(
"telescopeId");
94 if (iEyeId == componentIndex.end() || iTelId == componentIndex.end()) {
95 INFO(
"Called FdChannelMappingManager with wrong number of arguments!");
99 const int eyeId = boost::lexical_cast<
int>(iEyeId->second);
100 const int telId = boost::lexical_cast<
int>(iTelId->second);
101 const int indexEyeTel = eyeId*6*440 + telId*440;
103 IndexMap::const_iterator iId;
104 if (componentProperty ==
"channel_mapping")
105 iId = componentIndex.find(
"channelId");
106 else if (componentProperty ==
"pixel_mapping")
107 iId = componentIndex.find(
"pixelId");
109 INFO(
"Called FdChannelMappingManager with missing pixelId/channelId!");
112 const int id = boost::lexical_cast<
int>(iId->second);
113 const int dataId = indexEyeTel + id;
118 iPeriod != fPeriods.end(); ++iPeriod) {
120 if (!iPeriod->validity.IsValid())
123 if (componentProperty ==
"channel_mapping") {
124 const Mapping& channelMapping = iPeriod->channels;
125 const map<int, int>::const_iterator iMapping =
126 channelMapping.find(dataId);
127 if (iMapping != channelMapping.end()) {
128 returnData = iMapping->second;
133 if (componentProperty ==
"pixel_mapping") {
134 const Mapping& pixelMapping = iPeriod->pixels;
135 const map<int, int>::const_iterator iMapping =
136 pixelMapping.find(dataId);
137 if (iMapping != pixelMapping.end()) {
138 returnData = iMapping->second;
151 FdChannelMappingManager::FillMaps()
163 cB.GetChild(
"telescope").GetData(telId);
164 const int indexEyeTel = eyeId*6*440 + telId*440;
166 cB.GetChild(
"begin").GetData(begin);
168 cB.GetChild(
"end").GetData(end);
174 for (
Branch b = cB.GetChild(
"mapping").GetFirstChild();
175 b;
b =
b.GetNextSibling()) {
178 const int pixelId = boost::lexical_cast<
int>(atts.find(
"id")->second);
181 b.GetChild(
"channel").GetData(channelId);
184 if (pixelMapping.count(indexEyeTel + pixelId) ||
185 channelMapping.count(indexEyeTel + channelId)) {
186 ERROR_TERSE(
"double existance of pixels/channels");
190 pixelMapping[indexEyeTel + pixelId] = channelId;
191 channelMapping[indexEyeTel + channelId] = pixelId;
197 iPixel != pixelMapping.end(); ++iPixel) {
200 const int pixelId = iPixel->first;
202 if (iChannel == channelMapping.end()) {
210 mappingPeriod.
pixels = pixelMapping;
211 mappingPeriod.
channels = channelMapping;
212 fPeriods.push_back(mappingPeriod);
std::map< std::string, std::string > AttributeMap
#define INFO(message)
Macro for logging informational messages.
void Init()
Initialise the registry.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
std::map< int, int > Mapping
Class to manage Fd camera channel-pixel mapping.
A TimeStamp holds GPS second and nanosecond for some event.
Mapping::const_iterator ConstMappingIterator
Branch GetNextSibling() const
Get next sibling of this branch.
Class representing a document branch.
#define ERROR_TERSE(message)
Macro for logging error messages.
PeriodContainer::const_iterator ConstPeriodIterator
void GetData(bool &b) const
Overloads of the GetData member template function.
#define REGISTER_F_MANAGER(_name_, _Type_)
static CentralConfig * GetInstance()
Use this the first time you get an instance of central configuration.
std::map< std::string, std::string > IndexMap
Branch GetFirstChild() const
Get first child of this Branch.
Object to keep track of whether data are valid, or have expired.
det::ValidityStamp validity
utl::Branch GetTopBranch(const std::string &id)
Get top branch for moduleConfigLink with given id (XML files)
Status
Specifies success or (eventually) various possible failure modes.