Changeset 1474 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 08/02/02 09:32:34 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r1473 r1474 52 52 // // 53 53 // You can create a macro from a completely setup eventloop by: // 54 // ofstream fout("mymacro.C"); // 55 // evtloop.SavePrimitive(fout); // 54 // evtloop.MakeMacro("mymacro.C"); // 56 55 // // 57 56 // You will always need to check the macro, it will not run, but it // … … 66 65 // evtloop.Read("MyEvtloopKey"); // 67 66 // // 68 // To lookup the information write it to a file using SavePrimite//67 // To lookup the information write it to a file using MakeMacro // 69 68 // // 70 69 ////////////////////////////////////////////////////////////////////////////// 71 70 #include "MEvtLoop.h" 72 71 72 #include <time.h> 73 73 #include <fstream.h> // ofstream, SavePrimitive 74 74 #include <iostream.h> … … 292 292 } 293 293 294 void MEvtLoop::MakeMacro(const char *filename="evtloop.C") 295 { 296 TString name(filename); 297 298 if (!name.EndsWith(".C")) 299 name += ".C"; 300 301 time_t t = time(NULL); 302 303 ofstream fout(name); 304 fout << 305 "/* ======================================================================== *\\" << endl << 306 "!" << endl << 307 "! *" << endl << 308 "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl << 309 "! * Software. It is distributed to you in the hope that it can be a useful" << endl << 310 "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl << 311 "! * It is distributed WITHOUT ANY WARRANTY." << endl << 312 "! *" << endl << 313 "! * Permission to use, copy, modify and distribute this software and its" << endl << 314 "! * documentation for any purpose is hereby granted without fee," << endl << 315 "! * provided that the above copyright notice appear in all copies and" << endl << 316 "! * that both that copyright notice and this permission notice appear" << endl << 317 "! * in supporting documentation. It is provided \"as is\" without express" << endl << 318 "! * or implied warranty." << endl << 319 "! *" << endl << 320 "!" << endl << 321 "!" << endl << 322 "! Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl << 323 "!" << endl << 324 "! Copyright: MAGIC Software Development, 2000-2002" << endl << 325 "!" << endl << 326 "!" << endl << 327 "\\* ======================================================================== */" << endl << endl << 328 "// ------------------------------------------------------------------------" << endl << 329 "//" << endl << 330 "// This macro was automatically created on" << endl<< 331 "// " << ctime(&t) << 332 "// with the MEvtLoop::MakeMacro tool." << endl << 333 "//" << endl << 334 "// ------------------------------------------------------------------------" << endl << endl << 335 "void " << name(0, name.Length()-2) << "()" << endl << 336 "{" << endl; 337 338 SavePrimitive(fout); 339 340 fout << "}" << endl; 341 } 342 343 // -------------------------------------------------------------------------- 344 // 345 // Implementation of SavePrimitive. Used to write the call to a constructor 346 // to a macro. In the original root implementation it is used to write 347 // gui elements to a macro-file. 348 349 // 294 350 void MEvtLoop::SavePrimitive(ofstream &out, Option_t *) 295 351 { … … 297 353 298 354 out << " MEvtLoop evtloop;" << endl; 299 out << " evtloop.SetParList(&" << ToLower(fParList->GetName()) << ") " << endl;355 out << " evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl; 300 356 out << " if (!evtloop.Eventloop())" << endl; 301 357 out << " return;" << endl; 302 358 } 359 360 Int_t MEvtLoop::Read(const char *name) 361 { 362 Int_t n = 0; 363 TObjArray list; 364 365 n += TObject::Read(name); 366 n += list.Read((TString)name+"_names"); 367 368 fParList->SetNames(list); 369 370 return n; 371 } 372 373 Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize) 374 { 375 Int_t n = 0; 376 377 TObjArray list; 378 list.SetOwner(); 379 380 fParList->GetNames(list); 381 382 n += list.Write((TString)name+"_names", kSingleKey); 383 n += TObject::Write(name, option, bufsize); 384 385 return n; 386 } -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r1472 r1474 46 46 Bool_t Eventloop(Int_t maxcnt=-1, const char *tlist="MTaskList"); 47 47 48 void MakeMacro(const char *filename="evtloop.C"); 49 48 50 void SavePrimitive(ofstream &out, Option_t *o=""); 51 52 Int_t Read(const char *name); 53 Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0); 49 54 50 55 ClassDef(MEvtLoop, 1) // Class to execute the tasks in a tasklist -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r1471 r1474 39 39 #include <fstream.h> // ofstream, AsciiWrite 40 40 41 #include <TROOT.h> // TROOT::Identlevel 41 42 #include <TClass.h> // IsA 43 #include <TObjArray.h> // TObjArray 42 44 #include <TBaseClass.h> // GetClassPointer 43 #include <TROOT.h> // TROOT::Identlevel44 45 #include <TMethodCall.h> // TMethodCall, AsciiWrite 45 46 #include <TDataMember.h> // TDataMember, AsciiWrite … … 347 348 } 348 349 350 // -------------------------------------------------------------------------- 351 // 352 // Implementation of SavePrimitive. Used to write the call to a constructor 353 // to a macro. In the original root implementation it is used to write 354 // gui elements to a macro-file. 355 // 349 356 void MParContainer::SavePrimitive(ofstream &out, Option_t *o="") 350 357 { … … 354 361 } 355 362 363 void MParContainer::GetNames(TObjArray &arr) const 364 { 365 arr.AddLast(new TNamed(fName, fTitle)); 366 } 367 368 void MParContainer::SetNames(TObjArray &arr) 369 { 370 TNamed *name = (TNamed*)arr.First(); 371 372 fName = name->GetName(); 373 fTitle = name->GetTitle(); 374 375 delete arr.Remove(name); 376 arr.Compress(); 377 } -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r1471 r1474 77 77 virtual Bool_t AsciiWrite(ostream &out) const; 78 78 79 virtual void GetNames(TObjArray &arr) const; 80 virtual void SetNames(TObjArray &arr); 81 79 82 ClassDef(MParContainer, 0) //The basis for all parameter containers 80 83 }; -
trunk/MagicSoft/Mars/mbase/MParList.cc
r1471 r1474 660 660 } 661 661 662 // -------------------------------------------------------------------------- 663 // 664 // Implementation of SavePrimitive. Used to write the call to a constructor 665 // to a macro. In the original root implementation it is used to write 666 // gui elements to a macro-file. 667 // 662 668 void MParList::SavePrimitive(ofstream &out, Option_t *o="") 663 669 { 664 out << " MParList " << ToLower(fName) << ";" << endl << endl; 670 out << " MParList " << ToLower(fName) << "(\""; 671 out << fName << "\", \"" << fTitle << "\");" << endl << endl; 665 672 666 673 TIter Next(fContainer); … … 674 681 } 675 682 } 683 684 void MParList::GetNames(TObjArray &arr) const 685 { 686 MParContainer::GetNames(arr); 687 fContainer->ForEach(MParContainer, GetNames)(arr); 688 } 689 690 void MParList::SetNames(TObjArray &arr) 691 { 692 MParContainer::SetNames(arr); 693 cout << fContainer << endl; 694 // fContainer->ForEach(MParContainer, SetNames)(arr); 695 TIter Next(fContainer); 696 697 MParContainer *cont = NULL; 698 while ((cont=(MParContainer*)Next())) 699 { 700 cout << cont << " " << cont->GetName() << endl; 701 cont->SetNames(arr); 702 } 703 704 } 705 -
trunk/MagicSoft/Mars/mbase/MParList.h
r1472 r1474 80 80 void SavePrimitive(ofstream &out, Option_t *o=""); 81 81 82 void GetNames(TObjArray &arr) const; 83 void SetNames(TObjArray &arr); 84 82 85 ClassDef(MParList, 1) // list of parameter containers (MParContainer) 83 86 }; -
trunk/MagicSoft/Mars/mbase/MTask.cc
r1118 r1474 60 60 // - PostProcess(): executed after the eventloop. Here you can close // 61 61 // output files, start display of the run parameter, // 62 // etc. PostProcess should be executed only if//62 // etc. PostProcess is only executed in case of // 63 63 // PreProcess was successfull (returned kTRUE) // 64 64 // // 65 65 ///////////////////////////////////////////////////////////////////////////// 66 67 66 #include "MTask.h" 67 68 #include <fstream.h> 68 69 69 70 #include "MLog.h" … … 262 263 } 263 264 265 // -------------------------------------------------------------------------- 266 // 267 // Implementation of SavePrimitive. Used to write the call to a constructor 268 // to a macro. In the original root implementation it is used to write 269 // gui elements to a macro-file. 270 // 271 void MTask::SavePrimitive(ofstream &out, Option_t *o="") 272 { 273 MParContainer::SavePrimitive(out); 274 if (fFilter) 275 out << " " << ToLower(fName) << ".SetFilter(&" << ToLower(fFilter->GetName()) <<");" << endl; 276 } -
trunk/MagicSoft/Mars/mbase/MTask.h
r1108 r1474 71 71 const MFilter *GetFilter() const { return fFilter; } 72 72 virtual void PrintStatistics(const Int_t lvl=0) const; 73 virtual void SavePrimitive(ofstream &out, Option_t *o=""); 73 74 74 75 UInt_t GetNumExecutions() { return fNumExecutions; } -
trunk/MagicSoft/Mars/mbase/MTaskList.cc
r1471 r1474 514 514 } 515 515 516 516 // -------------------------------------------------------------------------- 517 // 518 // Implementation of SavePrimitive. Used to write the call to a constructor 519 // to a macro. In the original root implementation it is used to write 520 // gui elements to a macro-file. 521 // 517 522 void MTaskList::SavePrimitive(ofstream &out, Option_t *o="") 518 523 { 519 out << " MTaskList " << ToLower(fName) << ";" << endl << endl; 524 out << " MTaskList " << ToLower(fName) << "(\""; 525 out << fName << "\", \"" << fTitle << "\");" << endl << endl; 520 526 521 527 TIter Next(fTasks); … … 529 535 } 530 536 } 537 538 void MTaskList::GetNames(TObjArray &arr) const 539 { 540 MParContainer::GetNames(arr); 541 fTasks->ForEach(MParContainer, GetNames)(arr); 542 } 543 544 void MTaskList::SetNames(TObjArray &arr) 545 { 546 MParContainer::SetNames(arr); 547 fTasks->ForEach(MParContainer, SetNames)(arr); 548 } 549 -
trunk/MagicSoft/Mars/mbase/MTaskList.h
r1472 r1474 60 60 const TList *GetList() const { return fTasks; } 61 61 62 void GetNames(TObjArray &arr) const; 63 void SetNames(TObjArray &arr); 64 62 65 ClassDef(MTaskList, 1) //collection of tasks to be performed in the eventloop 63 66 };
Note:
See TracChangeset
for help on using the changeset viewer.