Changeset 4702


Ignore:
Timestamp:
08/23/04 11:41:30 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r4700 r4702  
    3434   * mimage/MHHillas.[h,cc]:
    3535     - added display of camera on top of MeanXY-plot
     36
     37   * mraw/MRawSocketRead.h:
     38     - added GetFileName()
     39
     40   * manalysis/MCerPhotEvt.[h,cc]:
     41     - added new data member fNumIslands
     42     - added new functions (CalcIsland/CalcIslands to calculate islands)
     43     - added new member function to sort pixels by index
     44     - added island index in GetPixelContent
     45     - increased version number
     46
     47   * manalysis/MCerPhotPix.[h,cc]:
     48     - added fIdxIsland data member
     49     - overloaded Compare function to be able to sort by pixel index
     50     - increased version number
     51
     52   * mhist/MHEvent.[h,cc]:
     53     - added new option for island index
     54
     55   * mimage/MImgCleanStd.[h,cc]:
     56     - added island calculation after image cleaning
     57     - fixed some output to be consistent
     58     - added ReadEnv
     59     - updated StreamPrimitive
     60
     61   * mimage/Makefile:
     62     - added mhist
     63
     64   * mmain/MEventDisplay.cc:
     65     - added display of island index
    3666
    3767
  • trunk/MagicSoft/Mars/NEWS

    r4694 r4702  
    1616
    1717   - Implemented automatic file splitting in MWriteRootFile
     18
     19   - After image cleaning an island index is assigned to all used pixels.
     20     The index corresponds to the order of the islands in size.
    1821
    1922
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r3734 r4702  
    3131//       risk!
    3232//
     33// Class Version 3:
     34// ----------------
     35//  - added fNumIslands
     36//           
    3337// Class Version 2:
    3438// ----------------
     
    4650#include <fstream>
    4751
     52#include <TArrayD.h>
    4853#include <TCanvas.h>
    4954
     
    5257
    5358#include "MGeomCam.h"
     59#include "MGeomPix.h"
    5460
    5561ClassImp(MCerPhotEvt);
     
    96102void MCerPhotEvt::Reset()
    97103{
    98     fNumPixels =  0;
    99     fMaxIndex  = -1;
     104    fNumPixels  =  0;
     105    fMaxIndex   = -1;
     106    fNumIslands = -1;
    100107    fLut.Set(0);
    101108    // fPixels->Delete();
     
    346353void MCerPhotEvt::RemoveUnusedPixels()
    347354{
     355    // Create iterator
    348356    TIter Next(fPixels);
    349357    MCerPhotPix *pix = NULL;
    350358
     359    fMaxIndex = -1;
     360
     361    // Remove all unused pixels from list, calculate new fMaxIndex
    351362    while ((pix=(MCerPhotPix*)Next()))
     363    {
    352364        if (!pix->IsPixelUsed())
    353365            fPixels->Remove(pix);
    354 
     366        else
     367            fMaxIndex = TMath::Max(fMaxIndex, pix->GetPixId());
     368    }
     369
     370    // Crompress array
    355371    fPixels->Compress();
     372
     373    // Get new number of entries in array
    356374    fNumPixels=fPixels->GetEntriesFast();
     375
     376    // Rebuild lookup table
     377    RebuildLut();
    357378}
    358379
     
    409430// --------------------------------------------------------------------------
    410431//
     432// This function recursively finds all pixels of one island and assigns
     433// the number num as island number to the pixel.
     434//
     435//  1) Check whether a pixel with the index idx exists, is unused
     436//     and has not yet a island number assigned.
     437//  2) Assign the island number num to the pixel
     438//  3) Loop over all its neighbors taken from the geometry geom. For all
     439//     neighbors recursively call this function (CalcIsland)
     440//  4) Sum the size of the pixel and all neighbors newly assigned
     441//     (by CalcIsland) to this island
     442//
     443// Returns the sum of the pixel size.
     444//
     445Double_t MCerPhotEvt::CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num)
     446{
     447    // Try to get the pixel information of a pixel with this index
     448    MCerPhotPix *pix = GetPixById(idx);
     449
     450    // If a pixel with this index is not existing... do nothing.
     451    if (!pix)
     452        return 0;
     453
     454    // If an island number was already assigned to this pixel... do nothing.
     455    if (pix->GetIdxIsland()>=0)
     456        return 0;
     457
     458    // If the pixel is an unused pixel... do nothing.
     459    if (!pix->IsPixelUsed())
     460        return 0;
     461
     462    // Assign the new island number num to this used pixel
     463    pix->SetIdxIsland(num);
     464
     465    // Get the geometry information (neighbors) of this pixel
     466    const MGeomPix &gpix = geom[idx];
     467
     468    // Get the size of this pixel
     469    Double_t size = pix->GetNumPhotons();
     470
     471    // Now do the same with all its neighbors and sum the
     472    // sizes which they correspond to
     473    const Int_t n = gpix.GetNumNeighbors();
     474    for (int i=0; i<n; i++)
     475        size += CalcIsland(geom, gpix.GetNeighbor(i), num);
     476
     477    // return size of this (sub)cluster
     478    return size;
     479}
     480
     481// --------------------------------------------------------------------------
     482//
     483// Each pixel which is maked as used is assigned an island number
     484// (starting from 0). A pixel without an island number assigned
     485// has island number -1.
     486//
     487// The index 0 corresponds to the island with the highest size (sum
     488// of GetNumPhotons() in island). The size is decreasing with
     489// increasing indices.
     490//
     491// The information about pixel neighbory is taken from the geometry
     492// MGeomCam geom;
     493//
     494// You can access this island number of a pixel with a call to
     495// MCerPhotPix->GetIdxIsland. The total number of islands available
     496// can be accessed with MCerPhotEvt->GetNumIslands.
     497//
     498// CalcIslands returns the number of islands found. If an error occurs,
     499// eg the geometry has less pixels than the highest index stored, -1 is
     500// returned.
     501//
     502Int_t MCerPhotEvt::CalcIslands(const MGeomCam &geom)
     503{
     504    if (fMaxIndex<0 || fNumPixels<=0)
     505    {
     506        *fLog << err << "ERROR - MCerPhotEvt doesn't contain pixels!" << endl;
     507        fNumIslands = 0;
     508        return -1;
     509    }
     510
     511    if ((UInt_t)fMaxIndex>=geom.GetNumPixels())
     512    {
     513        *fLog << err << "ERROR - MCerPhotEvt::CalcIslands: Size mismatch - geometry too small!" << endl;
     514        return -1;
     515    }
     516
     517    // Create a list to hold the sizes of the islands (The maximum
     518    // number of islands possible is rougly fNumPixels/4)
     519    TArrayD size(fNumPixels/3);
     520
     521    // Calculate Islands
     522    Int_t n=0;
     523
     524    // We could loop over all indices which looks more straight
     525    // forward but should be a lot slower (assuming zero supression)
     526    MCerPhotPix *pix=0;
     527
     528    TIter Next(*this);
     529    while ((pix=static_cast<MCerPhotPix*>(Next())))
     530    {
     531        // This 'if' is necessary (although it is done in GetIsland, too)
     532        // because otherwise the counter (n) would be wrong.
     533        // So only 'start' a new island for used pixels (selected by
     534        // using the Iterator) which do not yet belong to another island.
     535        if (pix->GetIdxIsland()<0)
     536        {
     537            Double_t sz = CalcIsland(geom, pix->GetPixId(), n);
     538            size[n++] = sz;
     539        }
     540    }
     541
     542    // Create an array holding the indices
     543    TArrayI idx(n);
     544
     545    // Sort the sizes descending
     546    TMath::Sort(n, size.GetArray(), idx.GetArray(), kTRUE);
     547
     548    // Replace island numbers by size indices -- After this
     549    // islands indices are sorted by the island size
     550    Next.Reset();
     551    while ((pix=static_cast<MCerPhotPix*>(Next())))
     552    {
     553        const Short_t i = pix->GetIdxIsland();
     554
     555        // Find new index
     556        Short_t j;
     557        for (j=0; j<n; j++)
     558            if (idx[j]==i)
     559                break;
     560
     561        pix->SetIdxIsland(j==n ? -1 : j);
     562    }
     563
     564    // Now assign number of islands found
     565    fNumIslands = n;
     566
     567    // return number of island
     568    return fNumIslands;
     569}
     570
     571// --------------------------------------------------------------------------
     572//
    411573// Returns, depending on the type flag:
    412574//
     
    416578//  3: Number of Photons
    417579//  4: Error
     580//  5: Island index
    418581//
    419582Bool_t MCerPhotEvt::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
     
    442605        val = pix->GetErrorPhot();
    443606        break;
     607    case 5:
     608        val = pix->GetIdxIsland();
     609        break;
    444610    default:
    445611        val = pix->GetNumPhotons()*ratio;
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r3734 r4702  
    2424private:
    2525    UInt_t        fNumPixels;
     26    Short_t       fNumIslands;
    2627     Int_t        fMaxIndex;
    2728    TArrayI       fLut;        // Lookup tabel to lookup pixel by index
    2829    TClonesArray *fPixels;     //-> FIXME: Change TClonesArray away from a pointer?
     30
     31    void RebuildLut()
     32    {
     33        // Resize Lut
     34        fLut.Set(fMaxIndex+1);
     35
     36        // Reset Lut
     37        fLut.Reset(-1);
     38
     39        // Rebuild Lut
     40        for (UInt_t i=0; i<GetNumPixels(); i++)
     41        {
     42            const MCerPhotPix &pix = (*this)[i];
     43            fLut[pix.GetPixId()] = i;
     44        }
     45    }
     46
     47    Double_t CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num);
    2948
    3049public:
     
    3251    ~MCerPhotEvt() { delete fPixels; }
    3352
    34     UInt_t GetNumPixels() const { return fNumPixels; }
    35     //void   InitSize(UInt_t num) { fPixels->Expand(num); }
     53    // Setter function to fill pixels
     54    MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0);
     55    void FixSize();
    3656
    37     MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0);
    38 
    39     void FixSize();
     57    // Getter functions
     58    UInt_t  GetNumPixels() const { return fNumPixels; }
     59    Short_t GetNumIslands() const { return fNumIslands; };
    4060
    4161    Bool_t  IsPixelExisting(Int_t id) const;
     
    5272    Float_t GetErrorPhotMax(const MGeomCam *geom=NULL) const;
    5373
     74    // Getter functions to access single pixels
    5475    MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
    5576    MCerPhotPix &operator[](int i) const { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
    5677
     78    MCerPhotPix *GetPixById(Int_t idx) const;
     79
     80    // Functions to change the contained data
    5781    void Scale(Double_t f) { fPixels->ForEach(MCerPhotPix, Scale)(f); }
    5882    void RemoveUnusedPixels();
     83    Int_t CalcIslands(const MGeomCam &geom);
     84    void Sort(Int_t upto = kMaxInt)
     85    {
     86        // Sort pixels by index
     87        fPixels->Sort(upto);
     88        RebuildLut();
     89    } // For convinience: Sort pixels by index
    5990
    60     MCerPhotPix *GetPixById(Int_t idx) const;
    61 
     91    // class MParContainer
    6292    void Reset();
    6393
     94    // class TObject
    6495    void Print(Option_t *opt=NULL) const;
    6596    void Clear(Option_t *opt=NULL) { Reset(); }
     
    69100    void DrawPixelContent(Int_t num) const;
    70101
     102    // To build an iterator for this class
    71103    operator TIterator*() const;
    72104
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.cc

    r3751 r4702  
    4545//  - added fIsHGSaturated
    4646//
     47// Version 5:
     48// ----------
     49//  - added fIdxIsland
     50//
    4751////////////////////////////////////////////////////////////////////////////
    4852#include "MCerPhotPix.h"
     
    6064//
    6165MCerPhotPix::MCerPhotPix(Int_t pix, Float_t phot, Float_t errphot) :
    62     fPixId(pix), fRing(1), fIsCore(kFALSE), fPhot(phot), fErrPhot(errphot),
     66    fPixId(pix), fIsCore(kFALSE), fRing(1), fIdxIsland(-1),
     67    fPhot(phot), fErrPhot(errphot),
    6368    fIsSaturated(kFALSE), fIsHGSaturated(kFALSE)
    6469{
    6570}
     71
     72// --------------------------------------------------------------------------
     73//
     74// From TObject:
     75//  Compare abstract method. Must be overridden if a class wants to be able
     76//  to compare itself with other objects. Must return -1 if this is smaller
     77//  than obj, 0 if objects are equal and 1 if this is larger than obj.
     78//
     79// Here:
     80//  Index numbers are compared
     81//
     82Int_t MCerPhotPix::Compare(const TObject *o) const
     83{
     84    const Int_t diff = fPixId - static_cast<const MCerPhotPix*>(o)->fPixId;
     85    return diff==0 ? 0 : TMath::Sign(1, diff);
     86}
    6687
    6788// --------------------------------------------------------------------------
  • trunk/MagicSoft/Mars/manalysis/MCerPhotPix.h

    r3751 r4702  
    1212    Int_t    fPixId;     // the pixel Id
    1313
    14    Short_t fRing;      // NT: number of analyzed rings around the core pixels, fRing>0 means: used, fRing= 0 means: unused, fRing= -1 means: unmapped (no possible to use in the calculation of the image parameters)
    15     Bool_t   fIsCore;    // the pixel is a Core pixel -> kTRUE
     14    Bool_t   fIsCore;     // the pixel is a Core pixel -> kTRUE
     15    Short_t  fRing;       // NT: number of analyzed rings around the core pixels, fRing>0 means: used, fRing= 0 means: unused, fRing= -1 means: unmapped (no possible to use in the calculation of the image parameters)
     16    Short_t  fIdxIsland;  // the pixel is a Core pixel -> kTRUE
    1617
    1718    Float_t  fPhot;      // The number of Cerenkov photons
     
    2627    MCerPhotPix(Int_t pix=-1, Float_t phot=0, Float_t errphot=0);
    2728
    28     Int_t    GetPixId() const            { return fPixId;   }
    29     Float_t  GetNumPhotons() const       { return fPhot;    }
    30     Float_t  GetErrorPhot() const        { return fErrPhot; }
     29    Int_t   GetPixId() const            { return fPixId;   }
     30    Float_t GetNumPhotons() const       { return fPhot;    }
     31    Float_t GetErrorPhot() const        { return fErrPhot; }
    3132   
    32     Bool_t   IsPixelUsed() const         { return fRing>0; }
    33     Bool_t   IsPixelUnmapped() const     { return fRing==-1; }
    34     void     SetPixelUnused()            { fRing=0; }
    35     void     SetPixelUsed()              { fRing=1; }
    36     void     SetPixelUnmapped()          { fRing=-1;}
     33    Bool_t  IsPixelUsed() const         { return fRing>0; }
     34    Bool_t  IsPixelUnmapped() const     { return fRing==-1; }
     35    void    SetPixelUnused()            { fRing=0; }
     36    void    SetPixelUsed()              { fRing=1; }
     37    void    SetPixelUnmapped()          { fRing=-1;}
     38    void    SetIdxIsland(Short_t num)   { fIdxIsland=num; }
     39    Short_t GetIdxIsland() const        { return fIdxIsland; }
    3740
    38     void     SetRing(UShort_t r)         { fRing = r;   }
    39     Short_t  GetRing() const             { return fRing;}
     41    void    SetRing(UShort_t r)         { fRing = r;   }
     42    Short_t GetRing() const             { return fRing;}
    4043
    41     void     SetPixelCore()              { fIsCore = kTRUE; }
    42     Bool_t   IsPixelCore() const         { return fIsCore;  }
     44    void    SetPixelCore()              { fIsCore = kTRUE; }
     45    Bool_t  IsPixelCore() const         { return fIsCore;  }
    4346
    44     void     SetNumPhotons(Float_t f)    { fPhot    = f; }
    45     void     SetErrorPhot(Float_t f)     { fErrPhot = f; }
    46     void     Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
     47    void    SetNumPhotons(Float_t f)    { fPhot    = f; }
     48    void    SetErrorPhot(Float_t f)     { fErrPhot = f; }
     49    void    Set(Float_t np, Float_t ep) { fPhot = np; fErrPhot = ep; }
    4750
    48     void     SetPixelSaturated()         { fIsSaturated = kTRUE; }
    49     Bool_t   IsPixelSaturated() const    { return fIsSaturated; }
     51    void    SetPixelSaturated()         { fIsSaturated = kTRUE; }
     52    Bool_t  IsPixelSaturated() const    { return fIsSaturated; }
    5053
    51     void     SetPixelHGSaturated()         { fIsHGSaturated = kTRUE; }
    52     Bool_t   IsPixelHGSaturated() const    { return fIsHGSaturated; }
     54    void    SetPixelHGSaturated()       { fIsHGSaturated = kTRUE; }
     55    Bool_t  IsPixelHGSaturated() const  { return fIsHGSaturated; }
    5356
    54     void     AddNumPhotons(Float_t f)    { fPhot += f; }
     57    void    AddNumPhotons(Float_t f)    { fPhot += f; }
    5558
    56     void     Scale(Float_t f)            { fPhot/=f; }
     59    void    Scale(Float_t f)            { fPhot/=f; }
    5760
    58     void     Print(Option_t *opt = NULL) const;
     61    void    Print(Option_t *opt = NULL) const;
     62    Int_t   Compare(const TObject *obj) const;
     63    Bool_t  IsSortable() const { return kTRUE; }
    5964
    60     ClassDef(MCerPhotPix, 4)  // class containing information about the Cerenkov Photons in a pixel
     65    ClassDef(MCerPhotPix, 5)  // class containing information about the Cerenkov Photons in a pixel
    6166};
    6267
  • trunk/MagicSoft/Mars/mhist/MHEvent.cc

    r3795 r4702  
    9696    fMcEvt       = (MMcEvt*)plist->FindObject("MMcEvt");
    9797
    98      fRawEvtData = (MRawEvtData*)plist->FindObject("MRawEvtData");
    99      if (!fRawEvtData)
     98    fRawEvtData = (MRawEvtData*)plist->FindObject("MRawEvtData");
     99    if (!fRawEvtData)
    100100        *fLog << warn << "MRawEvtData not found..." << endl;
    101101
     
    165165        fHist->SetName("Triggered pix");
    166166        fHist->SetYTitle("ON/OFF");
     167        fHist->SetPrettyPalette();
     168        break;
     169     case kEvtIslandIndex:
     170        fHist->SetName("Island Index");
     171        fHist->SetYTitle("Index");
    167172        fHist->SetPrettyPalette();
    168173        break;
     
    224229    case kEvtTrigPix:
    225230        fHist->SetCamContent(*event, 0);
     231        break;
     232    case kEvtIslandIndex:
     233        fHist->SetCamContent(*event, 5);
    226234        break;
    227235    }
  • trunk/MagicSoft/Mars/mhist/MHEvent.h

    r4524 r4702  
    2222        kEvtSignalRaw, kEvtSignalDensity, kEvtPedestal,
    2323        kEvtPedestalRMS, kEvtRelativeSignal, kEvtCleaningLevels,
    24         kEvtIdxMax, kEvtArrTime, kEvtTrigPix 
     24        kEvtIdxMax, kEvtArrTime, kEvtTrigPix, kEvtIslandIndex
    2525    };
    2626
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc

    r4608 r4702  
    250250#include <fstream>        // ofstream, SavePrimitive
    251251
     252#include <TEnv.h>
     253
    252254#include <TGFrame.h>      // TGFrame
    253255#include <TGLabel.h>      // TGLabel
     
    279281static const TString gsDefName  = "MImgCleanStd";
    280282static const TString gsDefTitle = "Task to perform image cleaning";
     283
     284const TString MImgCleanStd::gsNamePedPhotCam="MPedPhotCam"; // default name of the 'MPedPhotCam' container
    281285
    282286// --------------------------------------------------------------------------
     
    291295                           const char *name, const char *title)
    292296    : fCleaningMethod(kStandard), fCleanLvl1(lvl1),
    293       fCleanLvl2(lvl2), fCleanRings(1), fNamePedPhotContainer("MPedPhotCam")
     297      fCleanLvl2(lvl2), fCleanRings(1), fNamePedPhotCam(gsNamePedPhotCam)
    294298
    295299{
     
    499503    if (!fCam)
    500504    {
    501         *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
     505        *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl;
    502506        return kFALSE;
    503507    }
     
    506510    if (!fEvt)
    507511    {
    508         *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
     512        *fLog << err << "MCerPhotEvt not found... aborting." << endl;
    509513        return kFALSE;
    510514    }
    511515
    512     fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotContainer), "MPedPhotCam");
     516    fPed = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
    513517    if (!fPed)
    514518    {
    515         *fLog << dbginf << "MPedPhotCam not found... aborting." << endl;
     519        *fLog << err << "MPedPhotCam not found... aborting." << endl;
    516520        return kFALSE;
    517521    }
     522
     523    fTime = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
     524    if (!fTime && fCleaningMethod==kProbability)
     525        *fLog << warn << "MArrivalTime not found... probability cleaning done with signal only!" << endl;
    518526
    519527    fData = (MCameraData*)pList->FindCreateObj(AddSerialNumber("MCameraData"));
     
    541549        fData->CalcCleaningLevelDemocratic(*fEvt, *fPed, *fCam);
    542550        break;
     551        /*
     552    case kProbability:
     553        fData->CalcCleaningProbability(*fEvt, *fPed, *fCam, fTime);
     554        break;*/
     555    default:
     556        break;
    543557    }
    544558
     
    556570    // For speed reasons skip the rest of the cleaning if no
    557571    // action will be taken!
    558     if (fCleanLvl1<=fCleanLvl2)
    559         return kTRUE;
    560 
     572    if (fCleanLvl1>fCleanLvl2)
     573    {
    561574#ifdef DEBUG
    562     *fLog << all << "CleanStep 3" << endl;
     575        *fLog << all << "CleanStep 3" << endl;
    563576#endif
    564     CleanStep3();
     577        CleanStep3();
     578    }
     579
     580#ifdef DEBUG
     581        *fLog << all << "Calc Islands" << endl;
     582#endif
     583    // Takes roughly 10% of the time
     584    fEvt->CalcIslands(*fCam);
     585
    565586#ifdef DEBUG
    566587    *fLog << all << "Done." << endl;
     
    587608    case kScaled:
    588609        *fLog << "scaled";
     610        break;
     611    case kProbability:
     612        *fLog << "probability";
    589613        break;
    590614    }
     
    711735    out << ");" << endl;
    712736
    713     if (fCleaningMethod!=kDemocratic)
    714         return;
    715 
    716     out << "   " << GetUniqueName() << ".SetMethod(MImgCleanStd::kDemocratic);" << endl;
    717 
    718     if (fCleanRings==1)
    719         return;
    720 
    721     out << "   " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl;
    722 }
     737    if (fCleaningMethod!=kStandard)
     738    {
     739        out << "   " << GetUniqueName() << ".SetMethod(MImgCleanStd::k";
     740        switch (fCleaningMethod)
     741        {
     742        case kScaled:      out << "Scaled";      break;
     743        case kDemocratic:  out << "Democratic";  break;
     744        case kProbability: out << "Probability"; break;
     745        default:
     746            break;
     747        }
     748        out << ");" << endl;
     749    }
     750    if (fCleanRings!=1)
     751        out << "   " << GetUniqueName() << ".SetCleanRings(" << fCleanRings << ");" << endl;
     752
     753    if (gsNamePedPhotCam!=fNamePedPhotCam)
     754        out << "   " << GetUniqueName() << ".SetNamePedPhotCam(\"" << fNamePedPhotCam << "\");" << endl;
     755}
     756
     757// --------------------------------------------------------------------------
     758//
     759// Read the setup from a TEnv, eg:
     760//   MImgCleanStd.CleanLevel1: 3.0
     761//   MImgCleanStd.CleanLevel2: 2.5
     762//   MImgCleanStd.CleanMethod: Standard, Scaled, Democratic, Probability
     763//   MImgCleanStd.CleanRings:  1
     764//
     765Int_t MImgCleanStd::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     766{
     767    Bool_t rc = kFALSE;
     768    if (IsEnvDefined(env, prefix, "CleanRings", print))
     769    {
     770        rc = kTRUE;
     771        SetCleanRings(GetEnvValue(env, prefix, "CleanRings", fCleanRings));
     772    }
     773    if (IsEnvDefined(env, prefix, "CleanLevel1", print))
     774    {
     775        rc = kTRUE;
     776        fCleanLvl1 = GetEnvValue(env, prefix, "CleanLevel1", fCleanLvl1);
     777    }
     778    if (IsEnvDefined(env, prefix, "CleanLevel2", print))
     779    {
     780        rc = kTRUE;
     781        fCleanLvl2 = GetEnvValue(env, prefix, "CleanLevel2", fCleanLvl2);
     782    }
     783
     784    if (IsEnvDefined(env, prefix, "CleanMethod", print))
     785    {
     786        rc = kTRUE;
     787        TString s = GetEnvValue(env, prefix, "CleanMethod", "");
     788        s.ToLower();
     789        if (s.BeginsWith("standard"))
     790            SetMethod(kStandard);
     791        if (s.BeginsWith("scaled"))
     792            SetMethod(kScaled);
     793        if (s.BeginsWith("democratic"))
     794            SetMethod(kDemocratic);
     795        if (s.BeginsWith("probability"))
     796            SetMethod(kProbability);
     797    }
     798
     799    return rc;
     800}
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.h

    r4586 r4702  
    1111class MCerPhotEvt;
    1212class MPedPhotCam;
     13class MArrivalTime;
    1314class MCameraData;
    1415
     
    2122        kStandard,
    2223        kScaled,
    23         kDemocratic
     24        kDemocratic,
     25        kProbability
    2426    } CleaningMethod_t;
    2527
    2628private:
    27     const MGeomCam    *fCam;  //!
    28           MCerPhotEvt *fEvt;  //!
    29           MPedPhotCam *fPed;  //!
    30           MCameraData *fData; //!
     29    static const TString gsNamePedPhotCam; // default name of the 'MPedPhotCam' container
     30
     31    const MGeomCam     *fCam;  //!
     32          MCerPhotEvt  *fEvt;  //!
     33          MPedPhotCam  *fPed;  //!
     34          MArrivalTime *fTime; //!
     35          MCameraData  *fData; //!
    3136
    3237    CleaningMethod_t fCleaningMethod;
    3338
    34     Float_t fCleanLvl1;
    35     Float_t fCleanLvl2;
     39    Float_t  fCleanLvl1;
     40    Float_t  fCleanLvl2;
    3641
    3742    UShort_t fCleanRings;
    3843
    39     Float_t fInnerNoise;      //!
    40     TString fNamePedPhotContainer; // name of the 'MPedPhotCam' container
     44    TString  fNamePedPhotCam; // name of the 'MPedPhotCam' container
    4145
    4246
    43     void CreateGuiElements(MGGroupFrame *f);
    44     void StreamPrimitive(ofstream &out) const;
     47    void  CreateGuiElements(MGGroupFrame *f);
     48    void  StreamPrimitive(ofstream &out) const;
     49    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
    4550
    46     void   CleanStep3b(MCerPhotPix &pix);
    47     void   CleanStep4(UShort_t r, MCerPhotPix &pix);
     51    void  CleanStep3b(MCerPhotPix &pix);
     52    void  CleanStep4(UShort_t r, MCerPhotPix &pix);
    4853
    4954    void  CleanStep1();
     
    5661public:
    5762    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
    58               const char *name=NULL, const char *title=NULL);
     63                 const char *name=NULL, const char *title=NULL);
    5964    void Print(Option_t *o="") const;
    6065
     
    6772
    6873    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);
    69     void SetNamePedPhotContainer(const char *name)    { fNamePedPhotContainer = name; }
     74    void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
    7075
    7176    ClassDef(MImgCleanStd, 2)    // task doing the image cleaning
  • trunk/MagicSoft/Mars/mimage/Makefile

    r3927 r4702  
    2020#
    2121INCLUDES = -I. -I../mbase -I../mhbase -I../mgeom -I../manalysis \
    22            -I../mgui -I../mmc -I../mpointing -I../mpedestal
     22           -I../mgui -I../mmc -I../mpointing -I../mpedestal \
     23           -I../mhist
     24
     25# mhist: MHHillas (MHCamera)
     26
    2327
    2428SRCFILES = MImgCleanStd.cc \
  • trunk/MagicSoft/Mars/mmain/MEventDisplay.cc

    r4452 r4702  
    215215    fEvtLoop->SetParList(plist);
    216216
    217     MHEvent *evt1 = new MHEvent(MHEvent::kEvtSignalRaw);
    218     MHEvent *evt2 = new MHEvent(MHEvent::kEvtSignalRaw);
    219     MHEvent *evt3 = new MHEvent(MHEvent::kEvtPedestal);
    220     MHEvent *evt4 = new MHEvent(MHEvent::kEvtPedestalRMS);
    221     MHEvent *evt5 = new MHEvent(MHEvent::kEvtRelativeSignal);
    222     MHEvent *evt6 = new MHEvent(MHEvent::kEvtCleaningLevels);
    223     MHEvent *evt7 = new MHEvent(MHEvent::kEvtIdxMax);
    224     MHEvent *evt8 = new MHEvent(MHEvent::kEvtArrTime);
    225     MHEvent *evt9 = new MHEvent(MHEvent::kEvtTrigPix);
    226 
    227     evt1->SetName("Signal");
    228     evt2->SetName("Cleaned");
    229     evt3->SetName("Pedestal");
    230     evt4->SetName("PedRMS");
    231     evt5->SetName("Signal/PedRMS");
    232     evt6->SetName("CleanLevels");
    233     evt7->SetName("Max Slice Idx");
    234     evt8->SetName("Arrival Time");
    235     evt9->SetName("Trigger");
     217    MHEvent *evt01 = new MHEvent(MHEvent::kEvtSignalRaw);
     218    MHEvent *evt02 = new MHEvent(MHEvent::kEvtSignalRaw);
     219    MHEvent *evt03 = new MHEvent(MHEvent::kEvtPedestal);
     220    MHEvent *evt04 = new MHEvent(MHEvent::kEvtPedestalRMS);
     221    MHEvent *evt05 = new MHEvent(MHEvent::kEvtRelativeSignal);
     222    MHEvent *evt06 = new MHEvent(MHEvent::kEvtCleaningLevels);
     223    MHEvent *evt07 = new MHEvent(MHEvent::kEvtIdxMax);
     224    MHEvent *evt08 = new MHEvent(MHEvent::kEvtArrTime);
     225    MHEvent *evt09 = new MHEvent(MHEvent::kEvtTrigPix);
     226    MHEvent *evt10 = new MHEvent(MHEvent::kEvtIslandIndex);
     227
     228    evt01->SetName("Signal");
     229    evt02->SetName("Cleaned");
     230    evt03->SetName("Pedestal");
     231    evt04->SetName("PedRMS");
     232    evt05->SetName("Signal/PedRMS");
     233    evt06->SetName("CleanLevels");
     234    evt07->SetName("Max Slice Idx");
     235    evt08->SetName("Arrival Time");
     236    evt09->SetName("Trigger");
     237    evt10->SetName("Islands");
    236238
    237239    // This makes sure, that the containers are deleted...
    238     plist->AddToList(evt1);
    239     plist->AddToList(evt2);
    240     plist->AddToList(evt3);
    241     plist->AddToList(evt4);
    242     plist->AddToList(evt5);
    243     plist->AddToList(evt6);
    244     plist->AddToList(evt7);
    245     plist->AddToList(evt8);
    246     plist->AddToList(evt9);
    247 
    248     MCerPhotAnal2     *nanal = new MCerPhotAnal2;
    249     MFillH            *fill1 = new MFillH(evt1, "MCerPhotEvt", "MFillH1");
    250     MImgCleanStd      *clean = new MImgCleanStd;
    251     MFillH            *fill2 = new MFillH(evt2, "MCerPhotEvt", "MFillH2");
    252     MFillH            *fill3 = new MFillH(evt3, "MPedPhotCam", "MFillH3");
    253     MFillH            *fill4 = new MFillH(evt4, "MPedPhotCam", "MFillH4");
    254     MFillH            *fill5 = new MFillH(evt5, "MCameraData", "MFillH5");
    255     MFillH            *fill6 = new MFillH(evt6, "MCameraData", "MFillH6");
     240    plist->AddToList(evt01);
     241    plist->AddToList(evt02);
     242    plist->AddToList(evt03);
     243    plist->AddToList(evt04);
     244    plist->AddToList(evt05);
     245    plist->AddToList(evt06);
     246    plist->AddToList(evt07);
     247    plist->AddToList(evt08);
     248    plist->AddToList(evt09);
     249    plist->AddToList(evt10);
     250
     251    MCerPhotAnal2      *nanal  = new MCerPhotAnal2;
     252    MFillH             *fill01 = new MFillH(evt01, "MCerPhotEvt", "MFillH01");
     253    MImgCleanStd       *clean  = new MImgCleanStd;
     254    MFillH             *fill02 = new MFillH(evt02, "MCerPhotEvt", "MFillH02");
     255    MFillH             *fill03 = new MFillH(evt03, "MPedPhotCam", "MFillH03");
     256    MFillH             *fill04 = new MFillH(evt04, "MPedPhotCam", "MFillH04");
     257    MFillH             *fill05 = new MFillH(evt05, "MCameraData", "MFillH05");
     258    MFillH             *fill06 = new MFillH(evt06, "MCameraData", "MFillH06");
    256259//    MBlindPixelCalc   *blind = new MBlindPixelCalc;
    257     MHillasCalc       *hcalc = new MHillasCalc;
    258     MHillasSrcCalc    *scalc = new MHillasSrcCalc;
    259     MMcTriggerLvl2Calc *trcal = new MMcTriggerLvl2Calc;
    260     MFillH            *fill9 = new MFillH(evt9, "MMcTriggerLvl2", "MFillH9");
     260    MHillasCalc        *hcalc  = new MHillasCalc;
     261    MHillasSrcCalc     *scalc  = new MHillasSrcCalc;
     262    MMcTriggerLvl2Calc *trcal  = new MMcTriggerLvl2Calc;
     263    MFillH             *fill09 = new MFillH(evt09, "MMcTriggerLvl2", "MFillH09");
     264    MFillH             *fill10 = new MFillH(evt10, "MCerPhotEvt",    "MFillH10");
    261265
    262266    // If no pedestal or no calibration file is availble
     
    285289        mcupd->SetFilter(f1);
    286290        mccal->SetFilter(f1);
    287         trcal->SetFilter(f1);
     291        trcal->SetFilter(f1);
     292        //fill09->SetFilter(f1);
    288293
    289294        // Data
     
    309314    }
    310315
    311     tlist->AddToList(fill1);
     316    tlist->AddToList(fill01);
    312317    tlist->AddToList(clean);
    313     tlist->AddToList(fill2);
    314     tlist->AddToList(fill3);
    315     tlist->AddToList(fill4);
    316     tlist->AddToList(fill5);
    317     tlist->AddToList(fill6);
     318    tlist->AddToList(fill02);
     319    tlist->AddToList(fill03);
     320    tlist->AddToList(fill04);
     321    tlist->AddToList(fill05);
     322    tlist->AddToList(fill06);
    318323//    tlist->AddToList(blind);
    319324    tlist->AddToList(hcalc);
    320325    tlist->AddToList(scalc);
     326    tlist->AddToList(fill10);
    321327
    322328    if (!pcam || !ccam)
    323329    {
    324330        MArrivalTimeCalc  *tcalc = new MArrivalTimeCalc;
    325         MFillH            *fill7 = new MFillH(evt7, "MRawEvtData",     "MFillH7");
    326         MFillH            *fill8 = new MFillH(evt8, "MArrivalTimeCam", "MFillH8");
     331        MFillH            *fill07 = new MFillH(evt07, "MRawEvtData",     "MFillH7");
     332        MFillH            *fill08 = new MFillH(evt08, "MArrivalTimeCam", "MFillH8");
    327333        tlist->AddToList(tcalc);
    328         tlist->AddToList(fill7);
    329         tlist->AddToList(fill8);
     334        tlist->AddToList(fill07);
     335        tlist->AddToList(fill08);
    330336
    331337        tlist->AddToList(trcal);
    332         tlist->AddToList(fill9);
     338        tlist->AddToList(fill09);
    333339    }
    334340
Note: See TracChangeset for help on using the changeset viewer.