Ignore:
Timestamp:
04/15/07 10:38:08 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mmovie
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mmovie/MMovieData.h

    r8397 r8406  
    2323
    2424    Float_t fMax;
     25    Float_t fMedianPedestalRms;
    2526    UInt_t  fNumSlices;
    2627
     
    4142    Float_t GetMax() const { return fMax; }
    4243
     44    void SetMedianPedestalRms(Float_t m) { fMedianPedestalRms = m; }
     45    Float_t GetMedianPedestalRms() const { return fMedianPedestalRms; }
     46
    4347    void SetNumSlices(UInt_t n) { fNumSlices=n; }
    4448    UInt_t GetNumSlices() const { return fNumSlices; }
  • trunk/MagicSoft/Mars/mmovie/MMoviePrepare.cc

    r8397 r8406  
    4848//   MGeomCam
    4949//   MPedestalSubtractedEvt
     50//   MPedestalFundamental [MPedestalCam]
    5051//   MCalibrateData
    5152//   MCalibrationRelTimeCam
     
    7071#include "MGeomCam.h"
    7172#include "MGeomPix.h"
     73
     74#include "MPedestalCam.h"
     75#include "MPedestalPix.h"
     76
    7277
    7378#include "MCalibrationRelTimeCam.h"
     
    7883#include "MRawRunHeader.h"
    7984#include "MCalibrateData.h"
    80 //#include "MExtractedSignalCam.h"
    8185#include "MPedestalSubtractedEvt.h"
    8286
     
    111115//   MGeomCam
    112116//   MPedestalSubtractedEvt
     117//   MPedestalFundamental [MPedestalCam]
    113118//   MCalibrateData
    114119//   MCalibrationRelTimeCam
     
    132137        return kFALSE;
    133138    }
     139    fPed = (MPedestalCam*)plist->FindObject("MPedestalFundamental", "MPedestalCam");
     140    if (!fPed)
     141    {
     142        *fLog << err << "MPedestalFundamental [MPedestalCam] not found ... aborting." << endl;
     143        return kFALSE;
     144    }
    134145    fCal = (MCalibrateData*)plist->FindTaskListWithTask("MCalibrateData")->FindTask("MCalibrateData");
    135146    if (!fCal)
     
    184195    const MArrayF &calco = fCal->GetCalibConsts();
    185196
    186     Int_t n = fCam->GetNumPixWithArea(0);
    187 
    188     MArrayF calco0(n);
     197    Int_t n = fCam->GetNumPixWithAidx(0);
     198
     199    MArrayF arr(n);
    189200
    190201    for (UInt_t i=0; i<fCam->GetNumPixels(); i++)
    191202        if ((*fCam)[i].GetAidx()==0)
    192             calco0[--n] = calco[i];
    193 
    194     return TMath::Median(calco0.GetSize(), calco0.GetArray());
     203            arr[--n] = calco[i];
     204
     205    return TMath::Median(arr.GetSize(), arr.GetArray());
     206}
     207
     208// --------------------------------------------------------------------------
     209//
     210// Return the median of the pedestal rms of all pixels with area index 0
     211//
     212Double_t MMoviePrepare::GetMedianPedestalRms() const
     213{
     214    Int_t n = fCam->GetNumPixWithAidx(0);
     215
     216    MArrayF rms(n);
     217
     218    for (UInt_t i=0; i<fCam->GetNumPixels(); i++)
     219        if ((*fCam)[i].GetAidx()==0)
     220            rms[--n] = (*fPed)[i].GetPedestalRms();
     221
     222    return TMath::Median(rms.GetSize(), rms.GetArray());
    195223}
    196224
     
    252280    fOut->SetMax(max);
    253281    fOut->SetNumSlices(width);
     282    fOut->SetMedianPedestalRms(GetMedianPedestalRms());
    254283
    255284    return kTRUE;
  • trunk/MagicSoft/Mars/mmovie/MMoviePrepare.h

    r8397 r8406  
    99class MExtractor;
    1010class MMovieData;
    11 class MSignalCam;
    12 class MRawEvtHeader;
     11class MPedestalCam;
    1312class MRawRunHeader;
    1413class MCalibrateData;
     
    2423    MRawRunHeader          *fRun;    //! Run Header (sampling frequency)
    2524    MGeomCam               *fCam;    //! Pixel size
    26 //    MCalibConstCam         *fCal;
     25    MPedestalCam           *fPed;    //! Fundamental pedestal (slice by slice)
    2726
    2827    MMovieData             *fOut;    //! Prepared output container
     
    3130    UInt_t fLastSlice;
    3231
    33     //Float_t fSlope;
    34 
    3532    // MTask
    3633    Int_t  PreProcess(MParList *plist);
    37     //Bool_t ReInit(MParList *plist);
    3834    Int_t  Process();
    3935
     
    4339    // MMoviePrepare
    4440    Double_t GetMedianCalibConst() const;
     41    Double_t GetMedianPedestalRms() const;
    4542
    4643public:
     
    5350
    5451#endif
    55 
  • trunk/MagicSoft/Mars/mmovie/MMovieWrite.cc

    r8397 r8406  
    6060//
    6161//  The interpolation of the frames is done using a TSpline3. If the spline
    62 //  would extrapolate the contents is set to zero. Unsuitable pixels are
    63 //  interpolated frame by frame using the surrounding suitable pixels.
    64 //
    65 //
    66 // Input:
    67 //   - MGeomCam
    68 //   - MRawRunHeader
    69 //   - MRawEvtHeader
    70 //   - MSignalCam
    71 //   - MBadPixelsCam
    72 //   - MPedestalFundamental [MPedestalCam]
    73 //   - MMovieData
     62//  would extrapolate due to the shift by the relative time calibration the
     63//  contents is set to zero. Unsuitable pixels are interpolated frame by
     64//  frame using the surrounding suitable pixels.
     65//
     66//  A few words about file size: MPEG is a motion compensation compression,
     67//  which means that if a region of a past frame is shown again at the same
     68//  place or somewhere else this region is referenced instead of encoded again.
     69//  This means that in our case (almost all frames are identical!) the
     70//  increase of file size is far from linear with the number of encoded events!
     71//
     72//
     73//  Input:
     74//   MGeomCam
     75//   MRawRunHeader
     76//   MRawEvtHeader
     77//   MSignalCam
     78//   MBadPixelsCam
     79//   MMovieData
    7480//
    7581/////////////////////////////////////////////////////////////////////////////
     
    9197#include "MGeomCam.h"
    9298#include "MGeomPix.h"
    93 
    94 #include "MPedestalCam.h"
    95 #include "MPedestalPix.h"
    9699
    97100#include "MH.h"
     
    117120//
    118121MMovieWrite::MMovieWrite(const char *name, const char *title)
    119     : fPipe(0), fTargetLength(5), fThreshold(2), fNumEvents(1000), fFilename("movie.mpg")
     122    : fPipe(0), fTargetLength(5), fThreshold(2), fNumEvents(25000), fFilename("movie.mpg")
    120123{
    121124    fName  = name  ? name  : "MMovieWrite";
     
    172175
    173176    fPipe = gSystem->OpenPipe(name, "w");
    174     if (fPipe)
    175         return kTRUE;
    176 
    177     *fLog << err;
    178     *fLog << "Pipe: " << name << endl;
    179     *fLog << "Couldn't open pipe... aborting." << endl;
    180     CheckPipe();
    181     return kFALSE;
     177    if (!fPipe)
     178    {
     179        *fLog << err;
     180        *fLog << "Pipe: " << name << endl;
     181        *fLog << "Couldn't open pipe... aborting." << endl;
     182        CheckPipe();
     183        return kFALSE;
     184    }
     185
     186    *fLog << inf << "Setup pipe to ppmtoy4m and mpeg2enc to encode " << fFilename << "." << endl;
     187
     188    return kTRUE;
    182189
    183190    //  1: 37M name += "-f 9 -E 40 -H -4 1 -2 1 --dualprime-mpeg2";
     
    229236//   - MSignalCam
    230237//   - MBadPixelsCam
    231 //   - MPedestalFundamental [MPedestalCam]
    232238//   - MMovieData
    233239//
     
    265271    {
    266272        *fLog << err << "MBadPixelsCam not found ... aborting." << endl;
    267         return kFALSE;
    268     }
    269     fPed = (MPedestalCam*)plist->FindObject("MPedestalFundamental", "MPedestalCam");
    270     if (!fPed)
    271     {
    272         *fLog << err << "MPedestalFundamental [MPedestalCam] not found ... aborting." << endl;
    273273        return kFALSE;
    274274    }
     
    317317// and everything above gets colors.
    318318//
    319 void MMovieWrite::SetPalette(Double_t rms, const TH1 &h) const
     319Int_t MMovieWrite::SetPalette(Double_t rms, const TH1 &h) const
    320320{
    321321    const Double_t min = h.GetMinimum();
     
    335335
    336336    TArrayI col(99);
    337     gStyle->CreateGradientColorTable(6, s, r, g, b, col.GetSize());
     337
     338    const Int_t rc = gStyle->CreateGradientColorTable(6, s, r, g, b, col.GetSize());
    338339
    339340    // --- Overwrite the 'underflow' bin with white ---
     
    347348
    348349    gStyle->SetPalette(col.GetSize(), col.GetArray());
     350
     351    return rc;
     352}
     353
     354// --------------------------------------------------------------------------
     355//
     356// The created colors are not overwritten and must be deleted manually
     357// because having more than 32768 color in a palette will crash
     358// gPad->PaintBox
     359//
     360void MMovieWrite::DeletePalette(Int_t colidx) const
     361{
     362    for (int i=0; i<99; i++)
     363    {
     364        TColor *col = gROOT->GetColor(colidx+i);
     365        if (col)
     366            delete col;
     367    }
    349368}
    350369
     
    563582// --------------------------------------------------------------------------
    564583//
    565 // Return the median of the pedestal rms of all pixels with area index 0
    566 //
    567 Double_t MMovieWrite::GetMedianPedestalRms() const
    568 {
    569     Int_t n = fCam->GetNumPixWithAidx(0);
    570 
    571     MArrayF rms(n);
    572 
    573     for (UInt_t i=0; i<fCam->GetNumPixels(); i++)
    574         if ((*fCam)[i].GetAidx()==0)
    575             rms[--n] = (*fPed)[i].GetPedestalRms();
    576 
    577     return TMath::Median(rms.GetSize(), rms.GetArray());
    578 }
    579 
    580 // --------------------------------------------------------------------------
    581 //
    582584Bool_t MMovieWrite::Process(TH1 &h, TVirtualPad &c)
    583585{
     
    589591    //const Float_t len    = (slices-2)/freq;               // [ns]  length of data stream in data-time
    590592
    591     const Double_t rms = GetMedianPedestalRms();
     593    const Double_t rms = fIn->GetMedianPedestalRms();
    592594
    593595    h.SetMinimum(fIn->GetMax()-(fIn->GetMax()-rms)*99/98); // rms0
     
    601603
    602604    // Set new adapted palette for further rendering
    603     SetPalette(rms, h);
     605    const Int_t colidx = SetPalette(rms, h);
    604606
    605607    // Get the pad containing the camera with the movie
     
    638640            return kFALSE;
    639641    }
     642
     643    DeletePalette(colidx);
    640644
    641645    cout << setw(3) << GetNumExecutions() << ": " << Form("%6.2f", (float)numframes/(slices-2)) << " f/sl " << slices << " " << numframes+1 << endl;
  • trunk/MagicSoft/Mars/mmovie/MMovieWrite.h

    r8397 r8406  
    5454    void TreatBadPixels(TH1 &h) const;
    5555
    56     void SetPalette(Double_t rms, const TH1 &h) const;
     56    Int_t SetPalette(Double_t rms, const TH1 &h) const;
     57    void DeletePalette(Int_t colidx) const;
    5758
    5859    void UpdateImage(TASImage &img, TVirtualPad &pad);
Note: See TracChangeset for help on using the changeset viewer.