Changeset 2178 for trunk/MagicSoft/Mars


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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r2177 r2178  
    55   * mhist/MHOnSubtraction.cc:
    66     - worked around the non compiling source file
     7
     8   * merpp.cc:
     9     - set compression level default = 1
     10
     11   * macros/readCT1.C, macros/readMagic.C, macros/readcurrents.C,
     12     meventdisp/MGCamDisplay.cc
     13     - adapted to new MCamDisplay and MCamEvent
     14
     15   * macros/sumcurrents.C:
     16     - enhanced
     17
     18   * manalysis/MCerPhotCalc.[h, cc]:
     19     - simplified algorithm
     20
     21   * manalysis/MCerPhotEvt.[h,cc], manalysis/MCurrents.[h,cc],
     22     manalysis/MPedestalCam.[h,cc]:
     23     - derived from MCamEvent
     24     
     25   * manalysis/MMcPedestalNSBAdd.cc:
     26     - minor change
     27     
     28   * mbase/BaseLinkDef.h, mbase/Makefile:
     29     - added MDirIter
     30
     31   * mbase/MDirIter.[h,cc]:
     32     - added
     33     
     34   * mbase/MParList.cc:
     35     - enhnced some output
     36
     37   * mbase/MTaskInteractive.cc:
     38     - fixed a bug
     39     
     40   * mbase/MTaskList.cc:
     41     - added handling of gui events for Pre- and PostProcess
     42     
     43   * mgeom/MGeomPix.cc:
     44     - added a comment
     45     
     46   * mgui/MCamDisplay.[h,cc] -  PRELIMINARY:
     47     - added a notification list
     48     - fixed SetRange if pad is not the main pad
     49     - new Fill functions using MCamEvent, removed old ones
     50     
     51   * mhist/MFillH.cc:
     52     - check for the existance of the canvas
     53     
     54   * mhist/MHCerPhotEvt.cc:
     55     - take usage of MCamEvent
     56
     57   * mhist/MHCurrents.cc:
     58     - take usage of MCamEvent
     59     - added rms
     60     
     61   * mmain/MStatusDisplay.[h,cc]:
     62     - added "Reset" and "Remove Tab" to menu bar
     63
     64   * mraw/MRawEvtData.[h,cc]:
     65     - draw hi- and logains
     66     - derived from MCamEvent
     67     
     68   * mraw/MRawEvtPixelIter.[h,cc]:
     69     - added GetVarHiGainSamples
     70
     71   * mraw/Makefile:
     72     - added -I../mgui - PRELIMINARY
    773
    874
  • trunk/MagicSoft/Mars/macros/readCT1.C

    r2151 r2178  
    8989            continue;
    9090
    91         display.FillPhotNum(*evt);
     91        display.Fill(*evt);
    9292        display.Update();
    9393
     
    100100        newimgpar.Print();
    101101
    102         display.FillPhotNum(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
     102        display.Fill(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
    103103        display.Update();
    104104
  • trunk/MagicSoft/Mars/macros/readMagic.C

    r2173 r2178  
    104104        cout << "Event #" << read.GetNumEntry() ":" << endl;
    105105
    106         display.FillPhotNum(*(MCerPhotEvt*)clone.GetClone());
     106        display.Fill(*(MCerPhotEvt*)clone.GetClone());
    107107        gPad->Modified();
    108108        gPad->Update();
     
    116116        newimgpar.Print();
    117117
    118         display.FillPhotNum(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
     118        display.Fill(*(MCerPhotEvt*)plist.FindObject("MCerPhotEvt"));
    119119        gPad->Modified();
    120120        gPad->Update();
  • trunk/MagicSoft/Mars/macros/readcurrents.C

    r2153 r2178  
    4545}
    4646
    47 void readcurrents(const char *fname="../currents/dcs_vega.dat")
     47void readcurrents(const char *fname="../currents/dcs_arcturus.dat")
    4848{
    4949    MParList plist;
     
    8686    {
    8787        // cur.Print();
    88         display.FillCurrents(cur);
     88        display.Fill(cur);
    8989        gPad->Modified();
    9090        gPad->Update();
  • trunk/MagicSoft/Mars/macros/sumcurrents.C

    r2158 r2178  
    2929//  This macro shows how to fill and display a histogram using Mars
    3030//
    31 void sumcurrents(const char *fname="../currents/dcs_arcturus.dat")
     31void sumcurrents(const char *fname="../currents/spica_center.txt")
    3232{
    3333    //
     
    8383    MHCurrents &h = *(MHCurrents*)plist->FindObject("MHCurrents");
    8484
    85     MCamDisplay *disp = new MCamDisplay(&geom);
    86     disp->FillCurrents(h.GetSum());
    87     disp->Draw();
     85    TCanvas *c = MH::MakeDefCanvas();
     86    c->Divide(3, 2);
     87
     88    MCamDisplay *disp1=new MCamDisplay(&geom);
     89    MCamDisplay *disp2=new MCamDisplay(&geom);
     90    MCamDisplay *disp3=new MCamDisplay(&geom);
     91    disp1->Fill(h.GetSum());
     92    disp2->Fill(h.GetRms());
     93
     94    TArrayF arr(577);
     95    for (int i=0;i<577;i++)
     96    {
     97        TArrayF &r = h.GetRms();
     98        TArrayF &v = h.GetSum();
     99        arr[i] = (r[i]==0 ? 0 : v[i]/r[i]);
     100    }
     101    disp3->Fill(arr);
     102
     103    c->cd(1);
     104    gPad->SetBorderMode(0);
     105    gPad->Divide(1,1);
     106    gPad->cd(1);
     107    gPad->SetLogz();
     108    disp1->Draw();
     109    disp1->SetBit(kCanDelete);
     110    c->cd(2);
     111    gPad->SetBorderMode(0);
     112    gPad->Divide(1,1);
     113    gPad->cd(1);
     114    gPad->SetLogz();
     115    disp2->Draw();
     116    disp2->SetBit(kCanDelete);
     117    c->cd(3);
     118    gPad->SetBorderMode(0);
     119    gPad->Divide(1,1);
     120    gPad->cd(1);
     121    gPad->SetLogz();
     122    disp3->Draw();
     123    disp3->SetBit(kCanDelete);
     124    c->cd(4);
     125    gPad->SetBorderMode(0);
     126    h.GetHist().DrawClone();
     127    c->cd(5);
     128    gPad->SetBorderMode(0);
     129    TH1F h1("currents;rms", "Currents Rms", 577, -0.5, 576.5);
     130    for (int i=1;i<=577; i++)
     131        h1.SetBinContent(i, h.GetHist().GetBinError(i));
     132    h1.DrawCopy();
     133    c->cd(6);
     134    gPad->SetBorderMode(0);
     135    TH1F h2("currents;relerr", "Currents rel. Error [%]", 577, -0.5, 576.5);
     136    for (int i=1;i<=577; i++)
     137    {
     138        Float_t val = h.GetHist().GetBinContent(i);
     139        Float_t rms = h.GetHist().GetBinError(i);
     140        h2.SetBinContent(i, rms==0?0:val/rms);
     141    }
     142    h2.DrawCopy();
     143
     144    c->SaveAs("spica_center-avg.ps");
    88145}
  • trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.cc

    r2173 r2178  
    3232//   the array fWeight (default: all slices added up with weight 1).
    3333//
     34//   The weights are rescaled, such that sum(weigths)=num slices
     35//
    3436//  Input Containers:
    3537//   MRawRunHeader, MRawEvtData, MPedestalCam
     
    112114
    113115    // Calculate quadratic sum of weights:
    114     fSumQuadWeights = 0.;
    115     for (Int_t i = 0; i < fWeight.GetSize(); i++)
     116    fSumWeights = 0;
     117    fSumQuadWeights = 0;
     118    for (Int_t i=0; i<fWeight.GetSize(); i++)
     119    {
     120        fSumWeights += fWeight[i];
    116121        fSumQuadWeights += fWeight[i]*fWeight[i];
     122    }
    117123
    118124    fSumQuadWeights = sqrt(fSumQuadWeights);
     
    169175
    170176    MRawEvtPixelIter pixel(fRawEvt);
    171 
    172     TArrayF binsignal(fWeight.GetSize());
    173177
    174178    while (pixel.Next())
     
    194198        // Calculate pixel signal unless it has all FADC slices empty:
    195199        //
    196         const Byte_t *ptr = pixel.GetHiGainSamples();
    197 
    198         Float_t nphot = 0;
    199         Float_t nphoterr = 0;
    200 
    201         if (pixel.GetSumHiGainSamples()>0)
    202         {
    203             for (Int_t i=0; i<fWeight.GetSize(); i++)
    204             {
    205                 binsignal[i] =  ptr[i] - mean;
    206                 nphot       +=  binsignal[i] * fWeight[i];
    207             }
    208             nphoterr = ped.GetSigma() * fSumQuadWeights;
    209         }
     200        Byte_t *ptr = pixel.GetHiGainSamples();
     201
     202        Float_t nphot = 0;
     203        for(Int_t i=0; i<fWeight.GetSize(); i++)
     204            nphot += ptr[i]*fWeight[i];
     205
     206        nphot -= mean*fSumWeights;
     207
     208        const Float_t nphoterr = ped.GetSigma()* fSumQuadWeights;
    210209
    211210        fCerPhotEvt->AddPixel(pixid, nphot, nphoterr);
  • trunk/MagicSoft/Mars/manalysis/MCerPhotCalc.h

    r1715 r2178  
    3333
    3434    TArrayF         fWeight;  // Weights for adding up the ADC slices
     35    Float_t         fSumWeights;
    3536    Float_t         fSumQuadWeights;
    3637
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r2173 r2178  
    384384    fNumPixels=fPixels->GetEntriesFast();
    385385}
     386
     387Bool_t MCerPhotEvt::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio, Int_t type) const
     388{
     389    MCerPhotPix *pix = GetPixById(idx);
     390    if (!pix || !pix->IsPixelUsed())
     391        return kFALSE;
     392
     393    switch (type)
     394    {
     395    case 1:
     396        val = pix->GetErrorPhot()*TMath::Sqrt(ratio);
     397        return kTRUE;
     398    case 2:
     399        if (pix->GetErrorPhot()<=0)
     400            return kFALSE;
     401        val = pix->GetNumPhotons()*TMath::Sqrt(ratio)/pix->GetErrorPhot();
     402        return kTRUE;
     403    default:
     404        val = pix->GetNumPhotons()*ratio;
     405        return kTRUE;
     406    }
     407    return kTRUE;
     408}
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r2147 r2178  
    44#ifndef ROOT_TClonesArray
    55#include <TClonesArray.h>
     6#endif
     7#ifndef MARS_MCamEvent
     8#include "MCamEvent.h"
    69#endif
    710#ifndef MARS_MCerPhotPix
     
    1215class MCerPhotPix;
    1316
    14 class MCerPhotEvt : public MParContainer
     17class MCerPhotEvt : public MCamEvent
    1518{
    1619private:
     
    6164    void Clear(Option_t *opt=NULL) { Reset(); }
    6265
     66    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
     67    void DrawPixelContent(Int_t num) const
     68    {
     69    }
     70
    6371    ClassDef(MCerPhotEvt, 1)    // class for an event containing cerenkov photons
    6472};
  • trunk/MagicSoft/Mars/manalysis/MCurrents.h

    r2173 r2178  
    22#define MARS_MCurrents
    33
    4 #ifndef MARS_MParContainer
    5 #include "MParContainer.h"
     4#ifndef MARS_MCamEvent
     5#include "MCamEvent.h"
    66#endif
    77
     
    1010#endif
    1111
    12 class MCurrents : public MParContainer
     12#include <iostream.h>
     13class MCurrents : public MCamEvent
    1314{
    1415private:
     
    3738    void Print(Option_t *opt=NULL) const;
    3839
     40    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const
     41    {
     42        val = (*this)[idx];
     43        return val>0;
     44    }
     45    void DrawPixelContent(Int_t num) const
     46    {
     47    }
     48
    3949    ClassDef(MCurrents, 1) // Storage Container for the Currents (PRELIMINARY)
    4050};
  • trunk/MagicSoft/Mars/manalysis/MMcPedestalNSBAdd.cc

    r2173 r2178  
    1616!
    1717!
    18 !   Author(s): Oscar Blanch  11/2001 < mailto:blanch@ifae.es>
     18!   Author(s): Oscar Blanch, 11/2001 <mailto:blanch@ifae.es>
    1919!
    2020!   Copyright: MAGIC Software Development, 2000-2001
  • trunk/MagicSoft/Mars/manalysis/MPedestalCam.cc

    r2173 r2178  
    181181    return maxval;
    182182}
     183
     184Bool_t MPedestalCam::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const
     185{
     186    val = (*this)[idx].GetMean()*ratio;
     187    return kTRUE;
     188}
  • trunk/MagicSoft/Mars/manalysis/MPedestalCam.h

    r1540 r2178  
    22#define MARS_MPedestalCam
    33
    4 #ifndef MARS_MParContainer
    5 #include "MParContainer.h"
     4#ifndef MARS_MCamEvent
     5#include "MCamEvent.h"
    66#endif
    77
     
    1111class MPedestalPix;
    1212
    13 class MPedestalCam : public MParContainer
     13class MPedestalCam : public MCamEvent
    1414{
    1515private:
     
    3535    void Print(Option_t *o="") const;
    3636
     37    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
     38    void DrawPixelContent(Int_t num) const
     39    {
     40    }
     41
    3742    ClassDef(MPedestalCam, 1)   // Storage Container for all pedestal information of the camera
    3843};
  • trunk/MagicSoft/Mars/mbase/BaseLinkDef.h

    r2173 r2178  
    1616
    1717#pragma link C++ class MIter+;
     18#pragma link C++ class MDirIter+;
    1819
    1920#pragma link C++ class MTask+;
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r2173 r2178  
    472472    if (!pcont)
    473473    {
    474         *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
     474        *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "' Possible reasons:" << endl;
     475        *fLog << " - Class has no default constructor." << endl;
     476        *fLog << " - An abstract member functions of a base class is not overwritten." << endl;
    475477        return NULL;
    476478    }
  • trunk/MagicSoft/Mars/mbase/MTaskInteractive.cc

    r2173 r2178  
    2626//
    2727// MTaskInteractive
     28//
     29// If you want to create a new task inside a macro you will have to compile
     30// your macro using macro.C++, because the root interpreter cannot use
     31// uncompiled classes. To workaround this problem you can write simple
     32// funcions (which can be handled by CINT) and use MTaskInteractive.
     33//
     34// This is a simple way to develop new code in a macro without need
     35// to compile it.
    2836//
    2937//  Input Containers:
     
    7785
    7886    Long_t result;
    79     fCall[no]->Execute(params, result);
     87    fCall[no]->SetParamPtrs(params);
     88    fCall[no]->Execute(result);
     89
    8090    return result;
    8191}
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r2173 r2178  
    6060
    6161#include <TClass.h>
     62#include <TSystem.h>        // gSystem
    6263#include <TOrdCollection.h>
    6364
     
    365366
    366367        case kTRUE:
     368            // Handle GUI events (display changes, mouse clicks)
     369            if (fDisplay)
     370                gSystem->ProcessEvents();
    367371            continue;
    368372
     
    461465            //
    462466            rc = kFALSE;
     467            *fLog << inf << task->GetDescriptor() << " has stopped execution of " << GetDescriptor() << "." << endl;
    463468            break;
    464469
     
    531536        if (!task->CallPostProcess())
    532537            return kFALSE;
     538
     539        // Handle GUI events (display changes, mouse clicks)
     540        if (fDisplay)
     541            gSystem->ProcessEvents();
    533542    }
    534543
  • trunk/MagicSoft/Mars/mbase/Makefile

    r2156 r2178  
    4343           MEvtLoop.cc \
    4444           MIter.cc \
     45           MDirIter.cc \
    4546           MGList.cc \
    4647           MGTask.cc \
  • trunk/MagicSoft/Mars/merpp.cc

    r2173 r2178  
    5353        gLog << "     input file:   Magic DAQ binary file." << endl;
    5454        gLog << "     ouput file:   Merpped root file." << endl;
    55         gLog << "     compr. level: 1..9 [default=9]" << endl << endl;
     55        gLog << "     compr. level: 1..9 [default=1]" << endl << endl;
    5656        return -1;
    5757    }
     
    6767    const char *kNamein   = argv[1];
    6868    const char *kNameout  = argv[2];
    69     const int   kComprlvl = argc==4 ? atoi(argv[3]) : 9;
     69    const int   kComprlvl = argc==4 ? atoi(argv[3]) : 1;
    7070
    7171    //
  • trunk/MagicSoft/Mars/meventdisp/MGCamDisplay.cc

    r2161 r2178  
    4646#include "MImgCleanStd.h"        // MImgCleanStd
    4747#include "MGeomCamMagic.h"       // MGeomMagicCam
     48#include "MRawEvtData.h"         // MRawEvtData
    4849
    4950ClassImp(MGCamDisplay);
     
    137138    MGeomCamMagic *geom   = new MGeomCamMagic;
    138139    MPedestalCam  *pedest = new MPedestalCam;
     140    MRawEvtData   *event  = new MRawEvtData;
    139141
    140142    plist->AddToList(geom);
    141143    plist->AddToList(pedest);
     144    plist->AddToList(event);
    142145
    143146    return geom;
     
    176179        fDisplay[i]  = new MCamDisplay(geom);
    177180        fDisplay[i]->Draw();
     181        fDisplay[i]->AddNotify(*(MCamEvent*)GetParList()->FindObject("MRawEvtData"));
    178182        fCanvas2[i]->Update();
    179183        fList->Add(fDisplay[i]);
     
    245249    const MPedestalCam *ped   = (MPedestalCam*)plist->FindObject("MPedestalCam");
    246250
    247     fDisplay[0]->FillPhotNum(*evt);
    248     fDisplay[1]->FillErrorPhot(*evt);
    249     fDisplay[2]->FillRatio(*evt);
     251    fDisplay[0]->Fill((MCamEvent&)*evt, 0);
     252    fDisplay[1]->Fill((MCamEvent&)*evt, 1);
     253    fDisplay[2]->Fill((MCamEvent&)*evt, 2);
    250254    fDisplay[3]->FillLevels(*evt, *clean);
    251     fDisplay[4]->FillPedestals(*ped);
     255    fDisplay[4]->Fill((MCamEvent&)*ped);
    252256
    253257    for (int i=0; i<5; i++)
  • trunk/MagicSoft/Mars/mfileio/Makefile

    r2147 r2178  
    2121
    2222INCLUDES = -I. -I../mbase -I../mraw -I../mmc -I../mdata -I../manalysis \
    23            -I../mgeom -I../mhist -I../mmain -I../mreflector
     23           -I../mgeom -I../mhist -I../mmain -I../mreflector -I../mgui
    2424
    2525# @code
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.cc

    r2173 r2178  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!   Author(s): Harald Kornmayer 1/2001
    2020!
    21 !   Copyright: MAGIC Software Development, 2000-2002
     21!   Copyright: MAGIC Software Development, 2000-2003
    2222!
    2323!
     
    3535// MGeomPix.
    3636//
     37// FIXME: According to an agreement we have to change the name 'Id'
     38//        to 'idx'
     39//
    3740////////////////////////////////////////////////////////////////////////////
    38 
    3941#include "MGeomPix.h"
    4042
  • 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)
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r2173 r2178  
    501501
    502502    //
    503     // Check whether fDisplay has previously been used (fCanvas)
    504     // and fDisplay is still open.
    505     //
    506     if (fCanvas && fDisplay)
     503    // Check whether fDisplay has previously been used (fCanvas),
     504    // fDisplay is still open and the corresponding Canvas/Tab is
     505    // still existing.
     506    //
     507    if (fDisplay && fDisplay->HasCanvas(fCanvas))
    507508    {
    508509        fCanvas->cd();
  • trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc

    r2173 r2178  
    127127    const UInt_t n = evt->GetNumPixels();
    128128
    129     for (UInt_t i=0; i<n; i++)
     129    for (UInt_t idx=0; idx<n; idx++)
    130130    {
    131         const MCerPhotPix &pix = (*evt)[i];
     131        Float_t val;
     132        if (!evt->GetPixelContent(val, idx))
     133            continue;
    132134
    133         const Int_t id = pix.GetPixId();
    134 
    135         fSum[id].SetPixelUsed();
    136         fSum[id].AddNumPhotons(pix.GetNumPhotons());
     135        fSum[idx].SetPixelUsed();
     136        fSum[idx].AddNumPhotons(val);
    137137    }
    138138
     
    148148Bool_t MHCerPhotEvt::Finalize()
    149149{
    150     fSum.Scale(fEntries);
     150    if (fEntries<1)
     151        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl;
     152    else
     153        fSum.Scale(fEntries);
    151154    return kTRUE;
    152155}
     
    185188        fDispl = new MCamDisplay(fCam);
    186189
    187     fDispl->FillPhotNum(fSum);
     190    fDispl->Fill(fSum);
    188191    fDispl->Paint();
    189192}
  • trunk/MagicSoft/Mars/mhist/MHCurrents.cc

    r2173 r2178  
    3636
    3737#include "MParList.h"
     38#include "MBinning.h"
    3839#include "MCurrents.h"
    3940#include "MCamDisplay.h"
     
    5455    // FIXME: Implement a clear function with setmem
    5556    for (int i=0; i<577; i++)
     57    {
    5658        fSum[i] = 0;
     59        fRms[i] = 0;
     60    }
    5761
    5862    fEntries = 0;
     
    6569//
    6670MHCurrents::MHCurrents(const char *name, const char *title)
    67     : fSum(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
     71    : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
    6872{
    6973    //
     
    7478
    7579    Clear();
     80
     81    fHist.SetName("currents");
     82    fHist.SetTitle("Avg.Currents [nA]");
     83    fHist.SetDirectory(NULL);
     84    fHist.Sumw2();
    7685}
    7786
     
    105114    Clear();
    106115
     116    MBinning bins;
     117    bins.SetEdges(577, -0.5, 576.5);
     118    bins.Apply(fHist);
     119
    107120    return kTRUE;
    108121}
     
    121134    }
    122135
     136    for (UInt_t idx=0; idx<577; idx++)
     137    {
     138        Float_t val;
     139        if (!evt->GetPixelContent(val, idx))
     140            continue;
     141
     142        fSum[idx] += val;
     143        fRms[idx] += val*val;
     144    }
     145
     146    fEntries++;
     147
     148    return kTRUE;
     149}
     150
     151// --------------------------------------------------------------------------
     152//
     153// Scale the sum container with the number of entries
     154//
     155Bool_t MHCurrents::Finalize()
     156{
     157    if (fEntries<2)
     158    {
     159        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain enough entries." << endl;
     160        return kTRUE;
     161    }
     162
    123163    for (UInt_t i=0; i<577; i++)
    124         fSum[i] += (*evt)[i];
    125 
    126     fEntries++;
    127 
     164    {
     165        // calc sdev^2 for pixel index i
     166        // var^2 = (sum[xi^2] - sum[xi]^2/n) / (n-1);
     167        fRms[i] -= fSum[i]*fSum[i]/fEntries;
     168        fRms[i] /= fEntries-1;
     169        fRms[i]  = TMath::Sqrt(fRms[i]);
     170
     171        // calc mean value for pixel index i
     172        fSum[i] /= fEntries;
     173
     174        fHist.SetBinContent(i+1, fSum[i]);
     175        fHist.SetBinError(  i+1, fRms[i]);
     176    }
    128177    return kTRUE;
    129178}
     
    131180// --------------------------------------------------------------------------
    132181//
    133 // Scale the sum container with the number of entries
    134 //
    135 Bool_t MHCurrents::Finalize()
    136 {
    137     for (UInt_t i=0; i<577; i++)
    138         fSum[i] /= fEntries;
    139 
    140     return kTRUE;
    141 }
    142 
    143 // --------------------------------------------------------------------------
    144 //
    145182// Draw the present 'fill status'
    146183//
    147 void MHCurrents::Draw(Option_t *)
     184void MHCurrents::Draw(Option_t *o)
    148185{
    149186    if (!fCam)
     
    156193    pad->SetBorderMode(0);
    157194
     195    SetDrawOption(o);
    158196    AppendPad("");
    159197}
     
    174212        fDispl = new MCamDisplay(fCam);
    175213
    176     fDispl->FillCurrents(fSum);
     214    TString opt(GetDrawOption());
     215
     216    fDispl->Fill(opt.Contains("rms", TString::kIgnoreCase) ? fRms : fSum);
    177217    fDispl->Paint();
    178218}
  • trunk/MagicSoft/Mars/mhist/MHCurrents.h

    r2173 r2178  
    66#endif
    77
    8 #ifndef MARS_MCurrents
    9 #include "MCurrents.h"
     8#ifndef ROOT_TH1
     9#include <TH1.h>
    1010#endif
    1111
    12 class TH1D;
     12#ifndef ROOT_TArrayF
     13#include <TArrayF.h>
     14#endif
     15
     16class MCurrents;
    1317class MGeomCam;
    1418class MCamDisplay;
     
    1721{
    1822private:
    19     MCurrents    fSum;      // storing the sum
     23    TArrayF      fSum;      // storing the sum
     24    TArrayF      fRms;      // storing the rms
    2025    Int_t        fEntries;  // number of entries in the histogram
    2126    MGeomCam    *fCam;      // the present geometry
    2227    MCurrents   *fEvt;      //! the current event
    2328    MCamDisplay *fDispl;    //! the camera display
     29
     30    TH1F         fHist;
    2431
    2532public:
     
    3542    TH1 *GetHistByName(const TString name) { return NULL; }
    3643
    37     const MCurrents &GetSum() const { return fSum; }
     44    const TArrayF &GetSum() const { return fSum; }
     45    const TArrayF &GetRms() const { return fRms; }
     46
     47    const TH1F    &GetHist() const { return fHist; }
    3848
    3949    void Draw(Option_t *opt="");
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc

    r2173 r2178  
    181181    filemenu->AddEntry("Save As status.&root", kFileSaveAsRoot);
    182182    filemenu->AddSeparator();
     183    filemenu->AddEntry("Re&set",               kFileReset);
     184    filemenu->AddSeparator();
    183185    filemenu->AddEntry("Print with &lpr",      kFilePrint);
    184186    //filemenu->AddEntry("Set printer &name",    kFilePrinterName);
     
    196198    tabmenu->AddEntry("Save As tab-i.&C",    kTabSaveAsC);
    197199    tabmenu->AddEntry("Save As tab-i.&root", kTabSaveAsRoot);
     200    tabmenu->AddSeparator();
     201    tabmenu->AddEntry("Re&move",             kTabRemove);
    198202    tabmenu->AddSeparator();
    199203    tabmenu->AddEntry("Print with &lpr",     kFilePrint);
     
    560564// to the corresponding TCanvas. If it isn't found NULL is returned.
    561565//
    562 TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
     566TRootEmbeddedCanvas *MStatusDisplay::GetEmbeddedCanvas(TGCompositeFrame *cf) const
    563567{
    564568    TIter Next(cf->GetList());
     
    567571    while ((f=(TGFrameElement*)Next()))
    568572        if (f->fFrame->InheritsFrom(TRootEmbeddedCanvas::Class()))
    569             return ((TRootEmbeddedCanvas*)f->fFrame)->GetCanvas();
     573            return (TRootEmbeddedCanvas*)f->fFrame;
    570574
    571575    return NULL;
     576}
     577
     578// --------------------------------------------------------------------------
     579//
     580// Takes a TGCompositeFrame as argument. Searches for the first
     581// TRootEmbeddedCanvas which is contained by it and returns a pointer
     582// to the corresponding TCanvas. If it isn't found NULL is returned.
     583//
     584TCanvas *MStatusDisplay::GetCanvas(TGCompositeFrame *cf) const
     585{
     586    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(cf);
     587    return ec ? ec->GetCanvas() : NULL;
    572588}
    573589
     
    654670    c.SetBorderMode(0);
    655671
    656     // If kNoContaxtMenu set set kNoCOntextMenu of the canvas
     672    // If kNoContextMenu set set kNoContextMenu of the canvas
    657673    if (TestBit(kNoContextMenu))
    658674        c.SetBit(kNoContextMenu);
     
    738754
    739755    return pages;
     756}
     757
     758// --------------------------------------------------------------------------
     759//
     760// Remove tab no i if this tab contains a TRootEmbeddedCanvas
     761//
     762void MStatusDisplay::RemoveTab(int i)
     763{
     764    TGCompositeFrame *f = fTab->GetTabContainer(i);
     765    if (!f)
     766        return;
     767
     768    TRootEmbeddedCanvas *ec = GetEmbeddedCanvas(f);
     769    if (!ec)
     770        return;
     771
     772    TCanvas *c = ec->GetCanvas();
     773    if (!c)
     774        return;
     775
     776    const TString name(c->GetName());
     777
     778    f->RemoveFrame(ec);
     779    delete fList->Remove(ec);
     780
     781    fTab->RemoveTab(i);
     782
     783    // layout and map new tab
     784#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
     785    MapSubwindows();
     786    Layout();
     787#else
     788    Layout();
     789    MapSubwindows();
     790#endif
     791
     792    // display new tab in the main frame
     793    gClient->ProcessEventsFor(fTab);
     794
     795    *fLog << inf << "Removed Tab #" << i << " '" << name << "'" << endl;
     796}
     797
     798// --------------------------------------------------------------------------
     799//
     800// Use this to check whether the MStatusDisplay still contains the
     801// TCanvas c. It could be removed meanwhile by menu usage.
     802//
     803Bool_t MStatusDisplay::HasCanvas(const TCanvas *c) const
     804{
     805    for (int i=1; i<fTab->GetNumberOfTabs(); i++)
     806        if (c==GetCanvas(i))
     807            return kTRUE;
     808    return kFALSE;
    740809}
    741810
     
    773842        return kTRUE;
    774843
     844    case kFileReset:
     845        for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
     846            RemoveTab(i);
     847        return kTRUE;
    775848        /*
    776849    case kFileSave:
     
    828901    case kTabPrevious:
    829902        fTab->SetTab(fTab->GetCurrent()-1);
     903        return kTRUE;
     904
     905    case kTabRemove:
     906        RemoveTab(fTab->GetCurrent());
    830907        return kTRUE;
    831908
  • trunk/MagicSoft/Mars/mmain/MStatusDisplay.h

    r2117 r2178  
    2727class TGProgressBar;
    2828class TGHProgressBar;
     29class TRootEmbeddedCanvas;
    2930
    3031class MStatusDisplay : public TGMainFrame
     
    3536        kFileBrowser, kFileCanvas, kFileSave, kFileSaveAs, kFileSaveAsPS,
    3637        kFileSaveAsRoot, kFileSaveAsGIF, kFileSaveAsC, kFilePrint,
    37         kFilePrinterName, kFileExit,
     38        kFilePrinterName, kFileExit, kFileReset,
    3839        // kLoop
    3940        kLoopNone, kLoopStop,
    4041        // kTab
    4142        kTabSave, kTabSaveAs, kTabSaveAsPS, kTabSaveAsRoot, kTabSaveAsGIF,
    42         kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious,
     43        kTabSaveAsC, kTabPrint, kTabNext, kTabPrevious, kTabRemove,
    4344        // kSize
    4445        kSize640, kSize800, kSize960, kSize1024, kSize1280,
     
    102103    void UpdatePSHeader(const TString &name) const;
    103104
     105    void Reset();
     106    void RemoveTab(int i);
     107
     108    TRootEmbeddedCanvas *GetEmbeddedCanvas(TGCompositeFrame *cf) const;
     109
    104110public:
    105111     MStatusDisplay(Long_t t=1000);
     
    122128     TCanvas &AddTab(const char *name);
    123129
     130     Bool_t   HasCanvas(const TCanvas *c) const;
    124131     TCanvas *GetCanvas(int i) const;
    125132     TCanvas *GetCanvas(const TString &name) const;
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r2173 r2178  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2001
     18!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: MAGIC Software Development, 2000-2003
    2121!
    2222!
     
    4545//  --------------------------
    4646//  see fHiGainFadcSaples
     47//
     48//
     49//   Version 2: Derives from MCamEvent now
    4750//
    4851/////////////////////////////////////////////////////////////////////////////
     
    232235    if (!pix.Jump(id))
    233236    {
    234         *fLog << warn << "Pixel Id #" << id << " doesn't exist!" << endl;
     237        *fLog << warn << "Pixel Idx #" << id << " doesn't exist!" << endl;
    235238        return;
    236239    }
    237240
    238241    const Byte_t *higains = pix.GetHiGainSamples();
    239 
    240     const Int_t n = GetNumHiGainSamples();
    241 
    242     TString name = "Pixel No.";
     242    const Byte_t *logains = pix.GetLoGainSamples();
     243
     244    const Int_t nh = GetNumHiGainSamples();
     245    const Int_t nl = GetNumLoGainSamples();
     246
     247    TString name = "Pixel Idx.";
    243248    name += pix.GetPixelId();
    244249
     250    Bool_t same = str.Contains("same", TString::kIgnoreCase);
     251
    245252    if (str.BeginsWith("GRAPH", TString::kIgnoreCase))
    246253    {
    247         *fLog << inf << "Drawing Graph: Pixel Id #" << pix.GetPixelId();
     254        *fLog << inf << "Drawing Graph: Pixel Idx #" << pix.GetPixelId();
    248255        *fLog << " of " << (int)GetNumPixels() << "Pixels" << endl;
    249256
    250257        TGraph *graph = new TGraph;
    251258
    252         for (int i=0; i<n; i++)
     259        for (int i=0; i<nh; i++)
    253260            graph->SetPoint(graph->GetN(), i, higains[i]);
    254261
     
    257264
    258265        graph->SetBit(kCanDelete);
    259         graph->Draw("AC*");
     266        graph->Draw(same ? "C*" : "AC*");
    260267
    261268        TH1F *hist = graph->GetHistogram();
     
    269276    if (str.BeginsWith("HIST", TString::kIgnoreCase))
    270277    {
    271         *fLog << "Drawing Histogram of Pixel with Id " << pix.GetPixelId() << endl;
    272 
    273         TH1F *hist = new TH1F(name, "Hi Gain Samples FADC", n, 0, n);
    274         hist->SetXTitle("Time/FADC Slices");
    275         hist->SetYTitle("Signal/FADC Units");
    276 
    277         for (int i=0; i<n; i++)
    278             hist->Fill(0.5+i, higains[i]);
    279 
    280         hist->SetBit(kCanDelete);
    281         hist->Draw();
    282 
     278        // FIXME: Add Legend
     279        *fLog << "Drawing Histogram of Pixel with Idx " << pix.GetPixelId() << endl;
     280
     281        TH1F *histh = new TH1F(name, "FADC Samples",      nh, -0.5, nh-.5);
     282        histh->SetXTitle("Time [FADC Slices]");
     283        histh->SetYTitle("Signal [FADC Units]");
     284        histh->SetDirectory(NULL);
     285        for (int i=0; i<nh; i++)
     286            histh->Fill(i, higains[i]);
     287        histh->SetBit(kCanDelete);
     288        histh->Draw(same ? "same" : "");
     289
     290        if (nh>0)
     291        {
     292            TH1F *histl = new TH1F(name+";2", "FADC Samples", nl, -0.5, nl-.5);
     293            histl->SetLineColor(kBlue);
     294            histl->SetDirectory(NULL);
     295            for (int i=0; i<nl; i++)
     296                histl->Fill(i, logains[i]);
     297            histl->SetBit(kCanDelete);
     298            histl->Draw("same");
     299        }
    283300        return;
    284301    }
     
    447464}
    448465
     466Bool_t MRawEvtData::GetPixelContent(Float_t &val, Int_t idx, Float_t ratio, Int_t type) const
     467{
     468    MRawEvtPixelIter Next(const_cast<MRawEvtData*>(this));
     469    if (!Next.Jump(idx))
     470        return kFALSE;
     471
     472    val = Next.GetSumHiGainSamples();
     473    return kTRUE;
     474}
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.h

    r2173 r2178  
    22#define MARS_MRawEvtData
    33
    4 #ifndef MARS_MParContainer
    5 #include "MParContainer.h"
     4#ifndef MARS_MCamEvent
     5#include "MCamEvent.h"
    66#endif
    77
     
    1616class MArrayB;
    1717
    18 class MRawEvtData : public MParContainer
     18#include <iostream.h>
     19
     20class MRawEvtData : public MCamEvent
    1921{
    2022    friend class MRawEvtPixelIter;
     
    6365    void ReadEvt(istream &fin);
    6466
    65     ClassDef(MRawEvtData, 1) //Container to store the raw Event Data
     67    Bool_t GetPixelContent(Float_t &val, Int_t idx, Float_t ratio=1, Int_t type=0) const;
     68    void   DrawPixelContent(Int_t num) const
     69    {
     70        TString s("HIST");
     71        s += num;
     72        const_cast<MRawEvtData*>(this)->Draw(s);
     73    }
     74
     75    ClassDef(MRawEvtData, 2) //Container to store the raw Event Data
    6676};
    6777
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc

    r1548 r2178  
    187187}
    188188
     189Float_t MRawEvtPixelIter::GetVarHiGainSamples() const
     190{
     191    Byte_t *ptr = fHiGainPos;
     192    const Byte_t *end = ptr + fNumHiGainSamples;
     193
     194    ULong_t sum=0;
     195    ULong_t sqsum=0;
     196
     197    do {
     198        sum += *ptr;
     199        sqsum += (*ptr)*(*ptr);
     200    } while (++ptr != end);
     201
     202    return (sqsum-(Float_t)sum*sum/fNumHiGainSamples)/(fNumHiGainSamples-1);
     203}
     204
    189205// --------------------------------------------------------------------------
    190206//
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h

    r2123 r2178  
    7979    ULong_t GetSumHiGainSamples() const;
    8080    ULong_t GetSumSqrHiGainSamples() const;
     81    Float_t GetVarHiGainSamples() const;
    8182
    8283    Bool_t HasLoGain() const
  • trunk/MagicSoft/Mars/mraw/Makefile

    r1160 r2178  
    2222#  connect the include files defined in the config.mk file
    2323#
    24 INCLUDES = -I. -I../mbase -I../MBase
     24INCLUDES = -I. -I../mbase -I../MBase -I../mgui
    2525
    2626#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.