Changeset 9036 for trunk


Ignore:
Timestamp:
07/22/08 19:56:42 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9030 r9036  
    4444     - added
    4545
     46   * mfileio/MreadRflFile.[h,cc]:
     47     - derived from MReadFiles (untested)
     48
    4649   * datacenter/macros/checkfileavail.C:
    4750     - fixed a type (TSQLRow instead of TSQlRow)
     51     - added a missing ;
     52
     53   * mfileio/MReadTree.[h,cc]:
     54     - added some includes
     55     - added the IsOwned member function to make sure we don't
     56       spoil memory when out pointers are deleted in the destructor
     57     - removed some really obsolete workarounds
     58     - added a member function to add friends
     59     - don't allocate memory in AddFile
     60     - implemented the possibility to process also friends
     61     - implemented the possibility to read branches from unknown
     62       "vendors", i.e. branches for which the class is not available
     63       in the dictionary
     64     - added a list to hold all parameter containers to be able to
     65       call SetReadyToSave more easily than previously
     66
     67   * mbase/MParEmulated.[h,cc]:
     68     - added
     69
     70   * mbase/Makefile, mbase/BaseLinkDef.h:
     71     - added MParEmulated
     72
     73   * mbase/MParameters.h:
     74     - added functions to get the pointer to the values. Handle this
     75       with care.
     76
     77   * mbase/MParConatiner.h:
     78     - made GetterMethod virtual to allow MParEmulated to overwrite it
     79     - made fgListMethodCall protected to allow MParEmulated to
     80       add its new TMethodCalls
     81
     82   * datacenter/macros/checkfileavail.C:
     83     - removed dependence on caco-files.
     84     - fixed query
     85     - output query in case of failure
     86
     87   * datacenter/scripts/checkfilesforsequenceavail:
     88     - fixed to use new checkfileavail.C
     89
     90   * mcalib/MCalibrateData.cc:
     91     - removed the fixed scale factor for MCs. It is now left open,
     92       thus it can be changed from the callisto resource file
     93
     94   * mdata/MDataMember.cc:
     95     - small improvement to error output
     96
     97   * mfileio/MWriteRootFile.cc:
     98     - small change to log-level
     99
    48100
    49101
  • trunk/MagicSoft/Mars/NEWS

    r9024 r9036  
    2121   * sequences (MSequence or MSequenceSQL) can now directly be retrieved
    2222     from the database. See the constructors for more details.
     23
     24   * MReadTree now supports friends
     25
     26   * MReadTree can now read also files not written by MARS and store
     27     the data encapsulated in emulated MParContainers
    2328
    2429 ;merpp
  • trunk/MagicSoft/Mars/datacenter/macros/checkfileavail.C

    r9033 r9036  
    7575    // -------------------------------------------
    7676
    77     TString query = "MIN( NOT ("
     77    TString query = "SELECT MIN( NOT ("
    7878        "ISNULL(fRawFileAvail) OR "
    7979        "ISNULL(fCCFileAvail) OR "
    80         "ISNULL(fCaCoFileAvail) OR "
    81         "ISNULL(fCaCoFileFound) OR "
     80       // "ISNULL(fCaCoFileAvail) OR "
     81       // "ISNULL(fCaCoFileFound) OR "
    8282        "ISNULL(fTimingCorrection) OR "
    8383        "ISNULL(fCompmux) "
     
    9494    {
    9595        cout << "ERROR - Unexpected number of returned rows (" << res->GetRowCount() << ")" << endl;
     96        cout << query << endl;
    9697        delete res;
    9798        return 3;
     
    103104    {
    104105        cout << "ERROR - Unexpected result." << endl;
     106        cout << query << endl;
    105107        delete res;
    106108        return 3;
  • trunk/MagicSoft/Mars/datacenter/scripts/checkfilesforsequenceavail

    r9017 r9036  
    7272   checkfileavailpath=$logpath/$program/$no
    7373   makedir $checkfileavailpath  >> $scriptlog 2>&1
    74    checkfileavaillog=$checkfileavailpath/$program-$sequence.log
     74   checkfileavaillog=$checkfileavailpath/$program-$no2.log
    7575
    76    sequencefile=$sequpath/$no/sequence$no2.txt
    77 
    78    primvar=$no2
     76   primvar=$sequence
    7977   setstatus "start" >> $scriptlog 2>&1
    8078
    81    check1=`root -q -b $macrospath/checkfileavail.C+\(\""$sequencefile\",1"\) | tee $checkfileavaillog | intgrep`
     79   check1=`root -q -b $macrospath/checkfileavail.C+\($sequence,1\) | tee $checkfileavaillog | intgrep`
    8280
    8381   case $check1 in
  • trunk/MagicSoft/Mars/mcalib/MCalibrateData.cc

    r8957 r9036  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.71 2008-06-14 15:55:51 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrateData.cc,v 1.72 2008-07-22 18:55:08 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    156156    : fGeomCam(NULL),   fBadPixels(NULL), fCalibrations(NULL),
    157157      fQEs(NULL), fSignals(NULL), fCerPhotEvt(NULL), fCalibConstCam(NULL),
    158     fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1.)
     158    fPedestalFlag(kNo), fSignalType(kPhot), fRenormFactor(1.), fScaleFactor(1)
    159159{
    160160
     
    424424    if (header->IsMonteCarloRun())
    425425    {
    426         *fLog << inf << "Additional scale factor forced to: 1 (MonteCarloRun)" << endl;
    427         fScaleFactor = 1;
     426        if (fScaleFactor!=1)
     427            *fLog << warn << "WARNING - Additional scale factor for MonteCarlo run not unity but " << fScaleFactor << endl;
    428428    }
    429429    else
  • trunk/MagicSoft/Mars/mdata/MDataMember.cc

    r8892 r9036  
    136136
    137137    default:
    138         *fLog << err << "DataMember " << fDataMember << " of ";
    139         *fLog << fObject->GetName() << " neither int nor float... returning 0." << endl;
     138        *fLog << err << "ERROR - MDataMember::GetValue: " << fObject->GetName();
     139        *fLog << "." << fDataMember << " has unkown type (=";
     140        *fLog << fCall->ReturnType() << ")... returning 0." << endl;
    140141        return 0;
    141142    }
  • trunk/MagicSoft/Mars/mfileio/MReadTree.cc

    r9034 r9036  
    6060#include <TFile.h>           // TFile::GetName
    6161#include <TSystem.h>         // gSystem->ExpandPath
    62 #include <TLeafElement.h>
     62#include <TLeaf.h>
    6363#include <TChainElement.h>
    6464#include <TFriendElement.h>
     
    7070#include "MTaskList.h"
    7171#include "MParameters.h"
     72#include "MParEmulated.h"
    7273#include "MStatusDisplay.h"
    7374
     
    226227}
    227228
     229void MReadTree::GetListOfBranches(TList &list) const
     230{
     231    list.AddAll(fTree->GetListOfBranches());
     232
     233    TIter NextF(fTree->GetListOfFriends());
     234    TFriendElement *e = 0;
     235    while ((e=(TFriendElement*)NextF()))
     236        list.AddAll(e->GetTree()->GetListOfBranches());
     237}
     238
    228239// --------------------------------------------------------------------------
    229240//
     
    234245Bool_t MReadTree::CheckBranchSize()
    235246{
    236     TArrayI entries(fTree->GetListOfBranches()->GetSize());
    237     Int_t num=0;
    238 
    239     TIter Next(fTree->GetListOfBranches());
    240 
    241     TBranch *element = NULL;
    242     while ((element=(TBranch*)Next()))
    243         entries[num++] = (Int_t)element->GetEntries();
    244 
    245     // Check the number of entries of the branches pair-wise
    246     for (int i=0; i<num; i++)
    247         for (int j=i; j<num; j++)
     247    Int_t entries = -1;
     248
     249    TList list;
     250    GetListOfBranches(list);
     251
     252    TIter Next(&list);
     253    TBranch *b = NULL;
     254    while ((b=(TBranch*)Next()))
     255    {
     256        if (entries>=0 && entries!=(Int_t)b->GetEntries())
    248257        {
    249             if (entries[i]==entries[j])
    250                 continue;
    251 
    252258            *fLog << err << "ERROR - File corruption detected:" << endl;
    253             *fLog << "  Due to several circumstances (such at a bug in MReadTree or wrong" << endl;
    254             *fLog << "  usage of the file UPDATE mode) you may have produced a file in which" << endl;
    255             *fLog << "  at least two branches in the same tree (" << fTree->GetName() << ") have different" << endl;
    256             *fLog << "  number of entries. Sorry, but this file (" << GetFileName() << ")" << endl;
    257             *fLog << "  is unusable." << endl;
     259            *fLog << "  Due to several circumstances  (such at a bug in MReadTree or wrong usgae of" << endl;
     260            *fLog << "  the file  UPDATE  mode)  you may have produced a file in which at least two" << endl;
     261            *fLog << "  branches have different number of  entries.  Sorry, but this combination of" << endl;
     262            *fLog << "  branches, trees and files is unusable." << endl;
    258263            return kFALSE;
    259264        }
     265
     266        entries = (Int_t)b->GetEntries();
     267    }
    260268
    261269    return kTRUE;
     
    678686
    679687    SetBranchStatus(branch->GetListOfBranches(), kFALSE);
     688}
     689
     690MParContainer *MReadTree::FindCreateObj(MParList &plist, const char *cname, const char *name)
     691{
     692    MParContainer *pcont=plist.FindCreateObj(cname, name);
     693    if (!pcont)
     694    {
     695        //
     696        // if class is not existing in the (root) environment
     697        // we cannot proceed reading this branch
     698        //
     699        *fLog << err << dbginf << "ERROR - Class '" << cname;
     700        *fLog << "' for " << name << " not existing in dictionary. Branch skipped." << endl;
     701        return 0;
     702    }
     703
     704    fParList.Add(pcont);
     705    return pcont;
     706}
     707
     708void *MReadTree::GetParameterPtr(MParList &plist, const TString &name, const char *parname)
     709{
     710    if (name=="Int_t"   || name=="UInt_t"   ||
     711        name=="Short_t" || name=="UShort_t" ||
     712        name=="Char_t"  || name=="UChar_t"  ||
     713        name=="Bool_t")
     714    {
     715        MParameterI *par = (MParameterI*)FindCreateObj(plist, "MParameterI", parname);
     716        return par ? par->GetPtr() : 0;
     717    }
     718
     719    if (name=="Float_t" || name=="Double_t")
     720    {
     721        MParameterD *par = (MParameterD*)FindCreateObj(plist, "MParameterD", parname);
     722        return par ? par->GetPtr() : 0;
     723    }
     724
     725    // MParContainer **pcont= new MParContainer*;
     726    // return FindCreateObj(plist, name, parname);
     727
     728    MParEmulated *par = (MParEmulated*)FindCreateObj(plist, "MParEmulated", parname);
     729    if (!par)
     730        return 0;
     731
     732    par->SetClassName(name);
     733    return par->GetPtr();
     734}
     735
     736Bool_t MReadTree::SetBranchAddress(TBranch &b, void *ptr, const char *prefix, const char *type)
     737{
     738    if (!ptr)
     739    {
     740        DisableSubBranches(&b);
     741        return kFALSE;
     742    }
     743
     744    if (fChain)
     745    {
     746        TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(b.GetName());
     747        if (element && IsOwned(*element))
     748            *fLog << warn << "WARNING - Branch address for " << b.GetName() << " was already setup by the user." << endl;
     749    }
     750
     751    const TString bname = b.GetName();
     752    const TString cname = type ? type : b.GetClassName();
     753
     754    fTree->SetBranchAddress(bname, ptr);
     755
     756    *fLog << inf2 << prefix << " address '" << bname << "' ";
     757    if (bname!=cname)
     758        *fLog << "[" << cname << "] ";
     759    *fLog << "setup for reading." << endl;
     760
     761    return kTRUE;
    680762}
    681763
     
    751833    *fLog << inf << fNumEntries << " entries found in file(s)." << endl;
    752834
     835    // Get all branches of this tree and all friends
     836    TList blist;
     837    GetListOfBranches(blist);
     838
    753839    //
    754840    // Get all branches of this tree and
    755841    // create the Iterator to loop over all branches
    756842    //
    757     TIter Next(fTree->GetListOfBranches()); // *CHANGED-fChain-to-fTree*
     843    TIter Next(&blist); // *CHANGED-fChain-to-fTree*
    758844    TBranch *branch=NULL;
    759845
     
    784870        }
    785871
    786         //
    787         // Create a pointer to the pointer to the object in which the
    788         // branch data is stored. The pointers are stored in the TChain
    789         // object and we get the pointers from there to delete it.
    790         //
    791         MParContainer **pcont= new MParContainer*;
    792 
    793 #if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
    794         const char *classname = oname;
    795 #else
    796         const char *classname = branch->GetClassName();
    797 #endif
    798 
    799         //
    800         // check if object is existing in the list
    801         //
    802         *pcont=pList->FindCreateObj(classname, oname);
    803 
    804         if (!*pcont)
     872        // Branch already setup/ FIXME: WHAT IF THIS IS A TREE???
     873        if (fChain && fChain->GetStatus()->FindObject(branch->GetName()))
    805874        {
    806             //
    807             // if class is not existing in the (root) environment
    808             // we cannot proceed reading this branch
    809             //
    810             *fLog << warn << dbginf << "Warning: Class '" << classname;
    811             *fLog << "' for " << oname << " not existing in dictionary. Branch skipped." << endl;
    812             DisableSubBranches(branch);
     875            *fLog << warn << "WARNING - Branch " << branch->GetName() << " already setup." << endl;
    813876            continue;
    814877        }
    815878
    816         //
    817         // Check whether a Pointer to a pointer already exists.
    818         // If we created one already, delete it.
    819         //
    820         // *CHANGED-fChain-to-fTree*
    821         if (fChain)
     879        // Get the corresponding class
     880        const TString classname = branch->GetClassName();
     881
     882        TClass *cls = gROOT->GetClass(classname);
     883        if (!cls)
    822884        {
    823             TChainElement *element = (TChainElement*)fChain->GetStatus()->FindObject(bname);
    824             if (element)
    825                 delete (MParContainer**)element->GetBaddress();
     885            // FIXME: With or without dot?
     886            TLeaf *l = branch->GetLeaf(branch->GetName()); // FIXME: 1st leaf?
     887            if (!l)
     888                continue;
     889
     890            void *ptr = GetParameterPtr(*pList, l->GetTypeName(), oname);
     891            if (SetBranchAddress(*branch, ptr, "Leaf", l->GetTypeName()))
     892                num++;
     893
     894            continue;
    826895        }
    827         /* This can't be done here for memory trees - see
    828            PostProcess for more details.
     896
     897        // The class is known in the dictionary and loaded!
     898        if (!cls->IsLoaded() || !cls->InheritsFrom(MParContainer::Class()))
     899        {
     900            void *ptr = GetParameterPtr(*pList, classname, oname);
     901            if (SetBranchAddress(*branch, ptr, "Emulated branch"))
     902                num++;
     903        }
    829904        else
    830905        {
    831             TBranch *branch = (TBranch*)fTree->GetBranch(bname);
    832             if (branch)
    833             {
    834                 *fLog << bname << " " << (void*)branch->GetAddress() << " " << pcont << endl;
    835                 delete (MParContainer**)branch->GetAddress();
    836             }
     906            MParContainer **pcont= new MParContainer*;
     907            *pcont=FindCreateObj(*pList, classname, oname);
     908            if (SetBranchAddress(*branch, pcont, "Master branch"))
     909                num++;
    837910        }
    838         */
    839 
    840         //
    841         // here pcont is a pointer the to container in which the data from
    842         // the actual branch should be stored - enable branch.
    843         //
    844         fTree->SetBranchAddress(bname, pcont); // *CHANGED-fChain-to-fTree*
    845 
    846         *fLog << inf2 << "Master branch address '" << bname << "' ";
    847         if ((TString)bname!=(TString)classname)
    848             *fLog << "[" << classname << "] ";
    849         *fLog << "setup for reading." << endl;
    850 
    851         //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl;
    852         //branch->SetAutoDelete();
    853 
    854         num++;
    855911    }
    856912
     
    889945void MReadTree::SetReadyToSave(Bool_t flag)
    890946{
    891     if (!fChain)
    892         return;
    893 
    894     TIter Next(fChain->GetStatus());
    895 
    896     TChainElement *element = NULL;
    897     while ((element=(TChainElement*)Next()))
    898     {
    899         //
    900         // Check whether the branch is enabled
    901         //
    902         if (!element->GetStatus())
    903             continue;
    904 
    905         //
    906         // Get the pointer to the pointer of the corresponding container
    907         //
    908         MParContainer **pcont = (MParContainer**)element->GetBaddress();
    909 
    910         //
    911         // Check whether the pointer is not NULL
    912         //
    913         if (!pcont || !*pcont)
    914             continue;
    915 
    916         //
    917         // Set the ready to save status of the container.
    918         //
    919         (*pcont)->SetReadyToSave(flag);
    920     }
     947    fParList.R__FOR_EACH(MParContainer, SetReadyToSave)(flag);
    921948
    922949    MTask::SetReadyToSave(flag);
  • trunk/MagicSoft/Mars/mfileio/MReadTree.h

    r9034 r9036  
    3131
    3232    MTaskList *fTaskList;      // Tasklist to set StreamId
     33    TList      fParList;
    3334
    3435    enum { kChainWasChanged = BIT(14) };
     
    4243
    4344    Bool_t IsOwned(const TChainElement &e) const;
     45
     46    void GetListOfBranches(TList &list) const;
     47    MParContainer *FindCreateObj(MParList &plist, const char *cname, const char *name);
     48    void *GetParameterPtr(MParList &plist, const TString &bb, const char *parname);
     49    Bool_t SetBranchAddress(TBranch &b, void *ptr, const char *prefix, const char *type=0);
    4450
    4551    void DisableSubBranches(TBranch *b);
     
    103109
    104110#endif
    105 
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r8999 r9036  
    469469                }
    470470
    471                 *fLog << inf << "Unnecessary parameter container '" << cname << "' not found..." << endl;
     471                *fLog << inf2 << "Unnecessary parameter container '" << cname << "' not found..." << endl;
    472472                delete fBranches.Remove(entry);
    473473                continue;
Note: See TracChangeset for help on using the changeset viewer.