6 #include "GaudiKernel/MsgStream.h"
11 #define MAX_BUFFER_LEN 1024
39 return StatusCode::SUCCESS;
45 return StatusCode::SUCCESS;
50 return StatusCode::SUCCESS;
64 std::string
file = hadDMCoeffFileName;
67 std::ifstream
fin(
file.c_str());
69 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() - Can't open file " <<
file );
70 return StatusCode::FAILURE;
77 std::istringstream ist;
78 while(
fin.getline(cLine,
sizeof(cLine)-1)) {
79 if( strlen(cLine)==0 || cLine[0] ==
'#' || cLine[0] ==
'\n')
continue;
85 ist.clear(); ist.str(sLine);
86 if( !(ist >> sdummy >> dmArea.
m_indx >> dmArea.
m_is_on >> dmArea.
m_title) && sdummy.find(
"zone")==std::string::npos ) {
87 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() -> Error! Could not parse line '" << cLine <<
"' at p1." );
88 return StatusCode::FAILURE;
93 std::vector<CaloHadDMCoeff2::HadDMDimension > v_dims;
94 while(
fin.getline(cLine,
sizeof(cLine)-1)){
95 if( cLine[0] ==
'#')
continue;
98 if(sLine.find(
"npars") != std::string::npos){
99 ist.clear(); ist.str(sLine);
101 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() ->Error! Could not parse line '" << cLine <<
"' at p2." );
102 return StatusCode::FAILURE;
109 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() ->Error! Could not parse line '" << sLine <<
"' at p2a." );
110 return StatusCode::FAILURE;
112 v_dims.push_back(
dim);
115 int ndim = (
int) v_dims.size();
117 for(
int i=0;
i<ndim;
i++){
123 for(
int i_dim=0; i_dim<ndim; i_dim++){
125 for(
int j=i_dim+1; j<ndim; j++){
126 xloc = xloc*v_dims[j].m_vBins.size();
128 v_dims[i_dim].xloc = xloc;
130 if( v_dims.size() != 4 ){
131 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() ->Error! Wrong number of dimensions for area'" << dmArea.
m_title <<
"' at p3." );
132 return StatusCode::FAILURE;
146 for(
int i_len=0; i_len<dmArea.
m_length; i_len++){
147 if(!
fin.getline(cLine,
sizeof(cLine)-1)) {
149 return StatusCode::FAILURE;
152 ist.clear(); ist.str(sLine);
154 if( !(ist >> idummy) ) {
155 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() -> Warning! Area " << dmArea.
m_title <<
" doesn't have parameters." );
158 if(idummy != dmArea.
m_offset+i_len){
159 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() ->Error! Could not parse line '" << cLine <<
"' at p3." );
160 return StatusCode::FAILURE;
162 for(
int j=0; j<(
int)v_dims.size(); j++) {
163 if(!(ist >> idummy)) {
164 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() -> panic!" );
165 return StatusCode::FAILURE;
170 for(
int j=0; j<dmArea.
m_nPars; j++) {
171 if( !(ist >>
pars[j]) ) {
172 ATH_MSG_ERROR (
"LArReadHadDMCoeffFile2::initDataFromFile() ->Error! Could not parse line '" << cLine <<
"' at p4." );
174 return StatusCode::FAILURE;
181 return StatusCode::SUCCESS;
192 std::istringstream ist(sLine.c_str());
194 if( !(ist >>
dim.m_title >>
dim.m_nbins >>
dim.m_vMin >>
dim.m_vMax >> stype) ||
dim.m_nbins < 0 ||
dim.m_nbins > 1000){
195 std::cout <<
"LArReadHadDMCoeffFile2::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at pp1." << std::endl;
199 if(stype.find(
"flat") != std::string::npos) {
201 dim.m_bin_size = (
dim.m_vMax -
dim.m_vMin)/
float(
dim.m_nbins);
204 }
else if(stype.find(
"hand") != std::string::npos) {
207 for(
int i=0;
i<
dim.m_nbins;
i++)
if( ist >>
e )
dim.m_vBins.push_back(
e);
209 std::cout <<
"LArReadHadDMCoeffFile2::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at pp3." << std::endl;
212 if((
int)
dim.m_vBins.size() !=
dim.m_nbins){
213 std::cout <<
"LArReadHadDMCoeffFile2::parse_dim() -> Error! Could not parse line '" << sLine <<
"' at pp4." << std::endl;
216 return (
int)
dim.m_vBins.size();