Changeset 4738 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
08/26/04 13:19:20 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4736 r4738  
    2626     - changed calculation of sign of SignificanceLiMaSigned due to
    2727       bug #131
     28
     29   * readdaq.cc, readraw.cc:
     30     - updated to support MRawEvtData2
     31     
     32   * mraw/MRawEvtData.[h,cc], mraw/MRawFileRead.cc,
     33     mraw/MRawFileWrite.[h,cc], mraw/MRawRead.[h,cc],
     34     mraw/MRawSocketRead.cc:
     35     - updated to support negative pixel ids
     36
     37   * mraw/MRawRunHeader.[h,cc]:
     38     - increased max format version to 4
     39     - added GetNumNormalPixels
     40     - added GetNumSpecialPixels
     41     - added GetMinPixId
     42     - added GetMaxPixId
    2843
    2944
  • trunk/MagicSoft/Mars/NEWS

    r4723 r4738  
    3737   - added program doing the calibration and the signal extraction
    3838     and signal calibration: callisto
     39
     40   - implemented support for pixels with negative IDs (Raw file format
     41     version 4)
    3942
    4043
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r4648 r4738  
    100100//
    101101MRawEvtData::MRawEvtData(const char *name, const char *title)
     102    : fRunHeader(0)
    102103{
    103104    fName  = name  ? name  : "MRawEvtData";
     
    185186
    186187    *fLog << dec << all;
    187     *fLog << "HiGain: " << nHiPix << " Pixels with " << (Int_t)nHiSamp << " Samples" << endl;
    188     *fLog << "LoGain: " << nLoPix << " Pixels with " << (Int_t)nLoSamp << " Samples";;
     188    *fLog << GetDescriptor() << ": " << endl;
     189    *fLog << "HiGain: " << nHiPix << " Pixels with " << (Int_t)nHiSamp << " Samples  ";
     190    *fLog << "LoGain: " << nLoPix << " Pixels with " << (Int_t)nLoSamp << " Samples";
    189191
    190192    TString str(opt);
     
    361363// --------------------------------------------------------------------------
    362364//
    363 // Deletes all arrays describing the pixel Id and Samples in pixels.
    364 // The flag is for future usage.
    365 //
    366 void MRawEvtData::DeletePixels(Bool_t flag)
    367 {
    368     if (fRunHeader && flag)
    369     {
    370         //const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
    371         const int npix = fRunHeader->GetNumConnectedPixels();
    372 
    373         if (fArraySize == npix)
    374         {
    375             fPosInArray = 0;
    376             fConnectedPixels = 0;
    377             return;
    378         }
    379     }
    380 
    381     DeleteArrays();
    382     InitArrays(flag);
     365//  Deletes all the arrays
     366//  The flag is for future usage.
     367//
     368void MRawEvtData::InitArrays(UShort_t numconnected, UShort_t maxid)
     369{
     370    fHiGainPixId       = new MArrayS(numconnected);
     371    fLoGainPixId       = new MArrayS(numconnected);
     372    fHiGainFadcSamples = new MArrayB(numconnected*fRunHeader->GetNumSamplesHiGain());
     373    fLoGainFadcSamples = new MArrayB(numconnected*fRunHeader->GetNumSamplesLoGain());
     374
     375    fABFlags           = new MArrayB(maxid/8+1);
     376
     377    fConnectedPixels   = 0;
    383378}
    384379
     
    398393// --------------------------------------------------------------------------
    399394//
    400 //  Deletes all the arrays
    401 //  The flag is for future usage.
    402 //
    403 void MRawEvtData::InitArrays(Bool_t flag)
    404 {
    405     if (flag && fRunHeader)
    406     {
    407         const int npix = fRunHeader->GetNumConnectedPixels();
    408 
    409         fHiGainPixId       = new MArrayS(npix);
    410         fLoGainPixId       = new MArrayS(npix);
    411         fHiGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesHiGain());
    412         fLoGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesLoGain());
    413         fABFlags           = new MArrayB(fRunHeader->GetMaxPixId()/8+1);
    414 
    415         fArraySize  = npix;
    416     }
    417     else
    418     {
    419         fHiGainPixId       = new MArrayS(0);
    420         fLoGainPixId       = new MArrayS(0);
    421         fHiGainFadcSamples = new MArrayB(0);
    422         fLoGainFadcSamples = new MArrayB(0);
    423         fABFlags           = new MArrayB(0);
    424 
    425         fArraySize = 0;
    426     }
    427 
    428     fPosInArray = 0;
    429     fConnectedPixels = 0;
     395// Deletes all arrays describing the pixel Id and Samples in pixels.
     396// The flag is for future usage.
     397//
     398void MRawEvtData::ResetPixels(UShort_t numconnected, UShort_t maxid)
     399{
     400    //const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate();
     401    if (fHiGainPixId && fHiGainPixId->GetSize()==numconnected && (UShort_t)fABFlags->GetSize()==(maxid/8+1))
     402    {
     403        fConnectedPixels = 0;
     404        return;
     405    }
     406
     407    DeleteArrays();
     408    InitArrays(numconnected, maxid);
    430409}
    431410
     
    475454}
    476455
     456void MRawEvtData::ReadPixel(istream &fin, Int_t npix, Bool_t ab)
     457{
     458    Byte_t *poshi = fHiGainFadcSamples->GetArray() + fConnectedPixels*fRunHeader->GetNumSamplesHiGain();
     459    Byte_t *poslo = fLoGainFadcSamples->GetArray() + fConnectedPixels*fRunHeader->GetNumSamplesLoGain();
     460
     461    // Read data for one pixel
     462    fin.read((char*)poshi, fRunHeader->GetNumSamplesHiGain());
     463    fin.read((char*)poslo, fRunHeader->GetNumSamplesLoGain());
     464
     465    //
     466    //  This is to fill the data of one pixel to the MRawEvtHeader Class.
     467    //  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
     468    //  Add to lo gains if lflag = 1
     469    //
     470    fHiGainPixId->AddAt(npix, fConnectedPixels);
     471
     472    // FIXME: Not implemented in the raw files yet
     473    //if (IsLoGainOn(i, j))
     474    //{
     475    fLoGainPixId->AddAt(npix, fConnectedPixels);
     476    //}
     477
     478    if (ab)
     479        SETBIT((*fABFlags)[npix/8], npix%8);
     480    else
     481        CLRBIT((*fABFlags)[npix/8], npix%8);
     482
     483    fConnectedPixels++;
     484}
     485
    477486// --------------------------------------------------------------------------
    478487//
     
    480489//   WARNING: you have to use Init() before you can do this
    481490//
    482 void MRawEvtData::ReadEvt(istream &fin)
    483 {
    484     const UShort_t nlo = fRunHeader->GetNumSamplesLoGain();
    485     const UShort_t nhi = fRunHeader->GetNumSamplesHiGain();
     491/*
     492void MRawEvtData::ReadEvt(istream &fin, Int_t posinarray)
     493{
    486494
    487495    const UShort_t npic = fRunHeader->GetNumPixInCrate();
    488496
    489     const UShort_t npos = npic*fPosInArray;
    490 
    491     const Byte_t ab = fCrateArray->GetEntry(fPosInArray)->GetABFlags();
    492 
    493     Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nhi*fConnectedPixels;
    494     Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nlo*fConnectedPixels;
    495 
    496     for (int i=0; i<npic; i++)
    497     {
    498         fin.read((char*)higainsam, nhi);
    499         fin.read((char*)logainsam, nlo);
    500 
     497    const UShort_t npos = npic*posinarray;
     498
     499    //const Byte_t ab = fCrateArray->GetEntry(posinarray)->GetABFlags();
     500
     501    for (int i=npos; i<npic+npos; i++)
     502    {
    501503        // calc the spiral hardware pixel number
    502         const UShort_t ipos = npos+i;
     504        const UShort_t ipos = i;
    503505
    504506        // Get Hardware Id
     
    506508
    507509        // Check whether the pixel is connected or not
    508         if (hwid<=0)
    509             continue;
     510        if (hwid==0)
     511        {
     512            const UShort_t n = fRunHeader->GetNumSamplesLoGain()+fRunHeader->GetNumSamplesHiGain();
     513            fin.seekg(n, ios::cur);
     514            return;
     515        }
    510516
    511517        // -1 converts the hardware pixel Id into the software pixel index
    512         const Int_t npix = /*hwid>0 ?*/ (Int_t)hwid-1 /*: hwid*/;
    513 
    514         //
    515         //  This is to fill the data of one pixel to the MRawEvtHeader Class.
    516         //  The parameters are the pixelnumber and the FADC_SLICES values of ADCs
    517         //  Add to lo gains if lflag = 1
    518         //
    519         fHiGainPixId->AddAt(npix, fConnectedPixels);
    520         higainsam += nhi;
    521 
    522         // FIXME: Not implemented in the raw files yet
    523         //if (IsLoGainOn(i, j))
    524         //{
    525         fLoGainPixId->AddAt(npix, fConnectedPixels);
    526         logainsam += nlo;
    527         //}
    528 
    529         if (TESTBIT(ab, i))
    530             SETBIT((*fABFlags)[npix/8], npix%8);
    531         else
    532             CLRBIT((*fABFlags)[npix/8], npix%8);
    533 
    534         fConnectedPixels++;
    535     }
    536 
    537     fPosInArray++;
    538 }
     518        const Int_t npix = (Int_t)hwid-1;
     519
     520        const Byte_t ab = fCrateArray->GetEntry(posinarray)->GetABFlags();
     521        AddPixel(fin, npix, TESTBIT(ab, i-npos));
     522    }
     523}
     524*/
    539525
    540526// --------------------------------------------------------------------------
     
    608594    *evt.fABFlags = *fABFlags;
    609595
    610     evt.fPosInArray      = fPosInArray;
    611596    evt.fConnectedPixels = fConnectedPixels;
    612     evt.fArraySize       = fArraySize;
    613 }
     597}
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.h

    r4648 r4738  
    2525private:
    2626    MRawRunHeader  *fRunHeader;   //! provides information about numbers
    27     MRawCrateArray *fCrateArray;  //! provides information about ab flag
    2827
    2928    // FIXME: COMMENT ABOUT ORDERING
     
    3736    MArrayB *fABFlags;            //-> A information about the exact trigger position
    3837
    39     Int_t fPosInArray;        //!
    4038    Int_t fConnectedPixels;   //!
    41     Int_t fArraySize;         //!
    4239
    43     void InitArrays(Bool_t flag=kFALSE);
     40    void InitArrays(UShort_t numconnected=0, UShort_t maxid=0);
    4441    void DeleteArrays();
    4542
     
    5047    ~MRawEvtData();
    5148
    52     void InitRead(MRawRunHeader *rh, MRawCrateArray *arr)
     49    void InitRead(MRawRunHeader *rh)
    5350    {
    5451        //
     
    5754        //
    5855        fRunHeader  = rh;
    59         fCrateArray = arr;
    6056    }
    6157
     
    6460    void Draw (Option_t * = NULL);
    6561
    66     void DeletePixels(Bool_t flag=kFALSE);
    67     void ResetPixels() { DeletePixels(kTRUE); }
     62    void ResetPixels(UShort_t npix, UShort_t maxid);
    6863    void AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag=kFALSE);
    6964
     
    7267    UShort_t GetNumPixels() const;
    7368
    74     void ReadEvt(istream &fin);
     69    void ReadPixel(istream &fin, Int_t npix, Bool_t ab);
     70    //void ReadEvt(istream &fin, Int_t posinarray);
    7571    void SkipEvt(istream &fin);
    7672
  • trunk/MagicSoft/Mars/mraw/MRawFileRead.cc

    r4694 r4738  
    207207    //
    208208    fRawEvtHeader->InitRead(fRawRunHeader, fRawEvtTime);
    209     fRawEvtData  ->InitRead(fRawRunHeader, fRawCrateArray);
     209    fRawEvtData1 ->InitRead(fRawRunHeader);
     210    fRawEvtData2 ->InitRead(fRawRunHeader);
    210211
    211212    //
  • trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc

    r4694 r4738  
    3131//
    3232//  Input Containers:
    33 //   MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime
     33//   MRawRunHeader
     34//   MRawEvtHeader
     35//   MRawEvtData
     36//   MRawEvtData2 [MRawEvtData]
     37//   MRawCrateArray
     38//   MTime
    3439//
    3540//  Output Containers:
     
    6166// Default constructor. It opens the output file (root-file)
    6267//
    63 MRawFileWrite::MRawFileWrite(const char *fname,
    64                              const Option_t *opt,
    65                              const char *ftitle,
    66                              const Int_t comp,
    67                              const char *name, const char *title) : fSplit(kFALSE)
     68MRawFileWrite::MRawFileWrite(const char *fname,  const Option_t *opt,
     69                             const char *ftitle, const Int_t comp,
     70                             const char *name, const char *title)
     71    : fTData(0), fSplit(kFALSE)
    6872{
    6973    fName  = name  ? name  : "MRawFileWrite";
     
    8286MRawFileWrite::~MRawFileWrite()
    8387{
    84     if (fOut != fTData->GetCurrentFile())
    85     {
    86         *fLog << warn << endl;
    87         *fLog << "WARNING - MWriteRootFile:   Root's  TTree/TFile   has  opened   a  new  file" << endl;
    88         *fLog << "  automatically.  You can change this behaviour using TTree::SetMaxTreeSize." << endl;
    89         *fLog << "  You won't be able to read splitted  files  correctly with MReadMarsFile if" << endl;
    90         *fLog << "  they have more than one entry in 'RunHeaders' or you try to read more than" << endl;
    91         *fLog << "  one of such sequences at once." << endl;
    92         *fLog << endl;
    93     }
    94 
    95     //
    96     // For more information see TTree:ChangeFile()
    97     //
    98     fOut = fTData->GetCurrentFile();
     88    if (fTData)
     89    {
     90        if (fOut != fTData->GetCurrentFile())
     91        {
     92            *fLog << warn << endl;
     93            *fLog << "WARNING - MWriteRootFile:   Root's  TTree/TFile   has  opened   a  new  file" << endl;
     94            *fLog << "  automatically.  You can change this behaviour using TTree::SetMaxTreeSize." << endl;
     95            *fLog << "  You won't be able to read splitted  files  correctly with MReadMarsFile if" << endl;
     96            *fLog << "  they have more than one entry in 'RunHeaders' or you try to read more than" << endl;
     97            *fLog << "  one of such sequences at once." << endl;
     98            *fLog << endl;
     99        }
     100
     101        //
     102        // For more information see TTree:ChangeFile()
     103        //
     104        fOut = fTData->GetCurrentFile();
     105    }
    99106
    100107    //
     
    147154    if (!fRawEvtHeader)
    148155    {
    149         *fLog << err << dbginf << "MRawEvtHeader not found... aborting." << endl;
    150         return kFALSE;
    151     }
    152 
    153     fRawEvtData = (MRawEvtData*)pList->FindObject("MRawEvtData");
    154     if (!fRawEvtData)
    155     {
    156         *fLog << err << dbginf << "MRawEvtData not found... aborting." << endl;
     156        *fLog << err << "MRawEvtHeader not found... aborting." << endl;
     157        return kFALSE;
     158    }
     159
     160    fRawEvtData1 = (MRawEvtData*)pList->FindObject("MRawEvtData");
     161    if (!fRawEvtData1)
     162    {
     163        *fLog << err << "MRawEvtData not found... aborting." << endl;
     164        return kFALSE;
     165    }
     166    fRawEvtData2 = (MRawEvtData*)pList->FindObject("MRawEvtData2", "MRawEvtData");
     167    if (!fRawEvtData2)
     168    {
     169        *fLog << err << "MRawEvtData2 [MRawEvtData] not found... aborting." << endl;
    157170        return kFALSE;
    158171    }
     
    161174    if (!fRawCrateArray)
    162175    {
    163         *fLog << err << dbginf << "MRawCrateArray not found... aborting." << endl;
     176        *fLog << err << "MRawCrateArray not found... aborting." << endl;
    164177        return kFALSE;
    165178    }
     
    168181    if (!fTime)
    169182    {
    170         *fLog << err << dbginf << "MTime not found... aborting." << endl;
     183        *fLog << err << "MTime not found... aborting." << endl;
    171184        return kFALSE;
    172185    }
     
    175188    if (!fRawRunHeader)
    176189    {
    177         *fLog << err << dbginf << "MRawRunHeader not found... aborting." << endl;
     190        *fLog << err << "MRawRunHeader not found... aborting." << endl;
    178191        return kFALSE;
    179192    }
     
    220233    fTData->Branch("MTime.",          "MTime",          &fTime,          32000);
    221234    fTData->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    222     fTData->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
     235    fTData->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData1,   320000);
     236    fTData->Branch("MRawEvtData2.",   "MRawEvtData",    &fRawEvtData2,   320000);
    223237    fTData->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
    224238    if (!fSplit)
     
    229243    fTPedestal   ->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    230244    fTCalibration->Branch("MRawEvtHeader.",  "MRawEvtHeader",  &fRawEvtHeader,  32000);
    231     fTPedestal   ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
    232     fTCalibration->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData,    320000);
     245    fTPedestal   ->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData1,   320000);
     246    fTCalibration->Branch("MRawEvtData.",    "MRawEvtData",    &fRawEvtData1,   320000);
     247    fTPedestal   ->Branch("MRawEvtData2.",   "MRawEvtData",    &fRawEvtData2,   320000);
     248    fTCalibration->Branch("MRawEvtData2.",   "MRawEvtData",    &fRawEvtData2,   320000);
    233249    fTPedestal   ->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
    234250    fTCalibration->Branch("MRawCrateArray.", "MRawCrateArray", &fRawCrateArray, 32000);
  • trunk/MagicSoft/Mars/mraw/MRawFileWrite.h

    r4694 r4738  
    2222    MRawRunHeader  *fRawRunHeader;
    2323    MRawEvtHeader  *fRawEvtHeader;
    24     MRawEvtData    *fRawEvtData;
     24    MRawEvtData    *fRawEvtData1;
     25    MRawEvtData    *fRawEvtData2;
    2526    MRawCrateArray *fRawCrateArray;
    2627
     
    4041
    4142public:
    42     MRawFileWrite(const char *fname,
    43                   const Option_t *opt="RECREATE",
    44                   const char *ftitle="Untitled",
    45                   const Int_t comp=2,
     43    MRawFileWrite(const char *fname, const Option_t *opt="RECREATE",
     44                  const char *ftitle="Untitled", const Int_t comp=2,
    4645                  const char *name=NULL, const char *title=NULL);
    4746    ~MRawFileWrite();
  • trunk/MagicSoft/Mars/mraw/MRawRead.cc

    r4040 r4738  
    2424
    2525//////////////////////////////////////////////////////////////////////////////
    26 //                                                                         
     26//
    2727//  MRawRead
    28 //                                                                         
    29 //  This tasks reads the raw binary file like specified in the TDAS???     
    30 //  and writes the data in the corresponding containers which are           
    31 //  either retrieved from the parameter list or created and added.         
    32 //                                                                         
    33 //  Input Containers:                                                       
    34 //   -/-                                                                   
    35 //                                                                         
     28//
     29//  This tasks reads the raw binary file like specified in the TDAS???
     30//  and writes the data in the corresponding containers which are
     31//  either retrieved from the parameter list or created and added.
     32//
     33//  Input Containers:
     34//   -/-
     35//
    3636//  Output Containers:                                                     
    3737//   MRawRunHeader
    3838//   MRawEvtHeader
    3939//   MRawEvtData
     40//   MRawEvtData2 [MRawEvtData]
    4041//   MRawCrateArray
    41 //   MRawEvtTime
    42 //                                                                         
     42//   MTime
     43//
    4344//////////////////////////////////////////////////////////////////////////////
    4445#include "MRawRead.h"
     
    105106        return kFALSE;
    106107
    107     fRawEvtData = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
    108     if (!fRawEvtData)
     108    fRawEvtData1 = (MRawEvtData*)pList->FindCreateObj("MRawEvtData");
     109    if (!fRawEvtData1)
     110        return kFALSE;
     111
     112    fRawEvtData2 = (MRawEvtData*)pList->FindCreateObj("MRawEvtData", "MRawEvtData2");
     113    if (!fRawEvtData2)
    109114        return kFALSE;
    110115
     
    180185    // Delete arrays which stores the pixel information (time slices)
    181186    //
    182     fRawEvtData->ResetPixels();
     187    fRawEvtData1->ResetPixels(fRawRunHeader->GetNumNormalPixels(),  fRawRunHeader->GetMaxPixId());
     188    fRawEvtData2->ResetPixels(fRawRunHeader->GetNumSpecialPixels(), fRawRunHeader->GetMinPixId());
    183189
    184190    //
     
    189195
    190196    //
     197    // Calculate the number of byte to be skipped in a file if a pixel is not connected
     198    //
     199    const UShort_t nskip = fRawRunHeader->GetNumSamplesLoGain()+fRawRunHeader->GetNumSamplesHiGain();
     200
     201    //
    191202    // read the CRATE DATA (see specification) from file
    192203    //
     204    Int_t posinarray=0;
    193205    for (int i=0; i<nc; i++)
    194206    {
     
    197209            return kFALSE;
    198210
    199         fRawEvtData->ReadEvt(fin);
     211        //fRawEvtData1->ReadEvt(fin, posinarray++);
     212
     213        const UShort_t npic = fRawRunHeader->GetNumPixInCrate();
     214        const Byte_t   ab   = fRawCrateArray->GetEntry(posinarray)->GetABFlags();
     215        for (int j=0; j<npic; j++)
     216        {
     217            // calc the spiral hardware pixel number
     218             const UShort_t ipos = posinarray*npic+j;
     219
     220            // Get Hardware Id
     221            const Short_t hwid = fRawRunHeader->GetPixAssignment(ipos);
     222
     223            // Check whether the pixel is connected or not
     224            if (hwid==0)
     225            {
     226                fin.seekg(nskip, ios::cur);
     227                continue;
     228            }
     229
     230            // -1 converts the hardware pixel Id into the software pixel index
     231            if (hwid>0)
     232                fRawEvtData1->ReadPixel(fin,   hwid-1,  TESTBIT(ab, j));
     233            else
     234                fRawEvtData2->ReadPixel(fin, -(hwid-1), TESTBIT(ab, j));
     235
     236        }
    200237        if (!fin)
    201238            return kFALSE;
     239
     240        posinarray++;
    202241    }
    203242
     
    226265    {
    227266        fRawCrateArray->GetEntry(i)->SkipEvt(fin, ver);
    228         fRawEvtData->SkipEvt(fin);
     267        fRawEvtData1->SkipEvt(fin);
    229268    }
    230269}
  • trunk/MagicSoft/Mars/mraw/MRawRead.h

    r4114 r4738  
    1818    MRawRunHeader  *fRawRunHeader;  // run header information container to fill from file
    1919    MRawEvtHeader  *fRawEvtHeader;  // event header information container to fill from file
    20     MRawEvtData    *fRawEvtData;    // raw evt header infomation container to fill from file
     20    MRawEvtData    *fRawEvtData1;   // raw evt data infomation container to fill from file
     21    MRawEvtData    *fRawEvtData2;   // raw evt data for pixels with negative indices
    2122    MRawCrateArray *fRawCrateArray; // crate information array container to fill from file
    2223    MTime          *fRawEvtTime;    // raw evt time information container to fill from file
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.cc

    r3734 r4738  
    2929// Root storage container for the RUN HEADER information
    3030//
     31//  Format Version 4:
     32//  -----------------
     33//   - added support for pixels with negative IDs
     34//
     35//  Format Version 3:
     36//  -----------------
     37//   - ???
     38//
    3139//  Format Version 2:
    3240//  -----------------
     
    6270
    6371const UShort_t MRawRunHeader::kMagicNumber      = 0xc0c0;
    64 const Byte_t   MRawRunHeader::kMaxFormatVersion =      3;
     72const Byte_t   MRawRunHeader::kMaxFormatVersion =      4;
    6573
    6674// --------------------------------------------------------------------------
     
    239247// Return the assigned pixel number for the given FADC channel
    240248//
    241 UShort_t MRawRunHeader::GetPixAssignment(UShort_t i) const
     249Short_t MRawRunHeader::GetPixAssignment(UShort_t i) const
    242250{
    243251    // FIXME: Do we need a range check here?
    244     return (*fPixAssignment)[i];
     252    return (Short_t)(*fPixAssignment)[i];
    245253}
    246254
     
    248256//
    249257// Return the number of pixel which are markes as connected in the
    250 // pix assignment (>0)
     258// pix assignment (!=0)
    251259//
    252260UShort_t MRawRunHeader::GetNumConnectedPixels() const
     261{
     262    const Int_t num = fPixAssignment->GetSize();
     263
     264    UShort_t rc = 0;
     265    for (int i=0; i<num; i++)
     266    {
     267        if (GetPixAssignment(i)!=0)
     268            rc++;
     269    }
     270    return rc;
     271}
     272
     273// --------------------------------------------------------------------------
     274//
     275// Return the number of pixel which are markes as connected and so-called
     276// 'normal' pixels in the pix assignment (>0)
     277//
     278UShort_t MRawRunHeader::GetNumNormalPixels() const
    253279{
    254280    const Int_t num = fPixAssignment->GetSize();
     
    265291// --------------------------------------------------------------------------
    266292//
     293// Return the number of pixel which are markes as connected and so-called
     294// 'special' pixels in the pix assignment (<0)
     295//
     296UShort_t MRawRunHeader::GetNumSpecialPixels() const
     297{
     298    const Int_t num = fPixAssignment->GetSize();
     299
     300    UShort_t rc = 0;
     301    for (int i=0; i<num; i++)
     302    {
     303        if (GetPixAssignment(i)<0)
     304            rc++;
     305    }
     306    return rc;
     307}
     308
     309// --------------------------------------------------------------------------
     310//
    267311// Return the maximum id which exists in the pix assignment
    268312//
     
    271315    const Int_t num = fPixAssignment->GetSize();
    272316
    273     UShort_t rc = 0;
     317    Short_t rc = 0;
    274318    for (int i=0; i<num; i++)
    275319        rc = TMath::Max(GetPixAssignment(i), rc);
    276320
    277321    return rc;
     322}
     323
     324// --------------------------------------------------------------------------
     325//
     326// Return minus th minimum id which exists in the pix assignment
     327//
     328UShort_t MRawRunHeader::GetMinPixId() const
     329{
     330    const Int_t num = fPixAssignment->GetSize();
     331
     332    Short_t rc = 0;
     333    for (int i=0; i<num; i++)
     334        rc = TMath::Min(GetPixAssignment(i), rc);
     335
     336    return (UShort_t)-rc;
    278337}
    279338
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r3734 r4738  
    9595    const MTime &GetRunStart() const      { return fRunStart; }
    9696    const MTime &GetRunEnd() const        { return fRunStop; }
    97     UShort_t GetPixAssignment(UShort_t i) const;
     97    Short_t GetPixAssignment(UShort_t i) const;
    9898    UShort_t GetMaxPixId() const;
     99    UShort_t GetMinPixId() const;
    99100    UShort_t GetNumConnectedPixels() const;
     101    UShort_t GetNumNormalPixels() const;
     102    UShort_t GetNumSpecialPixels() const;
    100103
    101104    UInt_t GetNumSamplesPerCrate() const
  • trunk/MagicSoft/Mars/mraw/MRawSocketRead.cc

    r4577 r4738  
    263263    //
    264264    fRawEvtHeader->InitRead(fRawRunHeader, fRawEvtTime);
    265     fRawEvtData  ->InitRead(fRawRunHeader, fRawCrateArray);
     265    fRawEvtData1 ->InitRead(fRawRunHeader);
     266    fRawEvtData2 ->InitRead(fRawRunHeader);
    266267
    267268    if (!ReadEvent(*fIn))
  • trunk/MagicSoft/Mars/readdaq.cc

    r2728 r4738  
    143143    plist.AddToList(&evtdata);
    144144
     145    MRawEvtData evtdata2("MRawEvtData2");
     146    plist.AddToList(&evtdata2);
     147
    145148    MRawCrateArray cratearray;
    146149    plist.AddToList(&cratearray);
     
    162165    MPrint print3("MRawCrateArray", "", "PrintCrateArray");
    163166    MPrint print4("MRawEvtData", kDecimal?"dec":"hex", "PrintEvtData");
     167    MPrint print5("MRawEvtData2", kDecimal?"dec":"hex", "PrintEvtData2");
    164168
    165169    tasks.AddToList(&print0);
     
    169173        tasks.AddToList(&print3);
    170174    tasks.AddToList(&print4);
     175    tasks.AddToList(&print5);
    171176
    172177    //
  • trunk/MagicSoft/Mars/readraw.cc

    r4576 r4738  
    169169    MTime          *evttime   = NULL;
    170170    MRawEvtData    *evtdata   = NULL;
     171    MRawEvtData    *evtdata2  = NULL;
    171172    MRawCrateArray *evtcrate  = NULL;
    172173    MMcEvt         *evtmc     = NULL;
     
    176177    EnableBranch(evttree, "MTime",          &evttime);
    177178    EnableBranch(evttree, "MRawEvtData",    &evtdata);
     179    EnableBranch(evttree, "MRawEvtData2",   &evtdata2);
    178180    EnableBranch(evttree, "MRawCrateArray", &evtcrate);
    179181    EnableBranch(evttree, "MMcEvt",         &evtmc);
     
    209211        if (evtdata)
    210212            evtdata->Print(kDecimal?"dec":"hex");
     213        if (evtdata2)
     214            evtdata2->Print(kDecimal?"dec":"hex");
    211215
    212216        gLog << endl;
Note: See TracChangeset for help on using the changeset viewer.