35 std::vector<std::string> subdefs(2+
NFIELDS);
36 std::string valuesStr;
38 std::size_t pos1,pos2;
39 pos1=definition.find(
'[');
40 if( pos1==std::string::npos) {
45 std::size_t
i,iField=0;
46 for (
i=1+pos1;
i<definition.size();
i++) {
48 if (isspace(
c))
continue;
53 if (iField >= subdefs.size())
break;
56 subdefs[iField].push_back(
c);
59 if (iField!=subdefs.size()-1 ||
i==definition.size()) {
60 logStr << MSG::ERROR <<
"Definition String [" << definition <<
"] malformed. Expect "
65 valuesStr=definition.substr(
i+1);
69 std::string& subCaloStr=subdefs[0];
73 pos2=subCaloStr.find(
',',pos1);
74 if (pos2==std::string::npos)
75 len=subCaloStr.size();
78 if (subCaloStr.compare(pos1,len,
"EMB")==0)
80 else if(subCaloStr.compare(pos1,len,
"EMECIW")==0)
82 else if(subCaloStr.compare(pos1,len,
"EMECOW")==0)
84 else if(subCaloStr.compare(pos1,len,
"HEC")==0)
86 else if(subCaloStr.compare(pos1,len,
"FCAL")==0)
89 logStr << MSG::ERROR <<
"Unknown sub-calo name '"<< subCaloStr.substr(pos1,len) <<
"'found. "
90 <<
"Allowed values are EMB, EMECIW, EMECOW, HEC and FCAL" <<
endmsg;
95 while(pos2!=std::string::npos);
98 if (subdefs[1].
size()!=1) {
103 if (subdefs[1][0]==
'A')
105 else if (subdefs[1][0]==
'C')
107 else if (subdefs[1][0]==
'*')
110 logStr << MSG::ERROR <<
"Allowed values for side are: A,C or * (means both), found " << subdefs[1] <<
endmsg;
115 std::string& subdef=subdefs[
i+2];
118 if (subdef.compare(
"*")!=0) {
119 std::size_t pos1=subdef.find(
'-');
120 if (pos1==std::string::npos) {
121 if (isdigit(subdef[0]))
122 lower=
upper=atol(subdef.c_str());
124 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
127 std::string lStr=subdef.substr(0,pos1);
128 std::string uStr=subdef.substr(pos1+1);
130 if (isdigit(lStr[0]))
131 lower=atol(lStr.c_str());
133 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
136 if (isdigit(uStr[0]))
137 upper=atol(uStr.c_str());
139 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
147 const char* ptr1=valuesStr.c_str();
155 ptr1=
const_cast<const char*
>(ptr2+1);
159 logStr << MSG::INFO <<
"Sussefully parsed defintion string" <<
endmsg;
188 if (
pn<0 && !
m_neg)
return false;
189 if (
pn>0 && !
m_pos)
return false;
219 logStr << MSG::ERROR <<
"Malformed definition string '"<<problem <<
"'" <<
endmsg;
231 if (definitions.empty()) {
232 logStr << MSG::WARNING <<
"No definition string found" <<
endmsg;
237 const std::string& defaultValueStr=definitions[0];
239 const char* ptr1=defaultValueStr.c_str();
247 ptr1=
const_cast<const char*
>(ptr2+1);
252 m_groups.resize(definitions.size()-1);
254 bool s=
m_groups[
i].setDefinition(caloCellId,definitions[
i+1],logStr);
255 if (!
s)
return false;
257 logStr << MSG::ERROR <<
"Incosistent number of values!" <<
endmsg;
274 std::vector<CaloCellGroup>::const_iterator
it=
m_groups.begin();
275 std::vector<CaloCellGroup>::const_iterator it_e=
m_groups.end();
276 for(;
it!=it_e;++
it) {
278 if (
it->inGroup(
id))
result=&(
it->getValue());
285 std::cout <<
"Definitions: " << std::endl;
287 std::cout <<
"Group " <<
i <<
":" << std::endl;
290 std::cout <<
"Results: "<< std::endl;
295 for (std::size_t
i=0;
i<
x.size();
i++)
296 std::cout <<
x[
i] <<
" ";
297 std::cout <<
"]" << std::endl;
302 std::cout <<
"Definitions: " << std::endl;
304 std::cout <<
"Group " <<
i <<
":" << std::endl;
314 std::cout <<
"Values";
317 std::cout <<
" will be used for the following region:" << std::endl;
319 std::cout <<
"pos=" <<
m_pos <<
" neg=" <<
m_neg << std::endl;