11int main(
int argc,
char** argv)
14 std::cerr <<
"Usage: " << argv[0] <<
" <LUT file> <cal file(s)> <cross talk file>" << std::endl;
18 std::stringstream str;
31 std::ifstream lutFile(argv[1]);
33 while(std::getline(lutFile, line)) {
34 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c) { return std::isspace(c); }) || line[0] ==
'#')
continue;
39 str >> adc >> detType >> detNumber >> cryNumber >> globId >> timeOffset;
60 str.str(std::string());
76 std::cerr <<
"unknown detector type " << detType << std::endl;
80 str << std::setfill(
'0') << std::setw(2) << detNumber + 1;
82 if(detType == 1 || detType == 2) {
85 str << std::setw(1) << cryNumber;
90 channel =
new TChannel(str.str().c_str());
91 channel->
SetAddress((adc / 16) * 0x40 + adc % 16);
101 std::vector<Float_t> coefficients;
103 int maxRange = 30000;
104 for(
int i = 2; i < argc - 1; ++i) {
105 std::ifstream calFile(argv[i]);
107 while(std::getline(calFile, line)) {
109 line.erase(std::find_if(line.rbegin(), line.rend(), [](
int ch) { return !std::isspace(ch); }).base(), line.end());
111 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c) { return std::isspace(c); }) || line[0] ==
'#')
continue;
117 if(channel !=
nullptr) {
127 coefficients.push_back(tmpFloat);
133 maxRange = coefficients.back();
134 coefficients.pop_back();
135 minRange = coefficients.back();
136 coefficients.pop_back();
139 coefficients.clear();
142 channel->
SetENGRange(std::make_pair(minRange, maxRange), i - 2);
145 std::cerr <<
"Failed to find detector ID " << globId + 1 <<
" in TChannel" << std::endl;
151 std::ifstream xTalkFile(argv[argc - 1]);
156 while(std::getline(xTalkFile, line)) {
157 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c) { return std::isspace(c); }) || line[0] ==
'#')
continue;
161 str >> col >> row >> val;
167 if(channel ==
nullptr) {
170 if(channel ==
nullptr) {
171 std::cerr <<
"Failed to find channel \"" << Form(
"FI/IFG%02d%sN00X", detNumber,
TFipps::GetColorFromNumber(col)) <<
"\"" << std::endl;
180 if(col == 3 && row == 3) ++detNumber;