57{
58 std::optional<CaloLocalHadCoeff>
data=std::make_optional<CaloLocalHadCoeff>();
59
60 char cLine[1024];
61
62
63 std::cout <<
"CaloLCCoeffHelper::InitDataFromFile - Reading file '" <<
filename <<
"'." << std::endl;
64
65 std::ifstream
fin(filename);
66 if ( !fin ) {
67 std::cout <<
"CaloLCCoeffHelper::InitDataFromFile - Can't open file '" <<
filename <<
"'." << std::endl;
68 return std::nullopt;
69 }
70
71 std::string sLine;
72 std::istringstream ist;
73 while(
fin.getline(cLine,
sizeof(cLine)-1)) {
74 if( strlen(cLine)==0 || cLine[0] == '#' || cLine[0] == '\n') continue;
75
76
77 sLine = cLine;
78 ist.clear(); ist.str(sLine);
79 std::string sdummy, area_title;
80 int area_indx(0), area_type(0), area_npars(0);
81 if( !(ist >> sdummy >> area_indx >> area_title >> area_type >> area_npars) ||
82 area_npars < 0 || area_npars > 1000 ) {
83 std::cout << "CaloLCCoeffHelper::initDataFromFile() -> Error! Could not parse line '" << cLine << "' at p1." << std::endl;
84 return std::nullopt;
85 }
86
87 CaloLocalHadCoeff::LocalHadArea theArea(area_title.c_str(), area_type, area_npars);
88
89
90 while(
fin.getline(cLine,
sizeof(cLine)-1)){
91 if( cLine[0] == '#') continue;
92 sLine = cLine;
93 if(sLine.find("break") != std::string::npos) {
94 break;
95 }
97 if( !dim ) {
98 std::cout << "CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << sLine << "' at p2a." << std::endl;
99 return std::nullopt;
100 }
101 theArea.addDimension(*dim);
102 }
103 data->addArea(theArea);
104
105
106 for(int i_len=0; i_len<theArea.getLength(); i_len++){
107 if(!
fin.getline(cLine,
sizeof(cLine)-1)) {
108 std::cout << "panic " << std::endl;
109 return std::nullopt;
110 }
111 sLine = cLine;
112 ist.clear(); ist.str(sLine);
113 int idummy;
114 if( !(ist >> idummy) ) {
115 std::cout << "CaloLCCoeffHelper::initDataFromFile() -> Warning! Area " << theArea.getTitle() << " doesn't have parameters." << std::endl;
116 break;
117 }
118 if(idummy != theArea.getOffset()+i_len){
119 std::cout << "CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine << "' at p3." << std::endl;
120 return std::nullopt;
121 }
122 for(int j=0; j<theArea.getNdim(); j++) {
123 if(!(ist >> idummy)) {
124 std::cout << "CaloLCCoeffHelper::initDataFromFile() -> panic!" << std::endl;
125 return std::nullopt;
126 }
127 }
129 pars.resize(theArea.getNpars(),0.0);
130 for(int j=0; j<theArea.getNpars(); j++) {
131 if( !(ist >> pars[j]) ) {
132 std::cout << "CaloLCCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine << "' at p4." << std::endl;
133 std::cout << " dmArea.m_title" << theArea.getTitle() << std::endl;
134 return std::nullopt;
135 }
136 }
137 data->setCoeff(theArea.getOffset()+i_len, pars);
138 }
139 }
141
143}
char data[hepevt_bytes_allocation_ATLAS]
static std::optional< CaloLocalHadCoeff::LocalHadDimension > parse_dim(const std::string &sLine)
std::vector< float > LocalHadCoeff
Correction parameters for one general bin.