79{
80 CaloHadDMCoeff2 *
data =
new CaloHadDMCoeff2();
81
83
84
85 std::cout <<
"CaloHadDMCoeffHelper::InitDataFromFile() - Reading file '" <<
filename <<
"'." << std::endl;
86
88 if ( !fin ) {
89 std::cout <<
"CaloHadDMCoeffHelper::InitDataFromFile() - Can't open file '" <<
filename <<
"'." << std::endl;
90 delete data;
return nullptr;
91 }
92
94
95 std::string sLine;
96 std::string sdummy;
97 std::istringstream ist;
98 while(
fin.getline(cLine,
sizeof(cLine)-1)) {
99 if( strlen(cLine)==0 || cLine[0] == '#' || cLine[0] == '\n') continue;
100
101
102 CaloHadDMCoeff2::HadDMArea dmArea;
103
104 sLine = cLine;
105 ist.clear(); ist.str(sLine);
106 if( !(ist >> sdummy >> dmArea.
m_indx >> dmArea.
m_is_on >> dmArea.
m_title) && sdummy.find(
"zone")==std::string::npos ) {
107 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() -> Error! Could not parse line '" << cLine << "' at p1." << std::endl;
108 delete data;
return nullptr;
109 }
110
112 if(dmArea.
m_title.find(
"DEAD_FCAL") != std::string::npos) {
114 }
else if(dmArea.
m_title.find(
"DEAD_LEAKAGE") != std::string::npos) {
116 }
else if(dmArea.
m_title.find(
"DEAD_UNCLASS") != std::string::npos) {
118 }
119
120
121 std::vector<CaloHadDMCoeff2::HadDMDimension > v_dims;
122 while(
fin.getline(cLine,
sizeof(cLine)-1)){
123 if( cLine[0] == '#') continue;
124 sLine = cLine;
125
126 if(sLine.find("npars") != std::string::npos){
127 ist.clear(); ist.str(sLine);
128 if( !(ist >> sdummy >> dmArea.
m_nPars) ||
131 {
132 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine << "' at p2." << std::endl;
133 delete data;
return nullptr;
134 }
135
136 break;
137 }
138 CaloHadDMCoeff2::HadDMDimension
dim;
140 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << sLine << "' at p2a." << std::endl;
141 delete data;
return nullptr;
142 }
143 v_dims.push_back(std::move(dim));
144 }
145
146 int ndim = (
int) v_dims.size();
148 for(
int i=0;
i<ndim;
i++){
150 }
153
154 for(int i_dim=0; i_dim<ndim; i_dim++){
155 int xloc = 1;
156 for(int j=i_dim+1; j<ndim; j++){
157 xloc = xloc*v_dims[j].m_vBins.size();
158 }
159 v_dims[i_dim].xloc = xloc;
160 }
161 if( v_dims.size() != 4 ){
162 std::cout <<
"CaloHadDMCoeffHelper::initDataFromFile() ->Error! Wrong number of dimensions for area'" << dmArea.
m_title <<
"' at p3." << std::endl;
163 delete data;
return nullptr;
164 }
169
170 data->addHadDMArea(dmArea);
172
175 for(
int i_len=0; i_len<dmArea.
m_length; i_len++)
data->addHadDMCoeff(pars);
176
177 for(
int i_len=0; i_len<dmArea.
m_length; i_len++){
178 if(!
fin.getline(cLine,
sizeof(cLine)-1)) {
179 std::cout << "panic " << std::endl;
180 delete data;
return nullptr;
181 }
182 sLine = cLine;
183 ist.clear(); ist.str(sLine);
184 int idummy;
185 if( !(ist >> idummy) ) {
186 std::cout <<
"CaloHadDMCoeffHelper::initDataFromFile() -> Warning! Area " << dmArea.
m_title <<
" doesn't have parameters." << std::endl;
187 break;
188 }
189 if(idummy != dmArea.
m_offset+i_len){
190 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine << "' at p3." << std::endl;
191 delete data;
return nullptr;
192 }
193 for(
int j=0; j<(
int)v_dims.size(); j++) {
194 if(!(ist >> idummy)) {
195 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() -> panic!" << std::endl;
196 delete data;
return nullptr;
197 }
198 }
201 for(
int j=0; j<dmArea.
m_nPars; j++) {
202 if( !(ist >> pars[j]) ) {
203 std::cout << "CaloHadDMCoeffHelper::initDataFromFile() ->Error! Could not parse line '" << cLine << "' at p4." << std::endl;
204 std::cout <<
" dmArea.m_title" << dmArea.
m_title << std::endl;
205 delete data;
return nullptr;
206 }
207 }
209 }
210 }
212
214}
char data[hepevt_bytes_allocation_ATLAS]
std::vector< float > HadDMCoeff
int parse_dim(std::string &sLine, CaloHadDMCoeff2::HadDMDimension &dim)