Changeset 547


Ignore:
Timestamp:
01/18/01 09:36:12 (24 years ago)
Author:
harald
Message:
Now the readraw program is also able to read in the MC data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/readraw.cc

    r463 r547  
    6868    //  open the file
    6969    //
     70
     71    cout << " Open the file " << endl ;
     72
    7073    TFile input(argv[1], "READ");
    7174
     
    7477    //
    7578
     79    cout << " Check the RunHeader " << endl ;
    7680    TTree *runtree = (TTree*) input.Get("RunHeaders") ;
    7781   
    78     cout << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
    79 
    80     runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
    81     runtree->GetEvent(0);
    82 
    83     runheader->Print();
    84 
     82    if (!runtree)
     83      {
     84        cout << endl
     85             << "  WARNING: This file has NO RunHeader "
     86             << endl << endl ;
     87      }
     88    else
     89      { 
     90        cout << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
     91       
     92        runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
     93        runtree->GetEvent(0);
     94       
     95        runheader->Print();
     96      }
    8597
    8698    //
    8799    // open the DataTree and read in
    88100    //
    89     TTree *evttree = (TTree*) input.Get("Data") ;
    90101
    91     //
    92     //   connnect the branches in that tree
    93     //
    94     evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
    95     evttree->GetBranch("MTime")->SetAddress(&evttime);
    96     evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
    97     evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
     102    cout << " Check the Event Tree " << endl ;
     103   
     104    TTree *evttree = (TTree*) input.Get("Events") ;
    98105
     106    cout << " Check all the Branches in the Tree " << endl ;
     107   
     108   
     109    //  check the branches in the Tree
     110   
     111    TIter Next(evttree->GetListOfBranches());
     112    TBranch *branch=NULL;
     113   
     114    while ( (branch=(TBranch*)Next()) )
     115    {
     116        //
     117        // Get Name of Branch
     118        //
     119        const char *name = branch->GetName();
     120       
     121        //      cout << name << endl ;
     122
     123        if ( ! strcmp(name, "MRawEvtHeader") )
     124          evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
     125
     126        if ( ! strcmp(name, "MTime") )
     127          evttree->GetBranch("MTime")->SetAddress(&evttime);
     128
     129        if ( ! strcmp(name, "MRawEvtData") )
     130          evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
     131
     132        if ( ! strcmp(name, "MRawCrateArray") )
     133          evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
     134
     135        if ( ! strcmp(name, "MMcEvt") )
     136          cout << " Not able to connect to class MMcEvt yet " << endl ;
     137
     138        if ( ! strcmp(name, "MMcTrig") )
     139          cout << " Not able to connect to class MMcTrig yet " << endl ;
     140
     141
     142    }
     143   
     144    // loop over all entries
     145   
    99146    Int_t nent = (Int_t)evttree->GetEntries();
    100     cout << " Entries in Tree Data: " << dec << nent << endl;
     147   
     148    cout << endl << endl 
     149         << " Entries in Tree Data: " << dec << nent << endl;
    101150
    102151    for (Int_t i = 0; i<nent; i++)
Note: See TracChangeset for help on using the changeset viewer.