Ignore:
Timestamp:
06/16/03 13:45:01 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgui
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mgui/GuiLinkDef.h

    r1436 r2178  
    66
    77#pragma link C++ class MHexagon+;
     8#pragma link C++ class MCamEvent+;
    89#pragma link C++ class MCamDisplay+;
    910
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.cc

    r2173 r2178  
    6363
    6464#include "MCurrents.h"
     65#include "MCamEvent.h"
    6566
    6667#include "MImgCleanStd.h"
     
    9192    fMinimum = 0;
    9293    fMaximum = 1;
     94
     95    fNotify = new TList;
    9396}
    9497
     
    101104{
    102105    fGeomCam = (MGeomCam*)geom->Clone();
     106
     107    fNotify = new TList;
    103108
    104109    //
     
    211216
    212217    delete fGeomCam;
     218
     219    delete fNotify;
    213220}
    214221
     
    228235    pad->SetBorderMode(0);
    229236    pad->SetFillColor(16);
    230 
     237    //pad->Modified();
     238    /*
     239    pad->Divide(1,1);
     240    pad->cd(1);
     241    gPad->SetBorderMode(0);
     242    gPad->SetFillColor(16);
     243*/
    231244    AppendPad("");
    232245}
     
    240253    const float ratio = 1.15;
    241254
    242     const float w = gPad->GetWw();
    243     const float h = gPad->GetWh()*ratio;
    244 
     255    //
     256    // Calculate width and height of the current pad in pixels
     257    //
     258    Float_t w = gPad->GetWw();
     259    Float_t h = gPad->GetWh()*ratio;
     260
     261    //
     262    // This prevents the pad from resizing itself wrongly
     263    //
     264    if (gPad->GetMother() != gPad)
     265    {
     266        w *= gPad->GetMother()->GetAbsWNDC();
     267        h *= gPad->GetMother()->GetAbsHNDC();
     268    }
     269
     270    //
     271    // Set Range (coordinate system) of pad
     272    //
    245273    gPad->Range(-fRange, -fRange, (2*ratio-1)*fRange, fRange);
    246274
     275    //
     276    // Resize Pad to given ratio
     277    //
    247278    if (h<w)
    248         gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 0.9999999);
     279        gPad->SetPad((1.-h/w)/2, 0, (h/w+1.)/2, 1);
    249280    else
    250         gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2);
     281        gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1.)/2);
    251282}
    252283
     
    271302    }
    272303
     304    if (fMinimum==FLT_MAX && fMaximum==-FLT_MAX)
     305        fMinimum = fMaximum = 0;
    273306    if (fMinimum==fMaximum)
    274307        fMaximum = fMinimum + 1;
     
    282315        else
    283316            (*this)[i].SetFillColor(10);
    284 
    285317    }
    286318}
     
    314346
    315347    // Paint primitives (pixels, color legend, photons, ...)
    316     { fPixels->ForEach(TObject, Paint)(); }
    317     { fLegend->ForEach(TObject, Paint)(); }
     348    { fPixels->ForEach( TObject, Paint)(); }
     349    { fLegend->ForEach( TObject, Paint)(); }
    318350    { fLegText->ForEach(TObject, Paint)(); }
    319351    { fPhotons->ForEach(TObject, Paint)(); }
     
    445477// ------------------------------------------------------------------------
    446478//
    447 // Call this function to fill the number of photo electron into the
    448 // camera.
    449 //
    450 void MCamDisplay::FillPhotNum(const MCerPhotEvt &event)
     479// Call this function to fill the currents
     480//
     481void MCamDisplay::Fill(const MCamEvent &event, Int_t type)
    451482{
    452483    Reset();
    453484
    454     const Int_t entries = event.GetNumPixels();
    455 
    456     for (Int_t i=0; i<entries; i++)
    457     {
    458         const MCerPhotPix &pix = event[i];
    459         if (!pix.IsPixelUsed())
    460             continue;
    461 
    462         const Int_t id = pix.GetPixId();
    463 
    464         fData[id] = pix.GetNumPhotons()*fGeomCam->GetPixRatio(id);
    465         (*this)[id].SetBit(kIsUsed);
    466     }
    467 }
    468 
    469 // ------------------------------------------------------------------------
    470 //
    471 // Call this function to fill the number of photo electron into the
    472 // camera.
    473 //
    474 void MCamDisplay::FillPedestals(const MPedestalCam &event)
     485    // FIXME: Security check missing!
     486    for (UInt_t idx=0; idx<fNumPixels; idx++)
     487    {
     488        fData[idx] = 0;
     489        if (event.GetPixelContent(fData[idx], idx, fGeomCam->GetPixRatio(idx), type))
     490            (*this)[idx].SetBit(kIsUsed);
     491    }
     492}
     493
     494// ------------------------------------------------------------------------
     495//
     496// Call this function to fill the currents
     497//
     498void MCamDisplay::Fill(const TArrayF &event, Bool_t ispos)
    475499{
    476500    Reset();
    477501
    478     const Int_t entries = event.GetSize();
    479     for (Int_t i=0; i<entries; i++)
    480     {
    481         fData[i] = event[i].GetMean()*fGeomCam->GetPixRatio(i);
    482         (*this)[i].SetBit(kIsUsed);
    483     }
    484 }
    485 
    486 // ------------------------------------------------------------------------
    487 //
    488 // Call this function to fill the error of number of photo electron
    489 // into the camera.
    490 //
    491 void MCamDisplay::FillErrorPhot(const MCerPhotEvt &event)
    492 {
    493     Reset();
    494 
    495     const Int_t entries = event.GetNumPixels();
    496 
    497     for (Int_t i=0; i<entries; i++)
    498     {
    499         const MCerPhotPix &pix = event[i];
    500         if (!pix.IsPixelUsed())
    501             continue;
    502 
    503         const Int_t id = pix.GetPixId();
    504 
    505         fData[id] = pix.GetErrorPhot()*sqrt(fGeomCam->GetPixRatio(id));
    506         (*this)[id].SetBit(kIsUsed);
    507     }
    508 }
    509 
    510 // ------------------------------------------------------------------------
    511 //
    512 // Call this function to fill the ratio of the number of photons
    513 // divided by its error
    514 //
    515 void MCamDisplay::FillRatio(const MCerPhotEvt &event)
    516 {
    517     Reset();
    518 
    519     const Int_t entries = event.GetNumPixels();
    520 
    521     for (Int_t i=0; i<entries; i++)
    522     {
    523         const MCerPhotPix &pix = event[i];
    524 
    525         if (!pix.IsPixelUsed())
    526             continue;
    527 
    528         const Int_t id = pix.GetPixId();
    529 
    530         const Float_t  entry = pix.GetNumPhotons();
    531         const Float_t  noise = pix.GetErrorPhot();
    532         const Double_t ratio = TMath::Sqrt(fGeomCam->GetPixRatio(id));
    533 
    534         fData[id] = entry*ratio/noise;
    535         (*this)[id].SetBit(kIsUsed);
    536     }
    537 }
    538 
    539 // ------------------------------------------------------------------------
    540 //
    541 // Call this function to fill the currents
    542 //
    543 void MCamDisplay::FillCurrents(const MCurrents &event)
    544 {
    545     Reset();
    546 
    547     // FIXME: Security check missing!
    548     for (UInt_t i=0; i<fNumPixels; i++)
    549     {
    550         if (event[i]<=0)
    551             continue;
    552 
    553         (*this)[i].SetBit(kIsUsed);
    554         fData[i] = event[i];
    555     }
     502    fData = event;
     503
     504    for (UInt_t idx=0; idx<fNumPixels; idx++)
     505        if (!ispos || fData[idx]>0)
     506            (*this)[idx].SetBit(kIsUsed);
    556507}
    557508
     
    562513void MCamDisplay::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2)
    563514{
    564     FillRatio(event);
     515    Fill(event, 2);
    565516
    566517    for (UInt_t i=0; i<fNumPixels; i++)
     
    793744}
    794745
     746Int_t MCamDisplay::GetPixelIndex(Int_t px, Int_t py) const
     747{
     748    UInt_t i;
     749    for (i=0; i<fNumPixels; i++)
     750    {
     751        if ((*fPixels)[i]->DistancetoPrimitive(px, py)>0)
     752            continue;
     753
     754        return i;
     755    }
     756    return -1;
     757}
     758
    795759// ------------------------------------------------------------------------
    796760//
     
    800764char *MCamDisplay::GetObjectInfo(Int_t px, Int_t py) const
    801765{
    802     static char info[64];
    803 
    804     UInt_t i;
    805     for (i=0; i<fNumPixels; i++)
    806     {
    807         if ((*fPixels)[i]->DistancetoPrimitive(px, py)>0)
    808             continue;
    809 
    810         sprintf(info, "Pixel Id: %d", i);
    811         return info;
    812     }
    813     return TObject::GetObjectInfo(px, py);
    814 }
     766    static char info[128];
     767
     768    const Int_t idx=GetPixelIndex(px, py);
     769
     770    if (idx<0)
     771        return TObject::GetObjectInfo(px, py);
     772
     773    sprintf(info, "Software Pixel Index: %d (Hardware Id=%d)", idx, idx+1);
     774    return info;
     775}
     776
     777// ------------------------------------------------------------------------
     778//
     779// Execute a mouse event on the camera
     780//
     781void MCamDisplay::ExecuteEvent(Int_t event, Int_t px, Int_t py)
     782{
     783    //if (event==kMouseMotion && fStatusBar)
     784    //    fStatusBar->SetText(GetObjectInfo(px, py), 0);
     785    if (event!=kButton1Down)
     786        return;
     787
     788    const Int_t idx = GetPixelIndex(px, py);
     789    if (idx<0)
     790        return;
     791
     792    cout << "Software Pixel Index: " << idx << endl;
     793    cout << "Hardware Pixel Id:    " << idx+1 << endl;
     794    cout << "Contents:             " << fData[idx] << endl;
     795
     796    //fNotify->Print();
     797    if (fNotify->GetSize()>0)
     798        new TCanvas;
     799    fNotify->ForEach(MCamEvent, DrawPixelContent)(idx);
     800}
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.h

    r2171 r2178  
    2222class TText;
    2323class TArrow;
     24class TGStatusBar;
    2425
    2526class MGeomCam;
    2627class MHexagon;
     28class MCurrents;
     29class MCamEvent;
    2730class MRflEvtData;
    28 class MCurrents;
    2931class MCerPhotEvt;
    3032class MCerPhotPix;
     
    6062    Float_t        fMaximum;
    6163
     64    TList         *fNotify;
     65
     66    //TGStatusBar   *fStatusBar;
     67
    6268    TBox  *GetBox(Int_t i)  { return (TBox*) fLegend->At(i); }
    6369
     
    7177    void  SetPalette();
    7278
     79    Int_t GetPixelIndex(Int_t px, Int_t py) const;
     80
    7381    enum {
    7482        kIsUsed = BIT(14)
     
    8189
    8290    void  SetAutoScale(Bool_t input=kTRUE); // *MENU*
    83     void  FillPhotNum(const MCerPhotEvt &event);
    84     void  FillRatio(const MCerPhotEvt &event);
     91
     92    void  ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
     93    void  FillRflEvent(const MRflEvtData &event);
    8594    void  FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2);
    86     void  FillErrorPhot(const MCerPhotEvt &event);
    8795    void  FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);
    88     void  FillPedestals(const MPedestalCam &event);
    89     void  FillRflEvent(const MRflEvtData &event);
    90     void  FillCurrents(const MCurrents &event);
    91     void  ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
     96    void  Fill(const MCamEvent &event, Int_t type=0);
     97    void  Fill(const TArrayF &event, Bool_t ispos=kTRUE);
    9298
    9399    void  DrawPixelNumbers();
     
    99105    Int_t DistancetoPrimitive(Int_t px, Int_t py);
    100106    char *GetObjectInfo(Int_t px, Int_t py) const;
    101     //virtual void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
     107    void  ExecuteEvent(Int_t event, Int_t px, Int_t py);
    102108
    103109    void  SetPalette(Int_t ncolors, Int_t *colors);
     
    111117    void  SetMinimum(Float_t m); // *MENU*
    112118    void  SetMaximum(Float_t m); // *MENU*
     119
     120    void  AddNotify(const MCamEvent &event) { fNotify->Add((TObject*)(&event)); }
     121
     122    //void SetStatusBar(TGStatusBar *bar) { fStatusBar = bar; }
    113123
    114124    ClassDef(MCamDisplay, 0) // Displays the magic camera
  • trunk/MagicSoft/Mars/mgui/Makefile

    r2135 r2178  
    2323#
    2424INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist \
    25            -I../mreflector
     25           -I../mreflector -I../mraw
    2626
    2727#------------------------------------------------------------------------------
     
    3030
    3131SRCFILES = MHexagon.cc \
    32            MCamDisplay.cc
     32           MCamEvent.cc \
     33           MCamDisplay.cc
    3334
    3435SRCS    = $(SRCFILES)
Note: See TracChangeset for help on using the changeset viewer.