Changeset 1031 for trunk


Ignore:
Timestamp:
11/06/01 10:33:21 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1030 r1031  
    11                                                                  -*-*- END -*-*-
     2 2001/11/06: Thomas Bretz
     3
     4   * mraw/MRawCrateArray.[h,cc]:
     5     - added SetSize which takes care of the size of the array
     6     - changed the access to an unchecked one
     7
     8   * mraw/MRawCrateData.h
     9     - derives from MParContainer now
     10
     11   * mraw/MRawEvtData.[h,cc]:
     12     - made Print const
     13     - changed so, that the arrays are dreed and allocated only
     14       as less as possible
     15
     16   * mraw/MRawFileRead.[h,cc]:
     17     - changed to support faster I/O of MRawEvtData and MRawCrateArray
     18     - added sanity check (warning) to PostProcess
     19
     20   * mraw/MRawFileWrite.cc:
     21     - removed deletion of trees (done by ~TFile)
     22     - switched of AutoSave by use of a big size
     23     - removed '.' from Branch names (each tree contains only one master
     24       branch with equal subbranches)
     25
     26
    227
    328 2001/11/01: Thomas Bretz
  • trunk/MagicSoft/Mars/mraw/MRawCrateArray.cc

    r1004 r1031  
    4141
    4242#include "MLog.h"
     43#include "MRawCrateData.h"
    4344
    4445ClassImp(MRawCrateArray);
     
    8081}
    8182
    82 // --------------------------------------------------------------------------
    83 //
    84 // Return a pointer the i-th entry in the array
    85 //
    86 MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
     83void MRawCrateArray::SetSize(Int_t i)
    8784{
    88     return (MRawCrateData*)fArray->AddrAt(i);
     85    if (fArray->GetEntriesFast() == i)
     86        return;
     87
     88    fArray->ExpandCreateFast(i);
    8989}
    9090
    9191// --------------------------------------------------------------------------
    9292//
    93 // Return the i-th entry in the array
     93// Return a pointer the i-th entry in the array, without range check
     94//
     95MRawCrateData *MRawCrateArray::GetEntry(Int_t i)
     96{
     97    return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck
     98}
     99
     100// --------------------------------------------------------------------------
     101//
     102// Return the i-th entry in the array, with range check
    94103//
    95104MRawCrateData* &MRawCrateArray::operator[](Int_t i)
  • trunk/MagicSoft/Mars/mraw/MRawCrateArray.h

    r1018 r1031  
    2525    void Clear(Option_t *opt=NULL);
    2626
     27    void SetSize(Int_t i);
    2728    MRawCrateData *GetEntry(Int_t i);
    2829
  • trunk/MagicSoft/Mars/mraw/MRawCrateData.h

    r1018 r1031  
    22#define MARS_MRawCrateData
    33
    4 #ifndef MARS_MAGIC
    5 #include "MAGIC.h"
     4#ifndef MARS_MParContainer
     5#include "MParContainer.h"
    66#endif
    77
    88class ifstream;
    99
    10 class MRawCrateData : public TObject
     10class MRawCrateData : public MParContainer
    1111{
    1212private:
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r1030 r1031  
    138138//     "dec"      Prints the time slices decimal
    139139//
    140 void MRawEvtData::Print(Option_t *opt)
     140void MRawEvtData::Print(Option_t *opt) const
    141141{
    142142    //
     
    296296void MRawEvtData::DeletePixels(Bool_t flag)
    297297{
     298    const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
     299
     300    if (fArraySize == npix && flag)
     301    {
     302        fPosInArray = 0;
     303        return;
     304    }
     305
    298306    DeleteArrays();
    299307    InitArrays(flag);
     
    319327void MRawEvtData::InitArrays(Bool_t flag)
    320328{
    321     // const int npix = !flag ? 0 : fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
    322 
    323     fHiGainPixId       = new MArrayS(0);//npix);
    324     fLoGainPixId       = new MArrayS(0);//npix);
    325     fHiGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesHiGain());
    326     fLoGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesLoGain());
     329    if (flag)
     330    {
     331        const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
     332
     333        fHiGainPixId       = new MArrayS(npix);
     334        fLoGainPixId       = new MArrayS(npix);
     335        fHiGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesHiGain());
     336        fLoGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesLoGain());
     337
     338        fArraySize  = npix;
     339    }
     340    else
     341    {
     342        fHiGainPixId       = new MArrayS(0);
     343        fLoGainPixId       = new MArrayS(0);
     344        fHiGainFadcSamples = new MArrayB(0);
     345        fLoGainFadcSamples = new MArrayB(0);
     346
     347        fArraySize = 0;
     348    }
     349
     350    fPosInArray = 0;
    327351}
    328352
     
    384408    const UShort_t npic = fRunHeader->GetNumPixInCrate();
    385409
    386     //
    387     // Enhance array by the size which we'll read now
    388     //
    389     const int npixhi = fHiGainPixId->GetSize();
    390     const int npixlo = fLoGainPixId->GetSize();
    391 
    392     fHiGainPixId->Set(npixhi+npic);
    393     fLoGainPixId->Set(npixlo+npic);
    394 
    395     const int nsamhi = fHiGainFadcSamples->GetSize();
    396     const int nsamlo = fLoGainFadcSamples->GetSize();
    397 
    398     fHiGainFadcSamples->Set(nsamhi+nhi*npic);
    399     fLoGainFadcSamples->Set(nsamlo+nlo*npic);
    400 
    401     Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nsamhi;
    402     Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nsamlo;
     410    const UShort_t npos = npic*fPosInArray;
     411
     412    Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nhi*npos;
     413    Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nlo*npos;
     414
     415    // UShort_t *hipixid = (UShort_t*)fHiGainPixId->GetArray()+npos;
     416    // UShort_t *lopixid = (UShort_t*)fLoGainPixId->GetArray()+npos;
    403417
    404418    for (int i=0; i<npic; i++)
     
    409423        const UShort_t npix = fRunHeader->GetPixAssignment(i);
    410424
     425        const UShort_t ipos = npos+i;
    411426        //
    412427        //  This is to fill the data of one pixel to the MRawEvtHeader Class.
     
    414429        //  Add to lo gains if lflag = 1
    415430        //
    416         fHiGainPixId->AddAt(npix, npixhi+i);
     431        fHiGainPixId->AddAt(npix, ipos);
    417432        fin.read(higainsam, nhi);
    418433        higainsam += nhi;
     
    421436        //if (IsLoGainOn(i, j))
    422437        //{
    423         fLoGainPixId->AddAt(npix, npixlo+i);
     438        fLoGainPixId->AddAt(npix, ipos);
    424439        fin.read(logainsam, nlo);
    425440        logainsam += nlo;
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.h

    r1018 r1031  
    2727    MArrayB *fLoGainFadcSamples;  // list of lo gain samples of all pixels (ordering: see fLoGainPixId)
    2828
     29    Int_t fPosInArray;   //!
     30    Int_t fArraySize;    //!
     31
    2932    void InitArrays(Bool_t flag=kFALSE);
    3033    void DeleteArrays();
     
    4447
    4548    void Clear(Option_t * = NULL);
    46     void Print(Option_t * = NULL);
     49    void Print(Option_t * = NULL) const;
    4750    void Draw (Option_t * = NULL);
    4851
    4952    void DeletePixels(Bool_t flag=kFALSE);
     53    void ResetPixels() { DeletePixels(kTRUE); }
    5054    void AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag=kFALSE);
    5155
    52     Byte_t  GetNumHiGainSamples() const;
    53     Byte_t  GetNumLoGainSamples() const;
     56    Byte_t   GetNumHiGainSamples() const;
     57    Byte_t   GetNumLoGainSamples() const;
    5458    UShort_t GetNumPixels() const;
    5559
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.cc

    r1004 r1031  
    2525//////////////////////////////////////////////////////////////////////////////
    2626//                                                                          //
    27 //  MRawFile                                                                //
     27//  MRawFileRead                                                            //
    2828//                                                                          //
    2929//  This tasks reads the raw binary file like specified in the TDAS???      //
     
    3535//                                                                          //
    3636//  Output Containers:                                                      //
    37 //   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MTime      //
     37//   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime //
    3838//                                                                          //
    3939//////////////////////////////////////////////////////////////////////////////
     
    5555
    5656
    57 /*/  ----------- please don't delete and don't care about (Thomas) ------------
    58 #define kBUFSZ 1024
    59 
     57/*  ----------- please don't delete and don't care about (Thomas) ------------
     58#define kBUFSZ 64 //1024*1024*64
     59#include <iomanip.h>
    6060class bifstream : public istream, public streambuf
    6161{
     
    7272    {
    7373        int sz=fread(fBuffer, kBUFSZ, 1, fd);
     74        //int sz=fread(fBuffer, 1, kBUFSZ, fd);
    7475        setg(fBuffer, fBuffer, fBuffer+kBUFSZ);
    7576
    76         return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF;
     77        return sz==1 ? *(unsigned char*)fBuffer : EOF;//EOF;
     78        //return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF;
    7779    }
    7880public:
     
    9092//
    9193MRawFileRead::MRawFileRead(const char *fname, const char *name, const char *title)
     94    : fFileName(fname)
    9295{
    9396    fName  = name  ? name  : "MRawFileRead";
     
    198201
    199202    //
     203    //  Get number of crates from the run header
     204    //
     205    const UShort_t nc = fRawRunHeader->GetNumCrates();
     206
     207    //
    200208    // Delete arrays which stores the pixel information (time slices)
    201209    //
    202     fRawEvtData->DeletePixels();
     210    fRawEvtData->ResetPixels();
    203211
    204212    //
    205213    // clear the TClonesArray which stores the Crate Information
    206     //
    207     fRawCrateArray->Clear();
    208 
    209     //
    210     //  Get number of crates from the run header
    211     //
    212     const UShort_t nc = fRawRunHeader->GetNumCrates();
     214    // and create a new array of the correct size
     215    //
     216    fRawCrateArray->SetSize(nc);
    213217
    214218    //
     
    225229}
    226230
     231// --------------------------------------------------------------------------
     232//
     233//  Checks whether the number of read events differs from the number the
     234//  file should containe (MRawRunHeader). Prints a warning if it doesn't
     235//  match.
     236//
     237Bool_t MRawFileRead::PostProcess()
     238{
     239    if (fRawRunHeader->GetNumEvents() != GetNumExecutions()-1)
     240        *fLog << "WARNING - number of read events doesn't match number in run header." << endl;
     241
     242    return kTRUE;
     243}
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.h

    r1018 r1031  
    22#define MARS_MRawFileRead
    33
    4 #ifndef MARS_MTASK
     4#ifndef MARS_MTask
    55#include "MTask.h"
    66#endif
     
    3333    Bool_t PreProcess(MParList *pList);
    3434    Bool_t Process();
     35    Bool_t PostProcess();
    3536
    3637    ClassDef(MRawFileRead, 0)   // Task to read the raw data binary file
  • trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc

    r1004 r1031  
    8383
    8484    delete fOut;
     85
     86    //
     87    // Remark:
     88    // - Trees are automatically deleted by the the file
     89    //   (unless file.SetDirectory(0) was called)
     90    // - Branches are automatically deleted by the tree destructor
     91    //
    8592}
    8693
     
    156163
    157164    //
     165    // Remark:
     166    // - Trees are automatically deleted by the the file
     167    //   (unless file.SetDirectory(0) was called)
     168    // - Branches are automatically deleted by the tree destructor
     169    //
     170
     171    //
    158172    // Write the run header information to the file
    159173    //
    160     TTree   *rh = new TTree("RunHeaders", "Run headers of all runs in this file");
    161     TBranch *tb = rh->Branch("MRawRunHeader", "MRawRunHeader", &fRawRunHeader, 32000);
     174    TTree *rh = new TTree("RunHeaders", "Run headers of all runs in this file");
     175    rh->Branch("MRawRunHeader", "MRawRunHeader", &fRawRunHeader, 32000);
    162176    rh->Fill();
    163     rh->Write();
    164     delete tb;
    165     delete rh;
     177    //rh->Write();
    166178
    167179    //
     
    173185
    174186    //
     187    // From the root dicumentation:
     188    //
     189    // Note that calling TTree::AutoSave too frequently (or similarly calling
     190    // TTree::SetAutoSave with a small value) is an expensive operation.
     191    // You should make tests for your own application to find a compromize
     192    // between speed and the quantity of information you may loose in case of
     193    // a job crash.
     194    //
     195    // In case your program crashes before closing the file holding this tree,
     196    // the file will be automatically recovered when you will connect the file
     197    // in UPDATE mode.
     198    // The Tree will be recovered at the status corresponding to the last AutoSave.
     199    //
     200    fTData       ->SetAutoSave(2000000000); // 2GB
     201    fTPedestal   ->SetAutoSave(2000000000); // 2GB
     202    fTCalibration->SetAutoSave(2000000000); // 2GB
     203
     204    //
    175205    // create all branches which are necessary
    176206    //
    177     fTData       ->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
    178     fTPedestal   ->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
    179     fTCalibration->Branch("MTime.",          "MTime",          &fRawEvtTime,    32000);
    180     fTData       ->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    181     fTPedestal   ->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    182     fTCalibration->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    183     fTData       ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    32000);
    184     fTPedestal   ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
    185     fTCalibration->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
     207    // FIXME: Can we calculate a good buffer size out of the event size?
     208    //        using splitlevel=0 sppeds up writing by a factor of 5-10%
     209    fTData       ->Branch("MTime",          "MTime",          &fRawEvtTime,    32000);
     210    fTPedestal   ->Branch("MTime",          "MTime",          &fRawEvtTime,    32000);
     211    fTCalibration->Branch("MTime",          "MTime",          &fRawEvtTime,    32000);
     212    fTData       ->Branch("MRawEvtHeader",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
     213    fTPedestal   ->Branch("MRawEvtHeader",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
     214    fTCalibration->Branch("MRawEvtHeader",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
     215    fTData       ->Branch("MRawEvtData",    "MRawEvtData",    &fRawEvtData,    320000);
     216    fTPedestal   ->Branch("MRawEvtData",    "MRawEvtData",    &fRawEvtData,    320000);
     217    fTCalibration->Branch("MRawEvtData",    "MRawEvtData",    &fRawEvtData,    320000);
    186218    //fTree->Branch("MRawCrateArray",  fRawCrateArray->GetArray(),      32000, 1);
    187     fTData       ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
    188     fTPedestal   ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
    189     fTCalibration->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
     219    fTData       ->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000);
     220    fTPedestal   ->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000);
     221    fTCalibration->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000);
    190222
    191223    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.