Ignore:
Timestamp:
10/04/03 12:47:13 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2327 r2377  
    7878using namespace std;
    7979
    80 // ------------------------------------------------------------------------
    81 //
    82 //  Default Constructor. To be used by the root system ONLY.
    83 //
    84 MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
     80void MHCamera::Init()
    8581{
    8682    SetDirectory(NULL);
    8783
    88     fNotify  = NULL;
     84    SetLineColor(kGreen);
     85    SetMarkerStyle(kFullDotMedium);
     86    SetXTitle("Pixel Index");
     87
     88    fNotify  = new TList;
    8989
    9090#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
     
    9797// ------------------------------------------------------------------------
    9898//
     99//  Default Constructor. To be used by the root system ONLY.
     100//
     101MHCamera::MHCamera() : TH1D(), fGeomCam(NULL), fColors(kItemsLegend)
     102{
     103    Init();
     104}
     105
     106// ------------------------------------------------------------------------
     107//
    99108//  Constructor. Makes a clone of MGeomCam. Removed the TH1D from the
    100109// current directory. Calls Sumw2(). Set the histogram line color
     
    102111//
    103112MHCamera::MHCamera(const MGeomCam &geom, const char *name, const char *title)
    104 : TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
    105 fUsed(geom.GetNumPixels()), fColors(kItemsLegend)
    106 {
    107     fGeomCam = (MGeomCam*)geom.Clone();
    108 
    109     SetDirectory(NULL);
    110     Sumw2();
    111 
    112     SetLineColor(kGreen);
    113     SetMarkerStyle(kFullDotMedium);
    114     SetXTitle("Pixel Index");
    115 
    116     fNotify = new TList;
    117 
    118     //
    119     //  create the hexagons of the display
     113: fGeomCam(NULL), /*TH1D(name, title, geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5),
     114fUsed(geom.GetNumPixels()),*/ fColors(kItemsLegend)
     115{
     116    //fGeomCam = (MGeomCam*)geom.Clone();
     117    SetGeometry(geom, name, title);
     118    Init();
     119
    120120    //
    121121    // root 3.02
     
    123123    //    register BIT(8) as kNoContextMenu. If an object has this bit set it will
    124124    //    not get an automatic context menu when clicked with the right mouse button.
    125 
    126     //
    127     // Construct all hexagons. Use new-operator with placement
    128     //
     125}
     126
     127void MHCamera::SetGeometry(const MGeomCam &geom, const char *name, const char *title)
     128{
     129    SetNameTitle(name, title);
     130
     131    TAxis &x = *GetXaxis();
     132
     133    SetBins(geom.GetNumPixels(), 0, 1);
     134    x.Set(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
     135
     136    //SetBins(geom.GetNumPixels(), -0.5, geom.GetNumPixels()-0.5);
     137    //Rebuild();
     138
     139    Sumw2(); // necessary?
     140
     141    if (fGeomCam)
     142        delete fGeomCam;
     143    fGeomCam = (MGeomCam*)geom.Clone();
     144
     145    fUsed.Set(geom.GetNumPixels());
    129146    for (Int_t i=0; i<fNcells-2; i++)
    130147        ResetUsed(i);
    131148
    132 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
    133     SetPalette(1, 0);
    134 #else
    135     SetPalette(51, 0);
    136 #endif
    137149}
    138150
     
    229241Int_t MHCamera::Fill(Axis_t x, Axis_t y, Stat_t w)
    230242{
     243    if (fNcells<=1)
     244        return -1;
     245
    231246    for (Int_t idx=0; idx<fNcells-2; idx++)
    232247    {
     
    243258Stat_t MHCamera::GetMean(Int_t axis) const
    244259{
     260    if (fNcells<=1)
     261        return 0;
     262
    245263    Stat_t mean = 0;
    246264    for (int i=1; i<fNcells-1; i++)
     
    252270Stat_t MHCamera::GetRMS(Int_t axis) const
    253271{
     272    if (fNcells<=1)
     273        return -1;
     274
    254275    const Int_t n = fNcells-2;
    255276
     
    278299        return fMinimum;
    279300
     301    if (fNcells<=1)
     302        return 0;
     303
    280304    Double_t minimum=FLT_MAX;
    281305
     
    304328    if (fMaximum != -1111)
    305329        return fMaximum;
     330
     331    if (fNcells<=1)
     332        return 1;
    306333
    307334    Double_t maximum=-FLT_MAX;
     
    491518void MHCamera::Paint(Option_t *o)
    492519{
     520    if (fNcells<=1)
     521        return;
     522
    493523    TString opt(o);
    494524    opt.ToLower();
     
    585615void MHCamera::DrawPixelIndices()
    586616{
     617    if (fNcells<=1)
     618        return;
     619
    587620    // FIXME: Is this correct?
    588621    for (int i=0; i<kItemsLegend; i++)
     
    609642void MHCamera::DrawSectorIndices()
    610643{
     644    if (fNcells<=1)
     645        return;
     646
    611647    for (int i=0; i<kItemsLegend; i++)
    612648        fColors[i] = 16;
     
    637673void MHCamera::AddCamContent(const MCamEvent &event, Int_t type)
    638674{
     675    if (fNcells<=1)
     676        return;
     677
    639678    // FIXME: Security check missing!
    640679    for (Int_t idx=0; idx<fNcells-2; idx++)
     
    717756void MHCamera::CntCamContent(const MCamEvent &event, Double_t threshold, Int_t type)
    718757{
     758    if (fNcells<=1)
     759        return;
     760
    719761    // FIXME: Security check missing!
    720762    for (Int_t idx=0; idx<fNcells-2; idx++)
     
    757799void MHCamera::FillRandom()
    758800{
     801    if (fNcells<=1)
     802        return;
     803
    759804    Reset();
    760805
     
    775820void MHCamera::FillLevels(const MCerPhotEvt &event, Float_t lvl1, Float_t lvl2)
    776821{
     822    if (fNcells<=1)
     823        return;
     824
    777825    SetCamContent(event, 2);
    778826
     
    807855void MHCamera::Reset(Option_t *opt)
    808856{
     857    if (fNcells<=1)
     858        return;
     859
    809860    TH1::Reset(opt);
    810861
     
    9651016Int_t MHCamera::DistancetoPrimitive(Int_t px, Int_t py)
    9661017{
     1018    if (fNcells<=1)
     1019        return 999999;
     1020
    9671021    const Int_t kMaxDiff = 7;
    9681022
     
    10141068Int_t MHCamera::GetPixelIndex(Int_t px, Int_t py) const
    10151069{
     1070    if (fNcells<=1)
     1071        return -1;
     1072
    10161073    Int_t i;
    10171074    for (i=0; i<fNcells-2; i++)
Note: See TracChangeset for help on using the changeset viewer.