Ignore:
Timestamp:
08/02/02 09:32:34 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbase/MEvtLoop.cc

    r1473 r1474  
    5252//                                                                          //
    5353// 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");                                        //
    5655//                                                                          //
    5756// You will always need to check the macro, it will not run, but it         //
     
    6665//   evtloop.Read("MyEvtloopKey");                                          //
    6766//                                                                          //
    68 // To lookup the information write it to a file using SavePrimite           //
     67// To lookup the information write it to a file using MakeMacro             //
    6968//                                                                          //
    7069//////////////////////////////////////////////////////////////////////////////
    7170#include "MEvtLoop.h"
    7271
     72#include <time.h>
    7373#include <fstream.h>     // ofstream, SavePrimitive
    7474#include <iostream.h>
     
    292292}
    293293
     294void 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//
    294350void MEvtLoop::SavePrimitive(ofstream &out, Option_t *)
    295351{
     
    297353
    298354    out << "   MEvtLoop evtloop;" << endl;
    299     out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ")" << endl;
     355    out << "   evtloop.SetParList(&" << ToLower(fParList->GetName()) << ");" << endl;
    300356    out << "   if (!evtloop.Eventloop())" << endl;
    301357    out << "      return;" << endl;
    302358}
     359
     360Int_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
     373Int_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}
Note: See TracChangeset for help on using the changeset viewer.