Changeset 1661 for trunk/MagicSoft
- Timestamp:
- 11/21/02 15:04:04 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1660 r1661 1 -*-*- END -*-*-1 # -*-*- END -*-*- 2 2 2002/11/21: Thomas Bretz 3 3 … … 5 5 - introduced kERROR to stop an eventloop with an error 6 6 7 * mbase/MTask.h: 8 - made SetFilter virtual 9 10 * mbase/MTaskList.[h,cc]: 11 - added new member function AddToListBefore/After 12 - split the code of the AddToList function into CheckAddToList 13 7 14 * manalysis/MMultiDimDistCalc.cc: 8 15 - introduced usage of kERROR in case the matrix is not posdef. … … 10 17 * macros/collarea.C: 11 18 - some simplifications 19 20 * mdata/MDataChain.[h,cc]: 21 - added 'sqr' 22 23 * mfilter/MF.[h,cc]: 24 - added support for MFDataChain 25 26 * mfilter/MFDataChain.[h,cc]: 27 - added 28 29 * mfilter/Makefile, mfilter/FilterLinkDef.h: 30 - added MFDataChain 12 31 13 32 -
trunk/MagicSoft/Mars/mbase/MTask.h
r1574 r1661 65 65 virtual ~MTask(); 66 66 67 v oid SetFilter(MFilter *filter) { fFilter=filter; }67 virtual void SetFilter(MFilter *filter) { fFilter=filter; } 68 68 const MFilter *GetFilter() const { return fFilter; } 69 MFilter *GetFilter() { return fFilter; } // for MContinue only 69 70 virtual void PrintStatistics(const Int_t lvl=0, Bool_t title=kFALSE) const; 70 71 -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r1657 r1661 135 135 } 136 136 137 138 // -------------------------------------------------------------------------- 139 // 140 // schedule task for execution, whether as first task, or after 141 // 'where'. 'tType' is the event type which should be processed 142 // 143 Bool_t MTaskList::AddToList(MTask *task, const char *type, MTask *where) 144 { 145 // FIXME: We agreed to put the task into list in an ordered way. 146 137 Bool_t MTaskList::CheckAddToList(MTask *task, const char *type, const MTask *where) const 138 { 147 139 // 148 140 // Sanity check … … 182 174 } 183 175 184 if (where) 185 { 186 if (!fTasks->FindObject(where)) 187 { 188 *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl; 189 return kFALSE; 190 } 191 } 192 193 *fLog << inf << "Adding " << name << " to " << GetName() << " for " << type << "... " << flush; 194 176 if (!where) 177 return kTRUE; 178 179 if (fTasks->FindObject(where)) 180 return kTRUE; 181 182 *fLog << err << dbginf << "Error: Cannot find task after which the new task should be scheduled!" << endl; 183 return kFALSE; 184 } 185 186 187 // -------------------------------------------------------------------------- 188 // 189 // schedule task for execution, before 'where'. 190 // 'type' is the event type which should be processed 191 // 192 Bool_t MTaskList::AddToListBefore(MTask *task, const MTask *where, const char *type) 193 { 194 // FIXME: We agreed to put the task into list in an ordered way. 195 if (!CheckAddToList(task, type, where)) 196 return kFALSE; 197 198 *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush; 199 task->SetStreamId(type); 200 fTasks->AddBefore((TObject*)where, task); 201 *fLog << "Done." << endl; 202 203 return kTRUE; 204 } 205 206 // -------------------------------------------------------------------------- 207 // 208 // schedule task for execution, after 'where'. 209 // 'type' is the event type which should be processed 210 // 211 Bool_t MTaskList::AddToListAfter(MTask *task, const MTask *where, const char *type) 212 { 213 // FIXME: We agreed to put the task into list in an ordered way. 214 215 if (!CheckAddToList(task, type, where)) 216 return kFALSE; 217 218 *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush; 219 task->SetStreamId(type); 220 fTasks->AddAfter((TObject*)where, task); 221 *fLog << "Done." << endl; 222 223 return kTRUE; 224 } 225 226 // -------------------------------------------------------------------------- 227 // 228 // schedule task for execution, 'type' is the event type which should 229 // be processed 230 // 231 Bool_t MTaskList::AddToList(MTask *task, const char *type) 232 { 233 // FIXME: We agreed to put the task into list in an ordered way. 234 235 if (!CheckAddToList(task, type)) 236 return kFALSE; 237 238 *fLog << inf << "Adding " << task->GetName() << " to " << GetName() << " for " << type << "... " << flush; 195 239 task->SetStreamId(type); 196 240 fTasks->Add(task); 197 198 241 *fLog << "Done." << endl; 199 242 … … 325 368 *fLog << all << task->GetName() << "... " << flush; 326 369 327 if (CheckClassForProcess(task->IsA()))328 fTasksProcess.Add(task);329 330 370 // 331 371 // PreProcess the task and check for it's return value. … … 350 390 351 391 *fLog << all << endl; 392 393 Next.Reset(); 394 395 // 396 // loop over all tasks for preproccesing 397 // 398 while ((task=(MTask*)Next())) 399 if (CheckClassForProcess(task->IsA())) 400 fTasksProcess.Add(task); 352 401 353 402 return kTRUE; -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r1540 r1661 35 35 void StreamPrimitive(ofstream &out) const; 36 36 37 Bool_t CheckAddToList(MTask *task, const char *tType, const MTask *where=NULL) const; 38 37 39 public: 38 40 MTaskList(const char *name=NULL, const char *title=NULL); … … 43 45 void SetLogStream(MLog *log); 44 46 45 Bool_t AddToList(MTask *task, const char *tType="All", MTask *where = NULL); 47 Bool_t AddToListBefore(MTask *task, const MTask *where, const char *tType="All"); 48 Bool_t AddToListAfter(MTask *task, const MTask *where, const char *tType="All"); 49 Bool_t AddToList(MTask *task, const char *tType="All"); 46 50 47 51 TObject *FindObject(const char *name) const; -
trunk/MagicSoft/Mars/mdata/MDataChain.cc
r1629 r1661 69 69 // atan(x) arc tangent (inverse tangent) of x 70 70 // sqrt(x) square root of x 71 // sqr(x) square of x 71 72 // abs(x) absolute value of x, |x| 72 73 // floor(x) round down to the nearest integer (floor(9.9)=9) … … 225 226 if (txt=="atan") return kEATan; 226 227 if (txt=="sqrt") return kESqrt; 228 if (txt=="sqr") return kESqr; 227 229 if (txt=="exp") return kEExp; 228 230 if (txt=="pow10") return kEPow10; … … 468 470 case kEATan: return atan(val); 469 471 case kESqrt: return sqrt(val); 472 case kESqr: return val*val; 470 473 case kEExp: return exp(val); 471 474 case kEPow10: return pow(10, val); … … 551 554 case kEATan: str += "atan" ; break; 552 555 case kESqrt: str += "sqrt" ; break; 556 case kESqr: str += "sqr" ; break; 553 557 case kEExp: str += "exp" ; break; 554 558 case kEPow10: str += "pow10"; break; -
trunk/MagicSoft/Mars/mdata/MDataChain.h
r1629 r1661 34 34 kEATan, 35 35 kESqrt, 36 kESqr, 36 37 kEPow10, 37 38 kEExp, -
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.