Changeset 3573 for trunk/MagicSoft/Mars/mfbase/MF.cc
- Timestamp:
- 03/22/04 14:30:09 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfbase/MF.cc
r3330 r3573 71 71 // 72 72 // 73 // If you intend to use Data Chains in filters enclose the chains in74 // this {}-parenthesis, eg.75 //76 // "{MHillas.fSize*MHillas.fWidth}<0.5"77 //78 73 // FIXME: The possibility to use also complete filters is missing. 79 74 // Maybe we can use gInterpreter->Calc("") for this. … … 166 161 MFilter *MF::ParseRule(TString &txt, MFilter *filter0, Int_t level) const 167 162 { 168 TString text; 169 170 Bool_t isrule = kFALSE; 171 172 if (txt[0]=='{') 173 { 174 // 175 // Search for the corresponding bracket 176 // 177 Int_t first=1; 178 for (int cnt=0; first<txt.Length(); first++) 179 { 180 if (txt[first]=='{') 181 cnt++; 182 if (txt[first]=='}') 183 cnt--; 184 185 if (cnt==-1) 186 break; 187 } 188 189 if (first==txt.Length()) 190 { 191 *fLog << err << dbginf << "Syntax Error: '}' missing." << endl; 192 return NULL; 193 } 194 195 // 196 // Make a copy of the 'interieur' and delete the substringä 197 // including the brackets 198 // 199 TString sub = txt(1, first-1); 200 txt.Remove(0, first+1); 201 202 text=sub; 203 isrule = kTRUE; 204 } 205 else 206 { 207 int i = IsAlNum(txt); 208 209 if (i==0) 210 { 211 *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl; 212 return NULL; 213 } 214 215 text = txt(0, i); 216 217 txt.Remove(0, i); 218 } 219 220 txt = txt.Strip(TString::kBoth); 221 222 if (txt.IsNull()) 223 { 224 *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl; 163 // For backward compatibility 164 txt.ReplaceAll("{", "("); 165 txt.ReplaceAll("}", ")"); 166 167 const Int_t fg = txt.First('>'); 168 const Int_t lg = txt.First('>'); 169 const Int_t fl = txt.First('<'); 170 const Int_t ll = txt.First('<'); 171 172 if (fg<0 && fl<0) 173 { 174 *fLog << err << dbginf << "Syntax Error: No coditional sign found in " << txt << endl; 225 175 return NULL; 226 176 } 227 228 char c; 229 switch (txt[0]) 230 { 231 case '>': 232 case '<': 233 c = txt[0]; 234 txt.Remove(0, 1); 235 break; 236 237 default: 238 *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl; 177 if (fg>=0 && fl>=0) 178 { 179 *fLog << err << dbginf << "Syntax Error: Two coditional signs found in " << txt << endl; 180 *fLog << "Currently you have to enclose all conditions in brackets, like: \"(x<y) && (z<5)\"" << endl; 239 181 return NULL; 240 182 } 241 242 char *end; 243 Double_t num = strtod(txt.Data(), &end); 244 if (!end || txt.Data()==end) 245 { 246 *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl; 183 if (fg!=lg || fl!=ll) 184 { 185 *fLog << err << dbginf << "Syntax Error: Coditional sign found twice " << txt << endl; 247 186 return NULL; 248 187 } 249 188 250 txt.Remove(0, end-txt.Data()); 251 252 MFilter *newfilter; 253 if (isrule) 254 { 255 Int_t lvl = gLog.GetDebugLevel(); 256 gLog.SetDebugLevel(1); 257 newfilter = new MFDataChain(text.Data(), c, num); 258 newfilter->SetName(Form("Chain%02d%c%f", level, c, num)); 259 gLog.SetDebugLevel(lvl); 260 } 261 else 262 { 263 newfilter = new MFDataMember(text.Data(), c, num); 264 newfilter->SetName(Form("%s%c%f", text.Data(), c, num)); 265 } 266 267 return newfilter; 189 const Int_t cond = fg<0 ? fl : fg; 190 191 const TString rule1 = txt(0, cond); 192 const TString rule2 = txt(cond+1, txt.Length()); 193 194 Int_t lvl = gLog.GetDebugLevel(); 195 gLog.SetDebugLevel(1); 196 MFilter *f = new MFDataChain(rule1.Data(), txt[cond], rule2.Data()); 197 f->SetName(Form("Chain%02d%c", level, txt[cond])); 198 gLog.SetDebugLevel(lvl); 199 200 txt = ""; 201 202 return f; 268 203 } 269 204 // --------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.