Changeset 9369 for trunk/MagicSoft


Ignore:
Timestamp:
03/01/09 21:54:27 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
2 added
58 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9367 r9369  
    4646     - moved getter and setter to source file to avoid including of
    4747       TMath
     48
     49   * mgeom/MGeom.[h,cc]:
     50     - added
     51
     52   * mgeom/MGeomRectangle.[h,cc]:
     53     - added
     54
     55   * mgeom/MGeomCamSquare.[h,cc]:
     56     - added
     57
     58   * mgeom/Makefile, mgeom/GeomLinkDef.h:
     59     - added MGeom
     60     - added MGeomRectangle
     61     - added MGeomCamSquare
     62
     63   * Makefile.rules:
     64     - removed dependance on ROOTSYS from rmkdepend. It should be in
     65       the path anyway as rootcint
     66
     67   * ceres.rc:
     68     - added an example of setting the APD type
     69
     70   * mbadpixels/MBadPixelsCam.[h,cc], mbadpixels/MBadPixelsTreat.cc,
     71     mcalib/MCalibrationChargeCalc.cc, mcalib/MCalibrationTestCalc.cc,
     72     mfilter/MFSoftwareTrigger.cc:
     73     - replaced references to MGeomPix by references to MGeom
     74
     75   * mbase/MStatusDisplay.cc:
     76     - evaluate the return code of fwrite as suggested by newer
     77       gcc versions
     78     - set a paranthesis as suggested by a warning
     79
     80   * mgeom/MGeomCam.[h,cc]:
     81     - adapted to the changes in MGeomPix/MGeom
     82     - added SetAt function for external setup
     83     - added Copy constructor
     84
     85   * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamDwarf.cc,
     86     mgeom/MGeomCamMagic.cc, mhft/MHexagonFreqSpace.cc,
     87     mimage/MHillas.cc, mimage/MHillasExt.cc,
     88     mimage/MImgCleanStd.[h,cc], mimage/MNewImagePar.cc,
     89     mimage/MNewImagePar2.cc, mmuon/MHSingleMuon.cc,
     90     msignal/MSignalCam.cc, mtools/MagicJam.cc,
     91     
     92     - adapted to the changes in MGeomPix/MGeom
     93     - use SetAt for setup
     94
     95   * mgeom/MGeomPix.cc:
     96     - moved most of the code to new base class MGeom
     97     - now derives from MGeom
     98     - increased version number accordingly
     99
     100   * mhbase/MBinning.cc:
     101     - replaced a Int_t by UInt_t as suggested by a warning
     102
     103   * mhbase/MH.cc:
     104     - added a const_cast for GetObjectInfo (should be const,
     105       but isn't)
     106
     107   * mhbase/MHMatrix.cc, mhflux/MHAlpha.cc, mhflux/MHThetaSq.cc,
     108     mhflux/MHThetaSqN.cc, mhist/MHCamEventRot.cc, hvstime/MHVsTime.cc,
     109     mjobs/MJStar.cc, mraw/MRawEvtHeader.cc:
     110     - added paranthesis as suggested by a warning
     111
     112   * mhft/MGeomCamMagicXT.[h,cc]:
     113     - replaced by deriving from MGeomCamDwarf
     114
     115   * mhist/MHCamera.cc:
     116     - adapted to the changes in MGeomPix/MGeom
     117     - use SetAt for setup
     118     - use new PaintPrimitive to skip the usage of MHexagon
     119
     120   * mmc/MMcTrigHeader.hxx:
     121     - fixed wrong condition in SetTrigger
     122
     123   * msimcamera/MSimAPD.[h,cc]:
     124     - added a possibility to switch between the 50mu and 100mu
     125       Diodes
     126
     127   * mtools/MagicCivilization.[h,cc], mtools/MagicDomino.[h,cc],
     128     mtools/MagicReversi.[h,cc], mtools/MagicShow.[h,cc],
     129     mtools/MagicSnake.[h,cc], mtools/MineSweeper.[h,cc],
     130     - adapted to the changes in MGeomPix/MGeom, therefore restructered
     131       the code to get rid of MHexagon
     132
     133   *  mmovie/MMovieWrite.cc:
     134     - allow to switch off timing via preprocessor directive
     135     - replaced MGeomPix by MGeom
     136     - slightly changed palette
     137     - evaluate return of fwrite
    48138
    49139
  • trunk/MagicSoft/Mars/Makefile.rules

    r9368 r9369  
    104104
    105105diff:
    106         @cvs -d diff | grep -v "^? " > mars.diff
     106        @cvs diff | grep -v "^? " > mars.diff
    107107
    108108zdiff:
  • trunk/MagicSoft/Mars/NEWS

    r9367 r9369  
    1818     leading date with the underscore is missing in the expected filename
    1919
     20   * the geometry class now also supports other geometries than just hexagons
     21
    2022 ;automation
    2123
     
    9395
    9496   * Now outputs MSrcPosCam for Monte Carlos in the Events tree.
     97
     98   * The definition of fConcCore has slightly changed. The numbers
     99     might decrease a little bit (the effect should be rather small)
    95100
    96101 ;ganymed
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc

    r8601 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.cc,v 1.52 2007-06-24 16:31:57 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.cc,v 1.53 2009-03-01 21:48:13 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    185185// Calculate the number of pixels without the given type-flags.
    186186//
    187 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
     187// The second argument aidx is the area index (see MGeomCam, MGeom)
    188188// The default (or any value less than 0) means: all
    189189//
     
    216216// Calculate the number of pixels with the given type-flags.
    217217//
    218 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
     218// The second argument aidx is the area index (see MGeomCam, MGeom)
    219219// The default (or any value less than 0) means: all
    220220//
     
    263263// Counts the number of neighbors matching NOT UnsuitableType type
    264264//
    265 Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const
     265Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom &pix) const
    266266{
    267267    const Int_t n2 = pix.GetNumNeighbors();
     
    284284// doesn't matter) has less than two reliable neighbor pixels.
    285285//
    286 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
     286// The second argument aidx is the area index (see MGeomCam, MGeom)
    287287// The default (or any value less than 0) means: all
    288288//
     
    302302    for (int i=0; i<n; i++)
    303303    {
    304         const MGeomPix &pix = geom[i];
     304        const MGeom &pix = geom[i];
    305305        if (aidx>=0 && pix.GetAidx()!=aidx)
    306306            continue;
     
    320320// the function is called for all its neighbors. If
    321321//
    322 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
     322// The second argument aidx is the area index (see MGeomCam, MGeom)
    323323// The default (or any value less than 0) means: all
    324324//
     
    327327Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const
    328328{
    329     const MGeomPix *pix = (MGeomPix*)list[idx];
     329    const MGeom *pix = (MGeom*)list[idx];
    330330    if (!pix)
    331331        return 0;
     
    358358// type and the given area index.
    359359//
    360 // The second argument aidx is the area index (see MGeomCam, MGeomPix)
     360// The second argument aidx is the area index (see MGeomCam, MGeom)
    361361// The default (or any value less than 0) means: all
    362362//
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h

    r8788 r9369  
    11/* ======================================================================== *\
    2 !  $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.h,v 1.12 2007-12-14 09:56:01 tbretz Exp $
     2!  $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.h,v 1.13 2009-03-01 21:48:13 tbretz Exp $
    33\* ======================================================================== */
    44#ifndef MARS_MBadPixelsCam
     
    1515class TClonesArray;
    1616
    17 class MGeomPix;
     17class MGeom;
    1818
    1919class MBadPixelsCam : public MParContainer, public MCamEvent
     
    2222    TClonesArray *fArray; //->
    2323
    24     Short_t GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeomPix &pix) const;
     24    Short_t GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom &pix) const;
    2525    Short_t GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const;
    2626
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc

    r8801 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsTreat.cc,v 1.41 2008-01-09 11:30:24 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MBadPixelsTreat.cc,v 1.42 2009-03-01 21:48:13 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    257257        // Get the corresponding geometry and pedestal
    258258        //
    259         MSignalPix     &pix  = (*fEvt)[i];
    260         const MGeomPix &gpix = (*fGeomCam)[i];
     259        MSignalPix  &pix  = (*fEvt)[i];
     260        const MGeom &gpix = (*fGeomCam)[i];
    261261
    262262        // Do Not-Use-Central-Pixel
     
    346346        // Get the corresponding geometry and pedestal
    347347        //
    348         const MGeomPix    &gpix = (*fGeomCam)[i];
     348        const MGeom       &gpix = (*fGeomCam)[i];
    349349        const MPedPhotPix &ppix = pedphot[i];
    350350
     
    442442
    443443        // Geometry of bad pixel
    444         const MGeomPix &gpix = (*fGeomCam)[i];
     444        const MGeom &gpix = (*fGeomCam)[i];
    445445
    446446        // Number of neighbor pixels
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r9302 r9369  
    15041504    if (!p)
    15051505    {
    1506         *fLog << err << "ERROR - Couldn't open pipe " << pipe << endl;
     1506        *fLog << err << "ERROR - Couldn't open pipe " << pipe << ": " << strerror(errno) << endl;
    15071507        return kFALSE;
    15081508    }
     
    15141514    ULong_t i = 0;
    15151515    TGLongPosition pos;
     1516
     1517    Bool_t rc = kTRUE;
    15161518
    15171519    pos.fX = pos.fY = 0;
     
    15331535            i++;
    15341536        }
    1535         fwrite(buf2, sizeof(char), strlen(buf2)+1, p);
    1536 
     1537
     1538        const UInt_t len = sizeof(char)*(strlen(buf2)+1);
     1539
     1540        const size_t ret = fwrite(buf2, len, 1, p);
    15371541        delete [] buf1;
    15381542        delete [] buf2;
     1543
     1544        if (ret!=1)
     1545        {
     1546            *fLog << err << "ERROR - fwrite to pipe " << pipe << " failed: " << strerror(errno) << endl;
     1547            rc = kFALSE;
     1548            break;
     1549        }
     1550
    15391551        pos.fY++;
    15401552    }
     
    24872499{
    24882500    if (gROOT->IsBatch())
    2489         return num>0 && num<=fBatch->GetSize() || num<0;
     2501        return (num>0 && num<=fBatch->GetSize()) || num<0;
    24902502
    24912503    if (num>=fTab->GetNumberOfTabs())
  • trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc

    r9313 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.185 2009-02-11 10:48:24 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.186 2009-03-01 21:48:13 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    20502050     
    20512051      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    2052       MGeomPix &geo = (*fGeom)[i];
     2052      MGeom &geo = (*fGeom)[i];
    20532053
    20542054      const Float_t qe        = pix.GetPheFFactorMethod()
     
    21262126
    21272127      MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i];
    2128       MGeomPix &geo = (*fGeom)[i];
     2128      MGeom &geo = (*fGeom)[i];
    21292129
    21302130      const Float_t qe       =  pix.GetPheFFactorMethod()
  • trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.cc

    r8910 r9369  
    577577{
    578578 
    579   const MGeomPix &pix = (*fGeom)[idx];
     579  const MGeom &pix = (*fGeom)[idx];
    580580  const Byte_t neighbours = pix.GetNumNeighbors();
    581581
  • trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc

    r8618 r9369  
    137137
    138138    // Get the geometry information (neighbors) of this pixel
    139     const MGeomPix &gpix = (*fCam)[idx];
     139    const MGeom &gpix = (*fCam)[idx];
    140140
    141141    // Now do the same with all its neighbors and sum the
     
    342342        Int_t num = 1;
    343343
    344         const MGeomPix &gpix = (*fCam)[i];
     344        const MGeom &gpix = (*fCam)[i];
    345345
    346346        const Int_t nneighbors = gpix.GetNumNeighbors();
  • trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h

    r8920 r9369  
    55#pragma link off all functions;
    66
     7#pragma link C++ class MGeom+;
    78#pragma link C++ class MGeomPix+;
     9#pragma link C++ class MGeomRectangle+;
    810#pragma link C++ class MGeomCam-;
    911#pragma link C++ class MGeomPMT+;
     
    1618#pragma link C++ class MGeomCamDwarf+;
    1719#pragma link C++ class MGeomCamMagic+;
     20#pragma link C++ class MGeomCamSquare+;
    1821//#pragma link C++ class MGeomCamMagicHG+;
    1922//#pragma link C++ class MGeomCamMagic919+;
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r9259 r9369  
    8585//
    8686MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title)
    87     : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)),
    88     fPixels(npix), fMaxRadius(1), fMinRadius(1), fPixRatio(npix), fPixRatioSqrt(npix)
     87    : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), fPixels(npix),
     88    fMaxRadius(1), fMinRadius(1), fPixRatio(npix), fPixRatioSqrt(npix)
    8989{
    9090    fName  = name  ? name  : "MGeomCam";
     
    9595    //
    9696    fPixels.SetOwner();
    97 
    98     // For root versions <5.18 AddAt is mandatory, for newer
    99     // root-version the []-operator can be used safely
    100     for (UInt_t i=0; i<npix; i++)
    101         fPixels.AddAt(new MGeomPix, i);
    10297}
    10398
     
    126121    Int_t m = c.fPixels.GetEntriesFast();
    127122
     123    c.fPixels.Delete();
    128124    c.fPixels.Expand(n);
    129125
    130126    for (int i=m; i<n; i++)
    131         c.fPixels.AddAt(new MGeomPix, i);
    132 
    133     for (int i=0; i<n; i++)
    134         fPixels[i]->Copy(c[i]);
     127        c.fPixels.AddAt(fPixels[i]->Clone(), i);
    135128}
    136129
     
    141134// entries may crash the program!
    142135//
    143 MGeomPix &MGeomCam::operator[](Int_t i)
    144 {
    145     return *static_cast<MGeomPix*>(fPixels.UncheckedAt(i));
     136MGeom &MGeomCam::operator[](Int_t i)
     137{
     138    return *static_cast<MGeom*>(fPixels.UncheckedAt(i));
    146139}
    147140
     
    152145// entries may crash the program!
    153146//
    154 MGeomPix &MGeomCam::operator[](Int_t i) const
    155 {
    156     return *static_cast<MGeomPix*>(fPixels.UncheckedAt(i));
     147MGeom &MGeomCam::operator[](Int_t i) const
     148{
     149    return *static_cast<MGeom*>(fPixels.UncheckedAt(i));
    157150}
    158151
     
    240233    for (UInt_t i=0; i<fNumPixels; i++)
    241234    {
    242         const MGeomPix &pix = (*this)[i];
     235        const MGeom &pix = (*this)[i];
    243236
    244237        const UInt_t  s = pix.GetAidx();
     
    289282    for (unsigned int i=0; i<fNumPixels; i++)
    290283    {
    291         MGeomPix &gpix = (*this)[i];
     284        MGeom &gpix = (*this)[i];
    292285
    293286        Double_t phi[6];
     
    462455// The center pixel is also returned.
    463456//
    464 void MGeomCam::GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const
     457void MGeomCam::GetNeighbors(TArrayI &arr, const MGeom &pix, Float_t r) const
    465458{
    466459    arr.Set(GetNumPixels());
     
    490483    }
    491484
    492     const MGeomPix &pix = (*this)[idx];
     485    const MGeom &pix = (*this)[idx];
    493486    GetNeighbors(arr, pix, r);
    494487}
     
    499492// The center pixel is also returned.
    500493//
    501 void MGeomCam::GetNeighbors(TList &arr, const MGeomPix &pix, Float_t r) const
     494void MGeomCam::GetNeighbors(TList &arr, const MGeom &pix, Float_t r) const
    502495{
    503496    for (unsigned int i=0; i<GetNumPixels(); i++)
     
    518511        return;
    519512
    520     const MGeomPix &pix = (*this)[idx];
     513    const MGeom &pix = (*this)[idx];
    521514    GetNeighbors(arr, pix, r);
    522515}
     
    544537        return -1;
    545538
    546     const MGeomPix &pix=operator[](idx);
     539    const MGeom &pix=operator[](idx);
    547540
    548541    //
     
    598591        MGeomCam::Class()->WriteBuffer(b, this);
    599592}
     593
     594void MGeomCam::SetAt(UInt_t i, const MGeom &pix)
     595{
     596    if (i>=fNumPixels)
     597        return;
     598
     599    if (fPixels[i])
     600        delete fPixels.RemoveAt(i);
     601
     602    // For root versions <5.18 AddAt is mandatory, for newer
     603    // root-version the []-operator can be used safely
     604    fPixels.AddAt(pix.Clone(), i);
     605}
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r9259 r9369  
    2020class TVector2;
    2121class TArrayI;
    22 class MGeomPix;
     22class MGeom;
    2323
    2424class MGeomCam : public MParContainer
     
    4343//    Int_t     fNumAreas;        // Number of different pixel sizes
    4444
    45 protected:
    4645    void CalcMaxRadius();
    4746    void CalcNumSectors();
     
    5251public:
    5352    MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL);
     53    MGeomCam(const MGeomCam &cam) { cam.Copy(*this); }
    5454
    5555    void Copy(TObject &o) const;
     
    9595    UShort_t GetNumPixWithAidx(UInt_t i) const { return (UShort_t)fNumPixWithAidx[i]; }
    9696
    97     MGeomPix &operator[](Int_t i);
    98     MGeomPix &operator[](Int_t i) const;
     97    MGeom &operator[](Int_t i);
     98    MGeom &operator[](Int_t i) const;
    9999
    100100    Int_t GetPixelIdx(const TVector2 &v) const;
     
    108108    void GetNeighbors(TArrayI &arr, UInt_t idx,          Float_t r) const;
    109109    void GetNeighbors(TList &arr,   UInt_t idx,          Float_t r) const;
    110     void GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const;
    111     void GetNeighbors(TList &arr,   const MGeomPix &pix, Float_t r) const;
     110    void GetNeighbors(TArrayI &arr, const MGeom &pix, Float_t r) const;
     111    void GetNeighbors(TList &arr,   const MGeom &pix, Float_t r) const;
    112112
    113113    Int_t GetDirection(UInt_t p1, UInt_t p2) const;
     
    119119    void Print(Option_t *opt=NULL) const;
    120120
     121    void SetAt(UInt_t i, const MGeom &pix);
     122
    121123    ClassDef(MGeomCam, 5)  // Geometry base class for the camera
    122124};
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc

    r2521 r9369  
    222222    //  add the first pixel to the list
    223223    //
    224     Int_t pixnum = 0;
    225 
    226     (*this)[pixnum++].Set(0, 0, diameter);
     224    Int_t pixnum = 1;
     225
     226    SetAt(0, MGeomPix(0, 0, diameter));
    227227
    228228    for (Int_t ring=1; ring<7; ring++)
     
    233233        //
    234234        for (int i=0; i<ring; i++)
    235             (*this)[pixnum++].Set((ring-i*0.5)*diameter,
    236                                   i*kS32*diameter,
    237                                   diameter);
    238 
    239         for (int i=0; i<ring; i++)
    240             (*this)[pixnum++].Set((ring*0.5-i)*diameter,
    241                                   ring*kS32 * diameter,
    242                                   diameter);
    243 
    244         for (int i=0; i<ring; i++)
    245             (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
    246                                   (ring-i)*kS32*diameter,
    247                                   diameter);
    248 
    249         for (int i=0; i<ring; i++)
    250             (*this)[pixnum++].Set((0.5*i-ring)*diameter,
    251                                   -i*kS32*diameter,
    252                                   diameter);
    253 
    254         for (int i=0; i<ring; i++)
    255             (*this)[pixnum++].Set((i-ring*0.5)*diameter,
    256                                   -ring*kS32 * diameter,
    257                                   diameter);
    258 
    259         for (int i=0; i<ring; i++)
    260             (*this)[pixnum++].Set((ring+i)*0.5*diameter,
    261                                   (-ring+i)*kS32*diameter,
    262                                   diameter);
     235            SetAt(pixnum++, MGeomPix((ring-i*0.5)*diameter,
     236                                     i*kS32*diameter, diameter));
     237
     238        for (int i=0; i<ring; i++)
     239            SetAt(pixnum++, MGeomPix((ring*0.5-i)*diameter,
     240                                     ring*kS32 * diameter, diameter));
     241
     242        for (int i=0; i<ring; i++)
     243            SetAt(pixnum++, MGeomPix(-(ring+i)*0.5*diameter,
     244                                     (ring-i)*kS32*diameter, diameter));
     245
     246        for (int i=0; i<ring; i++)
     247            SetAt(pixnum++, MGeomPix((0.5*i-ring)*diameter,
     248                                     -i*kS32*diameter, diameter));
     249
     250        for (int i=0; i<ring; i++)
     251            SetAt(pixnum++, MGeomPix((i-ring*0.5)*diameter,
     252                                     -ring*kS32 * diameter, diameter));
     253
     254        for (int i=0; i<ring; i++)
     255            SetAt(pixnum++, MGeomPix((ring+i)*0.5*diameter,
     256                                     (-ring+i)*kS32*diameter, diameter));
    263257    }
    264258}
  • trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.cc

    r9259 r9369  
    102102TObject *MGeomCamDwarf::Clone(const char *newname) const
    103103{
    104     MGeomCam *cam = new MGeomCam(GetNumPixels(), GetCameraDist());
    105     for (UInt_t i=0; i<GetNumPixels(); i++)
    106         (*this)[i].Copy((*cam)[i]);
    107 
     104    MGeomCam *cam = new MGeomCam(*this);
    108105    cam->InitGeometry();
    109106    return cam;
     
    256253    //  add the first pixel to the list
    257254    //
    258     (*this)[0].Set(0, 0, diameter);
     255    SetAt(0, MGeomPix(0, 0, diameter));
    259256
    260257    Int_t cnt  = 1;
     
    268265                Double_t x, y;
    269266                CalcXY(dir, ring, i, x, y);
    270                 (*this)[cnt++].Set(x*diameter, y*diameter, diameter);
     267                SetAt(cnt++, MGeomPix(x*diameter, y*diameter, diameter));
    271268            }
    272269        }
     
    285282    //  add the first pixel to the list
    286283    //
    287     (*this)[0].Set(0, 0, diameter);
     284    SetAt(0, MGeomPix(0, 0, diameter));
    288285
    289286    Int_t cnt  = 1;
     
    300297                Double_t x, y;
    301298                if (CalcXY(dir, ring, i, x, y)<rad)
    302                     (*this)[cnt+n++].Set(x*diameter, y*diameter, diameter);
     299                    SetAt(cnt+n++, MGeomPix(x*diameter, y*diameter, diameter));
    303300            }
    304301        }
     
    323320    for (UInt_t i=0; i<GetNumPixels(); i++)
    324321    {
    325         MGeomPix &pix = (*this)[i];
     322        MGeomPix &pix = static_cast<MGeomPix&>((*this)[i]);
    326323
    327324        Int_t k = 0;
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc

    r9356 r9369  
    361361    //
    362362    for (UInt_t i=0; i<GetNumPixels(); i++)
    363         (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, sector[i], i>396?1:0);
     363        SetAt(i, MGeomPix(xtemp[i], ytemp[i], i>396?60:30, sector[i], i>396?1:0));
    364364    // (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, i>396?sector[i]+6:sector[i]);
    365365}
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.cc

    r9259 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1717!
    1818!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !   Author(s): Harald Kornmayer 1/2001
    20 !
    21 !   Copyright: MAGIC Software Development, 2000-2008
     19!
     20!   Copyright: MAGIC Software Development, 2000-2009
    2221!
    2322!
     
    4847//  - added fUserBits
    4948//
    50 //
    51 // FIXME: According to an agreement we have to change the name 'Id' to 'idx'
     49// Version 5:
     50// ----------
     51//  - now derives from MGeom to which some data members have been moved
    5252//
    5353////////////////////////////////////////////////////////////////////////////
     
    5656#include <TMath.h>
    5757#include <TVector2.h>
     58#include <TVirtualPad.h>
    5859
    5960#include "MLog.h"
     
    6162
    6263#include "MGeomCam.h"
     64#include "MHexagon.h"
    6365
    6466ClassImp(MGeomPix);
    6567
    66 using namespace std;
    67 
    68 const Float_t MGeomPix::gsTan30 = TMath::Tan(30/kRad2Deg); // sqrt(3)/3
    69 const Float_t MGeomPix::gsTan60 = TMath::Tan(60/kRad2Deg); // sqrt(3)
     68const Float_t MGeomPix::gsTan30 = TMath::Sqrt(3)/3;  //TMath::Tan(TMath::DegToRad()*30);
     69const Float_t MGeomPix::gsTan60 = TMath::Sqrt(3);    //TMath::Tan(TMath::DegToRad()*60);
     70
     71const Float_t MGeomPix::gsCos60 = 0.5;               //TMath::Cos(TMath::DegToRad()*60);
     72const Float_t MGeomPix::gsSin60 = TMath::Sqrt(3)/2;  //TMath::Sin(TMath::DegToRad()*60);
    7073
    7174// --------------------------------------------------------------------------
     
    7376// Initializes one pixel
    7477//
    75 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : fUserBits(0)
    76 {
    77     //  default constructor
    78     Set(x, y, r, s, a);
     78MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : MGeom(x, y, s, a)
     79{
     80    SetD(r);
    7981    SetNeighbors();
    8082}
     
    8284// --------------------------------------------------------------------------
    8385//
    84 // Return position as TVector2(fX, fY)
    85 //
    86 TVector2 MGeomPix::GetP() const
    87 {
    88     return TVector2(fX, fY);
    89 }
    90 
    91 // --------------------------------------------------------------------------
    92 //
    93 // Initializes Next Neighbors.
    94 //
    95 // WARNING: This function is public, but it is not meant for user access.
    96 // It should only be used from geometry classes (like MGeomCam)
    97 //
    98 void MGeomPix::SetNeighbors(Short_t i0, Short_t i1, Short_t i2,
    99                             Short_t i3, Short_t i4, Short_t i5)
    100 {
    101     fNeighbors[0] = i0;
    102     fNeighbors[1] = i1;
    103     fNeighbors[2] = i2;
    104     fNeighbors[3] = i3;
    105     fNeighbors[4] = i4;
    106     fNeighbors[5] = i5;
    107 
    108     int i;
    109     for (i=0; i<6; i++)
    110         if (fNeighbors[i]<0)
    111             break;
    112 
    113     fNumNeighbors = i;
    114 
    115     fNumNeighbors<5 ? SETBIT(fUserBits, kIsInOutermostRing) : CLRBIT(fUserBits, kIsInOutermostRing);
    116 }
    117 
    118 // --------------------------------------------------------------------------
    119 //
    120 //  Set the kIsOuterRing flag if this pixel has a outermost pixel
    121 //  as Next Neighbor and don't have the kIsOutermostRing flag itself.
    122 //
    123 void MGeomPix::CheckOuterRing(const MGeomCam &cam)
    124 {
    125     if (IsInOutermostRing())
    126         return;
    127 
    128     CLRBIT(fUserBits, kIsInOuterRing);
    129 
    130     for (int i=0; i<fNumNeighbors; i++)
    131         if (cam[fNeighbors[i]].IsInOutermostRing())
    132         {
    133             SETBIT(fUserBits, kIsInOuterRing);
    134             return;
    135         }
    136 }
    137 
    138 // --------------------------------------------------------------------------
    139 //
    14086// Print the geometry information of one pixel.
    14187//
    14288void MGeomPix::Print(Option_t *opt) const
    143 {
    144     //   information about a pixel
    145     *fLog << all << "MPixGeom:  x/y=" << fX << "/" << fY << "mm ";
    146     *fLog << "d= " << fD << "mm  A= " << fA << "mm² (";
    147     for (int i=0; i<fNumNeighbors; i++)
    148         *fLog << fNeighbors[i] << (i<fNumNeighbors-1?",":"");
    149     *fLog << ")" << endl;
    150 }
    151 
    152 // ------------------------------------------------------------------------
    153 //
    154 // Return distance of center to coordinate origin: hypot(fX,fY)
    155 //
    156 Float_t MGeomPix::GetDist() const
    157 {
    158     return TMath::Hypot(fX, fY);
    159 }
    160 
    161 // ------------------------------------------------------------------------
    162 //
    163 // Return distance of center to center of pix: hypot(fX-pix.fX,fY-pix.fY)
    164 //
    165 Float_t MGeomPix::GetDist(const MGeomPix &pix) const
    166 {
    167     return TMath::Hypot(fX-pix.fX, fY-pix.fY);
    168 }
    169 
    170 // ------------------------------------------------------------------------
    171 //
    172 // Return angle defined by the center and the center of pix:
    173 //  atan2(fX-pix.fX,fY-pix.fY)
    174 //
    175 Float_t MGeomPix::GetAngle(const MGeomPix &pix) const
    176 {
    177     return TMath::ATan2(fX - pix.GetX(), fY - pix.GetY());
    178 }
    179 
    180 // ------------------------------------------------------------------------
    181 //
    182 // compute the distance of a point (px,py) to the Hexagon center in
    183 // MGeomPix coordinates. Return kTRUE if inside.
    184 //
    185 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const
    186 {
     89{
     90    MGeom::Print(opt);
     91    gLog << " d=" << fD << "mm" << endl;
     92}
     93
     94// ------------------------------------------------------------------------
     95//
     96// compute the distance of a point (px,py) to the Hexagon center in world
     97// coordinates. Return -1 if inside.
     98//
     99Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const
     100{
     101    //FIXME: Rotation phi missing!
     102
    187103    //
    188104    //  compute the distance of the Point to the center of the Hexagon
    189105    //
    190     const Double_t dx = px-fX;
     106    //const Double_t dx = px-fX;
     107    //const Double_t dy = py-fY;
     108
     109    TVector2 v(px-fX, py-fY);
     110    // FIXME: fPhi or -fPhi?
     111    // v = v.Rotate(-fPhi);             // FIXME: Replace with a precalculates sin/cos vector
     112
     113    const Double_t dx = v.X();
     114    const Double_t dy = v.Y();
     115
     116    const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
    191117
    192118    //
     
    196122    // more, rotated with respect to that one by +- 60 degrees.
    197123    //
    198     if (TMath::Abs(dx)>fD/2)
    199         return kFALSE;
    200 
    201     const Double_t dy = py-fY;
    202 
    203     const static Double_t cos60 = TMath::Cos(60/kRad2Deg);
    204     const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
    205 
    206     const Double_t dxc = dx*cos60;
    207     const Double_t dys = dy*sin60;
    208 
    209     if  (TMath::Abs(dxc + dys)>fD/2)
    210         return kFALSE;
    211 
    212     if (TMath::Abs(dxc - dys)>fD/2)
    213         return kFALSE;
    214 
    215     return kTRUE;
    216 }
    217 
    218 // ------------------------------------------------------------------------
    219 //
    220 // Return the direction of the pixel pix w.r.t. this pixel.
    221 // Remark: This function assumes a simple geometry.
    222 //
    223 Int_t MGeomPix::GetDirection(const MGeomPix &pix) const
    224 {
    225     const Double_t x1 = GetX();
    226     const Double_t y1 = GetY();
    227 
    228     const Double_t x2 = pix.GetX();
    229     const Double_t y2 = pix.GetY();
    230 
    231     if (x1<=x2 && y1<y2) return kRightTop;
    232     if (x1<=x2 && y1>y2) return kRightBottom;
    233     if (x1>=x2 && y1<y2) return kLeftTop;
    234     if (x1>=x2 && y1>y2) return kLeftBottom;
    235     if (x1<x2)           return kRight;
    236     if (x1>x2)           return kLeft;
    237 
    238     cout << -1 << endl;
     124
     125    if (TMath::Abs(dx) > fD/2)
     126      return disthex;
     127
     128    const Double_t dx2 = dx*gsCos60 + dy*gsSin60;
     129
     130    if  (TMath::Abs(dx2) > fD/2)
     131      return disthex;
     132
     133    const Double_t dx3 = dx*gsCos60 - dy*gsSin60;
     134
     135    if  (TMath::Abs(dx3) > fD/2)
     136      return disthex;
    239137
    240138    return -1;
     
    243141// ------------------------------------------------------------------------
    244142//
    245 // compute the distance of a point (px,py) to the Hexagon center in world
    246 // coordinates. Return -1 if inside.
    247 //
    248 Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const
    249 {
    250     //FIXME: Rotation phi missing!
    251 
    252     static Double_t fgCos60 = 0.5;               //TMath::Cos(TMath::DegToRad()*60);
    253     static Double_t fgSin60 = TMath::Sqrt(3.)/2; //TMath::Sin(TMath::DegToRad()*60);
    254 
     143// Implementation of PaintPrimitive drwaing a hexagonal pixel
     144//
     145void MGeomPix::PaintPrimitive(const TAttLine &fill, const TAttFill &line, Double_t scalexy, Double_t scaled) const
     146{
     147    MHexagon hex;
     148
     149    fill.Copy(hex);
     150    line.Copy(hex);
     151
     152    hex.PaintHexagon(fX*scalexy, fY*scalexy, fD*scaled);
     153}
     154
     155
     156// ------------------------------------------------------------------------
     157//
     158// compute the distance of a point (px,py) to the Hexagon center in
     159// MGeomPix coordinates. Return kTRUE if inside.
     160//
     161Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const
     162{
    255163    //
    256164    //  compute the distance of the Point to the center of the Hexagon
    257165    //
    258     //const Double_t dx = px-fX;
    259     //const Double_t dy = py-fY;
    260 
    261     TVector2 v(px-fX, py-fY);
    262     // FIXME: fPhi or -fPhi?
    263     // v = v.Rotate(-fPhi);             // FIXME: Replace with a precalculates sin/cos vector
    264 
    265     const Double_t dx = v.X();
    266     const Double_t dy = v.Y();
    267 
    268     const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
     166    const Double_t dx = px-fX;
    269167
    270168    //
     
    274172    // more, rotated with respect to that one by +- 60 degrees.
    275173    //
    276 
    277     if (TMath::Abs(dx) > fD/2.)
    278       return disthex;
    279 
    280     const Double_t dx2 = dx*fgCos60 + dy*fgSin60;
    281 
    282     if  (TMath::Abs(dx2) > fD/2.)
    283       return disthex;
    284 
    285     const Double_t dx3 = dx*fgCos60 - dy*fgSin60;
    286 
    287     if  (TMath::Abs(dx3) > fD/2.)
    288       return disthex;
    289 
    290     return -1;
     174    if (TMath::Abs(dx)>fD/2)
     175        return kFALSE;
     176
     177    const Double_t dy = py-fY;
     178
     179    const static Double_t cos60 = TMath::Cos(60/kRad2Deg);
     180    const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
     181
     182    const Double_t dxc = dx*cos60;
     183    const Double_t dys = dy*sin60;
     184
     185    if  (TMath::Abs(dxc + dys)>fD/2)
     186        return kFALSE;
     187
     188    if (TMath::Abs(dxc - dys)>fD/2)
     189        return kFALSE;
     190
     191    return kTRUE;
    291192}
    292193
     
    460361}
    461362*/
    462 
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r9259 r9369  
    22#define MARS_MGeomPix
    33
    4 #ifndef MARS_MParContainer
    5 #include "MParContainer.h"
     4#ifndef MARS_MGeom
     5#include "MGeom.h"
    66#endif
    77
    8 class MGeomCam;
    9 class TVector2;
    10 class TOrdCollection;
    11 
    12 
    13 class MGeomPix : public MParContainer
     8class MGeomPix : public MGeom
    149{
    1510public:
     
    1712    static const Float_t gsTan30; // tan(30/kRad2Deg);
    1813
    19     enum {
    20         kRightTop,
    21         kRight,
    22         kRightBottom,
    23         kLeftBottom,
    24         kLeft,
    25         kLeftTop
    26     };
     14    static const Float_t gsCos60; // cos(60/kRad2Deg);
     15    static const Float_t gsSin60; // sin(30/kRad2Deg);
    2716
    2817private:
    29     enum {
    30         kIsInOutermostRing = 0,
    31         kIsInOuterRing     = 1,
    32     };
    33 
    34     Float_t fX;            // [mm]   the x coordinate of the center
    35     Float_t fY;            // [mm]   the y coordinate of the center
    3618    Float_t fD;            // [mm]   the d coordinate of the pixel (dist between two parallel sides)
    37     Float_t fA;            // [mm^2] Area of the pixel
    38 
    39     Byte_t  fNumNeighbors; // number of valid neighbors
    40     Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
    41 
    42     UInt_t fSector;        // Number of sector the pixels corresponds to
    43     UInt_t fAidx;          // Area index of the pixel
    44 
    45     Byte_t fUserBits;
    4619
    4720public:
     
    5124    {
    5225        MGeomPix &pix = (MGeomPix&)obj;
    53         pix.fX = fX;
    54         pix.fY = fY;
     26
    5527        pix.fD = fD;
    56         pix.fA = fA;
    57         pix.fNumNeighbors = fNumNeighbors;
    58         pix.fSector = fSector;
    59         pix.fAidx = fAidx;
    60         pix.fUserBits = fUserBits;
    61         for (int i=0; i<6; i++)
    62             pix.fNeighbors[i] = fNeighbors[i];
    6328
     29        MGeom::Copy(obj);
    6430        TObject::Copy(obj);
    6531    }
    6632
     33    void SetD(Float_t d=1) { fD=d; fA=d*d*gsTan60/2; }
     34
     35    Float_t GetD() const  { return fD; }         // Distance between two parallel sides
     36    Float_t GetL() const  { return fD*gsTan30; } // Length of one of the parallel sides
     37    Float_t GetT() const  { return fD/gsTan60; } // Distance between two opposite edges (traverse)
     38
     39    Bool_t  IsInside(Float_t px, Float_t py) const;
     40    Float_t DistanceToPrimitive(Float_t px, Float_t py) const;
     41    void    PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const;
     42
    6743    void Print(Option_t *opt=NULL) const;
    6844
    69     void Set(Float_t x, Float_t y, Float_t d=1, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fD=d; fA=d*d*gsTan60/2; fSector=s; fAidx=aidx; }
    70 
    71     void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
    72                       Short_t i3=-1, Short_t i4=-1, Short_t i5=-1);
    73 
    74     void CheckOuterRing(const MGeomCam &cam);
    75 
    76     Float_t GetX() const  { return fX; }
    77     Float_t GetY() const  { return fY; }
    78     Float_t GetD() const  { return fD; }         // Distance between two parellel sides
    79     Float_t GetL() const  { return fD*gsTan30; } // Length of one of the parallel sides
    80     Float_t GetT() const  { return fD/gsTan60; } // Distance between two opposite edges (traverse)
    81     UInt_t  GetSector() const { return fSector; }
    82 
    83     TVector2 GetP() const;
    84 
    85     Float_t GetDist() const;
    86     Float_t GetDist(const MGeomPix &pix) const;
    87     Float_t GetAngle(const MGeomPix &pix) const;
    88 
    89     Float_t GetA() const    { return fA; /*fD*fD*gsTan60/2;*/ }
    90     Int_t   GetAidx() const { return fAidx; }
    91 
    92     Byte_t  GetNumNeighbors() const { return fNumNeighbors; }
    93     Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; }
    94 
    95     Bool_t IsInOutermostRing() const { return TESTBIT(fUserBits, kIsInOutermostRing); }
    96     Bool_t IsInOuterRing() const     { return TESTBIT(fUserBits, kIsInOuterRing); }
    97 
    98     Bool_t IsInside(Float_t px, Float_t py) const;
    99     Int_t  GetDirection(const MGeomPix &pix) const;
    100 
    101     virtual Float_t DistanceToPrimitive(Float_t px, Float_t py) const;
    102     //void GetIntersectionBorder(TOrdCollection &col, const MGeomPix &hex) const;
    103     //Double_t CalcOverlapArea(const MGeomPix &cam) const;
    104 
    105     //TObject *GetGraphics() { return new MHexagon(*this); }
    106 
    107     ClassDef(MGeomPix, 4) // Geometry class describing the geometry of one pixel
     45    ClassDef(MGeomPix, 5) // Geometry class describing the geometry of one pixel
    10846};
    10947
  • trunk/MagicSoft/Mars/mgeom/Makefile

    r8386 r9369  
    1919#  connect the include files defined in the config.mk file
    2020#
    21 INCLUDES = -I. -I../mbase -I../MBase
     21INCLUDES = -I. -I../mbase -I../mgui -I../MBase
    2222
    23 SRCFILES = MGeomPix.cc \
     23SRCFILES = MGeom.cc \
     24           MGeomPix.cc \
     25           MGeomRectangle.cc \
    2426           MGeomCam.cc \
    2527           MGeomCamCT1.cc \
    2628           MGeomCamDwarf.cc \
    2729           MGeomCamMagic.cc \
     30           MGeomCamSquare.cc \
    2831           MGeomCorsikaCT.cc \
    2932           MGeomMirror.cc \
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r8907 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MBinning.cc,v 1.19 2008-06-02 08:46:47 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MBinning.cc,v 1.20 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    193193void MBinning::AddEdge(Axis_t up)
    194194{
    195     const Int_t n = fEdges.GetSize();
     195    const UInt_t n = fEdges.GetSize();
    196196
    197197    if (up<=fEdges[n-1])
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r9362 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.46 2009-02-22 23:36:00 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.47 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    18451845        return GetObjectInfoH(px, py, static_cast<const TH1&>(o));
    18461846
    1847     return "MH::GetObjectInfo: unknown class.";
     1847    return const_cast<char*>("MH::GetObjectInfo: unknown class.");
    18481848}
    18491849
  • trunk/MagicSoft/Mars/mhbase/MHMatrix.cc

    r9153 r9369  
    11771177
    11781178        if (i==0)
     1179        {
    11791180            if (fData)
    11801181            {
     
    11871188                SetBit(kIsOwner);
    11881189            }
     1190        }
    11891191
    11901192        fData->AddEntry(name);
  • trunk/MagicSoft/Mars/mhflux/MHAlpha.cc

    r9346 r9369  
    778778        delete pad->GetPad(2);
    779779
    780     if (fTimeEffOn && fTime || fHTime.GetNbinsX()>1 || fHTime.GetBinError(1)>0)
     780    if ((fTimeEffOn && fTime) || fHTime.GetNbinsX()>1 || fHTime.GetBinError(1)>0)
    781781    {
    782782        pad->cd(3);
     
    10971097
    10981098    if (!fSkipHistEnergy)
    1099         if (type==0)
    1100         {
    1101             fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal");
    1102             fMap[2] = -1;
    1103         }
    1104         else
    1105         {
    1106             fMap[1] = -1;
    1107             fMap[2] = fMatrix->AddColumn("MHillas.fSize");
    1108         }
     1099    {
     1100        fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1;
     1101        fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize");
     1102    }
    11091103
    11101104    if (!fSkipHistTheta)
  • trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc

    r7710 r9369  
    189189
    190190    if (!fSkipHistEnergy)
    191         if (type==0)
    192         {
    193             fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal");
    194             fMap[2] = -1;
    195         }
    196         else
    197         {
    198             fMap[1] = -1;
    199             fMap[2] = fMatrix->AddColumn("MHillas.fSize");
    200         }
     191    {
     192        fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1;
     193        fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize");
     194    }
    201195
    202196    if (!fSkipHistTheta)
  • trunk/MagicSoft/Mars/mhflux/MHThetaSqN.cc

    r9341 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHThetaSqN.cc,v 1.11 2009-02-15 15:43:30 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHThetaSqN.cc,v 1.12 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    354354
    355355    if (!fSkipHistEnergy)
    356         if (type==0)
    357         {
    358             fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal");
    359             fMap[2] = -1;
    360         }
    361         else
    362         {
    363             fMap[1] = -1;
    364             fMap[2] = fMatrix->AddColumn("MHillas.fSize");
    365         }
     356    {
     357        fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1;
     358        fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize");
     359    }
    366360
    367361    if (!fSkipHistTheta)
  • trunk/MagicSoft/Mars/mhft/MGeomCamMagicXT.cc

    r8910 r9369  
    3636#include "MGeomCamMagicXT.h"
    3737
    38 #include <TMath.h>
    39 
    40 #include "MGeomPix.h"
    41 
    4238ClassImp(MGeomCamMagicXT);
    4339
     
    4844//
    4945MGeomCamMagicXT::MGeomCamMagicXT(const char *name)
    50     : MGeomCam(1141, 17, name, "Geometry information of Magic Camera")
     46    : MGeomCamDwarf(19, 30, 17, name)
    5147{
    52     CreateCam();
    53     CreateNN();
    54     InitGeometry();
    5548}
    56 
    57 // --------------------------------------------------------------------------
    58 //
    59 //  This fills the geometry information from a table into the pixel objects.
    60 //
    61 void MGeomCamMagicXT::CreateCam()
    62 {
    63     //
    64     // fill the geometry class with the coordinates of the CT1 camera
    65     //
    66     //*fLog << inf << " Create CT1 geometry " << endl;
    67 
    68     //
    69     // this algorithm is from Martin Kestel originally
    70     // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
    71    
    72     const Float_t diameter = 30;    // units are mm
    73     const Float_t kS32  = sqrt(3)/2;
    74 
    75     //
    76     //  add the first pixel to the list
    77     //
    78     Int_t pixnum = 0;
    79 
    80     (*this)[pixnum++].Set(0, 0, diameter);
    81 
    82     for (Int_t ring=1; ring<20; ring++)
    83     {
    84         //
    85         // calc. coords for this ring counting from the
    86         // starting number to the ending number
    87         //
    88         for (int i=0; i<ring; i++)
    89             (*this)[pixnum++].Set((ring-i*0.5)*diameter,
    90                                   i*kS32*diameter,
    91                                   diameter);
    92 
    93         for (int i=0; i<ring; i++)
    94             (*this)[pixnum++].Set((ring*0.5-i)*diameter,
    95                                   ring*kS32 * diameter,
    96                                   diameter);
    97 
    98         for (int i=0; i<ring; i++)
    99             (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,
    100                                   (ring-i)*kS32*diameter,
    101                                   diameter);
    102 
    103         for (int i=0; i<ring; i++)
    104             (*this)[pixnum++].Set((0.5*i-ring)*diameter,
    105                                   -i*kS32*diameter,
    106                                   diameter);
    107 
    108         for (int i=0; i<ring; i++)
    109             (*this)[pixnum++].Set((i-ring*0.5)*diameter,
    110                                   -ring*kS32 * diameter,
    111                                   diameter);
    112 
    113         for (int i=0; i<ring; i++)
    114             (*this)[pixnum++].Set((ring+i)*0.5*diameter,
    115                                   (-ring+i)*kS32*diameter,
    116                                   diameter);
    117     }
    118 }
    119 
    120 // --------------------------------------------------------------------------
    121 //
    122 //  This fills the next neighbor information from a table into the pixel
    123 //  objects.
    124 //
    125 void MGeomCamMagicXT::CreateNN()
    126 {
    127     Int_t pos = 0;
    128 
    129     const Short_t nn[7][6] = {         // Neighbors of #
    130         {   1,   2,   3,   4,   5,   6}, // 0
    131         {   0,   2,   6,   7,   8,  18},
    132         {   0,   1,   3,   8,   9,  10},
    133         {   0,   2,   4,  10,  11,  12},
    134         {   0,   3,   5,  12,  13,  14},
    135         {   0,   4,   6,  14,  15,  16},
    136         {   0,   1,   5,  16,  17,  18}
    137     };
    138 
    139     for (Int_t i=0; i<7; i++)
    140         (*this)[pos++].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
    141                                     nn[i][3], nn[i][4], nn[i][5]);
    142 
    143     for (Int_t ring=2; ring<20; ring++)
    144     {
    145         for (Int_t s=0; s<6; s++)
    146         {
    147             for (int i=pos; i<ring+pos; i++)
    148             {
    149                 Int_t n[6], idx[6];
    150 
    151                 n[0] = i==pos&&s==0 ? i+6*ring : i-1;                // vor
    152                 n[1] = i==ring+pos-1&&s==5 ? i-12*(ring-1)-5 : i+1;  // danach
    153                 n[2] = i==pos ? i+6*ring-1+s   : i-6*(ring-1)-s;     // ring- groesser
    154                 n[3] = i==pos ? i-6*(ring-1)-s : i-6*(ring-1)-1-s;   // ring- kleiner
    155                 n[4] = i==pos&&s==0 ? i+12*ring+5 : i+6*ring+s;      // ring+ kleiner
    156                 n[5] = i+6*ring+1+s;                                 // ring+ groesser
    157 
    158                 if (n[0]>1140)
    159                     n[0] = -1;
    160                 if (n[1]>1140)
    161                     n[1] = -1;
    162                 if (n[2]>1140)
    163                     n[2] = -1;
    164                 if (n[3]>1140)
    165                     n[3] = -1;
    166                 if (n[4]>1140)
    167                     n[4] = -1;
    168                 if (n[5]>1140)
    169                     n[5] = -1;
    170 
    171                 TMath::Sort(6, n, idx);
    172 
    173                 (*this)[i].SetNeighbors(n[idx[0]],
    174                                         n[idx[1]],
    175                                         n[idx[2]],
    176                                         n[idx[3]],
    177                                         n[idx[4]],
    178                                         n[idx[5]]);
    179             }
    180 
    181             pos += ring;
    182         }
    183     }
    184 }
  • trunk/MagicSoft/Mars/mhft/MGeomCamMagicXT.h

    r5691 r9369  
    22#define MARS_MGeomCamMagicXT
    33
    4 #ifndef MARS_MGeomCam
    5 #include "MGeomCam.h"
     4#ifndef MARS_MGeomCamDwarf
     5#include "MGeomCamDwarf.h"
    66#endif
    77
    8 class MGeomCamMagicXT : public MGeomCam
     8class MGeomCamMagicXT : public MGeomCamDwarf
    99{
    10 private:
    11     void CreateCam();
    12     void CreateNN();
    13 
    1410public:
    1511    MGeomCamMagicXT(const char *name=NULL);
  • trunk/MagicSoft/Mars/mhft/MHexagonFreqSpace.cc

    r8911 r9369  
    169169            int idx1 = (j+n)*(j+n+1)/2 + j;
    170170
    171             (*cam)[idx1].Set(n-j, (n+j-num/2)*fgTan30, 2);
    172             (*cam)[idx1].SetNeighbors(-1, -1, -1, -1, -1, -1);
     171            cam->SetAt(idx1, MGeomPix(n-j, (n+j-num/2)*fgTan30, 2));
     172            (*cam)[idx1].SetNeighbors();
    173173        }
    174174    }
  • trunk/MagicSoft/Mars/mhist/MHCamEventRot.cc

    r9153 r9369  
    226226            if (fUseThreshold!=kNoBound)
    227227            {
    228                 if (val>fThreshold && fUseThreshold==kIsLowerBound ||
    229                     val<fThreshold && fUseThreshold==kIsUpperBound)
     228                if ((val>fThreshold && fUseThreshold==kIsLowerBound) ||
     229                    (val<fThreshold && fUseThreshold==kIsUpperBound))
    230230                    fHist.Fill(cx[ix], cy[iy]);
    231231            }
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r9367 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.118 2009-03-01 12:51:03 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.119 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    7979#include "MString.h"
    8080#include "MBinning.h"
    81 #include "MHexagon.h"
    8281
    8382#include "MGeomPix.h"
     
    109108    gROOT->GetListOfCleanups()->Add(fNotify);
    110109
     110    /*
    111111    TVirtualPad *save = gPad;
    112112    gPad = 0;
    113     /*
    114113#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
    115114    SetPalette(1, 0);
     
    123122    SetInvDeepBlueSeaPalette();
    124123#endif
     124    gPad = save;
    125125*/
    126     gPad = save;
    127126}
    128127
     
    218217Bool_t MHCamera::MatchSector(Int_t idx, const TArrayI &sector, const TArrayI &aidx) const
    219218{
    220     const MGeomPix &pix = (*fGeomCam)[idx];
     219    const MGeom &pix = (*fGeomCam)[idx];
    221220    return FindVal(sector, pix.GetSector()) && FindVal(aidx, pix.GetAidx());
    222221}
     
    980979        gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
    981980
    982     MHexagon hex;
     981    TAttLine line;
     982    TAttFill fill;
     983    line.SetLineStyle(kSolid);
     984    line.SetLineColor(kBlack);
    983985    for (Int_t i=0; i<fNcells-2; i++)
    984986    {
    985         hex.SetFillStyle(issame || (IsTransparent() && !IsUsed(i)) ? 0 : 1001);
     987        fill.SetFillStyle(issame || (IsTransparent() && !IsUsed(i)) ? 0 : 1001);
    986988
    987989        if (!issame)
     
    990992            if (!IsUsed(i) || !iscol || isnan)
    991993            {
    992                 hex.SetFillColor(10);
     994                fill.SetFillColor(10);
    993995
    994996                if (isnan)
     
    996998            }
    997999            else
    998                 hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog));
     1000                fill.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog));
    9991001        }
    10001002
    1001         const MGeomPix &pix = (*fGeomCam)[i];
    1002 
    1003         Float_t x = pix.GetX()*conv/(fAbberation+1);
    1004         Float_t y = pix.GetY()*conv/(fAbberation+1);
    1005         Float_t d = pix.GetD()*conv;
    1006 
    1007         if (!isbox)
    1008             if (IsUsed(i) || !TestBit(kNoUnused))
    1009                 hex.PaintHexagon(x, y, d);
    1010         else
    1011             if (IsUsed(i) && TMath::Finite(fArray[i+1]))
    1012             {
    1013                 Float_t size = d*(GetBinContent(i+1)-min)/(max-min);
    1014                 if (size>d)
    1015                     size=d;
    1016                 hex.PaintHexagon(x, y, size);
    1017             }
     1003        const MGeom &pix = (*fGeomCam)[i];
     1004
     1005        Double_t scale = 1;//conv/(fAbberation+1);
     1006
     1007        if (!isbox && !IsUsed(i) && TestBit(kNoUnused))
     1008            continue;
     1009
     1010        if (isbox && (!IsUsed(i) || !TMath::Finite(fArray[i+1])))
     1011            continue;
     1012
     1013        if (isbox)
     1014        {
     1015            scale = (GetBinContent(i+1)-min)/(max-min);
     1016            if (scale>1)
     1017                scale=1;
     1018        }
     1019
     1020        pix.PaintPrimitive(line, fill, conv, scale/(fAbberation+1));
    10181021    }
    10191022}
     
    13191322    for (Int_t i=0; i<fNcells-2; i++)
    13201323    {
    1321         const MGeomPix &h = (*fGeomCam)[i];
     1324        const MGeom &h = (*fGeomCam)[i];
    13221325
    13231326        TString num;
     
    13351338        //(GetColor(GetBinContent(i+1), min, max, 0));
    13361339        txt.SetTextColor(kRed);
    1337         txt.SetTextSize(0.3*h.GetD()/fGeomCam->GetMaxRadius()/1.05);
     1340        txt.SetTextSize(0.3*h.GetT()/fGeomCam->GetMaxRadius()/1.05);
    13381341        txt.PaintText(h.GetX(), h.GetY(), num);
    13391342    }
     
    20242027        return -1;
    20252028
    2026     Int_t i;
    2027     for (i=0; i<fNcells-2; i++)
    2028     {
    2029         MHexagon hex((*fGeomCam)[i]);
    2030         if (hex.DistancetoPrimitive(px, py, conv)>0)
    2031             continue;
    2032 
    2033         return i;
    2034     }
     2029    for (Int_t i=0; i<fNcells-2; i++)
     2030        if ((*fGeomCam)[i].DistancetoPrimitive(px*conv, py*conv)<=0)
     2031            return i;
     2032
    20352033    return -1;
    20362034}
  • trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc

    r9153 r9369  
    245245    if (fN==fNumEvents)
    246246    {
    247         if (fMaxPts>0 && fGraph->GetN()>fMaxPts || fGraph->IsEditable())
     247        if ((fMaxPts>0 && fGraph->GetN()>fMaxPts) || fGraph->IsEditable())
    248248        {
    249249            fGraph->RemovePoint(0);
  • trunk/MagicSoft/Mars/mimage/MHillas.cc

    r8911 r9369  
    291291            continue;
    292292
    293         const MGeomPix &gpix = geom[i];
     293        const MGeom &gpix = geom[i];
    294294
    295295        const Float_t nphot = pix.GetNumPhotons();
     
    339339            continue;
    340340
    341         const MGeomPix &gpix = geom[i];
     341        const MGeom &gpix = geom[i];
    342342
    343343        const Float_t dx = gpix.GetX() - fMeanX;     // [mm]
  • trunk/MagicSoft/Mars/mimage/MHillasExt.cc

    r8619 r9369  
    161161            continue;
    162162
    163         const MGeomPix &gpix = geom[i];
     163        const MGeom &gpix = geom[i];
    164164
    165165        const Double_t x = gpix.GetX();
     
    238238    // Asymmetry
    239239    //
    240     const MGeomPix &maxp = geom[maxpixid];
     240    const MGeom &maxp = geom[maxpixid];
    241241    fAsym = (hil.GetMeanX()-maxp.GetX())*c + (hil.GetMeanY()-maxp.GetY())*s;            // [mm]
    242242
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc

    r9352 r9369  
    395395//
    396396//
    397 Bool_t MImgCleanStd::HasCoreNeighbors(const MGeomPix &gpix) const
     397Bool_t MImgCleanStd::HasCoreNeighbors(const MGeom &gpix) const
    398398{
    399399//    if (fKeepIsolatedPixels)
     
    428428}
    429429
    430 Bool_t MImgCleanStd::HasUsedNeighbors(const MGeomPix &gpix) const
     430Bool_t MImgCleanStd::HasUsedNeighbors(const MGeom &gpix) const
    431431{
    432432    //loop on the neighbors to check if they are used
     
    448448
    449449
    450 void MImgCleanStd::SetUsedNeighbors(const MGeomPix &gpix, Int_t r) const
     450void MImgCleanStd::SetUsedNeighbors(const MGeom &gpix, Int_t r) const
    451451{
    452452    if (r>fCleanRings)
     
    527527            continue;
    528528
    529         const MGeomPix &gpix = (*fCam)[idx];
     529        const MGeom &gpix = (*fCam)[idx];
    530530
    531531        // Check if the pixel is an isolated core pixel
     
    556556
    557557/*
    558 Float_t MImgCleanStd::GetArrivalTimeNeighbor(const MGeomPix &gpix) const
     558Float_t MImgCleanStd::GetArrivalTimeNeighbor(const MGeom &gpix) const
    559559{
    560560    Float_t min = FLT_MAX;
     
    595595            continue;
    596596
    597         const MGeomPix &gpix = (*fCam)[idx];
     597        const MGeom &gpix = (*fCam)[idx];
    598598
    599599        // If isolated possible-corepixel doesn't have used
     
    638638            continue;
    639639
    640         const MGeomPix &gpix = (*fCam)[idx];
     640        const MGeom &gpix = (*fCam)[idx];
    641641
    642642        // If isolated possible-corepixel doesn't have used
     
    676676
    677677        // loop over its neighbpors
    678         const MGeomPix &gpix = (*fCam)[idx];
     678        const MGeom &gpix = (*fCam)[idx];
    679679
    680680        Int_t cnt = 0;
  • trunk/MagicSoft/Mars/mimage/MImgCleanStd.h

    r8765 r9369  
    77
    88class MGeomCam;
    9 class MGeomPix;
     9class MGeom;
    1010class MSignalCam;
    1111class MPedPhotCam;
     
    5858
    5959    // MImgCleanStd
    60     Bool_t HasCoreNeighbors(const MGeomPix &gpix) const;
    61     Bool_t HasUsedNeighbors(const MGeomPix &gpix) const;
    62     void   SetUsedNeighbors(const MGeomPix &gpix, Int_t r=1) const;
     60    Bool_t HasCoreNeighbors(const MGeom &gpix) const;
     61    Bool_t HasUsedNeighbors(const MGeom &gpix) const;
     62    void   SetUsedNeighbors(const MGeom &gpix, Int_t r=1) const;
    6363    Int_t  DoCleaning(Float_t &size) const;
    6464    void   ResetCleaning() const;
  • trunk/MagicSoft/Mars/mimage/MNewImagePar.cc

    r8958 r9369  
    160160
    161161        // Get geometry of pixel
    162         const MGeomPix &gpix = geom[i];
     162        const MGeom &gpix = geom[i];
    163163
    164164        // Find the three pixels which are next to the COG
     
    220220        const Double_t dzx   =  hillas.GetCosDelta()*dx + hillas.GetSinDelta()*dy; // [mm]
    221221        const Double_t dzy   = -hillas.GetSinDelta()*dx + hillas.GetCosDelta()*dy; // [mm]
    222         const Double_t dz    =  gpix.GetD()*gpix.GetD()/4;
     222        const Double_t dz    =  gpix.GetT()*gpix.GetT()/4;
    223223        const Double_t tana  =  dzy*dzy/(dzx*dzx);
    224224        const Double_t distr =  (1+tana)/(rl + tana*rw);
  • trunk/MagicSoft/Mars/mimage/MNewImagePar2.cc

    r8106 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MNewImagePar2.cc,v 1.2 2006-10-17 17:16:00 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MNewImagePar2.cc,v 1.3 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    9191        Int_t used=0;
    9292
    93         const MGeomPix &gpix = geom[i];
     93        const MGeom &gpix = geom[i];
    9494        const Int_t nn = gpix.GetNumNeighbors();
    9595        for (int j=0; j<nn; j++)
     
    108108            evt[i].ResetBit(BIT(14));
    109109
    110         fBorderLinePixel += (nn-used)*gpix.GetL();
     110        // FIXME: GetT is not the correct value
     111        fBorderLinePixel += (nn-used)*gpix.GetT();
    111112    }
    112113
     
    115116        const Int_t l = idx[m];
    116117
    117         const MGeomPix &gpix = geom[l];
     118        const MGeom &gpix = geom[l];
    118119
    119120        const Int_t nn = gpix.GetNumNeighbors();
  • trunk/MagicSoft/Mars/mjobs/MJStar.cc

    r9343 r9369  
    373373
    374374    if (fSequence.IsMonteCarlo())
     375    {
    375376        if (fMuonAnalysis)
    376377            writem.AddCopySource("OriginalMC");
    377378        else
    378379            write.AddCopySource("OriginalMC");
     380    }
    379381
    380382    MTaskList tlist2("Events");
  • trunk/MagicSoft/Mars/mmovie/MMovieWrite.cc

    r9303 r9369  
    290290}
    291291
     292#ifdef USE_TIMING
    292293TStopwatch clockT, clock1, clock2, clock3;
     294#endif
    293295
    294296// --------------------------------------------------------------------------
     
    304306    }
    305307
     308#ifdef USE_TIMING
    306309    *fLog << all << endl;
    307310    *fLog << "Snap: " << flush;
     
    314317    clockT.Print();
    315318    *fLog << endl;
     319#endif
    316320
    317321    return kTRUE;
     
    338342
    339343    double r[6] = {1.0, 1.0,  1.0, 0.85,  0.1,     0.0 };
    340     double g[6] = {1.0, 1.0,  1.0, 0.0,   0.1,     0.0 };
    341     double b[6] = {0.9, 0.55, 0.4, 0.0,   0.7,     0.1 };
     344    double g[6] = {1.0, 1.0,  1.0, 0.15,  0.1,     0.0 };
     345    double b[6] = {0.9, 0.55, 0.4, 0.15,  0.7,     0.1 };
    342346
    343347    TArrayI col(99);
     
    481485    UInt_t *argb = img.GetArgbArray();
    482486    for (UInt_t *ptr=argb; ptr<argb+img.GetWidth()*img.GetHeight(); ptr++)
    483         fwrite(ptr, 1, 3, fPipe);
     487        if (fwrite(ptr, 3, 1, fPipe)!=1)
     488            break;
    484489
    485490    return CheckPipe();
     
    493498Bool_t MMovieWrite::WriteImage(TASImage &img, TVirtualPad &pad)
    494499{
     500#ifdef USE_TIMING
    495501    clock1.Start(kFALSE);
    496502    UpdateImage(img, pad);
     
    502508
    503509    return rc;
     510#else
     511    UpdateImage(img, pad);
     512    return WriteImage(img);
     513#endif
    504514}
    505515
     
    524534            continue;
    525535
    526         const MGeomPix &gpix = (*fCam)[i];
     536        const MGeom &gpix = (*fCam)[i];
    527537
    528538        Int_t    num = 0;
     
    572582            continue;
    573583
    574         const MGeomPix &gpix = (*fCam)[i];
     584        const MGeom &gpix = (*fCam)[i];
    575585
    576586        //
     
    671681Int_t MMovieWrite::Process()
    672682{
     683#ifdef USE_TIMING
    673684    clockT.Start(kFALSE);
    674685
    675686    clock3.Start(kFALSE);
    676 
     687#endif
    677688    // ---------------- Prepare display ------------------
    678689
     
    802813    // ---------------- Show data ------------------
    803814    gStyle->SetOptStat(1000000001);
    804 /*                     
     815/*
    805816    p0.Modified();
    806817    p1.Modified();
     
    815826
    816827    // ---------------- Show data ------------------
    817 
     828#ifdef USE_TIMING
    818829    clock3.Stop();
     830#endif
    819831
    820832    // Switch off automatical adding to directory (SetName would do)
     
    827839    TH1::AddDirectory(add);
    828840
     841#ifdef USE_TIMING
    829842    clockT.Stop();
     843#endif
    830844
    831845    gROOT->SetBatch(batch);
  • trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc

    r9153 r9369  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.18 2008-11-11 11:46:25 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.19 2009-03-01 21:48:14 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    215215    {
    216216        const MSignalPix &pix  = (*fSignalCam)[i];
    217         const MGeomPix   &gpix = (*fGeomCam)[i];
     217        const MGeom      &gpix = (*fGeomCam)[i];
    218218
    219219        const Float_t dx = gpix.GetX() - cenx;
     
    266266    {
    267267        const MSignalPix &pix  = (*fSignalCam)[i];
    268         const MGeomPix   &gpix = (*fGeomCam)[i];
     268        const MGeom      &gpix = (*fGeomCam)[i];
    269269
    270270        const Float_t dx = gpix.GetX() - cenx;
     
    403403    const Int_t m = fHistWidth.GetMaximumBin();
    404404    if (first>last)
     405    {
    405406        if (m>n)       // If maximum is on the right side of histogram
    406407            last = n;
    407408        else
    408409            first = 0; // If maximum is on the left side of histogram
     410    }
    409411
    410412    if (last-first<=3)
  • trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc

    r9308 r9369  
    282282
    283283    abstime[0] =
    284         abstime[0]>>7 & 0x00010000 |
    285         abstime[0]>>5 & 0x00020000 |
    286         abstime[0]>>3 & 0x00040000 |
    287         abstime[0]>>1 & 0x00080000 |
    288         abstime[0]    & 0xff00ffff;
     284        (abstime[0]>>7 & 0x00010000) |
     285        (abstime[0]>>5 & 0x00020000) |
     286        (abstime[0]>>3 & 0x00040000) |
     287        (abstime[0]>>1 & 0x00080000) |
     288        (abstime[0]    & 0xff00ffff);
    289289
    290290    //
  • trunk/MagicSoft/Mars/msignal/MSignalCam.cc

    r9261 r9369  
    374374
    375375    // Get the geometry information (neighbors) of this pixel
    376     const MGeomPix &gpix = geom[idx];
     376    const MGeom &gpix = geom[idx];
    377377
    378378    // Get the size of this pixel
  • trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc

    r9356 r9369  
    7777//
    7878MSimAPD::MSimAPD(const char* name, const char *title)
    79 : fGeom(0), fEvt(0), fStat(0)
     79: fGeom(0), fEvt(0), fStat(0), fType(1)
    8080{
    8181    fName  = name  ? name  : "MSimAPD";
     
    131131Bool_t MSimAPD::ReInit(MParList *plist)
    132132{
    133     if (UInt_t(fAPDs.GetEntriesFast())!=fGeom->GetNumPixels())
    134     {
    135         fAPDs.Delete();
    136 
    137         // FIXME:
    138         //   * initialize an empty APD and read the APD setup from a file to
    139         //     allow different APDs.
    140         //   * Make the arguments a data member of MSimAPD
    141 
    142         for (UInt_t i=0; i<fGeom->GetNumPixels(); i++)
    143             //fAPDs.Add(new APD(60, 0.2, 3, 8.75));
    144             //fAPDs.Add(new APD(60/2, 0.2, 3e-9, 8.75e-9*4));
    145             fAPDs.Add(new APD(60/2, 0.2, 3, 8.75*4));
    146     }
     133    if (UInt_t(fAPDs.GetEntriesFast())==fGeom->GetNumPixels())
     134        return kTRUE;
     135
     136    fAPDs.Delete();
     137
     138    // FIXME:
     139    //   * initialize an empty APD and read the APD setup from a file to
     140    //     allow different APDs.
     141    //   * Make the arguments a data member of MSimAPD
     142
     143    Int_t   ncells    = 0;
     144    Float_t crosstalk = 0;
     145    Float_t deadtime  = 0;
     146    Float_t recovery  = 0;
     147
     148    switch (fType)
     149    {
     150    case 1:
     151        ncells    = 30;
     152        crosstalk = 0.2;
     153        deadtime  = 3;
     154        recovery  = 8.75*4;
     155        break;
     156
     157    case 2:
     158        ncells    = 60;
     159        crosstalk = 0.2;
     160        deadtime  = 3;
     161        recovery  = 8.75;
     162        break;
     163
     164    default:
     165        *fLog << err << "ERROR - APD type " << fType << " undefined." << endl;
     166        return kFALSE;
     167    }
     168
     169    for (UInt_t i=0; i<fGeom->GetNumPixels(); i++)
     170        fAPDs.Add(new APD(ncells, crosstalk, deadtime, recovery));
    147171
    148172    return kTRUE;
     
    216240//
    217241// NameGeomCam
     242// Type: 1
    218243//
    219244Int_t MSimAPD::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    226251    }
    227252
     253    if (IsEnvDefined(env, prefix, "Type", print))
     254    {
     255        rc = kTRUE;
     256        fType = GetEnvValue(env, prefix, "Type", fType);
     257    }
     258
    228259    return rc;
    229260}
  • trunk/MagicSoft/Mars/msimcamera/MSimAPD.h

    r9328 r9369  
    2828    Double_t fFreq;              // Frequency of random phtons which hit the APDs
    2929
     30    Int_t fType;
     31
    3032    // MParContainer
    3133    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
  • trunk/MagicSoft/Mars/mtools/MagicCivilization.cc

    r2173 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1616!
    1717!
    18 !   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2002
     18!   Author(s): Thomas Bretz7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: CheObs Software Development, 2000-2009
    2121!
    2222!
     
    6565#include <TInterpreter.h>
    6666
    67 #include "MHexagon.h"
     67#include "MH.h"
    6868
    6969#include "MGeomPix.h"
     
    8080        return;
    8181
    82     fPixels->Delete();
    83 
    84     delete fPixels;
    85 
    8682    delete fGeomCam;
    87 }
    88 
    89 // ------------------------------------------------------------------------
    90 //
    91 // Draw all pixels of the camera
    92 //  (means apend all pixelobjects to the current pad)
    93 //
    94 void MagicCivilization::DrawHexagons()
    95 {
    96     for (UInt_t i=0; i<fNumPixels; i++)
    97         (*this)[i].Draw();
    9883}
    9984
     
    11196    ct1 = !ct1;
    11297
    113     DrawHexagons();
     98    AppendPad();
    11499}
    115100
     
    117102{
    118103    Free();
    119 
    120     //
    121     //  Reset the display geometry
    122     //
    123     fW=0;
    124     fH=0;
    125104
    126105    //
     
    135114    fRange     = fGeomCam->GetMaxRadius();
    136115
    137     //
    138     // Construct all hexagons. Use new-operator with placement
    139     //
    140     fPixels = new TClonesArray("MHexagon", fNumPixels);
    141 
    142     for (UInt_t i=0; i<fNumPixels; i++)
    143     {
    144         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
    145 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    146         h.SetBit(kNoContextMenu|kCannotPick);
    147 #endif
    148     }
     116    fColors.Set(fNumPixels);
    149117}
    150118
     
    154122//
    155123MagicCivilization::MagicCivilization(Byte_t lim, UShort_t init)
    156     : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim), fW(0), fH(0)
     124    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim)
    157125{
    158126    SetNewCamera(new MGeomCamMagic);
     
    179147    fTimer.TurnOff();
    180148    Free();
    181 
    182     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    183     {
    184         fDrawingPad->RecursiveRemove(this);
    185         delete fDrawingPad;
    186     }
    187149}
    188150
     
    195157void MagicCivilization::Paint(Option_t *opt)
    196158{
    197     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    198     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    199 
    200     //
    201     // Check for a change in width or height, and make sure, that the
    202     // first call also sets the range
    203     //
    204     if (w*fH == h*fW && fW && fH)
    205         return;
    206 
    207     //
    208     // Calculate aspect ratio (5/4=1.25 recommended)
    209     //
    210     const Double_t ratio = (Double_t)w/h;
    211 
    212     Float_t x;
    213     Float_t y;
    214 
    215     if (ratio>1.0)
    216     {
    217         x = fRange*(ratio*2-1);
    218         y = fRange;
    219     }
    220     else
    221     {
    222         x = fRange;
    223         y = fRange/ratio;
    224     }
    225 
    226     fH = h;
    227     fW = w;
    228 
    229     //
    230     // Set new range
    231     //
    232     fDrawingPad->Range(-fRange, -y, x, y);
     159    const Float_t r = fGeomCam->GetMaxRadius();
     160
     161    MH::SetPadRange(-r, -r, r, r*1.1);
     162
     163    TAttLine line;
     164    TAttFill fill;
     165
     166    // FIXME:
     167    for (UInt_t i=0; i<fNumPixels; i++)
     168    {
     169        const MGeom &pix = (*fGeomCam)[i];
     170
     171        fill.SetFillColor(fColors[i]);
     172        pix.PaintPrimitive(line, fill);
     173    }
     174 /*
     175    for (int i=0; i<6; i++)
     176        fText[i]->Paint();
     177        */
    233178}
    234179
     
    266211    fStep = 0;
    267212
     213    fColors.Reset();
     214
    268215    Update();
    269216
    270     fDrawingPad->Modified();
    271     fDrawingPad->Update();
     217    gPad->Modified();
     218    gPad->Update();
    272219}
    273220
     
    284231    // if no canvas is yet existing to draw into, create a new one
    285232    //
    286     /*TCanvas *c =*/ new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
    287     //c->ToggleEventStatus();
    288 
    289     fDrawingPad = gPad;
    290     fDrawingPad->SetBorderMode(0);
    291     fDrawingPad->SetFillColor(22);
     233    new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800);
     234
     235    gPad->SetBorderMode(0);
     236    gPad->SetFillColor(22);
    292237
    293238    //
     
    296241    //
    297242    AppendPad(option);
    298 
    299     //
    300     // Reset the game pad
    301     //
    302     DrawHexagons();
    303243
    304244    fCivilization.SetTextAlign(23);   // centered/bottom
     
    349289        fAuto = !fAuto;
    350290        Update();
    351         fDrawingPad->Update();
     291        gPad->Update();
    352292        return;
    353293
     
    395335    for (int i=0; i<fNumPixels; i++)
    396336    {
    397         MGeomPix &pix = (*fGeomCam)[i];
     337        MGeom &pix = (*fGeomCam)[i];
    398338
    399339        Byte_t cnt=0;
     
    411351    for (int i=0; i<fNumPixels; i++)
    412352    {
    413         MGeomPix &pix = (*fGeomCam)[i];
    414         MHexagon &hex = (*this)[i];
     353        MGeom &pix = (*fGeomCam)[i];
    415354
    416355        if (pix.TestBit(kHasCreation))
    417356        {
    418357            pix.SetBit(kHasFlag);
    419             hex.SetFillColor(kBlack);
     358            fColors[i] = kBlack;
    420359            fNumCivilizations++;
    421360        }
     
    423362        {
    424363            pix.ResetBit(kHasFlag);
    425             hex.SetFillColor(kBackground);
     364            fColors[i] = kBackground;
    426365        }
    427366        pix.ResetBit(kHasCreation);
     
    435374    Update();
    436375
    437     fDrawingPad->Update();
     376    gPad->Update();
    438377
    439378    return kTRUE;
  • trunk/MagicSoft/Mars/mtools/MagicCivilization.h

    r1440 r9369  
    1414#ifndef ROOT_TClonesArray
    1515#include <TClonesArray.h>
     16#endif
     17#ifndef ROOT_TArrayI
     18#include <TArrayI.h>
    1619#endif
    1720
     
    5053    TText     fCivilization;    // TText showing the numbers of pixels and bombs
    5154
    52     UInt_t    fW;               // Width of canvas
    53     UInt_t    fH;               // Height of canvas
    54 
    55     TClonesArray *fPixels;      // array of all hexagons
    56     TVirtualPad  *fDrawingPad;  // pad in which we are drawing
    57 
    58     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
     55    TArrayI fColors;
    5956
    6057    void   Update();
    6158    void   Free();
    62     void   DrawHexagons();
    6359    void   SetNewCamera(MGeomCam *);
    6460
  • trunk/MagicSoft/Mars/mtools/MagicDomino.cc

    r8910 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1616!
    1717!
    18 !   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2008
     20!   Copyright: CheObs Software Development, 2000-2009
    2121!
    2222!
     
    6868#include <TInterpreter.h>
    6969
    70 #include "MHexagon.h"
     70#include "MH.h"
    7171
    7272#include "MGeomPix.h"
     
    8787        return;
    8888
    89     fPixels->Delete();
    90 
    91     delete fPixels;
    92 
    9389    delete fGeomCam;
    94 }
    95 
    96 // ------------------------------------------------------------------------
    97 //
    98 // Draw all pixels of the camera
    99 //  (means apend all pixelobjects to the current pad)
    100 //
    101 void MagicDomino::DrawHexagons()
    102 {
    103     for (UInt_t i=0; i<fNumPixels; i++)
    104         (*this)[i].Draw();
    10590}
    10691
     
    123108
    124109    Reset();
    125     DrawHexagons();
     110    AppendPad();
    126111}
    127112
     
    133118{
    134119    Free();
    135 
    136     //
    137     //  Reset the display geometry
    138     //
    139     fW=0;
    140     fH=0;
    141120
    142121    //
     
    151130    fRange     = fGeomCam->GetMaxRadius();
    152131
    153     //
    154     // Construct all hexagons. Use new-operator with placement
    155     //
    156     fPixels = new TClonesArray("MHexagon", fNumPixels);
    157 
     132    fColors.Set(fNumPixels);
     133}
     134
     135// ------------------------------------------------------------------------
     136//
     137// remove the pixel numbers in the tile from the pad
     138//
     139void MagicDomino::RemoveNumbers()
     140{
     141    for (int i=0; i<6; i++)
     142        fText[i]->SetText(0, 0, "");
     143}
     144
     145// ------------------------------------------------------------------------
     146//
     147// Reset/restart the game
     148//
     149void MagicDomino::Reset()
     150{
    158151    for (UInt_t i=0; i<fNumPixels; i++)
    159152    {
    160         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
     153        fColors[i] = kBackground;
     154        (*fGeomCam)[i].ResetBit(kUserBits);
     155    }
     156
     157
    161158#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    162         h.SetBit(kNoContextMenu|kCannotPick);
    163 #endif
    164     }
    165 }
    166 
    167 // ------------------------------------------------------------------------
    168 //
    169 // remove the pixel numbers in the tile from the pad
    170 //
    171 void MagicDomino::RemoveNumbers()
    172 {
    173     for (int i=0; i<6; i++)
    174         if (fText[i])
    175         {
    176             delete fText[i];
    177             fText[i] = NULL;
    178         }
    179 }
    180 
    181 // ------------------------------------------------------------------------
    182 //
    183 // Reset/restart the game
    184 //
    185 void MagicDomino::Reset()
    186 {
    187     for (UInt_t i=0; i<fNumPixels; i++)
    188     {
    189         MHexagon &h = (*this)[i];
    190         h.SetFillColor(kBackground);
    191         h.ResetBit(kUserBits);
    192     }
    193 
    194 
    195 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    196     fDrawingPad->SetBit(kNoContextMenu);
    197159    SetBit(kNoContextMenu);
    198160#endif
     
    205167
    206168
    207     fDrawingPad->SetFillColor(22);
     169    gPad->SetFillColor(22);
    208170
    209171    fNumPixel = -1;
     
    218180void MagicDomino::Init()
    219181{
    220     memset(fText, 0, sizeof(fText));
     182    for (int i=0; i<6; i++)
     183    {
     184        fText[i] = new TText(0, 0, "");
     185        fText[i]->SetTextFont(122);
     186        fText[i]->SetTextAlign(22);   // centered/centered
     187    }
    221188
    222189    //
     
    260227
    261228    RemoveNumbers();
    262 
    263     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    264     {
    265         fDrawingPad->RecursiveRemove(this);
    266         delete fDrawingPad;
    267     }
    268 
    269229}
    270230
     
    277237void MagicDomino::Paint(Option_t *opt)
    278238{
    279     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    280     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    281 
    282     //
    283     // Check for a change in width or height, and make sure, that the
    284     // first call also sets the range
    285     //
    286     if (w*fH == h*fW && fW && fH)
    287         return;
    288 
    289     //
    290     // Calculate aspect ratio (5/4=1.25 recommended)
    291     //
    292     const Double_t ratio = (Double_t)w/h;
    293 
    294     Float_t x;
    295     Float_t y;
    296 
    297     if (ratio>1.0)
    298     {
    299         x = fRange*(ratio*2-1);
    300         y = fRange;
    301     }
    302     else
    303     {
    304         x = fRange;
    305         y = fRange/ratio;
    306     }
    307 
    308     fH = h;
    309     fW = w;
    310 
    311     //
    312     // Set new range
    313     //
    314     fDrawingPad->Range(-fRange, -y, x, y);
     239    const Float_t r = fGeomCam->GetMaxRadius();
     240
     241    MH::SetPadRange(-r, -r, r, r*1.1);
     242
     243    TAttLine line;
     244    TAttFill fill;
     245
     246    // FIXME:
     247    for (UInt_t i=0; i<fNumPixels; i++)
     248    {
     249        const MGeom &pix = (*fGeomCam)[i];
     250
     251        fill.SetFillColor(fColors[i]);
     252        pix.PaintPrimitive(line, fill);
     253    }
     254
     255    for (int i=0; i<6; i++)
     256        fText[i]->Paint();
    315257}
    316258
     
    327269    // if no canvas is yet existing to draw into, create a new one
    328270    //
    329     /*TCanvas *c =*/ new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
    330     //c->ToggleEventStatus();
    331 
    332     fDrawingPad = gPad;
    333     fDrawingPad->SetBorderMode(0);
     271    new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800);
     272
     273    gPad->SetBorderMode(0);
    334274
    335275    //
     
    343283    //
    344284    Reset();
    345     DrawHexagons();
    346 
    347     /*
    348      TPave *p = new TPave(-0.66*fRange, 0.895*fRange, 0.66*fRange, 0.995*fRange, 4, "br");
    349      p->ConvertNDCtoPad();
    350      p->SetFillColor(12);
    351      p->SetBit(kCanDelete);
    352      p->Draw();
    353      */
    354285
    355286    fDomino.SetTextAlign(23);   // centered/bottom
     
    408339    if (fNumPixel>=0)
    409340    {
    410         const MGeomPix &pix=(*fGeomCam)[fNumPixel];
    411         (*this)[fNumPixel].ResetBit(kIsTile);
     341        MGeom &pix=(*fGeomCam)[fNumPixel];
     342        pix.ResetBit(kIsTile);
    412343        for (int i=0; i<pix.GetNumNeighbors(); i++)
    413             (*this)[pix.GetNeighbor(i)].ResetBit(kIsTile);
     344            (*fGeomCam)[pix.GetNeighbor(i)].ResetBit(kIsTile);
    414345
    415346        fPoints += pix.GetNumNeighbors();
     
    425356    Update();
    426357
    427     fDrawingPad->Update();
     358    gPad->Update();
    428359}
    429360
     
    444375
    445376    Int_t cnt=0;
    446     const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
     377    const MGeom &pix1=(*fGeomCam)[fNumPixel];
    447378    for (int i=0; i<pix1.GetNumNeighbors(); i++)
    448379    {
    449380        const Int_t idx1 = pix1.GetNeighbor(i);
    450         const MGeomPix &pix2 = (*fGeomCam)[idx1];
     381        const MGeom &pix2 = (*fGeomCam)[idx1];
    451382
    452383        Byte_t ignored = 0;
     
    454385        for (int j=0; j<pix2.GetNumNeighbors(); j++)
    455386        {
    456             const Int_t    idx2 = pix2.GetNeighbor(j);
    457             const MHexagon &hex = (*this)[idx2];
    458 
    459             if (hex.TestBit(kIsTile) || hex.GetFillColor()==kBackground)
     387            const Int_t idx2 = pix2.GetNeighbor(j);
     388            const MGeom &hex = (*fGeomCam)[idx2];
     389
     390            if (hex.TestBit(kIsTile) || fColors[idx2]==kBackground)
    460391            {
    461392                ignored++;
     
    463394            }
    464395
    465             if (hex.GetFillColor()==(*this)[idx1].GetFillColor())
     396            if (fColors[idx2]==fColors[idx1])
    466397                found++;
    467398        }
     
    487418    fDomino.SetTextColor(kBlue);
    488419
    489     fDrawingPad->SetFillColor(kRed);
     420    gPad->SetFillColor(kRed);
    490421#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    491422    fDone->SetBit(kNoContextMenu|kCannotPick);
    492     fDrawingPad->ResetBit(kNoContextMenu);
    493423    ResetBit(kNoContextMenu);
    494424#endif
    495425
    496     fDrawingPad->Modified();
    497     fDrawingPad->Update();
     426    gPad->Modified();
     427    gPad->Update();
    498428}
    499429
     
    572502    Update();
    573503
    574     fDrawingPad->Modified();
    575     fDrawingPad->Update();
     504    gPad->Modified();
     505    gPad->Update();
    576506}
    577507
     
    585515        return;
    586516
    587     MagicDomino &This = *this;
    588 
    589517    RemoveNumbers();
    590518
    591     const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
    592     This[fNumPixel].SetFillColor(fOldColors[6]);
    593     This[fNumPixel].ResetBit(kIsTile);
     519    MGeom &pix1=(*fGeomCam)[fNumPixel];
     520    fColors[fNumPixel] = fOldColors[6];
     521    pix1.ResetBit(kIsTile);
    594522    for (int i=0; i<pix1.GetNumNeighbors(); i++)
    595523    {
    596524        Int_t idx = pix1.GetNeighbor(i);
    597525
    598         This[idx].SetFillColor(fOldColors[i]);
    599         This[idx].ResetBit(kIsTile);
     526        fColors[idx] = fOldColors[i];
     527        (*fGeomCam)[idx].ResetBit(kIsTile);
    600528    }
    601529}
     
    609537    if (fNumPixel<0)
    610538        return;
    611 
    612     MagicDomino &This = *this;
    613539
    614540    Int_t indices[6];
     
    617543    RemoveNumbers();
    618544
    619     const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
    620     fOldColors[6] = This[fNumPixel].GetFillColor();
    621     This[fNumPixel].SetFillColor(kBlack);
    622     This[fNumPixel].SetBit(kIsTile);
     545    MGeom &pix2=(*fGeomCam)[fNumPixel];
     546    fOldColors[6] = fColors[fNumPixel];
     547    fColors[fNumPixel] = kBlack;
     548    pix2.SetBit(kIsTile);
    623549    for (int i=0; i<pix2.GetNumNeighbors(); i++)
    624550    {
    625551        Int_t idx = pix2.GetNeighbor(i);
    626552
    627         fOldColors[i] = This[idx].GetFillColor();
     553        fOldColors[i] = fColors[idx];
    628554
    629555        int j=0;
     
    631557            j++;
    632558
    633         This[idx].SetFillColor(fNewColors[(j+fPosition)%6]);
    634         This[idx].SetBit(kIsTile);
     559        MGeom &pix = (*fGeomCam)[idx];
     560
     561        fColors[idx] = fNewColors[(j+fPosition)%6];
     562        pix.SetBit(kIsTile);
    635563
    636564        TString num;
    637565        num += idx;
    638566
    639         fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
    640         fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
    641         fText[i]->SetTextFont(122);
    642         fText[i]->SetTextAlign(22);   // centered/centered
    643         fText[i]->Draw();
     567        fText[i]->SetText(pix.GetX(), pix.GetY(), num);
     568        fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius());
    644569    }
    645570}
     
    659584    Update();
    660585
    661     fDrawingPad->Update();
     586    gPad->Update();
    662587}
    663588
     
    668593Short_t MagicDomino::AnalysePixel(Int_t dir)
    669594{
    670     const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
     595    const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
    671596
    672597    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
     
    674599    for (int i=0; i<pix.GetNumNeighbors(); i++)
    675600    {
    676         MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
     601        MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)];
    677602        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
    678603    }
     
    714639void MagicDomino::GetSortedNeighbors(Int_t indices[6])
    715640{
    716     const MGeomPix &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
     641    const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];
    717642
    718643    Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 };
     
    720645    for (int i=0; i<pix.GetNumNeighbors(); i++)
    721646    {
    722         MGeomPix &next = (*fGeomCam)[pix.GetNeighbor(i)];
     647        MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)];
    723648        fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX());
    724649    }
  • trunk/MagicSoft/Mars/mtools/MagicDomino.h

    r8755 r9369  
    1111#ifndef ROOT_TClonesArray
    1212#include <TClonesArray.h>
     13#endif
     14#ifndef ROOT_TArrayI
     15#include <TArrayI.h>
    1316#endif
    1417
     
    5962    TText    *fDone;            // game over text
    6063
    61     UInt_t    fW;               // Width of canvas
    62     UInt_t    fH;               // Height of canvas
    63 
    64     TClonesArray *fPixels;      // array of all hexagons
    65     TVirtualPad  *fDrawingPad;  // pad in which we are drawing
    66 
    67     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
     64    TArrayI fColors;
    6865
    6966    Bool_t  CheckTile();
     
    7774    void    Done();
    7875    void    RemoveNumbers();
    79     void    DrawHexagons();
    8076    void    SetNewCamera(MGeomCam *);
    8177    void    ChangePixel(Int_t add);
  • trunk/MagicSoft/Mars/mtools/MagicJam.cc

    r9312 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    141141            Float_t x0 = TMath::Odd(y) ? x-0.25 : x+0.25;
    142142
    143             cam[x + y*fWidth].Set(x0-dx, (y-dy)*0.866, 1);
    144         }
     143            cam.SetAt(x + y*fWidth, MGeomPix(x0-dx, (y-dy)*0.866, 1));
     144        }
     145
     146
     147    cam.InitGeometry();
    145148
    146149    SetGeometry(cam);
     
    442445
    443446        TVirtualPad *p = dynamic_cast<TVirtualPad*>(o);
    444         if (p && p->GetPad(1))
    445         {
    446             p->GetPad(1)->Modified();
    447             p->GetPad(1)->Update();
     447        if (p)
     448        {
     449            p->Modified();
     450            p->Update();
    448451        }
    449452    }
     
    508511    const Int_t newval = fBinEntries[idx+1]+1;
    509512
    510     const MGeomPix &gpix = (*fGeomCam)[idx];
     513    const MGeom &gpix = (*fGeomCam)[idx];
    511514    const Int_t n = gpix.GetNumNeighbors();
    512515
     
    721724        dy += y;
    722725
    723         cam[i].Set(dx, dy*0.866);
     726        cam.SetAt(i, MGeomPix(dx, dy*0.866));
    724727    }
    725728
  • trunk/MagicSoft/Mars/mtools/MagicReversi.cc

    r8756 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1616!
    1717!
    18 !   Author(s): Thomas Bretz 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz3/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: CheObs Software Development, 2000-2009
    2121!
    2222!
     
    6262#include <TInterpreter.h>
    6363
    64 #include "MHexagon.h"
     64#include "MH.h"
    6565
    6666#include "MGeomPix.h"
     
    8888        return;
    8989
    90     fPixels->Delete();
    9190    fText->Delete();
    9291    fFlags->Delete();
     
    9493    delete fText;
    9594    delete fFlags;
    96     delete fPixels;
    9795
    9896    delete fGeomCam;
     
    113111
    114112    Reset();
    115     DrawHexagons();
    116113}
    117114
     
    119116{
    120117    Free();
    121 
    122     //
    123     //  Reset the display geometry
    124     //
    125     fW=0;
    126     fH=0;
    127118
    128119    //
     
    144135    fText   = new TClonesArray("TText",    fNumPixels);
    145136    fFlags  = new TClonesArray("TMarker",  fNumPixels);
    146     fPixels = new TClonesArray("MHexagon", fNumPixels);
     137    fColors.Set(fNumPixels);
    147138
    148139    for (UInt_t i=0; i<fNumPixels; i++)
    149140    {
    150         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
    151 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    152         h.SetBit(kNoContextMenu|kCannotPick);
    153 #endif
     141        const MGeom &pix = (*fGeomCam)[i];
    154142
    155143        TText &t = *new ((*fText)[i]) TText;
    156144        t.SetTextFont(122);
    157145        t.SetTextAlign(22);   // centered/centered
    158         t.SetTextSize(0.3*h.GetD()/fRange);
     146        t.SetTextSize(0.3*pix.GetT()/fRange);
    159147#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    160148        t.SetBit(kNoContextMenu|kCannotPick);
    161149#endif
    162 
    163         const MGeomPix &pix = (*fGeomCam)[i];
    164150
    165151        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
     
    170156}
    171157
     158/*
    172159// ------------------------------------------------------------------------
    173160//
     
    180167        (*this)[i].Draw();
    181168}
     169*/
    182170
    183171void MagicReversi::Init()
     
    201189//
    202190MagicReversi::MagicReversi()
    203     : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
     191    : fGeomCam(NULL), fDone(NULL)
    204192{
    205193    SetNewCamera(new MGeomCamMagic);
     
    209197
    210198MagicReversi::MagicReversi(const MGeomCam &geom)
    211     : fGeomCam(NULL), fDone(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
     199    : fGeomCam(NULL), fDone(NULL)
    212200{
    213201    SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
     
    229217    if (fDone)
    230218        delete fDone;
    231 
    232     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    233     {
    234         fDrawingPad->RecursiveRemove(this);
    235         delete fDrawingPad;
    236     }
    237219}
    238220
     
    245227void MagicReversi::Paint(Option_t *opt)
    246228{
    247     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    248     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    249 
    250     //
    251     // Check for a change in width or height, and make sure, that the
    252     // first call also sets the range
    253     //
    254     if (w*fH == h*fW && fW && fH)
    255         return;
    256 
    257     //
    258     // Calculate aspect ratio (5/4=1.25 recommended)
    259     //
    260     const Double_t ratio = (Double_t)w/h;
    261 
    262     Float_t x;
    263     Float_t y;
    264 
    265     if (ratio>1.0)
    266     {
    267         x = fRange*(ratio*2-1);
    268         y = fRange;
    269     }
    270     else
    271     {
    272         x = fRange;
    273         y = fRange/ratio;
    274     }
    275 
    276     fH = h;
    277     fW = w;
    278 
    279     //
    280     // Set new range
    281     //
    282     fDrawingPad->Range(-fRange, -y, x, y);
    283 
    284     //
    285     // Adopt absolute sized of markers to relative range
    286     //
     229    const Float_t r = fGeomCam->GetMaxRadius();
     230
     231    MH::SetPadRange(-r, -r, r, r*1.1);
     232
     233    TAttLine line;
     234    TAttFill fill;
     235
     236    // FIXME:
    287237    for (UInt_t i=0; i<fNumPixels; i++)
    288238    {
    289         Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
     239        const MGeom &pix = (*fGeomCam)[i];
     240
     241        fill.SetFillColor(fColors[i]);
     242        pix.PaintPrimitive(line, fill);
     243
     244        //
     245        // Adopt absolute sized of markers to relative range
     246        //
     247        Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325;
    290248        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
     249
     250        if (pix.TestBit(kHasFlag))
     251            GetFlag(i)->Paint();
     252
     253        GetText(i)->Paint();
    291254    }
    292255}
     
    301264void MagicReversi::Draw(Option_t *option)
    302265{
    303     // root 3.02:
    304     // gPad->SetFixedAspectRatio()
    305 
    306     if (fDrawingPad)
    307         return;
    308 
    309266    //
    310267    // if no canvas is yet existing to draw into, create a new one
    311268    //
    312269    if (!gPad)
    313     {
    314         /*TCanvas *c =*/ new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
    315         //c->ToggleEventStatus();
    316         fIsAllocated = kTRUE;
    317     }
    318     else
    319         fIsAllocated = kFALSE;
    320 
    321     fDrawingPad = gPad;
    322     fDrawingPad->SetBorderMode(0);
     270        new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800);
     271
     272    gPad->SetBorderMode(0);
    323273
    324274    //
     
    347297    //
    348298    Reset();
    349     DrawHexagons();
    350299}
    351300
     
    411360    for (UInt_t i=0; i<fNumPixels; i++)
    412361    {
    413         Remove(GetText(i));
    414         Remove(GetFlag(i));
    415 
    416         (*this)[i].SetFillColor(kEmpty);
     362        fColors[i] = kEmpty;
    417363        (*fGeomCam)[i].ResetBit(kUserBits);
    418364
    419365        GetFlag(i)->SetMarkerColor(kBlack);
     366        GetText(i)->SetText(0, 0, "");
    420367    }
    421368
     
    427374    for (int i=1; i<5*fNumUsers; i++)
    428375    {
    429         (*this)[i-1].SetFillColor(i%fNumUsers+kRed);
     376        fColors[i-1] = i%fNumUsers+kRed;
    430377        fUsrPts[i%fNumUsers]++;
    431378    }
     
    433380    Update();
    434381
    435     fDrawingPad->SetFillColor(22);
     382    gPad->SetFillColor(22);
    436383
    437384#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    438     fDrawingPad->SetBit(kNoContextMenu);
    439385    SetBit(kNoContextMenu);
    440386#endif
     
    468414    fDone->Draw();
    469415
    470     fDrawingPad->SetFillColor(winner+kRed);
     416    gPad->SetFillColor(winner+kRed);
    471417
    472418#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    473     fDrawingPad->ResetBit(kNoContextMenu);
    474419    ResetBit(kNoContextMenu);
    475420#endif
    476 }
    477 
    478 void MagicReversi::Remove(TObject *obj)
    479 {
    480     fDrawingPad->RecursiveRemove(obj);
    481421}
    482422
     
    495435        {
    496436            idx = fGeomCam->GetNeighbor(idx, dir);
    497             if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)
     437            if (idx<0 || fColors[idx]==kEmpty)
    498438                break;
    499439
    500             if ((*this)[idx].GetFillColor()==col)
     440            if (fColors[idx]==col)
    501441            {
    502442                if (length!=0)
     
    523463                idx = fGeomCam->GetNeighbor(idx, dir);
    524464
    525                 fUsrPts[(*this)[idx].GetFillColor()-kRed]--;
     465                fUsrPts[fColors[idx]-kRed]--;
    526466                fUsrPts[fNumUser]++;
    527467
    528                 (*this)[idx].SetFillColor(col);
     468                fColors[idx] = col;
    529469            }
    530470    }
     
    536476{
    537477    for (unsigned int i=0; i<fNumPixels; i++)
    538         if ((*this)[i].GetFillColor()==kEmpty && Flip(i, kFALSE))
     478        if (fColors[i]==kEmpty && Flip(i, kFALSE))
    539479            return kTRUE;
    540480    return kFALSE;
     
    557497    {
    558498        Done();
    559         fDrawingPad->Modified();
    560         fDrawingPad->Update();
     499        gPad->Modified();
     500        gPad->Update();
    561501        return;
    562502    }
     
    564504    UInt_t idx;
    565505    for (idx=0; idx<fNumPixels; idx++)
    566         if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
     506        if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0)
    567507            break;
    568508
     
    570510        return;
    571511
    572     if (event==kButton1Down && (*this)[idx].GetFillColor()==kEmpty)
     512    if (event==kButton1Down && fColors[idx]==kEmpty)
    573513    {
    574514        if (!Flip(idx, kTRUE))
     
    577517        fUsrPts[fNumUser]++;
    578518
    579         (*this)[idx].SetFillColor(kRed+fNumUser);
     519        fColors[idx] = kRed+fNumUser;
    580520
    581521        Int_t start = fNumUser;
     
    600540    }
    601541
    602     fDrawingPad->Modified();
    603 }
     542    gPad->Modified();
     543}
  • trunk/MagicSoft/Mars/mtools/MagicReversi.h

    r8756 r9369  
    77#ifndef ROOT_TClonesArray
    88#include <TClonesArray.h>
     9#endif
     10#ifndef ROOT_TArrayI
     11#include <TArrayI.h>
    912#endif
    1013
     
    2427    Float_t        fRange;         // the range in millimeters of the present geometry
    2528
    26     TClonesArray  *fPixels;        // array of all hexagons
    2729    TClonesArray  *fText;          // array of all texts
    2830    TClonesArray  *fFlags;         // array of all texts
    2931
     32    TArrayI fColors;
     33
    3034    TText         *fDone;          // TText showing the 'Game over'
    3135    TText         *fUsrTxt[6];     // TText showing the numbers of pixels and bombs
    32 
    33     UInt_t         fW;             // Width of canvas
    34     UInt_t         fH;             // Height of canvas
    35     TVirtualPad   *fDrawingPad;    // pad in which we are drawing
    36     Bool_t         fIsAllocated;
    3736
    3837    Int_t          fNumUsers;
     
    4948    };
    5049
    51     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
    52 
    5350    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
    5451    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
    5552
    56     void  Remove(TObject *);
    5753    void  Done();
    5854    void  Update();
    5955    void  SetNewCamera(MGeomCam *);
    60     void  DrawHexagons();
    6156    void  Free();
    6257    void  Init();
  • trunk/MagicSoft/Mars/mtools/MagicShow.cc

    r8755 r9369  
    6464#include <TInterpreter.h>
    6565
    66 #include "MHexagon.h"
     66#include "MH.h"
    6767
    6868#include "MGeomPix.h"
     
    8383        return;
    8484
    85     fPixels->Delete();
    86 
    87     delete fPixels;
    88 
    8985    delete fGeomCam;
    90 }
    91 
    92 // ------------------------------------------------------------------------
    93 //
    94 // Draw all pixels of the camera
    95 //  (means apend all pixelobjects to the current pad)
    96 //
    97 void MagicShow::DrawHexagons()
    98 {
    99     for (UInt_t i=0; i<fNumPixels; i++)
    100     {
    101         MHexagon &h = (*this)[i];
    102 
    103         h.SetFillColor(kBackground);
    104         h.Draw();
    105     }
    10686}
    10787
     
    123103    ct1 = !ct1;
    124104
    125     DrawHexagons();
     105    Update();
     106
     107    fColors.Reset();
     108
     109    // FIXME: Reset all texts
     110
     111    AppendPad();
    126112}
    127113
     
    133119{
    134120    Free();
    135 
    136     //
    137     //  Reset the display geometry
    138     //
    139     fW=0;
    140     fH=0;
    141121
    142122    //
     
    151131    fRange     = fGeomCam->GetMaxRadius();
    152132
    153     fNumPixel  = fNumPixels-1;
    154 
    155     //
    156     // Construct all hexagons. Use new-operator with placement
    157     //
    158     fPixels = new TClonesArray("MHexagon", fNumPixels);
    159 
    160     for (UInt_t i=0; i<fNumPixels; i++)
    161     {
    162         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
    163 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    164         h.SetBit(kNoContextMenu|kCannotPick);
    165 #endif
    166     }
     133    fNumPixel  = 0;//fNumPixels-1;
     134
     135    fColors.Set(fNumPixels);
     136
     137    for (int i=0; i<6; i++)
     138    {
     139        fText[i] = new TText(0, 0, "");
     140        fText[i]->SetTextFont(122);
     141        fText[i]->SetTextAlign(22);   // centered/centered
     142    }
     143
    167144}
    168145
    169146void MagicShow::Init()
    170147{
    171     memset(fText, 0, sizeof(fText));
    172 
    173148    //
    174149    // Make sure, that the object is destroyed when the canvas/pad is
     
    189164//
    190165MagicShow::MagicShow()
    191     : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
     166    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE)
    192167{
    193168    SetNewCamera(new MGeomCamMagic);
     
    200175//
    201176MagicShow::MagicShow(const MGeomCam &geom)
    202     : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE), fW(0), fH(0)
     177    : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE)
    203178{
    204179    SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
     
    215190
    216191    for (int i=0; i<6; i++)
    217         if (fText[i])
    218             delete fText[i];
    219 
    220     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    221     {
    222         fDrawingPad->RecursiveRemove(this);
    223         delete fDrawingPad;
    224     }
     192        delete fText[i];
    225193}
    226194
     
    233201void MagicShow::Paint(Option_t *opt)
    234202{
    235     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    236     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    237 
    238     //
    239     // Check for a change in width or height, and make sure, that the
    240     // first call also sets the range
    241     //
    242     if (w*fH == h*fW && fW && fH)
    243         return;
    244 
    245     //
    246     // Calculate aspect ratio (5/4=1.25 recommended)
    247     //
    248     const Double_t ratio = (Double_t)w/h;
    249 
    250     Float_t x;
    251     Float_t y;
    252 
    253     if (ratio>1.0)
    254     {
    255         x = fRange*(ratio*2-1);
    256         y = fRange;
    257     }
    258     else
    259     {
    260         x = fRange;
    261         y = fRange/ratio;
    262     }
    263 
    264     fH = h;
    265     fW = w;
    266 
    267     //
    268     // Set new range
    269     //
    270     fDrawingPad->Range(-fRange, -y, x, y);
     203    const Float_t r = fGeomCam->GetMaxRadius();
     204
     205    MH::SetPadRange(-r, -r, r, r*1.1);
     206
     207    TAttLine line;
     208    TAttFill fill;
     209
     210    // FIXME:
     211    for (UInt_t i=0; i<fNumPixels; i++)
     212    {
     213        const MGeom &pix = (*fGeomCam)[i];
     214
     215        fill.SetFillColor(fColors[i]);
     216        pix.PaintPrimitive(line, fill);
     217    }
     218
     219    for (int i=0; i<6; i++)
     220        fText[i]->Paint();
    271221}
    272222
     
    283233    // if no canvas is yet existing to draw into, create a new one
    284234    //
    285     /*TCanvas *c =*/ new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
    286     //c->ToggleEventStatus();
    287 
    288     fDrawingPad = gPad;
    289     fDrawingPad->SetBorderMode(0);
    290     fDrawingPad->SetFillColor(22);
     235    new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800);
     236
     237    gPad->SetBorderMode(0);
     238    gPad->SetFillColor(22);
    291239
    292240    //
     
    295243    //
    296244    AppendPad(option);
    297 
    298     //
    299     // Reset the game pad
    300     //
    301     DrawHexagons();
    302245
    303246    fShow.SetTextAlign(23);   // centered/bottom
     
    339282        fAuto = !fAuto;
    340283        Update();
    341         fDrawingPad->Update();
     284        gPad->Update();
    342285        return;
    343286
     
    382325void MagicShow::ChangePixel(Int_t add)
    383326{
    384     MagicShow &This = *this;
    385 
    386     const MGeomPix &pix1=(*fGeomCam)[fNumPixel];
    387     This[fNumPixel].SetFillColor(kBackground);
     327    const MGeom &pix1=(*fGeomCam)[fNumPixel];
     328
     329    fColors[fNumPixel] = kBackground;
    388330    for (int i=0; i<pix1.GetNumNeighbors(); i++)
    389331    {
    390         This[pix1.GetNeighbor(i)].SetFillColor(kBackground);
    391         if (!fText[i])
     332        fColors[pix1.GetNeighbor(i)] = kBackground;
     333        if (TString(fText[i]->GetTitle()).IsNull())
    392334            continue;
    393335
    394         delete fText[i];
    395         fText[i] = NULL;
     336        fText[i]->SetText(0, 0, "");
    396337    }
    397338
     
    403344        fNumPixel = fNumPixels-1;
    404345
    405     const MGeomPix &pix2=(*fGeomCam)[fNumPixel];
    406     This[fNumPixel].SetFillColor(kBlue);
     346    const MGeom &pix2=(*fGeomCam)[fNumPixel];
     347
     348    fColors[fNumPixel] = kBlue;
     349
    407350    for (int i=0; i<pix2.GetNumNeighbors(); i++)
    408351    {
    409352        Int_t idx = pix2.GetNeighbor(i);
    410353
    411         This[idx].SetFillColor(kMagenta);
     354        fColors[idx] = kMagenta;
    412355
    413356        TString num;
    414357        num += idx;
    415358
    416         fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num);
    417         fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius());
    418         fText[i]->SetTextFont(122);
    419         fText[i]->SetTextAlign(22);   // centered/centered
    420         fText[i]->Draw();
     359        const MGeom &pix=(*fGeomCam)[idx];
     360
     361        fText[i]->SetText(pix.GetX(), pix.GetY(), num);
     362        fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius());
    421363    }
    422364
    423365    Update();
    424366
    425     fDrawingPad->Update();
     367    gPad->Update();
    426368}
    427369
  • trunk/MagicSoft/Mars/mtools/MagicShow.h

    r8755 r9369  
    1414#ifndef ROOT_TClonesArray
    1515#include <TClonesArray.h>
     16#endif
     17#ifndef ROOT_TArrayI
     18#include <TArrayI.h>
    1619#endif
    1720
     
    4548    TText    *fText[6];         // ttext showing the pixel numbers of the neighbors
    4649
    47     UInt_t    fW;               // Width of canvas
    48     UInt_t    fH;               // Height of canvas
    49 
    50     TClonesArray *fPixels;      // array of all hexagons
    51     TVirtualPad  *fDrawingPad;  // pad in which we are drawing
    52 
    53     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
     50    TArrayI fColors;
    5451
    5552    void   Update();
    5653    void   Free();
    57     void   DrawHexagons();
    5854    void   SetNewCamera(MGeomCam *);
    5955    void   ChangePixel(Int_t add);
  • trunk/MagicSoft/Mars/mtools/MagicSnake.cc

    r8755 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1616!
    1717!
    18 !   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     18!   Author(s): Thomas Bretz7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2002
     20!   Copyright: CheObs Software Development, 2000-2009
    2121!
    2222!
     
    6363#include <TInterpreter.h>
    6464
    65 #include "MHexagon.h"
     65#include "MH.h"
    6666
    6767#include "MGeomPix.h"
     
    7878        return;
    7979
    80     fPixels->Delete();
    81 
    82     delete fPixels;
    83 
    8480    delete fGeomCam;
    8581
    8682    delete fArray;
    87 }
    88 
    89 // ------------------------------------------------------------------------
    90 //
    91 // Draw all pixels of the camera
    92 //  (means apend all pixelobjects to the current pad)
    93 //
    94 void MagicSnake::DrawHexagons()
    95 {
    96     for (UInt_t i=0; i<fNumPixels; i++)
    97         (*this)[i].Draw();
    9883}
    9984
     
    115100
    116101    Reset();
    117     DrawHexagons();
     102    AppendPad();
    118103}
    119104
     
    121106{
    122107    Free();
    123 
    124     //
    125     //  Reset the display geometry
    126     //
    127     fW=0;
    128     fH=0;
    129108
    130109    //
     
    139118    fRange     = fGeomCam->GetMaxRadius();
    140119
    141     //
    142     // Construct all hexagons. Use new-operator with placement
    143     //
    144     fPixels = new TClonesArray("MHexagon", fNumPixels);
    145 
    146     for (UInt_t i=0; i<fNumPixels; i++)
    147     {
    148         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
    149 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    150         h.SetBit(kNoContextMenu|kCannotPick);
    151 #endif
    152     }
     120    fColors.Set(fNumPixels);
    153121}
    154122
     
    175143//
    176144MagicSnake::MagicSnake()
    177     : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
     145    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL)
    178146{
    179147    SetNewCamera(new MGeomCamMagic);
     
    186154//
    187155MagicSnake::MagicSnake(const MGeomCam &geom)
    188     : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL), fW(0), fH(0)
     156    : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL)
    189157{
    190158    SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
     
    203171#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    204172        fPaused->SetBit(kNoContextMenu|kCannotPick);
    205         fDrawingPad->ResetBit(kNoContextMenu);
    206173        ResetBit(kNoContextMenu);
    207174#endif
    208         fDrawingPad->Update();
     175        //fDrawingPad->Update();
    209176    }
    210177
     
    215182    {
    216183#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    217         fDrawingPad->SetBit(kNoContextMenu);
     184        //fDrawingPad->SetBit(kNoContextMenu);
    218185        SetBit(kNoContextMenu);
    219186#endif
     
    222189        return;
    223190
    224     Remove(fPaused);
    225 
    226     fDrawingPad->Update();
     191    //fDrawingPad->Update();
    227192
    228193    delete fPaused;
     
    241206    if (fDone)
    242207        delete fDone;
    243 
     208/*
    244209    if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    245210    {
    246211        fDrawingPad->RecursiveRemove(this);
    247212        delete fDrawingPad;
    248     }
     213    }*/
    249214}
    250215
     
    257222void MagicSnake::Paint(Option_t *opt)
    258223{
    259     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    260     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    261 
    262     //
    263     // Check for a change in width or height, and make sure, that the
    264     // first call also sets the range
    265     //
    266     if (w*fH == h*fW && fW && fH)
    267         return;
    268 
    269     //
    270     // Calculate aspect ratio (5/4=1.25 recommended)
    271     //
    272     const Double_t ratio = (Double_t)w/h;
    273 
    274     Float_t x;
    275     Float_t y;
    276 
    277     if (ratio>1.0)
    278     {
    279         x = fRange*(ratio*2-1);
    280         y = fRange;
    281     }
    282     else
    283     {
    284         x = fRange;
    285         y = fRange/ratio;
    286     }
    287 
    288     fH = h;
    289     fW = w;
    290 
    291     //
    292     // Set new range
    293     //
    294     fDrawingPad->Range(-fRange, -y, x, y);
     224    const Float_t r = fGeomCam->GetMaxRadius();
     225
     226    MH::SetPadRange(-r, -r, r, r*1.1);
     227
     228    TAttLine line;
     229    TAttFill fill;
     230
     231    for (UInt_t i=0; i<fNumPixels; i++)
     232    {
     233        const MGeom &pix = (*fGeomCam)[i];
     234
     235        fill.SetFillColor(fColors[i]);
     236        pix.PaintPrimitive(line, fill);
     237    }
    295238}
    296239
     
    307250    // if no canvas is yet existing to draw into, create a new one
    308251    //
    309     /*TCanvas *c =*/ new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
    310     //c->ToggleEventStatus();
    311 
    312     fDrawingPad = gPad;
    313     fDrawingPad->SetBorderMode(0);
     252    new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800);
     253
     254    //fDrawingPad = gPad;
     255    gPad->SetBorderMode(0);
    314256
    315257    //
     
    323265    //
    324266    Reset();
    325     DrawHexagons();
    326267
    327268    fShow.SetTextAlign(23);   // centered/bottom
     
    355296    for (UInt_t i=0; i<fNumPixels; i++)
    356297    {
    357         (*this)[i].SetFillColor(kBackground);
     298        fColors[i] = kBackground;
    358299        (*fGeomCam)[i].ResetBit(kUserBits);
    359300    }
     
    372313
    373314        (*fGeomCam)[idx].SetBit(kHasBomb);
    374         (*this)[idx].SetFillColor(kRed);
     315        fColors[idx] = kRed;
    375316    }
    376317
    377318    fNumFood = fNumPixels/6;
     319    // FIXME. gROOT->GetColor doesn't allow more than 100 colors!
     320    if (fNumFood>46)
     321        fNumFood=46;
    378322
    379323    fArray = new Int_t[fNumFood+3];
     
    395339
    396340        (*fGeomCam)[idx].SetBit(kHasFood);
    397         (*this)[idx].SetFillColor(kGreen);
     341        fColors[idx] = kGreen;
    398342    }
    399343
     
    409353        fTransport[i] = idx;
    410354        (*fGeomCam)[idx].SetBit(kHasTransport);
    411         (*this)[idx].SetFillColor(kYellow);
    412     }
    413 
    414     fDrawingPad->SetFillColor(22);
     355        fColors[idx] = kYellow;
     356    }
     357
     358    gPad->SetFillColor(22);
    415359
    416360#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    417     fDrawingPad->SetBit(kNoContextMenu);
     361    //fDrawingPad->SetBit(kNoContextMenu);
    418362    SetBit(kNoContextMenu);
    419363#endif
     
    435379    fDone->SetTextSize(0.05); // white
    436380    fDone->Draw();
    437     fDrawingPad->SetFillColor(col);
     381    gPad->SetFillColor(col);
    438382#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    439383    fDone->SetBit(kNoContextMenu|kCannotPick);
    440     fDrawingPad->ResetBit(kNoContextMenu);
    441384    ResetBit(kNoContextMenu);
    442385#endif
    443 }
    444 
    445 void MagicSnake::Remove(TObject *obj)
    446 {
    447     fDrawingPad->RecursiveRemove(obj);
    448386}
    449387
     
    500438    if ((*fGeomCam)[newpix].TestBit(kHasTransport))
    501439    {
    502         (*this)[fArray[0]].SetFillColor(kBackground);
     440        fColors[fArray[0]] = kBackground;
    503441        (*fGeomCam)[fArray[0]].ResetBit(kHasWorm);
    504442
     
    513451    if (!(*fGeomCam)[newpix].TestBit(kHasFood))
    514452    {
    515         MGeomPix &pix = (*fGeomCam)[fArray[0]];
     453        MGeom &pix = (*fGeomCam)[fArray[0]];
    516454
    517455        if (!pix.TestBit(kHasTransport))
     456        {
    518457            if (pix.TestBit(kHasDoor))
    519                 (*this)[fArray[0]].SetFillColor(kMagenta);
     458                fColors[fArray[0]] = kMagenta;
    520459            else
    521                 (*this)[fArray[0]].SetFillColor(kBackground);
     460                fColors[fArray[0]] = kBackground;
     461        }
    522462
    523463        pix.ResetBit(kHasWorm);
     
    538478            for (int i=1; i<7; i++)
    539479            {
    540                 (*this)[i].SetFillColor(kMagenta);
     480                fColors[i] = kMagenta;
    541481                (*fGeomCam)[i].SetBit(kHasDoor);
    542482            }
     
    552492        const Int_t idx = fArray[i];
    553493
    554         MGeomPix &pix = (*fGeomCam)[idx];
     494        MGeom &pix = (*fGeomCam)[idx];
    555495
    556496        if (pix.TestBit(kHasTransport))
     
    559499        pix.SetBit(kHasWorm);
    560500
    561         Int_t color = 51+fLength-i;
    562         (*this)[idx].SetFillColor(color);
     501        fColors[idx] = 51+fLength-i;
    563502    }
    564503}
     
    568507    const Int_t first = fArray[fLength-1];
    569508
    570     const MGeomPix &pix=(*fGeomCam)[first];
     509    const MGeom &pix=(*fGeomCam)[first];
    571510
    572511    Double_t dx = pix.GetX();
     
    577516    {
    578517        const Int_t     idx  = pix.GetNeighbor(i);
    579         const MGeomPix &next = (*fGeomCam)[idx];
     518        const MGeom &next = (*fGeomCam)[idx];
    580519
    581520        const Double_t x = next.GetX();
     
    596535        return -1;
    597536
    598     const MGeomPix &np = (*fGeomCam)[newpix];
     537    const MGeom &np = (*fGeomCam)[newpix];
    599538
    600539    if (fNumFood==0 && np.TestBit(kHasDoor))
     
    611550
    612551Bool_t MagicSnake::HandleTimer(TTimer *timer)
    613 {
     552{     
    614553    if (fDone || fPaused)
    615554        return kTRUE;
     
    637576    Update();
    638577
    639     //cout << "Update " << flush;
    640 
    641     fDrawingPad->Modified();
    642     fDrawingPad->Update();
    643 
    644     //cout << "Done." << endl;
     578    gPad->Modified();
     579    gPad->Update();
    645580
    646581    return kTRUE;
  • trunk/MagicSoft/Mars/mtools/MagicSnake.h

    r8755 r9369  
    1414#ifndef ROOT_TClonesArray
    1515#include <TClonesArray.h>
     16#endif
     17#ifndef ROOT_TArrayI
     18#include <TArrayI.h>
    1619#endif
    1720
     
    6063    Float_t   fRange;           // the range in millimeters of the present geometry
    6164
     65    TArrayI fColors;
     66
    6267    TText    *fDone;            // TText showing the 'Game over'
    6368    TText    *fPaused;          // TText showing the 'Game over'
    6469    TText     fShow;            // TText showing the numbers of pixels and bombs
    6570
    66     UInt_t    fW;               // Width of canvas
    67     UInt_t    fH;               // Height of canvas
    68 
    69     TClonesArray  *fPixels;     // array of all hexagons
    7071    TVirtualPad   *fDrawingPad; // pad in which we are drawing
    7172
    72     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
    73 
    74     void   Remove(TObject *);
    7573    void   Done(TString, Int_t col);
    7674    void   Step(Int_t newpix);
  • trunk/MagicSoft/Mars/mtools/MineSweeper.cc

    r8755 r9369  
    22!
    33! *
    4 ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     4! * This file is part of CheObs, the Modular Analysis and Reconstruction
    55! * Software. It is distributed to you in the hope that it can be a useful
    66! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     
    99! * Permission to use, copy, modify and distribute this software and its
    1010! * documentation for any purpose is hereby granted without fee,
    11 ! * provided that the above copyright notice appear in all copies and
     11! * provided that the above copyright notice appears in all copies and
    1212! * that both that copyright notice and this permission notice appear
    1313! * in supporting documentation. It is provided "as is" without express
     
    1616!
    1717!
    18 !   Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2002
     18!   Author(s): Thomas Bretz7/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: CheObs Software Development, 2000-2009
    2121!
    2222!
     
    5757#include <TInterpreter.h>
    5858
    59 #include "MHexagon.h"
     59#include "MH.h"
    6060
    6161#include "MGeomPix.h"
     
    8282        return;
    8383
    84     fPixels->Delete();
    8584    fText->Delete();
    8685    fFlags->Delete();
     
    8887    delete fText;
    8988    delete fFlags;
    90     delete fPixels;
    9189
    9290    delete fGeomCam;
     
    107105
    108106    Reset();
    109     DrawHexagons();
     107    AppendPad();
    110108}
    111109
     
    113111{
    114112    Free();
    115 
    116     //
    117     //  Reset the display geometry
    118     //
    119     fW=0;
    120     fH=0;
    121113
    122114    //
     
    138130    fText   = new TClonesArray("TText",    fNumPixels);
    139131    fFlags  = new TClonesArray("TMarker",  fNumPixels);
    140     fPixels = new TClonesArray("MHexagon", fNumPixels);
     132    fColors.Set(fNumPixels);
     133    //fPixels = new TClonesArray("MHexagon", fNumPixels);
    141134
    142135    for (UInt_t i=0; i<fNumPixels; i++)
    143136    {
    144         MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]);
    145 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    146         h.SetBit(kNoContextMenu|kCannotPick);
    147 #endif
     137        const MGeom &pix = (*fGeomCam)[i];
    148138
    149139        TText &t = *new ((*fText)[i]) TText;
    150140        t.SetTextFont(122);
    151141        t.SetTextAlign(22);   // centered/centered
    152         t.SetTextSize(0.3*h.GetD()/fRange);
     142        t.SetTextSize(0.3*pix.GetT()/fRange);
    153143#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    154144        t.SetBit(kNoContextMenu|kCannotPick);
    155145#endif
    156146
    157         const MGeomPix &pix = (*fGeomCam)[i];
    158 
    159147        TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar);
    160148#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     
    162150#endif
    163151    }
    164 }
    165 
    166 // ------------------------------------------------------------------------
    167 //
    168 // Draw all pixels of the camera
    169 //  (means apend all pixelobjects to the current pad)
    170 //
    171 void MineSweeper::DrawHexagons()
    172 {
    173     for (UInt_t i=0; i<fNumPixels; i++)
    174         (*this)[i].Draw();
    175152}
    176153
     
    193170//
    194171MineSweeper::MineSweeper()
    195     : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
     172    : fGeomCam(NULL), fDone(NULL), fShow(NULL)
    196173{
    197174    SetNewCamera(new MGeomCamMagic);
     
    200177
    201178MineSweeper::MineSweeper(const MGeomCam &geom)
    202     : fGeomCam(NULL), fDone(NULL), fShow(NULL), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
     179    : fGeomCam(NULL), fDone(NULL), fShow(NULL)
    203180{
    204181    SetNewCamera(static_cast<MGeomCam*>(geom.Clone()));
     
    218195    if (fDone)
    219196        delete fDone;
    220 
    221     if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)
    222     {
    223         fDrawingPad->RecursiveRemove(this);
    224         delete fDrawingPad;
    225     }
    226197}
    227198
     
    234205void MineSweeper::Paint(Option_t *opt)
    235206{
    236     const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC());
    237     const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC());
    238 
    239     //
    240     // Check for a change in width or height, and make sure, that the
    241     // first call also sets the range
    242     //
    243     if (w*fH == h*fW && fW && fH)
    244         return;
    245 
    246     //
    247     // Calculate aspect ratio (5/4=1.25 recommended)
    248     //
    249     const Double_t ratio = (Double_t)w/h;
    250 
    251     Float_t x;
    252     Float_t y;
    253 
    254     if (ratio>1.0)
    255     {
    256         x = fRange*(ratio*2-1);
    257         y = fRange;
    258     }
    259     else
    260     {
    261         x = fRange;
    262         y = fRange/ratio;
    263     }
    264 
    265     fH = h;
    266     fW = w;
    267 
    268     //
    269     // Set new range
    270     //
    271     fDrawingPad->Range(-fRange, -y, x, y);
    272 
    273     //
    274     // Adopt absolute sized of markers to relative range
    275     //
     207    const Float_t r = fGeomCam->GetMaxRadius();
     208
     209    MH::SetPadRange(-r, -r, r, r*1.1);
     210
     211    TAttLine line;
     212    TAttFill fill;
     213
     214    // FIXME:
    276215    for (UInt_t i=0; i<fNumPixels; i++)
    277216    {
    278         Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325;
     217        const MGeom &pix = (*fGeomCam)[i];
     218
     219        fill.SetFillColor(fColors[i]);
     220        pix.PaintPrimitive(line, fill);
     221
     222        //
     223        // Adopt absolute sized of markers to relative range
     224        //
     225        Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325;
    279226        GetFlag(i)->SetMarkerSize(20.0*r/fRange);
     227
     228        if (pix.TestBit(kHasFlag))
     229            GetFlag(i)->Paint();
     230
     231        GetText(i)->Paint();
    280232    }
    281233}
     
    293245    // gPad->SetFixedAspectRatio()
    294246
    295     if (fDrawingPad)
    296         return;
    297 
    298247    //
    299248    // if no canvas is yet existing to draw into, create a new one
    300249    //
    301250    if (!gPad)
    302     {
    303         /*TCanvas *c =*/ new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
    304         //c->ToggleEventStatus();
    305         fIsAllocated = kTRUE;
    306     }
    307     else
    308         fIsAllocated = kFALSE;
    309 
    310     fDrawingPad = gPad;
    311     fDrawingPad->SetBorderMode(0);
     251        new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800);
     252
     253    gPad->SetBorderMode(0);
    312254
    313255    //
     
    330272    //
    331273    Reset();
    332     DrawHexagons();
    333274}
    334275
     
    357298    for (UInt_t i=0; i<fNumPixels; i++)
    358299    {
    359         Remove(GetText(i));
    360         Remove(GetFlag(i));
    361 
    362         (*this)[i].SetFillColor(kHidden);
     300        fColors[i] = kHidden;
    363301        (*fGeomCam)[i].ResetBit(kUserBits);
    364302
    365303        GetFlag(i)->SetMarkerColor(kBlack);
     304        GetText(i)->SetText(0, 0, "");
    366305    }
    367306    Update(fNumBombs);
     
    378317    }
    379318
    380     fDrawingPad->SetFillColor(22);
    381 
    382 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    383     fDrawingPad->SetBit(kNoContextMenu);
     319    gPad->SetFillColor(22);
     320
     321#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     322    gPad->SetBit(kNoContextMenu);
    384323    SetBit(kNoContextMenu);
    385324#endif
     
    391330        if ((*fGeomCam)[j].TestBit(kHasBomb))
    392331        {
    393             (*this)[j].SetFillColor(kBlack);
     332            fColors[j] = kBlack;
    394333            GetFlag(j)->SetMarkerColor(kWhite);
    395334        }
     
    404343    fDone->Draw();
    405344
    406     fDrawingPad->SetFillColor(col);
    407 
    408 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
    409     fDrawingPad->ResetBit(kNoContextMenu);
     345    gPad->SetFillColor(col);
     346
     347#if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)
     348    gPad->ResetBit(kNoContextMenu);
    410349    ResetBit(kNoContextMenu);
    411350#endif
     
    419358void MineSweeper::OpenHexagon(Int_t idx)
    420359{
    421     MGeomPix &pix=(*fGeomCam)[idx];
     360    MGeom &pix=(*fGeomCam)[idx];
    422361
    423362    if (pix.TestBit(kIsVisible))
    424363        return;
    425 
    426     if (pix.TestBit(kHasFlag))
    427         Remove(GetFlag(idx));
    428364
    429365    pix.SetBit(kIsVisible);
     
    435371            cnt++;
    436372
    437     (*this)[idx].SetFillColor(fColorBombs[cnt]);
    438 
     373    fColors[idx] = fColorBombs[cnt];
     374
     375    TString str;
    439376    if (cnt)
    440     {
    441         TText *txt = GetText(idx);
    442         TString str;
    443377        str += cnt;
    444         txt->SetText(pix.GetX(), pix.GetY(), str);
    445         txt->Draw();
    446         return;
    447     }
     378
     379    TText *txt = GetText(idx);
     380    txt->SetText(pix.GetX(), pix.GetY(), str);
     381
     382    if (cnt)
     383        return;
    448384
    449385    for (int j=0; j<pix.GetNumNeighbors(); j++)
    450386        OpenHexagon(pix.GetNeighbor(j));
    451 }
    452 
    453 void MineSweeper::Remove(TObject *obj)
    454 {
    455     fDrawingPad->RecursiveRemove(obj);
    456387}
    457388
     
    479410    UInt_t idx;
    480411    for (idx=0; idx<fNumPixels; idx++)
    481         if ((*fPixels)[idx]->DistancetoPrimitive(px, py)==0)
     412        if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0)
    482413            break;
    483414
     
    485416        return;
    486417
    487     MGeomPix &pix=(*fGeomCam)[idx];
     418    MGeom &pix=(*fGeomCam)[idx];
    488419
    489420    if (event==kButton1Double)
     
    496427
    497428    if (event==kButton1Down && !pix.TestBit(kIsVisible))
    498     {
    499         if (pix.TestBit(kHasFlag))
    500             Remove(GetFlag(idx));
    501         else
    502             GetFlag(idx)->Draw();
    503 
    504429        pix.InvertBit(kHasFlag);
    505     }
    506430
    507431    UInt_t vis=fNumBombs;
     
    520444        Done("Great! Congratulations, you did it!", kGreen);
    521445
    522     fDrawingPad->Modified();
     446    gPad->Modified();
    523447
    524448    /*
  • trunk/MagicSoft/Mars/mtools/MineSweeper.h

    r8755 r9369  
    88#include <TClonesArray.h>
    99#endif
     10#ifndef ROOT_TArrayI
     11#include <TArrayI.h>
     12#endif
    1013
    1114class TText;
     
    1316class TVirtualPad;
    1417
     18class MGeom;
    1519class MGeomCam;
    1620class MHexagon;
     
    2731    Float_t        fRange;         // the range in millimeters of the present geometry
    2832
    29     TClonesArray  *fPixels;        // array of all hexagons
    3033    TClonesArray  *fText;          // array of all texts
    3134    TClonesArray  *fFlags;         // array of all texts
    3235
     36    TArrayI fColors;
     37
    3338    TText         *fDone;          // TText showing the 'Game over'
    3439    TText         *fShow;          // TText showing the numbers of pixels and bombs
    35 
    36     UInt_t         fW;             // Width of canvas
    37     UInt_t         fH;             // Height of canvas
    38     TVirtualPad   *fDrawingPad;    // pad in which we are drawing
    39     Bool_t         fIsAllocated;
    4040
    4141    enum
     
    4848    };
    4949
    50     MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
    51 
    5250    TText   *GetText(Int_t i) { return (TText*)fText->At(i); }
    5351    TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); }
    5452
    55     void  Remove(TObject *);
    5653    void  OpenHexagon(Int_t idx);
    5754    void  Done(TString, Int_t);
    5855    void  Update(Int_t);
    5956    void  SetNewCamera(MGeomCam *);
    60     void  DrawHexagons();
     57    void  PaintPrimitives();
    6158    void  Free();
    6259    void  Init();
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.hxx

    r7880 r9369  
    6666  void SetTrigPattern (UInt_t upi, UInt_t loi){
    6767
    68     if (upi==loi==0) {
     68    if (upi==0 && loi==0) {
    6969      fTrigPattern[0]= (UInt_t) fThreshold[0];
    7070      fTrigPattern[1]= (UInt_t) (100*fMultiplicity+fTopology);
Note: See TracChangeset for help on using the changeset viewer.