Ignore:
Timestamp:
10/04/03 12:47:13 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
6 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++)
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r2298 r2377  
    3838
    3939    //TGStatusBar   *fStatusBar;
     40    void Init();
    4041
    4142    Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog);
     
    7273    MHCamera(const MGeomCam &geom, const char *name="", const char *title="");
    7374    ~MHCamera();
     75
     76    void SetGeometry(const MGeomCam &geom, const char *name="", const char *title="");
     77    const MGeomCam* GetGeometry() const { return fGeomCam; }
    7478
    7579    Bool_t IsUsed(Int_t idx) const { return TESTBIT(const_cast<TArrayC&>(fUsed)[idx], kIsUsed); }
  • trunk/MagicSoft/Mars/mhist/MHCurrents.cc

    r2191 r2377  
    5353void MHCurrents::Clear(const Option_t *)
    5454{
     55    const Int_t n = fCam ? fCam->GetNumPixels() : 577;
     56
    5557    // FIXME: Implement a clear function with setmem
    56     for (int i=0; i<577; i++)
     58    fSum.Set(n); // also clears memory
     59    fRms.Set(n);
     60/*    for (int i=0; i<577; i++)
    5761    {
    5862        fSum[i] = 0;
    5963        fRms[i] = 0;
    60     }
     64    }*/
    6165
    6266    fEntries = 0;
     
    6973//
    7074MHCurrents::MHCurrents(const char *name, const char *title)
    71     : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
     75    : /*fSum(577), fRms(577), */fCam(NULL), fEvt(NULL), fDispl(NULL)
    7276{
    7377    //
     
    113117
    114118    fCam = (MGeomCam*)plist->FindObject("MGeomCam");
    115     if (!fCam)
    116         *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
     119    /*
     120    if (!fCam)
     121        *fLog << warn << GetDescriptor() << ": No MGeomCam found... assuming Magic geometry!" << endl;
     122    */
     123    if (!fCam)
     124    {
     125        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
     126        return kFALSE;
     127    }
    117128
    118129    Clear();
    119130
     131    const Int_t n = fSum.GetSize();
     132
    120133    MBinning bins;
    121     bins.SetEdges(577, -0.5, 576.5);
     134    bins.SetEdges(n, -0.5, n-0.5);
    122135    bins.Apply(fHist);
    123136
     
    138151    }
    139152
    140     for (UInt_t idx=0; idx<577; idx++)
     153    const Int_t n = fSum.GetSize();
     154    for (UInt_t idx=0; idx<n; idx++)
    141155    {
    142156        Float_t val;
     
    166180    }
    167181
    168     for (UInt_t i=0; i<577; i++)
     182    const Int_t n = fSum.GetSize();
     183    for (UInt_t i=0; i<n; i++)
    169184    {
    170185        // calc sdev^2 for pixel index i
  • trunk/MagicSoft/Mars/mhist/MHFadcCam.cc

    r2333 r2377  
    3737#include "MLogManip.h"
    3838
     39#include "MParList.h"
     40#include "MGeomCam.h"
     41
    3942#include "MRawEvtData.h"
    4043#include "MRawEvtPixelIter.h"
     
    4952//  creates an a list of histograms for all pixels and both gain channels
    5053//
    51 MHFadcCam::MHFadcCam(const Int_t n, MHFadcPix::Type_t t, const char *name, const char *title)
     54MHFadcCam::MHFadcCam(/*const Int_t n,*/ MHFadcPix::Type_t t, const char *name, const char *title)
    5255    : fNumHiGains(-1), fNumLoGains(-1), fType(t)
    5356{
     
    6366    // connect all the histogram with the container fHist
    6467    //
    65     fArray = new TObjArray(n);
     68    fArray = new TObjArray;
     69    fArray->SetOwner();
    6670
    67     for (Int_t i=0; i<n; i++)
    68         (*fArray)[i] = new MHFadcPix(i, fType);
     71    //    for (Int_t i=0; i<n; i++)
     72    //        (*fArray)[i] = new MHFadcPix(i, fType);
    6973}
    7074
     
    8791    // FIXME, this might be done faster and more elegant, by direct copy.
    8892    //
    89     MHFadcCam *cam = new MHFadcCam(n);
     93    MHFadcCam *cam = new MHFadcCam(fType);
     94
     95    cam->fArray->Expand(n);
    9096
    9197    for (int i=0; i<n; i++)
     
    95101    }
    96102    return cam;
     103}
     104
     105// --------------------------------------------------------------------------
     106//
     107// To setup the object we get the number of pixels from a MGeomCam object
     108// in the Parameter list.
     109//
     110Bool_t MHFadcCam::SetupFill(const MParList *pList)
     111{
     112    MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
     113    if (!cam)
     114    {
     115        *fLog << err << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
     116        return kFALSE;
     117    }
     118
     119    const Int_t n = cam->GetNumPixels();
     120
     121    fArray->Delete();
     122    fArray->Expand(n);
     123
     124    for (Int_t i=0; i<n; i++)
     125        (*fArray)[i] = new MHFadcPix(i, fType);
     126
     127    return kTRUE;
    97128}
    98129
  • trunk/MagicSoft/Mars/mhist/MHFadcCam.h

    r2333 r2377  
    3333
    3434public:
    35     MHFadcCam(const Int_t n=577, MHFadcPix::Type_t t=MHFadcPix::kValue, const char *name=NULL, const char *title=NULL);
     35    MHFadcCam(/*const Int_t n=577,*/ MHFadcPix::Type_t t=MHFadcPix::kValue, const char *name=NULL, const char *title=NULL);
    3636    ~MHFadcCam();
    3737
     
    4545    const TH1F *GetHistLo(UInt_t i) const { return (*this)[i].GetHistLo(); }
    4646
     47    Bool_t SetupFill(const MParList *pList);
    4748    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
    4849    Bool_t Fill(const MRawEvtData *par);
  • trunk/MagicSoft/Mars/mhist/MHTriggerLvl0.cc

    r2298 r2377  
    100100    MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam");
    101101    if (!cam)
    102         *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl;
     102    {
     103        *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
     104        return kFALSE;
     105    }
    103106
    104107    if (fSum)
Note: See TracChangeset for help on using the changeset viewer.