Changeset 1661 for trunk/MagicSoft/Mars/mfilter
- Timestamp:
- 11/21/02 15:04:04 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mfilter
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h
r1588 r1661 12 12 #pragma link C++ class MFTriggerLvl1+; 13 13 #pragma link C++ class MFParticleId+; 14 #pragma link C++ class MFDataChain+; 14 15 #pragma link C++ class MFDataMember+; 15 16 -
trunk/MagicSoft/Mars/mfilter/MF.cc
r1588 r1661 44 44 // "MHillas.fSize>200 || (MHillas.fWidth<0.5 && MHillas.fLength<0.6)" 45 45 // 46 // If you want to use mathematic expressions (as defined in MDataChain) 47 // you must encapsulate it in {}-Brackets, eg: 48 // "{log10(MHillas.fSize)}>3" 49 // 46 50 // The allowed logigal conditionals are: 47 51 // &&: logical and … … 53 57 // are allowed. 54 58 // 59 // 55 60 // Warning: There is no priority rule build in. So better use brackets 56 61 // to get correct results. The rule is parsed/evaluated from the left … … 80 85 81 86 #include "MFilterList.h" 87 #include "MFDataChain.h" 82 88 #include "MFDataMember.h" 83 89 … … 139 145 // in the given string 140 146 // 141 Int_t MF::IsAlNum(TString txt) 147 Int_t MF::IsAlNum(TString txt) const 142 148 { 143 149 int l = txt.Length(); … … 149 155 } 150 156 157 MFilter *MF::ParseRule(TString &txt, MFilter *filter0) const 158 { 159 TString text; 160 161 Bool_t isrule = kFALSE; 162 163 if (txt[0]=='{') 164 { 165 // 166 // Search for the corresponding bracket 167 // 168 Int_t first=1; 169 for (int cnt=0; first<txt.Length(); first++) 170 { 171 if (txt[first]=='{') 172 cnt++; 173 if (txt[first]=='}') 174 cnt--; 175 176 if (cnt==-1) 177 break; 178 } 179 180 if (first==txt.Length()) 181 { 182 *fLog << err << dbginf << "Syntax Error: '}' missing." << endl; 183 return NULL; 184 } 185 186 // 187 // Make a copy of the 'interieur' and delete the substringä 188 // including the brackets 189 // 190 TString sub = txt(1, first-1); 191 txt.Remove(0, first+1); 192 193 text=sub; 194 isrule = kTRUE; 195 } 196 else 197 { 198 int i = IsAlNum(txt); 199 200 if (i==0) 201 { 202 *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl; 203 return NULL; 204 } 205 206 text = txt(0, i); 207 208 txt.Remove(0, i); 209 } 210 211 txt = txt.Strip(TString::kBoth); 212 213 if (txt.IsNull()) 214 { 215 *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl; 216 return NULL; 217 } 218 219 char c; 220 switch (txt[0]) 221 { 222 case '>': 223 case '<': 224 c = txt[0]; 225 txt.Remove(0, 1); 226 break; 227 228 default: 229 *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl; 230 return NULL; 231 } 232 233 char *end; 234 Double_t num = strtod(txt.Data(), &end); 235 if (!end || txt.Data()==end) 236 { 237 *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl; 238 return NULL; 239 } 240 241 txt.Remove(0, end-txt.Data()); 242 243 MFilter *newfilter; 244 if (isrule) 245 newfilter = new MFDataChain(text.Data(), c, num); 246 else 247 newfilter = new MFDataMember(text.Data(), c, num); 248 249 newfilter->SetName(Form("%s%c%f", text.Data(), c, num)); 250 251 return newfilter; 252 } 151 253 // -------------------------------------------------------------------------- 152 254 // … … 222 324 return NULL; 223 325 326 224 327 case '&': 225 328 case '|': … … 264 367 265 368 default: 266 int i = IsAlNum(txt); 267 268 if (i==0) 369 newfilter = ParseRule(txt, filter0); 370 if (!newfilter) 269 371 { 270 *fLog << err << dbginf << "Syntax Error: Name of data member missing in '" << txt << "'" << endl;271 372 if (filter0) 272 373 delete filter0; 273 374 return NULL; 274 375 } 275 276 TString text = txt(0, i);277 278 txt.Remove(0, i);279 txt = txt.Strip(TString::kBoth);280 281 if (txt.IsNull())282 {283 *fLog << err << dbginf << "Syntax Error: No conditional in '" << text << "'" << endl;284 if (filter0)285 delete filter0;286 return NULL;287 }288 289 char c;290 switch (txt[0])291 {292 case '>':293 case '<':294 c = txt[0];295 txt.Remove(0, 1);296 break;297 298 default:299 *fLog << err << dbginf << "Syntax Error: Conditional '" << txt[0] << "' unknown." << endl;300 if (filter0)301 delete filter0;302 return NULL;303 }304 305 char *end;306 Double_t num = strtod(txt.Data(), &end);307 if (!end || txt.Data()==end)308 {309 *fLog << err << dbginf << "Error trying to convert '" << txt << "' to value." << endl;310 if (filter0)311 delete filter0;312 return NULL;313 }314 315 txt.Remove(0, end-txt.Data());316 317 newfilter = new MFDataMember(text.Data(), c, num);318 newfilter->SetName(Form("%s%c%f", text.Data(), c, num));319 376 } 320 377 -
trunk/MagicSoft/Mars/mfilter/MF.h
r1588 r1661 23 23 MFilter *fFilter; // Filter 24 24 25 Int_t IsAlNum(TString txt) ;25 Int_t IsAlNum(TString txt) const; 26 26 27 MFilter *ParseRule(TString &txt, MFilter *filter0) const; 27 28 MFilter *ParseString(TString txt, Int_t level); 28 29 -
trunk/MagicSoft/Mars/mfilter/MFDataMember.cc
r1493 r1661 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 01/2002 <mailto:tbretz@ uni-sw.gwdg.de>18 ! Author(s): Thomas Bretz 01/2002 <mailto:tbretz@astro.uni-wueruburg.de> 19 19 ! 20 20 ! Copyright: MAGIC Software Development, 2000-2002 -
trunk/MagicSoft/Mars/mfilter/Makefile
r1588 r1661 35 35 MFilterList.cc \ 36 36 MFEventSelector.cc \ 37 MFDataChain.cc \ 37 38 MFDataMember.cc \ 38 39 MFParticleId.cc \
Note:
See TracChangeset
for help on using the changeset viewer.