Changeset 1914 for trunk/MagicSoft


Ignore:
Timestamp:
04/07/03 17:28:54 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1912 r1914  
    3131   * macros/dohtml.C:
    3232     - added testenv.C
     33
     34   * readraw.cc:
     35     - simplified
     36   
     37   * mraw/MRawEvtData.cc:
     38     - fixed a bug in the draw function (the drawn pixel has not been the
     39       one with the given Id, but simply the i-th entry in the array)
    3340
    3441
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r1082 r1914  
    6262#include "MArrayB.h"
    6363#include "MRawRunHeader.h"
     64#include "MRawEvtPixelIter.h"
    6465
    6566ClassImp(MRawEvtData);
     
    217218    TString str(opt);
    218219
    219     UInt_t num = 0;
     220    UInt_t id = 0;
    220221
    221222    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
    222     {
    223223        if (str.Length()>5)
    224             sscanf(&str[5], "%d", &num);
    225 
    226         if (num>=GetNumPixels())
    227             num= GetNumPixels();
    228 
    229         *fLog << inf << "Drawing Graph: Pixel #" << num << " of " << (int)GetNumPixels() << endl;
    230 
    231         const Int_t n = GetNumHiGainSamples();
    232 
    233         Float_t *x = new Float_t[n];
    234         Float_t *y = new Float_t[n];
     224            sscanf(&str[5], "%d", &id);
     225    if (str.BeginsWith("HIST", TString::kIgnoreCase))
     226        if (str.Length()>4)
     227            sscanf(&str[4], "%d", &id);
     228
     229    MRawEvtPixelIter pix(this);
     230    if (!pix.Jump(id))
     231    {
     232        *fLog << warn << "Pixel Id #" << id << " doesn't exist!" << endl;
     233        return;
     234    }
     235
     236    const Byte_t *higains = pix.GetHiGainSamples();
     237
     238    const Int_t n = GetNumHiGainSamples();
     239
     240    TString name = "Pixel No.";
     241    name += pix.GetPixelId();
     242
     243    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
     244    {
     245        *fLog << inf << "Drawing Graph: Pixel Id #" << pix.GetPixelId();
     246        *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl;
     247
     248        TGraph *graph = new TGraph;
    235249
    236250        for (int i=0; i<n; i++)
    237         {
    238             x[i] = i;
    239             y[i] = (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()];
    240         }
    241 
    242         TGraph *graph = new TGraph(n, x, y);
     251            graph->SetPoint(graph->GetN(), i, higains[i]);
     252
    243253        graph->SetMaximum(256);
    244254        graph->SetMinimum(0);
     
    257267    if (str.BeginsWith("HIST", TString::kIgnoreCase))
    258268    {
    259         *fLog << "Length: " << str.Length() << endl;
    260 
    261         if (str.Length()>4)
    262             sscanf(&str[4], "%d", &num);
    263 
    264         if (num>=GetNumPixels())
    265             num= GetNumPixels();
    266 
    267         *fLog << "Drawing Histogram of Pixel " << num << endl;
    268 
    269         const Int_t n = GetNumHiGainSamples();
    270 
    271         char *name = new char[16];
    272 
    273         sprintf(name, "Pixel No.%d", (*fHiGainPixId)[num]);
     269        *fLog << "Drawing Histogram of Pixel with Id " << pix.GetPixelId() << endl;
    274270
    275271        TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n);
     
    278274
    279275        for (int i=0; i<n; i++)
    280             hist->Fill(0.5+i, (*fHiGainFadcSamples)[i + num*GetNumHiGainSamples()]);
     276            hist->Fill(0.5+i, higains[i]);
    281277
    282278        hist->SetBit(kCanDelete);
  • trunk/MagicSoft/Mars/readraw.cc

    r993 r1914  
    2525//
    2626/////////////////////////////////////////////////////////////////////////////
     27
     28void EnableBranch(TTree *t, TString name, void *ptr)
     29{
     30    if (!t->GetBranch(name+"."))
     31        return;
     32
     33    t->GetBranch(name+".")->SetAddress(ptr);
     34    gLog << " Found '" << name << "'" << endl;
     35}
    2736
    2837int main(const int argc, const char **argv)
     
    5968    }
    6069
    61     MRawRunHeader  *runheader = new MRawRunHeader();
    62     MRawEvtHeader  *evtheader = new MRawEvtHeader();
    63     MTime          *evttime   = new MTime();
    64     MRawEvtData    *evtdata   = new MRawEvtData();
    65     MRawCrateArray *evtcrate  = new MRawCrateArray();
    66 
    67     MMcEvt         *evtmc     = new MMcEvt() ;
    68     MMcTrig        *trigmc    = new MMcTrig() ;
    69 
    7070    //
    7171    //  open the file
    7272    //
    73     gLog << " Open the file " << endl ;
     73    gLog << " Open the file '" << argv[1] << "'" << endl;
    7474    TFile input(argv[1], "READ");
    7575
     
    7777    // open the Run Header and read in
    7878    //
    79     gLog << " Check the RunHeader " << endl ;
    80     TTree *runtree = (TTree*) input.Get("RunHeaders") ;
    81    
     79    gLog << " Check for Tree 'RunHeaders'" << endl;
     80    TTree *runtree = (TTree*)input.Get("RunHeaders");
    8281    if (!runtree)
    83     {
    84         gLog << endl
    85             << "  WARNING: This file has NO RunHeader "
    86             << endl << endl ;
    87     }
     82        gLog << " WARNING: This file has NO Tree 'RunHeaders'" << endl << endl;
    8883    else
    8984    {
    90         gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl ;
     85        gLog << " Entries in Tree RunHeaders: " << dec << runtree->GetEntries() << endl;
    9186
     87        MRawRunHeader *runheader = NULL;
    9288        runtree->GetBranch("MRawRunHeader")->SetAddress(&runheader);
    9389        runtree->GetEvent(0);
    94 
    9590        runheader->Print();
    9691    }
     
    9994    // open the DataTree and read in
    10095    //
    101     gLog << " Check the Event Tree " << endl ;
    102     TTree *evttree = (TTree*) input.Get("Events") ;
    103     gLog << " Check all the Branches in the Tree " << endl ;
    104    
     96    gLog << " Check the Tree 'Events'" << endl ;
     97    TTree *evttree = (TTree*)input.Get("Events") ;
     98    if (!evttree)
     99    {
     100        gLog << "Tree 'Events' not found in file... exit!" << endl;
     101        return -1;
     102    }
     103
    105104    //
    106105    //  check the branches in the Tree
    107106    //
    108     TIter Next(evttree->GetListOfBranches());
    109     TBranch *branch=NULL;
    110    
    111     while ((branch=(TBranch*)Next()))
    112     {
    113         //
    114         // Get Name of Branch
    115         //
    116         const char *name = branch->GetName();
    117        
    118         if (!strcmp(name, "MRawEvtHeader"))
    119             evttree->GetBranch("MRawEvtHeader")->SetAddress(&evtheader);
     107    gLog << " Check all the Branches in the Tree." << endl;
     108    gLog << endl;
    120109
    121         if (!strcmp(name, "MTime"))
    122             evttree->GetBranch("MTime")->SetAddress(&evttime);
     110    MRawEvtHeader  *evtheader = NULL;
     111    MTime          *evttime   = NULL;
     112    MRawEvtData    *evtdata   = NULL;
     113    MRawCrateArray *evtcrate  = NULL;
     114    MMcEvt         *evtmc     = NULL;
     115    MMcTrig        *trigmc    = NULL;
    123116
    124         if (!strcmp(name, "MRawEvtData"))
    125             evttree->GetBranch("MRawEvtData")->SetAddress(&evtdata);
    126 
    127         if (!strcmp(name, "MRawCrateArray"))
    128             evttree->GetBranch("MRawCrateArray")->SetAddress(&evtcrate);
    129 
    130         if (!strcmp(name, "MMcTrig"))
    131             evttree->GetBranch("MMcTrig")->SetAddress(&trigmc);
    132 
    133         if (!strcmp(name, "MMcEvt"))
    134             evttree->GetBranch("MMcEvt")->SetAddress(&evtmc);
    135     }
     117    EnableBranch(evttree, "MRawEvtHeader",  &evtheader);
     118    EnableBranch(evttree, "MTime",          &evttime);
     119    EnableBranch(evttree, "MRawEvtData",    &evtdata);
     120    EnableBranch(evttree, "MRawCrateArray", &evtcrate);
     121    EnableBranch(evttree, "MMcEvt",         &evtmc);
     122    EnableBranch(evttree, "MMcTrig",        &trigmc);
    136123
    137124    //
     
    140127    Int_t nent = (Int_t)evttree->GetEntries();
    141128
    142     gLog << endl << endl;
     129    gLog << endl;
    143130    gLog << " Entries in Tree Data: " << dec << nent << endl;
     131    gLog << endl;
    144132
    145133    for (Int_t i = 0; i<nent; i++)
     
    152140        evttree->GetEvent(i);
    153141
    154         evtmc->Print();
    155        
    156         evtheader->Print();
    157         evttime->Print();
    158         evtcrate->Print();
    159         evtdata->Print();
     142        if (evtmc)
     143            evtmc->Print();
     144        if (trigmc)
     145            trigmc->Print();
     146        if (evtheader)
     147            evtheader->Print();
     148        if (evttime)
     149            evttime->Print();
     150        if (evtcrate)
     151            evtcrate->Print();
     152        if (evtdata)
     153            evtdata->Print();
    160154    }
    161155   
Note: See TracChangeset for help on using the changeset viewer.