Changeset 8406


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r8405 r8406  
    1919                                                 -*-*- END OF LINE -*-*-
    2020
     21 2007/04/15 Thomas Bretz
     22
     23   * callisto.cc:
     24     - added an option to write a movie
     25
     26   * mjobs/MJCalibrateSignal.[h,cc]:
     27     - added the code to write a movie
     28     - added new option (fIsMovieMode) to switch it on and off
     29
     30   * mmovie/MMovieData.h:
     31     - added data member fMedianPedestalRms
     32
     33   * mmovie/MMoviePrepare.[h,cc]:
     34     - added calculation of median pedestal rms
     35
     36   * mmovie/MMovieWrite.[h,cc]:
     37     - added comments
     38     - added return value to SetPalette
     39     - delete palette entries after usage
     40     - get median pedestal rms from MMovieData
     41
     42
     43
    2144 2007/04/12 Daniela Dorner
    2245
     
    77100     movie/MovieIncl.h:
    78101     - added
     102
     103   * mbase/MArrayB.h, mbase/MArrayD.h, mbase/MArrayF.h, mbase/MArrayI.h,
     104     mbase/MArrayS.h:
     105     - added Reset() member function or improved performance of it
     106
     107   * mcalib/MCalibrationChargeCalc.cc:
     108     - fixed the alignment in an output
     109
     110   * mhbase/MBinning.h:
     111     - added operator[] member function
     112
     113   * mhist/MHCamera.cc:
     114     - changed such that it is allowed to use palettes with a different
     115       number of contours.
     116     - fixed the number of ticks written on the axis to 25
     117     - use MBinnig to calculate the legend color boxes
     118     - fixed a minor bug in the assignment of the color levels, which
     119       gave visibly wrong result if the transition between two colors
     120       was important but was not noticable in normal circumstances
     121
     122   * mjobs/MDataSet.h, mjobs/MSequence.h:
     123     - increased class version to 1 to make it writable
     124     - added Print to the context menu
     125
     126   * mgeom/MGeomCam.[h,cc]:
     127     - removed fNumSectors
     128     - removed fNumAreas
     129     - added fNumPixInSector
     130     - added fNumPixWithAidx
     131     - changed CalcSectors and CalcArea to fill new data members
     132     - fixed a bug in the range check of GetMaxRadius and GetMinRadius
     133       (the range was to wide by 1 at the upper edge)
     134     - increased class version from 4 to 5
    79135
    80136
  • trunk/MagicSoft/Mars/callisto.cc

    r8245 r8406  
    8383    gLog << "   --use-test                Apply calibration constants to same calibration" << endl;
    8484    gLog << "                             file (for testing, calibration mode only)" << endl;
     85    gLog << "   --movie                   Write a movie in addition to Mode-Y (this might " << endl;
     86    gLog << "                             stop the eventloop before all evts are processed)" << endl;
    8587    gLog << "   --moon                    Force using pedestal fits instead of calculated RMS" << endl;
    8688    gLog << "   --config=callisto.rc      Resource file [default=callisto.rc]" << endl;
     
    170172    const Bool_t  kPrintFound = arg.HasOnlyAndRemove("--print-found");
    171173    const Bool_t  kUseTest    = arg.HasOnlyAndRemove("--use-test");
     174    const Bool_t  kMovie      = arg.HasOnlyAndRemove("--movie");
    172175    const Bool_t  kDebugMem   = arg.HasOnlyAndRemove("--debug-mem");
    173176          Bool_t  kMoon       = arg.HasOnlyAndRemove("--moon");
     
    225228        gLog <<        "specified! You can also give the operation mode by the options defining the" << endl;
    226229        gLog <<        "output path --outc, --outy or --out." << endl;
     230        Usage();
     231        return 2;
     232    }
     233    if (!kModeY && kMovie)
     234    {
     235        gLog << err << "Signal extraction mode (-y) not switched on but movie requested." << endl;
    227236        Usage();
    228237        return 2;
     
    626635        job4.SetPathOut(kOutpathY);
    627636        job4.SetDataType(kDataType);
     637        job4.SetMovieMode(kMovie);
    628638        if (kDataType!=MJCalib::kIsUseMC)
    629639            job4.SetExtractor(job2.GetExtractor());
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.cc

    r8396 r8406  
    112112#include "MWriteRootFile.h"
    113113
    114 /*
    115  #include "MFEvtNumber.h"
    116  #include "MMoviePrepare.h"
    117  #include "MMovieWrite.h"
    118  #include "MImgCleanStd.h"
    119  */
     114#include "MFEvtNumber.h"
     115#include "MMoviePrepare.h"
     116#include "MMovieWrite.h"
     117#include "MImgCleanStd.h"
    120118
    121119ClassImp(MJCalibrateSignal);
     
    134132//
    135133MJCalibrateSignal::MJCalibrateSignal(const char *name, const char *title)
    136     : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kFALSE)
     134    : fExtractor(0), fIsInterlaced(kTRUE), fIsRelTimesUpdate(kFALSE), fIsMovieMode(kFALSE)
    137135{
    138136    fName  = name  ? name  : "MJCalibrateSignal";
     
    224222    SetInterlaced(GetEnv("Interlaced", fIsInterlaced));
    225223    SetRelTimesUpdate(GetEnv("RelTimesUpdate", fIsRelTimesUpdate));
     224    SetMovieMode(GetEnv("MovieMode", fIsMovieMode));
    226225
    227226    return MJCalib::CheckEnvLocal();
     
    802801
    803802     tlist2.AddToList(&fillP);
    804 
    805      // --- Start: Code for encoding movies ---
    806 
    807      MMoviePrepare movprep;
    808      MMovieWrite   movwrite;
    809      movprep.SetRangeFromExtractor(*extractor1);
    810 
    811      MFDataPhrase movfilt("MMovieData.fMax>150");
    812 
    813      MImgCleanStd movclean(8.5, 4.0);
    814      movclean.SetMethod(MImgCleanStd::kAbsolute);
    815 
    816      //movprep.SetFilter(&evtnum);
    817      movclean.SetFilter(&movfilt);
    818      movwrite.SetFilter(&movfilt);
    819 
    820      MTaskList tlistmov;
    821      tlistmov.AddToList(&movprep);
    822      tlistmov.AddToList(&movfilt);
    823      tlistmov.AddToList(&movclean);
    824      tlistmov.AddToList(&movwrite);
    825 
    826      MFEvtNumber evtnum;
    827      //evtnum.SetFileName("ganymed00000001.root");
    828      tlistmov.SetFilter(&evtnum);
    829 
    830      //tlist2.AddToList(&evtnum);
    831      //tlist2.AddToList(&tlistmov);
    832 
    833      // --- End: Code for encoding movies ---
    834803     */
     804
     805    // ----- Start: Code for encoding movies -----
     806
     807    MMoviePrepare movprep;
     808    MMovieWrite   movwrite;
     809    movprep.SetRangeFromExtractor(*extractor1);
     810
     811    //MFDataPhrase movfilt("MMovieData.fMax>150");
     812    MFDataPhrase movfilt("MMovieData.fMax>5*MMovieData.fMedianPedestalRms", "MovieFilter");
     813
     814    MImgCleanStd movclean(8.5, 4.0);
     815    movclean.SetMethod(MImgCleanStd::kAbsolute);
     816
     817    //movprep.SetFilter(&evtnum);
     818    movclean.SetFilter(&movfilt);
     819    movwrite.SetFilter(&movfilt);
     820
     821    MTaskList tlistmov;
     822    tlistmov.AddToList(&movprep);
     823    tlistmov.AddToList(&movfilt);
     824    tlistmov.AddToList(&movclean);
     825    tlistmov.AddToList(&movwrite);
     826
     827    MFEvtNumber evtnum;
     828    //evtnum.SetSelector("ThetaSquared.fVal<0.04");
     829    //evtnum.SetFileName("ganymed00000001.root");
     830    tlistmov.SetFilter(&evtnum);
     831
     832    if (fIsMovieMode)
     833    {
     834        tlist2.AddToList(&evtnum);
     835        tlist2.AddToList(&tlistmov);
     836    }
     837
     838    // ----- End: Code for encoding movies -----
    835839
    836840    tlist2.AddToList(&fillflorian);
  • trunk/MagicSoft/Mars/mjobs/MJCalibrateSignal.h

    r6979 r8406  
    2424    Bool_t fIsInterlaced;               // Distinguish interlaced from other calibration
    2525    Bool_t fIsRelTimesUpdate;           // Choose to update relative times from interlaced
    26    
     26    Bool_t fIsMovieMode;                // Choose to encode a movie
     27
    2728    Bool_t CheckEnvLocal();
    2829
     
    3738   
    3839public:
    39 
    4040    MJCalibrateSignal(const char *name=NULL, const char *title=NULL);
    4141    ~MJCalibrateSignal();
     
    4343    Bool_t Process(MPedestalCam &camab, MPedestalCam &cam1, MPedestalCam &cam2);
    4444
    45     void SetInterlaced     ( const Bool_t b=kTRUE )  { fIsInterlaced      = b; }
    46     void SetRelTimesUpdate ( const Bool_t b=kTRUE )  { fIsRelTimesUpdate  = b; }
     45    void SetInterlaced    (const Bool_t b=kTRUE) { fIsInterlaced     = b; }
     46    void SetRelTimesUpdate(const Bool_t b=kTRUE) { fIsRelTimesUpdate = b; }
     47    void SetMovieMode     (const Bool_t b=kTRUE) { fIsMovieMode      = b; }
    4748
    4849    void SetExtractor(const MExtractor *ext=NULL);
  • 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.