Ignore:
Timestamp:
12/27/04 13:13:32 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mranforest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mranforest/MRanForestCalc.cc

    r3238 r5690  
    7272//
    7373MRanForestCalc::MRanForestCalc(const char *name, const char *title)
    74     : fNum(100), fHadronnessName("MHadronness"), fData(NULL)
     74    : fNum(100), fHadronnessName("MHadronness"), fData(NULL), fRanForest(0), fRanTree(0)
    7575{
    7676    //
     
    8787MRanForestCalc::~MRanForestCalc()
    8888{
    89     //    delete fData;
     89    if (!IsOwner())
     90        return;
     91
     92    delete fRanForest;
     93    delete fRanTree;
    9094}
    9195
     
    103107Int_t MRanForestCalc::PreProcess(MParList *plist)
    104108{
    105     fRanForest = (MRanForest*)plist->FindObject("MRanForest");
    106109    if (!fRanForest)
    107110    {
    108         *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
    109         return kFALSE;
    110     }
    111 
    112     fRanTree = (MRanTree*)plist->FindObject("MRanTree");
     111        fRanForest = (MRanForest*)plist->FindObject("MRanForest");
     112        if (!fRanForest)
     113        {
     114            *fLog << err << dbginf << "MRanForest not found... aborting." << endl;
     115            return kFALSE;
     116        }
     117    }
     118
    113119    if (!fRanTree)
    114120    {
    115         *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
    116         return kFALSE;
    117     }
    118 
    119     /*if(!fRanForest->GetCurTree())
    120     {
    121         *fLog << err << dbginf << "MRanForest does not contain trees... aborting." << endl;
    122         return kFALSE;
    123     }*/
     121        fRanTree = (MRanTree*)plist->FindObject("MRanTree");
     122        if (!fRanTree)
     123        {
     124            *fLog << err << dbginf << "MRanTree not found... aborting." << endl;
     125            return kFALSE;
     126        }
     127    }
    124128
    125129    fData = fRanTree->GetRules();
     
    253257    return kTRUE;
    254258}
     259
     260Int_t MRanForestCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     261{
     262    if (!IsEnvDefined(env, prefix, "File",     print))
     263        return kFALSE;
     264
     265    TString fname = GetEnvValue(env, prefix, "File", "RF.root");
     266    TString tname = GetEnvValue(env, prefix, "Tree", "Tree");
     267    const Int_t   num   = GetEnvValue(env, prefix, "NumTrees", 100);
     268    const Bool_t  debug = GetEnvValue(env, prefix, "Debug", kFALSE);
     269
     270    fname.ReplaceAll("\015", "");
     271    tname.ReplaceAll("\015", "");
     272
     273    *fLog << dbginf << "Reading " << num << " trees " << tname << " from file " << fname << endl;
     274
     275    gLog.SetNullOutput(!debug);
     276    MEvtLoop evtloop;
     277    MParList  plist;
     278    evtloop.SetParList(&plist);
     279    MLog l;
     280    l.SetNullOutput(!debug);
     281    evtloop.SetLogStream(&l);
     282    gLog.SetNullOutput(debug);
     283
     284    if (IsOwner())
     285    {
     286        delete fRanForest;
     287        delete fRanTree;
     288    }
     289    fRanForest = new MRanForest;
     290    fRanTree   = new MRanTree;
     291    SetOwner();
     292
     293    plist.AddToList(fRanForest);
     294    plist.AddToList(fRanTree);
     295
     296    MTaskList tlist;
     297    plist.AddToList(&tlist);
     298
     299    MReadTree read(tname, fname);
     300    read.DisableAutoScheme();
     301
     302    MRanForestFill rffill;
     303    rffill.SetNumTrees(num);
     304
     305    tlist.AddToList(&read);
     306    tlist.AddToList(&rffill);
     307
     308    if (!evtloop.Eventloop())
     309    {
     310        *fLog << err << "ERROR - Reading " << tname << " from file " << fname << endl;
     311        return kERROR;
     312    }
     313
     314    return kTRUE;
     315}
  • trunk/MagicSoft/Mars/mranforest/MRanForestCalc.h

    r2862 r5690  
    3131    Int_t Process();
    3232
     33    enum { kIsOwner = BIT(14) };
     34
     35    Bool_t IsOwner() const { return TestBit(kIsOwner); }
     36    void SetOwner() { SetBit(kIsOwner); }
     37
    3338public:
    3439    MRanForestCalc(const char *name=NULL, const char *title=NULL);
    3540    ~MRanForestCalc();
     41
     42    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    3643
    3744    void SetHadronnessName(const TString name) { fHadronnessName = name; }
Note: See TracChangeset for help on using the changeset viewer.