source: trunk/MagicSoft/Mars/mbase/MEvtLoop.cc@ 1965

Last change on this file since 1965 was 1965, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 26.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2001
21!
22!
23\* ======================================================================== */
24
25
26//////////////////////////////////////////////////////////////////////////////
27// //
28// MEvtLoop //
29// //
30// This class is the core of each event processing. //
31// First you must set the parameter list to use. The parameter list //
32// must contain the task list (MTaskList) to use. The name of the task //
33// list can be specified if you call Eventloop. The standard name is //
34// "MTaskList". The name you specify must match the name of the MTaskList //
35// object. //
36// //
37// If you call Eventloop first all PreProcess functions - with the //
38// parameter list as an argument - of the tasks in the task list are //
39// executed. If one of them returns kFALSE then the execution is stopped. //
40// If the preprocessing was ok. The Process funtion of the tasks are //
41// as long as one function returns kSTOP. Only the tasks which are marked //
42// marked as "All" or with a string which matches the MInputStreamID of //
43// MTaskList are executed. If one tasks returns kCONTINUE the pending //
44// tasks in the list are skipped and the execution in continued with //
45// the first one in the list. //
46// Afterwards the PostProcess functions are executed. //
47// //
48// If you want to display the progress in a gui you can use SetProgressBar //
49// and a TGProgressBar or a MProgressBar. If you set a MStatusDisplay //
50// using SetDisplay, the Progress bar from this display is used. //
51// //
52// You can create a macro from a completely setup eventloop by: //
53// evtloop.MakeMacro("mymacro.C"); //
54// //
55// You will always need to check the macro, it will not run, but it //
56// should have al important information. //
57// //
58// //
59// You can also write all this information to a root file: //
60// TFile file("myfile.root"); //
61// evtloop.Write("MyEvtloopKey"); //
62// //
63// You can afterwards read the information from an open file by: //
64// evtloop.Read("MyEvtloopKey"); //
65// //
66// To lookup the information write it to a file using MakeMacro //
67// //
68//////////////////////////////////////////////////////////////////////////////
69#include "MEvtLoop.h"
70
71#include <time.h> // time_t
72#include <fstream.h> // ofstream, SavePrimitive
73#include <iostream.h>
74
75#include <TTime.h> // TTime
76#include <TFile.h> // gFile
77#include <TSystem.h> // gSystem
78#include <TStopwatch.h>
79#include <TGProgressBar.h>
80
81#include "MLog.h"
82#include "MLogManip.h"
83
84#include "MParList.h"
85#include "MTaskList.h"
86#ifdef __MARS__
87#include "MRead.h" // for setting progress bar
88#include "MProgressBar.h" // MProgressBar::GetBar
89#include "MStatusDisplay.h" // MStatusDisplay::GetBar
90#endif
91
92ClassImp(MEvtLoop);
93
94
95//!
96//! Maybe we can add a static parameter list to MEvtLoop
97//! Also we can derive MEvtLoop from MTaskList to have a static tasklist, too
98//!
99
100TList *gListOfPrimitives; // forard declaration in MParContainer.h
101
102// --------------------------------------------------------------------------
103//
104// default constructor
105//
106MEvtLoop::MEvtLoop(const char *name) : fParList(NULL), fProgress(NULL)
107{
108 fName = name;
109
110 *fLog << inf << "Instantiated MEvtLoop (" << name << "), using ROOT v" << ROOTVER << endl;
111}
112
113// --------------------------------------------------------------------------
114//
115// destructor
116//
117MEvtLoop::~MEvtLoop()
118{
119 if (TestBit(kIsOwner) && fParList)
120 delete fParList;
121}
122
123// --------------------------------------------------------------------------
124//
125// if you set the Eventloop as owner the destructor of the given parameter
126// list is calles by the destructor of MEvtLoop, otherwise not.
127//
128void MEvtLoop::SetOwner(Bool_t enable)
129{
130 enable ? SetBit(kIsOwner) : ResetBit(kIsOwner);
131}
132
133#ifdef __MARS__
134// --------------------------------------------------------------------------
135//
136// Specify an existing MProgressBar object. It will display the progress
137// graphically. This will make thing about 1-2% slower.
138//
139void MEvtLoop::SetProgressBar(MProgressBar *bar)
140{
141 fProgress = bar->GetBar();
142}
143#endif
144
145// --------------------------------------------------------------------------
146//
147// The proprocessing part of the eventloop. Be careful, this is
148// for developers or use in special jobs only!
149//
150Bool_t MEvtLoop::PreProcess(const char *tlist)
151{
152 //
153 // check if the needed parameter list is set.
154 //
155 if (!fParList)
156 {
157 *fLog << err << dbginf << "Parlist not initialized." << endl;
158 return kFALSE;
159 }
160
161 //
162 // check for the existance of the specified task list
163 // the default name is "MTaskList"
164 //
165 fTaskList = (MTaskList*)fParList->FindObject(tlist, "MTaskList");
166 if (!fTaskList)
167 {
168 *fLog << err << dbginf << "Cannot find tasklist '" << tlist << "' in parameter list." << endl;
169 return kFALSE;
170 }
171
172 if (fLog != &gLog)
173 fParList->SetLogStream(fLog);
174
175#ifdef __MARS__
176 //
177 // Check whether display is still existing
178 //
179 if (fDisplay && !gROOT->GetListOfSpecials()->FindObject(fDisplay))
180 fDisplay = NULL;
181 if (fDisplay)
182 {
183 // Lock display to prevent user from deleting it
184 fDisplay->Lock();
185 // Get pointer to update Progress bar
186 fProgress = fDisplay->GetBar();
187 // Don't display context menus
188 fDisplay->SetNoContextMenu();
189 // Set window and icon name
190 fDisplay->SetWindowName(TString("Status Display: ")+fName);
191 fDisplay->SetIconName(fName);
192 // Set status lines
193 fDisplay->SetStatusLine1("PreProcessing...");
194 fDisplay->SetStatusLine2("");
195 // Start automatic update
196 fDisplay->StartUpdate();
197 // Cascade display through childs
198 fParList->SetDisplay(fDisplay);
199 }
200#endif
201
202 //
203 // execute the preprocess of all tasks
204 // connect the different tasks with the right containers in
205 // the parameter list
206 //
207 if (!fTaskList->PreProcess(fParList))
208 {
209 *fLog << err << "Error detected while PreProcessing" << endl;
210 return kFALSE;
211 }
212
213 *fLog << endl;
214
215 return kTRUE;
216}
217
218Bool_t MEvtLoop::ProcessGuiEvents(Int_t num)
219{
220 if (!fProgress)
221 return kTRUE;
222
223 //
224 // Check status of display
225 //
226 Bool_t rc = kTRUE;
227
228 if (fDisplay)
229 switch (fDisplay->CheckStatus())
230 {
231 case MStatusDisplay::kLoopNone:
232 break;
233 case MStatusDisplay::kLoopStop:
234 rc = kFALSE;
235 fDisplay->ClearStatus();
236 break;
237 case MStatusDisplay::kFileExit:
238 fParList->SetDisplay(NULL);
239 delete fDisplay;
240 SetDisplay(NULL);
241 fProgress = NULL;
242 gSystem->ProcessEvents();
243 return kTRUE;
244 default:
245 fDisplay->ClearStatus();
246 *fLog << warn << "Display shows unknown status... cleared." << endl;
247 break;
248 }
249
250 //
251 // Check System time (don't loose too much time by updates)
252 //
253 static TTime t0 = gSystem->Now();
254
255 const TTime t1 = gSystem->Now();
256 if (t1-t0 < (TTime)20)
257 return rc;
258
259 t0 = t1;
260
261 //
262 // Set new progress bar position
263 //
264 fProgress->SetPosition(num);
265
266 //
267 // Handle GUI events (display changes)
268 //
269#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
270 gSystem->ProcessEvents();
271#else
272 if (fDisplay)
273 gSystem->ProcessEvents();
274 else
275 gClient->ProcessEventsFor(fProgress);
276#endif
277
278 return rc;
279}
280
281// --------------------------------------------------------------------------
282//
283// The processing part of the eventloop. Be careful, this is
284// for developers or use in special jobs only!
285//
286Bool_t MEvtLoop::Process(Int_t maxcnt)
287{
288 //
289 // loop over all events and process all tasks for
290 // each event
291 //
292 *fLog << all <<"Eventloop running (";
293
294 if (maxcnt<0)
295 *fLog << "all";
296 else
297 *fLog << dec << maxcnt;
298
299 *fLog << " events)..." << flush;
300
301 Int_t entries = INT_MAX;
302
303 if (fProgress)
304 {
305 fProgress->Reset();
306#ifdef __MARS__
307 // limits.h
308 MRead *read = (MRead*)fTaskList->FindObject("MRead");
309 if (read && read->GetEntries()>0)
310 entries = read->GetEntries();
311#endif
312
313 if (maxcnt>0)
314 fProgress->SetRange(0, TMath::Min(maxcnt, entries));
315 else
316 if (entries!=INT_MAX)
317 fProgress->SetRange(0, entries);
318 }
319
320 if (fDisplay)
321 {
322 fDisplay->SetStatusLine1("Processing...");
323 fDisplay->SetStatusLine2("");
324 }
325
326 Int_t dummy = maxcnt<0 ? 0 : maxcnt;
327
328 //
329 // start a stopwatch
330 //
331 TStopwatch clock;
332 clock.Start();
333
334 //
335 // This is the MAIN EVENTLOOP which processes the data
336 // if maxcnt<0 the number of processed events is counted
337 // else only maxcnt events are processed
338 //
339 Int_t numcnts = 0;
340
341 Bool_t rc = kTRUE;
342 if (maxcnt<0)
343 // process first and increment if sucessfull
344 while ((rc=fTaskList->Process())==kTRUE)
345 {
346 numcnts++;
347 if (!ProcessGuiEvents(++dummy))
348 break;
349 }
350 else
351 // check for number and break if unsuccessfull
352 while (dummy-- && (rc=fTaskList->Process())==kTRUE)
353 {
354 numcnts++;
355 if (!ProcessGuiEvents(maxcnt - dummy))
356 break;
357 }
358
359 //
360 // stop stop-watch, print results
361 //
362 clock.Stop();
363
364 if (fProgress)
365 {
366 fProgress->SetPosition(maxcnt>0 ? TMath::Min(maxcnt, entries) : entries);
367#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
368 gSystem->ProcessEvents();
369#else
370 gClient->ProcessEventsFor(fDisplay ? fDisplay : fProgress);
371#endif
372 }
373
374 *fLog << all << "Ready!" << endl << endl;
375
376 *fLog << dec << endl << "CPU - "
377 << "Time: " << clock.CpuTime() << "s"
378 << " for " << numcnts << " Events"
379 << " --> " << numcnts/clock.CpuTime() << " Events/s"
380 << endl;
381 *fLog << "Real - "
382 << "Time: " << clock.RealTime() << "s"
383 << " for " << numcnts << " Events"
384 << " --> " << numcnts/clock.RealTime() << " Events/s"
385 << endl << endl;
386
387 return rc!=kERROR;
388}
389
390// --------------------------------------------------------------------------
391//
392// The postprocessing part of the eventloop. Be careful, this is
393// for developers or use in special jobs only!
394//
395Bool_t MEvtLoop::PostProcess() const
396{
397 //
398 // execute the post process of all tasks
399 //
400 if (fDisplay)
401 {
402 // Set status lines
403 fDisplay->SetStatusLine1("PostProcessing...");
404 fDisplay->SetStatusLine2("");
405 }
406 return fTaskList->PostProcess();
407}
408
409// --------------------------------------------------------------------------
410//
411// See class description above.
412//
413Bool_t MEvtLoop::Eventloop(Int_t maxcnt, const char *tlist)
414{
415 Bool_t rc = PreProcess();
416
417 //
418 // If all Tasks were PreProcesses successfully start Processing.
419 //
420 if (rc)
421 rc = Process(maxcnt);
422
423 //
424 // Now postprocess all tasks. Only successfully preprocessed tasks are
425 // postprocessed. If the Postprocessing of one task fail return an error.
426 //
427 if (!PostProcess())
428 return kFALSE;
429
430 if (!fDisplay)
431 return rc;
432
433 // Set status lines
434 fDisplay->SetStatusLine1(fName);
435 fDisplay->SetStatusLine2(rc ? "Done." : "ERROR");
436 // Stop automatic update
437 fDisplay->StopUpdate();
438 // Reallow context menus
439 fDisplay->SetNoContextMenu(kFALSE);
440 // Reallow user to exit window by File menu
441 fDisplay->UnLock();
442
443 //
444 // If postprocessing of all preprocessed tasks was sucefully return rc.
445 // This gives an error in case the preprocessing has failed already.
446 // Otherwise the eventloop is considered: successfully.
447 //
448 return rc;
449}
450
451// --------------------------------------------------------------------------
452//
453// After you setup (or read) an Evtloop you can use this to write the
454// eventloop setup as a macro. The default name is "evtloop.C". The default
455// extension is .C If the extension is not given, .C is added.
456// I the last character in the argument is a '+' the file is not closed.
457// This is usefull if you have an eventloop which runs three times and
458// you want to write one macro. If the first character is a '+' no
459// opening is written, eg:
460//
461// MEvtLoop evtloop;
462// // some setup
463// evtloop.MakeMacro("mymacro+");
464// // replace the tasklist the first time
465// evtloop.MakeMacro("+mymacro+");
466// // replace the tasklist the second time
467// evtloop.MakeMacro("+mymacro");
468//
469void MEvtLoop::MakeMacro(const char *filename)
470{
471 TString name(filename);
472
473 name = name.Strip(TString::kBoth);
474
475 Bool_t open = kTRUE;
476 Bool_t close = kTRUE;
477 if (name[0]=='+')
478 {
479 open = kFALSE;
480 name.Remove(0, 1);
481 name = name.Strip(TString::kBoth);
482 }
483
484 if (name[name.Length()-1]=='+')
485 {
486 close = kFALSE;
487 name.Remove(name.Length()-1, 1);
488 name = name.Strip(TString::kBoth);
489 }
490
491 if (!name.EndsWith(".C"))
492 name += ".C";
493
494 ofstream fout;
495
496 if (!open)
497 {
498 fout.open(name, ios::app);
499 fout << endl;
500 fout << " // ----------------------------------------------------------------------" << endl;
501 fout << endl;
502 }
503 else
504 {
505 fout.open(name);
506
507 time_t t = time(NULL);
508 fout <<
509 "/* ======================================================================== *\\" << endl <<
510 "!" << endl <<
511 "! *" << endl <<
512 "! * This file is part of MARS, the MAGIC Analysis and Reconstruction" << endl <<
513 "! * Software. It is distributed to you in the hope that it can be a useful" << endl <<
514 "! * and timesaving tool in analysing Data of imaging Cerenkov telescopes." << endl <<
515 "! * It is distributed WITHOUT ANY WARRANTY." << endl <<
516 "! *" << endl <<
517 "! * Permission to use, copy, modify and distribute this software and its" << endl <<
518 "! * documentation for any purpose is hereby granted without fee," << endl <<
519 "! * provided that the above copyright notice appear in all copies and" << endl <<
520 "! * that both that copyright notice and this permission notice appear" << endl <<
521 "! * in supporting documentation. It is provided \"as is\" without express" << endl <<
522 "! * or implied warranty." << endl <<
523 "! *" << endl <<
524 "!" << endl <<
525 "!" << endl <<
526 "! Author(s): Thomas Bretz et al. <mailto:tbretz@astro.uni-wuerzburg.de>" << endl <<
527 "!" << endl <<
528 "! Copyright: MAGIC Software Development, 2000-2002" << endl <<
529 "!" << endl <<
530 "!" << endl <<
531 "\\* ======================================================================== */" << endl << endl <<
532 "// ------------------------------------------------------------------------" << endl <<
533 "//" << endl <<
534 "// This macro was automatically created on" << endl<<
535 "// " << ctime(&t) <<
536 "// with the MEvtLoop::MakeMacro tool." << endl <<
537 "//" << endl <<
538 "// ------------------------------------------------------------------------" << endl << endl <<
539 "void " << name(0, name.Length()-2) << "()" << endl <<
540 "{" << endl;
541 }
542
543 SavePrimitive(fout, (TString)"" + (open?"open":"") + (close?"close":""));
544
545 if (!close)
546 return;
547
548 fout << "}" << endl;
549
550 *fLog << inf << "Macro '" << name << "' written." << endl;
551}
552
553// --------------------------------------------------------------------------
554//
555// Implementation of SavePrimitive. Used to write the call to a constructor
556// to a macro. In the original root implementation it is used to write
557// gui elements to a macro-file.
558//
559void MEvtLoop::StreamPrimitive(ofstream &out) const
560{
561 out << " MEvtLoop " << GetUniqueName();
562 if (fName!="Evtloop")
563 out << "(\"" << fName << "\")";
564 out << ";" << endl;
565}
566
567// --------------------------------------------------------------------------
568//
569//
570void MEvtLoop::SavePrimitive(ofstream &out, Option_t *opt)
571{
572 TString options = opt;
573 options.ToLower();
574
575 if (HasDuplicateNames("MEvtLoop::SavePrimitive"))
576 {
577 out << " // !" << endl;
578 out << " // ! WARNING - Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
579 out << " // ! one object (MParContainer, MTask, ...) with the same name. The created macro" << endl;
580 out << " // ! may need manual intervention before it can be used." << endl;
581 out << " // !" << endl;
582 out << endl;
583 }
584
585 if (!options.Contains("open"))
586 {
587 if (gListOfPrimitives)
588 {
589 *fLog << err << "MEvtLoop::SavePrimitive - Error: old file not closed." << endl;
590 gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
591 delete gListOfPrimitives;
592 }
593 gListOfPrimitives = new TList;
594 }
595
596 if (fParList)
597 fParList->SavePrimitive(out);
598
599 MParContainer::SavePrimitive(out);
600
601 if (fParList)
602 out << " " << GetUniqueName() << ".SetParList(&" << fParList->GetUniqueName() << ");" << endl;
603 else
604 out << " // fParList empty..." << endl;
605 out << " if (!" << GetUniqueName() << ".Eventloop())" << endl;
606 out << " return;" << endl;
607
608 if (!options.Contains("close"))
609 return;
610
611 gListOfPrimitives->ForEach(TObject, ResetBit)(BIT(15));
612 delete gListOfPrimitives;
613 gListOfPrimitives = 0;
614}
615
616// --------------------------------------------------------------------------
617//
618// Get a list of all conmtainer names which are somehow part of the
619// eventloop. Chack for duplicate members and print a warning if
620// duplicates are found. Return kTRUE if duplicates are found, otherwise
621// kFALSE;
622//
623Bool_t MEvtLoop::HasDuplicateNames(TObjArray &arr, const TString txt) const
624{
625 arr.Sort();
626
627 TIter Next(&arr);
628 TObject *obj;
629 TString name;
630 Bool_t found = kFALSE;
631 while ((obj=Next()))
632 {
633 if (name==obj->GetName())
634 {
635 if (!found)
636 {
637 *fLog << warn << endl;
638 *fLog << " ! WARNING (" << txt << ")" << endl;
639 *fLog << " ! Your eventloop (MParList, MTaskList, ...) contains more than" << endl;
640 *fLog << " ! one object (MParContainer, MTask, ...) with the same name." << endl;
641 *fLog << " ! Creating a macro from it using MEvtLoop::MakeMacro may create" << endl;
642 *fLog << " ! a macro which needs manual intervention before it can be used." << endl;
643 found = kTRUE;
644 }
645 *fLog << " ! Please rename: " << obj->GetName() << endl;
646 }
647 name = obj->GetName();
648 }
649
650 return found;
651}
652
653// --------------------------------------------------------------------------
654//
655// Get a list of all conmtainer names which are somehow part of the
656// eventloop. Chack for duplicate members and print a warning if
657// duplicates are found. Return kTRUE if duplicates are found, otherwise
658// kFALSE;
659//
660Bool_t MEvtLoop::HasDuplicateNames(const TString txt) const
661{
662 if (!fParList)
663 return kFALSE;
664
665 TObjArray list;
666 list.SetOwner();
667
668 fParList->GetNames(list);
669
670 return HasDuplicateNames(list, txt);
671}
672
673// --------------------------------------------------------------------------
674//
675// Reads a saved eventloop from a file. The default name is "Evtloop".
676// Therefor an open file must exist (See TFile for more information)
677//
678// eg:
679// TFile file("myfile.root", "READ");
680// MEvtLoop evtloop;
681// evtloop.Read();
682// evtloop.MakeMacro("mymacro");
683//
684Int_t MEvtLoop::Read(const char *name)
685{
686 if (!gFile)
687 {
688 *fLog << err << "MEvtloop::Read: No file found. Please create a TFile first." << endl;
689 return 0;
690 }
691
692 if (!gFile->IsOpen())
693 {
694 *fLog << err << "MEvtloop::Read: File not open. Please open the TFile first." << endl;
695 return 0;
696 }
697
698 Int_t n = 0;
699 TObjArray list;
700
701 n += TObject::Read(name);
702
703 if (n==0)
704 {
705 *fLog << err << "MEvtloop::Read: No objects read." << endl;
706 return 0;
707 }
708
709 n += list.Read((TString)name+"_names");
710
711 fParList->SetNames(list);
712
713 HasDuplicateNames(list, "MEvtLoop::Read");
714
715 *fLog << inf << "Eventloop '" << name << "' read from file." << endl;
716
717 return n;
718}
719
720// --------------------------------------------------------------------------
721//
722// If available print the contents of the parameter list.
723//
724void MEvtLoop::Print(Option_t *opt) const
725{
726 if (fParList)
727 fParList->Print();
728 else
729 *fLog << all << "MEvtloop: No Parameter List available." << endl;
730}
731
732// --------------------------------------------------------------------------
733//
734// Writes a eventloop to a file. The default name is "Evtloop".
735// Therefor an open file must exist (See TFile for more information)
736//
737// eg:
738// TFile file("myfile.root", "RECREATE");
739// MEvtLoop evtloop;
740// evtloop.Write();
741// file.Close();
742//
743Int_t MEvtLoop::Write(const char *name, Int_t option, Int_t bufsize)
744{
745 if (!gFile)
746 {
747 *fLog << err << "MEvtloop::Write: No file found. Please create a TFile first." << endl;
748 return 0;
749 }
750
751 if (!gFile->IsOpen())
752 {
753 *fLog << err << "MEvtloop::Write: File not open. Please open the TFile first." << endl;
754 return 0;
755 }
756
757 if (!gFile->IsWritable())
758 {
759 *fLog << err << "MEvtloop::Write: File not writable." << endl;
760 return 0;
761 }
762
763 Int_t n = 0;
764
765 TObjArray list;
766 list.SetOwner();
767
768 fParList->GetNames(list);
769
770 n += TObject::Write(name, option, bufsize);
771
772 if (n==0)
773 {
774 *fLog << err << "MEvtloop::Read: No objects written." << endl;
775 return 0;
776 }
777
778 n += list.Write((TString)name+"_names", kSingleKey);
779
780 HasDuplicateNames(list, "MEvtLoop::Write");
781
782 *fLog << inf << "Eventloop written to file as " << name << "." << endl;
783
784 return n;
785}
786
787// --------------------------------------------------------------------------
788//
789// Read the contents/setup of a parameter container/task from a TEnv
790// instance (steering card/setup file).
791// The key to search for in the file should be of the syntax:
792// prefix.vname
793// While vname is a name which is specific for a single setup date
794// (variable) of this container and prefix is something like:
795// evtloopname.name
796// While name is the name of the containers/tasks in the parlist/tasklist
797//
798// eg. Job4.MImgCleanStd.CleaningLevel1: 3.0
799// Job4.MImgCleanStd.CleaningLevel2: 2.5
800//
801// If this cannot be found the next step is to search for
802// MImgCleanStd.CleaningLevel1: 3.0
803// And if this doesn't exist, too, we should search for:
804// CleaningLevel1: 3.0
805//
806// Warning: The programmer is responsible for the names to be unique in
807// all Mars classes.
808//
809Bool_t MEvtLoop::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
810{
811 if (!prefix.IsNull())
812 *fLog << warn << "WARNING - Second argument in MEvtLoop::ReadEnv has no meaning... ignored." << endl;
813
814 prefix = fName;
815 prefix += ".";
816
817 *fLog << inf << "Reading resources for " << prefix /*TEnv::fRcName << " from " << env.GetRcName()*/ << endl;
818
819 if (fParList->ReadEnv(env, prefix, print)==kERROR)
820 {
821 *fLog << err << "ERROR - Reading Environment file." << endl;
822 return kFALSE;
823 }
824
825 return kTRUE;
826}
827
828// --------------------------------------------------------------------------
829//
830// Write the contents/setup of a parameter container/task to a TEnv
831// instance (steering card/setup file).
832// The key to search for in the file should be of the syntax:
833// prefix.vname
834// While vname is a name which is specific for a single setup date
835// (variable) of this container and prefix is something like:
836// evtloopname.name
837// While name is the name of the containers/tasks in the parlist/tasklist
838//
839// eg. Job4.MImgCleanStd.CleaningLevel1: 3.0
840// Job4.MImgCleanStd.CleaningLevel2: 2.5
841//
842// If this cannot be found the next step is to search for
843// MImgCleanStd.CleaningLevel1: 3.0
844// And if this doesn't exist, too, we should search for:
845// CleaningLevel1: 3.0
846//
847// Warning: The programmer is responsible for the names to be unique in
848// all Mars classes.
849//
850Bool_t MEvtLoop::WriteEnv(TEnv &env, TString prefix, Bool_t print) const
851{
852 if (!prefix.IsNull())
853 *fLog << warn << "WARNING - Second argument in MEvtLoop::WriteEnv has no meaning... ignored." << endl;
854
855 prefix = fName;
856 prefix += ".";
857
858 *fLog << inf << "Writing resources: " << prefix /*TEnv::fRcName << " to " << env.GetRcName()*/ << endl;
859
860 if (fParList->WriteEnv(env, prefix, print)!=kTRUE)
861 {
862 *fLog << err << "ERROR - Writing Environment file." << endl;
863 return kFALSE;
864 }
865
866 return kTRUE;
867}
Note: See TracBrowser for help on using the repository browser.