11int main(
int argc,
char** argv) {
13 std::cerr<<
"Usage: "<<argv[0]<<
" <LUT file> <cal file(s)> <cross talk file>"<<std::endl;
17 std::stringstream str;
30 std::ifstream lutFile(argv[1]);
32 while(std::getline(lutFile, line)) {
33 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c){ return std::isspace(c); }) || line[0] ==
'#')
continue;
38 str>>adc>>detType>>detNumber>>cryNumber>>globId>>timeOffset;
59 str.str(std::string());
75 std::cerr<<
"unknown detector type "<<detType<<std::endl;
79 str<<std::setfill(
'0')<<std::setw(2)<<detNumber+1;
81 if(detType == 1 || detType == 2) {
84 str<<std::setw(1)<<cryNumber;
89 channel =
new TChannel(str.str().c_str());
100 std::vector<Float_t> coefficients;
102 int maxRange = 30000;
103 for(
int i = 2; i < argc-1; ++i) {
104 std::ifstream calFile(argv[i]);
106 while(std::getline(calFile, line)) {
108 line.erase(std::find_if(line.rbegin(), line.rend(), [](
int ch) { return !std::isspace(ch); }).base(), line.end());
110 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c){ return std::isspace(c); }) || line[0] ==
'#')
continue;
116 if(channel !=
nullptr) {
126 coefficients.push_back(tmpFloat);
132 maxRange = coefficients.back();
133 coefficients.pop_back();
134 minRange = coefficients.back();
135 coefficients.pop_back();
138 coefficients.clear();
141 channel->
SetENGRange(std::make_pair(minRange, maxRange), i-2);
144 std::cerr<<
"Failed to find detector ID "<<globId+1<<
" in TChannel"<<std::endl;
150 std::ifstream xTalkFile(argv[argc-1]);
155 while(std::getline(xTalkFile, line)) {
156 if(line.empty() || std::all_of(line.begin(), line.end(), [](
char c){ return std::isspace(c); }) || line[0] ==
'#')
continue;
166 if(channel ==
nullptr) {
169 if(channel ==
nullptr) {
170 std::cerr<<
"Failed to find channel \""<<Form(
"FI/IFG%02d%sN00X", detNumber,
TFipps::GetColorFromNumber(col))<<
"\""<<std::endl;
179 if(col == 3 && row == 3) ++detNumber;