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();
80 if (subCaloStr.compare(pos1,len,
"EMB")==0)
82 else if(subCaloStr.compare(pos1,len,
"EMECIW")==0)
84 else if(subCaloStr.compare(pos1,len,
"EMECOW")==0)
86 else if(subCaloStr.compare(pos1,len,
"HEC")==0)
88 else if(subCaloStr.compare(pos1,len,
"FCAL")==0)
91 logStr << MSG::ERROR <<
"Unknown sub-calo name '"<< subCaloStr.substr(pos1,len) <<
"'found. "
92 <<
"Allowed values are EMB, EMECIW, EMECOW, HEC and FCAL" <<
endmsg;
96 while(pos2!=std::string::npos);
99 if (subdefs[1].
size()!=1) {
104 if (subdefs[1][0]==
'A')
106 else if (subdefs[1][0]==
'C')
108 else if (subdefs[1][0]==
'*')
111 logStr << MSG::ERROR <<
"Allowed values for side are: A,C or * (means both), found " << subdefs[1] <<
endmsg;
116 std::string& subdef=subdefs[
i+2];
119 if (subdef.compare(
"*")!=0) {
120 std::size_t pos1=subdef.find(
'-');
121 if (pos1==std::string::npos) {
122 if (isdigit(subdef[0]))
123 lower=
upper=atol(subdef.c_str());
125 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
128 std::string lStr=subdef.substr(0,pos1);
129 std::string uStr=subdef.substr(pos1+1);
131 if (isdigit(lStr[0]))
132 lower=atol(lStr.c_str());
134 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
137 if (isdigit(uStr[0]))
138 upper=atol(uStr.c_str());
140 logStr << MSG::ERROR <<
"Malformed string [" << subdef <<
"], expected numerical value!" <<
endmsg;
148 const char* ptr1=valuesStr.c_str();
156 ptr1=
const_cast<const char*
>(ptr2+1);
189 if (
pn<0 && !
m_neg)
return false;
190 if (
pn>0 && !
m_pos)
return false;
220 logStr << MSG::ERROR <<
"Malformed definition string '"<<problem <<
"'" <<
endmsg;
232 if (definitions.empty()) {
233 logStr << MSG::WARNING <<
"No definition string found" <<
endmsg;
238 const std::string& defaultValueStr=definitions[0];
240 const char* ptr1=defaultValueStr.c_str();
248 ptr1=
const_cast<const char*
>(ptr2+1);
253 m_groups.resize(definitions.size()-1);
255 bool s=
m_groups[
i].setDefinition(caloCellId,definitions[
i+1],logStr);
256 if (!
s)
return false;
258 logStr << MSG::ERROR <<
"Incosistent number of values!" <<
endmsg;
275 std::vector<CaloCellGroup>::const_iterator
it=
m_groups.begin();
276 std::vector<CaloCellGroup>::const_iterator it_e=
m_groups.end();
277 for(;
it!=it_e;++
it) {
279 if (
it->inGroup(
id))
result=&(
it->getValue());
286 std::cout <<
"Definitions: " << std::endl;
288 std::cout <<
"Group " <<
i <<
":" << std::endl;
291 std::cout <<
"Results: "<< std::endl;
296 for (std::size_t
i=0;
i<
x.size();
i++)
297 std::cout <<
x[
i] <<
" ";
298 std::cout <<
"]" << std::endl;
303 std::cout <<
"Definitions: " << std::endl;
305 std::cout <<
"Group " <<
i <<
":" << std::endl;
315 std::cout <<
"Values";
318 std::cout <<
" will be used for the following region:" << std::endl;
320 std::cout <<
"pos=" <<
m_pos <<
" neg=" <<
m_neg << std::endl;