Ignore:
Timestamp:
05/23/03 17:30:31 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.cc

    r2122 r2135  
    4141#include <TLatex.h>
    4242#include <TStyle.h>
     43#include <TMarker.h>
    4344#include <TCanvas.h>
     45#include <TArrayF.h>
    4446#include <TClonesArray.h>
    4547
     
    4850
    4951#include "MGeomCam.h"
     52
     53#include "MRflEvtData.h"
    5054
    5155#include "MCerPhotPix.h"
     
    99103    //    register BIT(8) as kNoContextMenu. If an object has this bit set it will
    100104    //    not get an automatic context menu when clicked with the right mouse button.
     105
     106    fPhotons = new TClonesArray("TMarker", 0);
    101107
    102108    //
     
    180186    fLegend->Delete();
    181187    fLegText->Delete();
     188    fPhotons->Delete();
    182189
    183190    delete fPixels;
    184191    delete fLegend;
    185192    delete fLegText;
     193    delete fPhotons;
    186194
    187195    delete fArrowX;
     
    322330
    323331    //
    324     // Paint primitives
    325     //
    326     for (UInt_t i=0; i<fNumPixels; i++)
    327         (*this)[i].Paint();
    328 
    329     for (Int_t i=0; i<kItemsLegend; i++)
    330     {
    331         GetBox(i)->Paint();
    332         GetText(i)->Paint();
    333     }
    334 
     332    // Paint Legend
     333    //
    335334    fArrowX->Paint(">");
    336335    fArrowY->Paint(">");
     
    338337    fLegRadius->Paint();
    339338    fLegDegree->Paint();
     339
     340    //
     341    // Paint primitives (pixels, color legend, photons, ...)
     342    //
     343    { fPixels->ForEach(TObject, Paint)(); }
     344    { fLegend->ForEach(TObject, Paint)(); }
     345    { fLegText->ForEach(TObject, Paint)(); }
     346    { fPhotons->ForEach(TObject, Paint)(); }
    340347}
    341348
     
    671678// ------------------------------------------------------------------------
    672679//
     680// Show a reflector event. EMarkerStyle is defined in root/include/Gtypes.h
     681// To remove the photons from the display call FillRflEvent(NULL)
     682//
     683void MCamDisplay::ShowRflEvent(const MRflEvtData *event, EMarkerStyle ms)
     684{
     685    const Int_t num = event ? event->GetNumPhotons() : 0;
     686
     687    fPhotons->ExpandCreate(num);
     688    if (num < 1)
     689        return;
     690
     691    Int_t i=num-1;
     692    do
     693    {
     694        const MRflSinglePhoton &ph = event->GetPhoton(i);
     695        TMarker &m = (TMarker&)*fPhotons->UncheckedAt(i);
     696        m.SetX(ph.GetX());
     697        m.SetY(ph.GetY());
     698        m.SetMarkerStyle(ms);
     699    } while (i--);
     700}
     701
     702// ------------------------------------------------------------------------
     703//
     704// Fill a reflector event. Sums all pixels in each pixel as the
     705// pixel contents.
     706//
     707// WARNING: Due to the estimation in DistanceToPrimitive and the
     708//          calculation in pixels instead of x, y this is only a
     709//          rough estimate.
     710//
     711void MCamDisplay::FillRflEvent(const MRflEvtData &event)
     712{
     713    //
     714    // reset pixel colors to background color
     715    //
     716    Reset();
     717
     718    //
     719    // sum the photons content in each pixel
     720    //
     721    const Int_t entries = event.GetNumPhotons();
     722
     723    TArrayF arr(fNumPixels);
     724    for (Int_t i=0; i<entries; i++)
     725    {
     726        const MRflSinglePhoton &ph = event.GetPhoton(i);
     727
     728        UInt_t id;
     729        for (id=0; id<fNumPixels; id++)
     730        {
     731            if ((*this)[id].DistanceToPrimitive(ph.GetX(), ph.GetY())<0)
     732                break;
     733        }
     734        if (id==fNumPixels)
     735            continue;
     736
     737        arr[id] += 1;
     738    }
     739
     740    //
     741    // Scale with the area and determin maximum
     742    //
     743    Float_t max = 0;
     744    for (UInt_t id=0; id<fNumPixels; id++)
     745    {
     746        arr[id] *= fGeomCam->GetPixRatio(id);
     747        if (arr[id]>max)
     748            max = arr[id];
     749    }
     750
     751    //
     752    // Update legend
     753    //
     754    if (fAutoScale)
     755        UpdateLegend(0, max==0 ? 1 : max);
     756
     757    //
     758    // Set color of pixels
     759    //
     760    for (UInt_t id=0; id<fNumPixels; id++)
     761        if (arr[id]>0)
     762            (*this)[id].SetFillColor(GetColor(arr[id], 0, max));
     763}
     764
     765// ------------------------------------------------------------------------
     766//
    673767// Reset the all pixel colors to a default value
    674768//
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.h

    r2109 r2135  
    44#ifndef MARS_MAGIC
    55#include "MAGIC.h"
     6#endif
     7#ifndef ROOT_Gtypes
     8#include <Gtypes.h>
    69#endif
    710#ifndef ROOT_TClonesArray
     
    1518class MGeomCam;
    1619class MHexagon;
     20class MRflEvtData;
    1721class MCerPhotEvt;
    1822class MCerPhotPix;
     
    4246    TClonesArray  *fLegend;      // array of all color bars
    4347    TClonesArray  *fLegText;     // array of all texts
    44 
     48    TClonesArray  *fPhotons;     // array of reflector photons
     49 
    4550    UInt_t         fW;           // Width of canvas
    4651    UInt_t         fH;           // Height of canvas
     
    7479    void FillLevels(const MCerPhotEvt &event, const MImgCleanStd &clean);
    7580    void FillPedestals(const MPedestalCam &event);
     81    void FillRflEvent(const MRflEvtData &event);
     82    void ShowRflEvent(const MRflEvtData *event=NULL, EMarkerStyle m=kFullDotMedium);
    7683
    7784    void DrawPixelNumbers();
  • trunk/MagicSoft/Mars/mgui/MHexagon.cc

    r1965 r2135  
    6767    fX = pix.GetX();
    6868    fY = pix.GetY();
    69     fD = pix.GetR();
     69    fD = pix.GetD();
    7070}
    7171
     
    139139    // comput the distance of hexagon center to pixel border
    140140    //
    141     const Double_t dx = fD * cosa / 2;
    142     const Double_t dy = fD * sina / 2;
     141    const Double_t dx = fD/2 * cosa;
     142    const Double_t dy = fD/2 * sina;
    143143
    144144    const Int_t pxborder = gPad->XtoAbsPixel(fX + dx);
     
    155155    //
    156156    return distborder < disthex ? (int)(disthex-distborder+1) : 0;
     157}
     158
     159// ------------------------------------------------------------------------
     160//
     161// compute the distance of a point (px,py) to the Hexagon in world
     162// coordinates. Return -1 if inside.
     163//
     164Float_t MHexagon::DistanceToPrimitive(Float_t px, Float_t py)
     165{
     166    //
     167    //  compute the distance of the Point to the center of the Hexagon
     168    //
     169    const Double_t dx = px-fX;
     170    const Double_t dy = py-fY;
     171
     172    const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
     173
     174    //
     175    //  compute the distance from the border of Pixel
     176    //  here in the first implementation is just circle inside
     177    //
     178    return fD*0.5772 < disthex ? disthex-fD*0.5772 : -1;
    157179}
    158180
  • trunk/MagicSoft/Mars/mgui/MHexagon.h

    r1880 r2135  
    5050        ;
    5151
    52     virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
     52    virtual Int_t   DistancetoPrimitive(Int_t px, Int_t py);
     53    virtual Float_t DistanceToPrimitive(Float_t px, Float_t py);
    5354    virtual void  DrawHexagon(Float_t x, Float_t y, Float_t d);
    5455
  • trunk/MagicSoft/Mars/mgui/Makefile

    r1965 r2135  
    2222#  connect the include files defined in the config.mk file
    2323#
    24 INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist
     24INCLUDES = -I. -I../mbase -I../mgeom -I../manalysis -I../mimage -I../mhist \
     25           -I../mreflector
    2526
    2627#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.