Changeset 1481 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 08/05/02 14:30:21 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r1476 r1481 70 70 #include "MEvtLoop.h" 71 71 72 #include <time.h> 73 #include <fstream.h> // ofstream, SavePrimitive72 #include <time.h> // time_t 73 #include <fstream.h> // ofstream, SavePrimitive 74 74 #include <iostream.h> 75 75 76 #include <TSystem.h> 76 #include <TFile.h> // gFile 77 #include <TSystem.h> // gSystem 77 78 #include <TStopwatch.h> 78 79 #include <TGProgressBar.h> … … 352 353 // to a macro. In the original root implementation it is used to write 353 354 // gui elements to a macro-file. 354 355 355 // 356 356 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *) 357 357 { 358 fParList->SavePrimitive(out); 358 if (HasDuplicateNames("MEvtLoop::SavePrimitive")) 359 { 360 out << " // !" << endl; 361 out << " // ! WARNING - Your eventloop (MParList, MTaskList, ...) contains more than" << endl; 362 out << " // ! one object (MParContainer, MTask, ...) with the same name. The created macro" << endl; 363 out << " // ! may need manual intervention before it can be used." << endl; 364 out << " // !" << endl; 365 out << endl; 366 } 367 368 if (fParList) 369 fParList->SavePrimitive(out); 359 370 360 371 out << " MEvtLoop evtloop;" << endl; 361 out << " evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl; 372 if (fParList) 373 out << " evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl; 374 else 375 out << " // fParList empty..." << endl; 362 376 out << " if (!evtloop.Eventloop())" << endl; 363 377 out << " return;" << endl; 364 378 } 365 379 380 // -------------------------------------------------------------------------- 381 // 382 // Get a list of all conmtainer names which are somehow part of the 383 // eventloop. Chack for duplicate members and print a warning if 384 // duplicates are found. Return kTRUE if duplicates are found, otherwise 385 // kFALSE; 386 // 387 Bool_t MEvtLoop::HasDuplicateNames(TObjArray &arr, const TString txt) const 388 { 389 arr.Sort(); 390 391 TIter Next(&arr); 392 TObject *obj; 393 TString name; 394 Bool_t found = kFALSE; 395 while ((obj=Next())) 396 { 397 if (name==obj->GetName()) 398 { 399 if (!found) 400 { 401 *fLog << warn << endl; 402 *fLog << " ! WARNING (" << txt << ")" << endl; 403 *fLog << " ! Your eventloop (MParList, MTaskList, ...) contains more than" << endl; 404 *fLog << " ! one object (MParContainer, MTask, ...) with the same name." << endl; 405 *fLog << " ! Creating a macro from it using MEvtLoop::MakeMacro may create" << endl; 406 *fLog << " ! a macro which needs manual intervention before it can be used." << endl; 407 found = kTRUE; 408 } 409 *fLog << " ! Please rename: " << obj->GetName() << endl; 410 } 411 name = obj->GetName(); 412 } 413 414 return found; 415 } 416 417 // -------------------------------------------------------------------------- 418 // 419 // Get a list of all conmtainer names which are somehow part of the 420 // eventloop. Chack for duplicate members and print a warning if 421 // duplicates are found. Return kTRUE if duplicates are found, otherwise 422 // kFALSE; 423 // 424 Bool_t MEvtLoop::HasDuplicateNames(const TString txt) const 425 { 426 if (!fParList) 427 return kFALSE; 428 429 TObjArray list; 430 list.SetOwner(); 431 432 fParList->GetNames(list); 433 434 return HasDuplicateNames(list, txt); 435 } 436 437 // -------------------------------------------------------------------------- 438 // 439 // Reads a saved eventloop from a file. The default name is "Evtloop". 440 // Therefor an open file must exist (See TFile for more information) 441 // 442 // eg: 443 // TFile file("myfile.root", "READ"); 444 // MEvtLoop evtloop; 445 // evtloop.Read(); 446 // evtloop.MakeMacro("mymacro"); 447 // 366 448 Int_t MEvtLoop::Read(const char *name) 367 449 { 450 if (!gFile) 451 { 452 *fLog << err << "MEvtloop::Read: No file found. Please create a TFile first." << endl; 453 return 0; 454 } 455 456 if (!gFile->IsOpen()) 457 { 458 *fLog << err << "MEvtloop::Read: File not open. Please open the TFile first." << endl; 459 return 0; 460 } 461 368 462 Int_t n = 0; 369 463 TObjArray list; 370 464 371 465 n += TObject::Read(name); 466 467 if (n==0) 468 { 469 *fLog << err << "MEvtloop::Read: No objects read." << endl; 470 return 0; 471 } 472 372 473 n += list.Read((TString)name+"_names"); 373 474 374 475 fParList->SetNames(list); 375 476 477 HasDuplicateNames(list, "MEvtLoop::Read"); 478 376 479 return n; 377 480 } 378 481 482 // -------------------------------------------------------------------------- 483 // 484 // Writes a eventloop to a file. The default name is "Evtloop". 485 // Therefor an open file must exist (See TFile for more information) 486 // 487 // eg: 488 // TFile file("myfile.root", "RECREATE"); 489 // MEvtLoop evtloop; 490 // evtloop.Write(); 491 // file.Close(); 492 // 379 493 Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize) 380 494 { 495 if (!gFile) 496 { 497 *fLog << err << "MEvtloop::Write: No file found. Please create a TFile first." << endl; 498 return 0; 499 } 500 501 if (!gFile->IsOpen()) 502 { 503 *fLog << err << "MEvtloop::Write: File not open. Please open the TFile first." << endl; 504 return 0; 505 } 506 507 if (!gFile->IsWritable()) 508 { 509 *fLog << err << "MEvtloop::Write: File not writable." << endl; 510 return 0; 511 } 512 381 513 Int_t n = 0; 382 514 … … 386 518 fParList->GetNames(list); 387 519 520 n += TObject::Write(name, option, bufsize); 521 522 if (n==0) 523 { 524 *fLog << err << "MEvtloop::Read: No objects written." << endl; 525 return 0; 526 } 527 388 528 n += list.Write((TString)name+"_names", kSingleKey); 389 n += TObject::Write(name, option, bufsize); 529 530 HasDuplicateNames(list, "MEvtLoop::Write"); 390 531 391 532 return n; -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r1474 r1481 27 27 28 28 enum { kIsOwner = BIT(14) }; 29 30 Bool_t HasDuplicateNames(const TString txt) const; 31 Bool_t HasDuplicateNames(TObjArray &arr, const TString txt) const; 29 32 30 33 public: -
trunk/MagicSoft/Mars/mbase/MFilter.cc
r1211 r1481 98 98 return kTRUE; 99 99 } 100 101 TString MFilter::GetRule() const 102 { 103 return "<GetRule not available for " + fName + ">"; 104 } -
trunk/MagicSoft/Mars/mbase/MFilter.h
r1211 r1481 19 19 virtual Bool_t PostProcess(); 20 20 21 virtual TString GetRule() const; 22 21 23 ClassDef(MFilter, 0) // Abstract base class for the filters 22 24 }; -
trunk/MagicSoft/Mars/mbase/MFilterList.cc
r1283 r1481 31 31 #include "MFilterList.h" 32 32 33 #include <fstream.h> 34 33 35 #include <TString.h> 34 36 … … 53 55 // lor, || : is a logical or 54 56 // 55 MFilterList::MFilterList(const char *type) 56 { 57 MFilterList::MFilterList(const char *type, const char *name, const char *title) 58 { 59 fName = name ? name : "MFilterList"; 60 fTitle = title ? title : "List combining filters logically."; 61 57 62 fFilterType = kEAnd; 58 63 … … 236 241 void MFilterList::Print(Option_t *opt) const 237 242 { 243 *fLog << all << GetRule(opt) << flush; 244 } 245 246 // -------------------------------------------------------------------------- 247 // 248 // Implementation of SavePrimitive. Used to write the call to a constructor 249 // to a macro. In the original root implementation it is used to write 250 // gui elements to a macro-file. 251 // 252 void MFilterList::StreamPrimitive(ofstream &out) const 253 { 254 out << " MFilterList " << ToLower(fName) << "(\""; 255 256 switch (fFilterType) 257 { 258 case kEAnd: 259 out << "&"; 260 break; 261 262 case kEOr: 263 out << "|"; 264 break; 265 266 case kEXor: 267 out << "^"; 268 break; 269 270 case kELAnd: 271 out << "&&"; 272 break; 273 274 case kELOr: 275 out << "||"; 276 break; 277 } 278 279 out << fName << "\", \"" << fName << "\", \"" << fTitle << "\");" << endl << endl; 280 281 TIter Next(&fFilters); 282 283 TObject *cont = NULL; 284 while ((cont=Next())) 285 { 286 cont->SavePrimitive(out, ""); 287 288 out << " " << ToLower(fName) << ".AddToList(&"; 289 out << ToLower(cont->GetName()) << ");" << endl << endl; 290 } 291 } 292 293 TString MFilterList::GetRule(Option_t *opt) const 294 { 238 295 TString str(opt); 239 296 const Bool_t verbose = str.Contains("V", TString::kIgnoreCase); 240 297 241 //*fLog << all << "(" << GetName() << "=" << (int)fFilterType << ")"; 242 243 *fLog << all << "("; 298 TString ret = "("; 244 299 245 300 TIter Next(&fFilters); … … 251 306 // 252 307 if (!filter) 253 { 254 *fLog << "<empty>)" << flush; 255 return; 256 } 257 258 filter->Print(); 308 return "<empty>"; 309 310 ret += filter->GetRule(); 259 311 260 312 while ((filter=(MFilter*)Next())) … … 263 315 { 264 316 case kEAnd: 265 *fLog <<(verbose?" and ":" & ");317 ret += (verbose?" and ":" & "); 266 318 break; 267 319 268 320 case kEOr: 269 *fLog <<(verbose?" or ":" | ");321 ret += (verbose?" or ":" | "); 270 322 break; 271 323 272 324 case kEXor: 273 *fLog <<(verbose?" xor ":" ^ ");325 ret += (verbose?" xor ":" ^ "); 274 326 break; 275 327 276 328 case kELAnd: 277 *fLog <<(verbose?" land ":" && ");329 ret += (verbose?" land ":" && "); 278 330 break; 279 331 280 332 case kELOr: 281 *fLog <<(verbose?" lor ":" || ");333 ret += (verbose?" lor ":" || "); 282 334 break; 283 335 } 284 336 285 filter->Print(); 286 } 287 288 *fLog << ")" << flush; 289 } 290 337 ret += filter->GetRule(); 338 } 339 340 return ret+")"; 341 } -
trunk/MagicSoft/Mars/mbase/MFilterList.h
r1020 r1481 29 29 enum { kIsOwner = BIT(14) }; 30 30 31 void StreamPrimitive(ofstream &out) const; 32 31 33 public: 32 MFilterList(const char *type="&&" );34 MFilterList(const char *type="&&", const char *name=NULL, const char *title=NULL); 33 35 MFilterList(MFilterList &ts); 34 36 ~MFilterList() … … 48 50 49 51 void Print(Option_t *opt = "") const; 52 TString GetRule(Option_t *opt="") const; 50 53 51 ClassDef(MFilterList, 0) // List to combine several filters logically54 ClassDef(MFilterList, 1) // List to combine several filters logically 52 55 }; 53 56 -
trunk/MagicSoft/Mars/mbase/MTask.h
r1477 r1481 24 24 TList *fListOfBranches; //! List of Branch names for auto enabeling scheme 25 25 26 const MFilter *fFilter;// Filter for conditional task execution26 MFilter *fFilter; // Filter for conditional task execution 27 27 28 28 Bool_t fIsPreprocessed; //! Indicates the success of the PreProcessing (set by MTaskList) … … 68 68 virtual ~MTask(); 69 69 70 void SetFilter( constMFilter *filter) { fFilter=filter; }70 void SetFilter(MFilter *filter) { fFilter=filter; } 71 71 const MFilter *GetFilter() const { return fFilter; } 72 72 virtual void PrintStatistics(const Int_t lvl=0) const;
Note:
See TracChangeset
for help on using the changeset viewer.