Ignore:
Timestamp:
10/01/04 16:41:51 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHCamEvent.cc

    r5143 r5156  
    3030// currents or enything else derived from MCamEvent
    3131//
     32// Setup
     33// =====
     34//
    3235// To plot the variance instead of the rms use:
    3336//    MHCamEvent::SetBit(MHCamera::kVariance);
     37//  or
     38//    MHCamEvent::EnableVariance()
     39//
     40// To count how often a certain pixel is above or below a threshold do:
     41//    MHCamEvent::SetThreshold(5.5);  // Default=LowerBound
     42//    MHCamEvent::SetThreshold(5.5, MHCamEvent::kIsUpperBound);
     43//
    3444//
    3545// Axis titles
     
    4757//   MHCamEvent myhist("Titele;;y [cm]");
    4858//
    49 //
    5059/////////////////////////////////////////////////////////////////////////////
    5160#include "MHCamEvent.h"
     
    8897//
    8998MHCamEvent::MHCamEvent(const char *name, const char *title)
    90     : fSum(NULL), fEvt(NULL), fType(0)
     99    : fSum(NULL), fEvt(NULL), fType(0), fThreshold(0), fUseThreshold(0)
    91100{
    92101    Init(name, title);
     
    98107//
    99108MHCamEvent::MHCamEvent(Int_t type, const char *name, const char *title)
    100     : fSum(NULL), fEvt(NULL), fType(type)
     109    : fSum(NULL), fEvt(NULL), fType(type), fThreshold(0), fUseThreshold(0)
    101110{
    102111    Init(name, title);
     
    111120    if (fSum)
    112121        delete fSum;
     122}
     123
     124// --------------------------------------------------------------------------
     125//
     126// use this to display the variance instead of the rms.
     127//
     128void MHCamEvent::EnableVariance(Bool_t b)
     129{
     130    b ? SetBit(MHCamera::kVariance) : ResetBit(MHCamera::kVariance);
    113131}
    114132
     
    140158    }
    141159
     160    // Delete a posible old histogram from a previous loop
    142161    if (fSum)
    143162        delete (fSum);
    144163
     164    // combine name
    145165    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
    146166
     167    // create and setup MHCamera
    147168    fSum = new MHCamera(*cam, name+";avg");
    148169    if (fTitle!=gsDefTitle)
     
    169190        return kFALSE;
    170191    }
    171     fSum->AddCamContent(*evt, fType);
     192    if (fUseThreshold)
     193        fSum->CntCamContent(*evt, fThreshold, fType, fUseThreshold>0);
     194    else
     195        fSum->AddCamContent(*evt, fType);
    172196    return kTRUE;
    173197}
     
    274298    MHCamera *cam = new MHCamera(*fSum->GetGeometry());
    275299    cam->SetName(Form("Err_%p", this));
    276     cam->SetTitle(TestBit(MHCamera::kVariance)?"Variance":"Root Mean Squared (rms)");
     300    cam->SetTitle(fSum->TestBit(MHCamera::kVariance)?"Variance":"Root Mean Squared (rms)");
    277301    cam->SetYTitle(fSum->GetYaxis()->GetTitle());
    278302    cam->SetCamContent(*fSum, 1);
     
    292316    h->Draw();
    293317}
     318
  • trunk/MagicSoft/Mars/mhist/MHCamEvent.h

    r5143 r5156  
    1515    static const TString gsDefTitle;
    1616
    17     MHCamera  *fSum; // storing the sum
    18     MCamEvent *fEvt; //! the current event
     17    MHCamera  *fSum;       // storing the sum
     18    MCamEvent *fEvt;       //! the current event
    1919
    20     TString fNameEvt;
     20    TString fNameEvt;      // Nameof MCamEvent to fill into histogram
    2121
    22     Int_t fType;
     22    Int_t fType;           // Type to used for calling GetPixelContent
     23
     24    Float_t fThreshold;    // Count pixel above/below this threshold
     25    Char_t fUseThreshold;  // Use a threshold? Which direction has it?
    2326
    2427    void Init(const char *name, const char *title);
     
    2831
    2932public:
     33    enum { kIsLowerBound=1, kIsUpperBound=-1, kNoBound=0 };
     34
    3035    MHCamEvent(const char *name=NULL, const char *title=NULL);
    3136    MHCamEvent(Int_t type, const char *name=NULL, const char *title=NULL);
     
    4247    void PrintOutliers(Float_t s) const;
    4348
     49    void SetThreshold(Float_t f, Char_t direction=kIsLowerBound) { fThreshold = f; fUseThreshold=direction; }
     50    void EnableVariance(Bool_t b=kTRUE);
     51
    4452    ClassDef(MHCamEvent, 1) // Histogram to sum camera events
    4553};
  • trunk/MagicSoft/Mars/mhist/MHCamEventRot.cc

    r3786 r5156  
    7171//
    7272MHCamEventRot::MHCamEventRot(const char *name, const char *title)
    73     : fTime(0), fPointPos(0), fObservatory(0), fType(0), fNameTime("MTime")
     73    : fTime(0), fPointPos(0), fObservatory(0), fType(0), fNameTime("MTime"),
     74    fThreshold(0), fUseThreshold(kNoBound)
    7475{
    7576    //
     
    192193
    193194            // Fill histogram
    194             fHist.Fill(cx[ix], cy[iy], val);
     195            if (fUseThreshold!=kNoBound)
     196            {
     197                if (val>fThreshold && fUseThreshold==kIsLowerBound ||
     198                    val<fThreshold && fUseThreshold==kIsUpperBound)
     199                    fHist.Fill(cx[ix], cy[iy]);
     200            }
     201            else
     202                fHist.Fill(cx[ix], cy[iy], val);
    195203        }
    196204    }
  • trunk/MagicSoft/Mars/mhist/MHCamEventRot.h

    r3786 r5156  
    2828    TH2D    fHist;               // Alpha vs. x and y
    2929
    30     Int_t fType;
     30    Int_t fType;                 // Type to used for calling GetPixelContent
    3131
    3232    Double_t fRa;
     
    3535    TString fNameTime;
    3636
     37    Float_t fThreshold;          // Count pixel above/below this threshold
     38    Char_t fUseThreshold;        // Use a threshold? Which direction has it?
     39
    3740    TObject *GetCatalog();
    3841
    3942public:
     43    enum { kIsLowerBound=1, kIsUpperBound=-1, kNoBound=0 };
     44
    4045    MHCamEventRot(const char *name=NULL, const char *title=NULL);
    4146
     
    4954    void Draw(Option_t *option="");
    5055
     56    void SetThreshold(Float_t f, Char_t direction=kIsLowerBound) { fThreshold = f; fUseThreshold=direction; }
     57
    5158    ClassDef(MHCamEventRot, 1) //2D-histogram in MCamEvent data (derotated)
    5259};
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r5143 r5156  
    12571257// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
    12581258//
     1259// in unused pixel is not counted if it didn't fullfill the condition.
     1260//
    12591261void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type, Bool_t isabove)
    12601262{
     
    12671269        Double_t val=threshold;
    12681270        if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
     1271        {
    12691272            SetUsed(idx);
    12701273
    1271         if (val>threshold && isabove)
    1272             Fill(idx);
    1273         if (val<threshold && !isabove)
    1274             Fill(idx);
     1274            if (isabove && val>threshold)
     1275                Fill(idx);
     1276            if (!isabove && val<threshold)
     1277                Fill(idx);
     1278        }
    12751279    }
    12761280    fEntries++;
     
    12831287// 1 is added to each pixel if the contents of MCamEvent<threshold (in case isabove is set to kFALSE)
    12841288//
     1289// in unused pixel is not counted if it didn't fullfill the condition.
     1290//
    12851291void MHCamera::CntCamContent(const MCamEvent &event, TArrayD threshold, Int_t type, Bool_t isabove)
    12861292{
     
    12931299        Double_t val=threshold[idx];
    12941300        if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/)
     1301        {
    12951302            SetUsed(idx);
    12961303
    1297         if (val>threshold[idx] && isabove)
    1298             Fill(idx);
    1299         if (val<threshold[idx] && !isabove)
    1300             Fill(idx);
     1304            if (val>threshold[idx] && isabove)
     1305                Fill(idx);
     1306            if (val<threshold[idx] && !isabove)
     1307                Fill(idx);
     1308        }
    13011309    }
    13021310    fEntries++;
     
    13151323    for (Int_t idx=0; idx<fNcells-2; idx++)
    13161324    {
    1317         if (const_cast<TArrayD&>(event)[idx]>threshold)
     1325        if (event[idx]>threshold)
    13181326            Fill(idx);
    13191327
Note: See TracChangeset for help on using the changeset viewer.