Ignore:
Timestamp:
03/01/01 15:42:32 (24 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgui
Files:
4 added
2 deleted
6 edited

Legend:

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

    r602 r653  
    22
    33#include <math.h>
     4
    45#include <TClonesArray.h>
    56#include <TCanvas.h>
     
    910
    1011#include "MHexagon.h"
    11 #include "MCamGeom.h"
     12#include "MGeomCam.h"
    1213
    1314#include "MCerPhotEvt.h"
    1415
     16#define kITEMS_LEGEND 25
    1517
    1618ClassImp(MCamDisplay)
    1719
    18 MCamDisplay::MCamDisplay (Int_t type )
     20    MCamDisplay::MCamDisplay (Int_t type ) : fAutoScale(kTRUE)
    1921{
    20   //    default constructor
    21 
    22   //    set the color palette
    23 
    24   gStyle->SetPalette(1,0) ;
    25 
    26   fAutoScale  = kTRUE ;
    27  
    28   MCamGeom *geometry  = new MCamGeom( type ) ;
    29 
    30   fNbPixels = geometry->GetNbPixels() ;
    31   fPixels = new TClonesArray("MHexagon", fNbPixels ) ;
    32 
    33   //  create the hexagons of the display
    34  
    35   TClonesArray &obj = *fPixels ;
    36  
    37   for (Int_t i=0; i< fNbPixels; i++ )
    38     {
    39       new (obj[i]) MHexagon(geometry->GetX(i) ,
    40                             geometry->GetY(i) ,
    41                             geometry->GetR(i) ) ;
    42     }
    43 
    44   // set the range to default
    45 
    46   fMinPhe  = -2.  ;
    47   fMaxPhe  = 50. ;
    48 
    49   // set up the Legend
    50 
    51   fLegend = new TClonesArray("TBox", ITEMS_LEGEND ) ;
    52   TClonesArray &obj1 = *fLegend ;
    53 
    54   fLegText = new TClonesArray("TText", ITEMS_LEGEND ) ;
    55   TClonesArray &obj2 = *fLegText ;
    56  
    57   char text[100] ;
    58 
    59   Float_t help ;
    60 
    61   help = 50. / ITEMS_LEGEND ;
    62 
    63   for ( Int_t il = 0 ; il < ITEMS_LEGEND ; il++ )
    64     {
    65       new ( obj1[il] ) TBox(650, il*40-500 , 700, il*40-460 ) ;
    66       ( (TBox*) fLegend->At(il))->SetFillColor( GetColor ( (Float_t) help*il) ) ;
    67  
    68       sprintf ( text, "%5.1f",  (Float_t) help * il ) ;
    69       new ( obj2[il] ) TText(720, il*40-480, text ) ;
    70       ( (TText*) fLegText->At(il))->SetTextSize (0.025) ;
    71       ( (TText*) fLegText->At(il))->SetTextAlign(12) ;
    72   }
    73 }
     22    // default constructor
     23
     24    //
     25    // create a object which contains the camera geometry
     26    //
     27    MGeomCam geom(type) ;
     28
     29    //
     30    //    set the color palette
     31    //
     32    gStyle->SetPalette(1,0) ;
     33
     34    //
     35    //  create the hexagons of the display
     36    //
     37    fNbPixels = geom.GetNbPixels() ;
     38    fPixels   = new TClonesArray("MHexagon", fNbPixels ) ;
     39
     40    for (Int_t i=0; i< fNbPixels; i++ )
     41    {
     42        (*fPixels)[i] = new MHexagon(geom[i]) ;
     43    }
     44
     45    //
     46    // set the range to default
     47    //
     48    fMinPhe  = -2.  ;
     49    fMaxPhe  = 50. ;
     50
     51    //
     52    // set up the Legend
     53    //
     54    fLegend  = new TClonesArray("TBox",  kITEMS_LEGEND ) ;
     55    fLegText = new TClonesArray("TText", kITEMS_LEGEND ) ;
     56
     57    char text[10] ;
     58    for ( Int_t il = 0 ; il < kITEMS_LEGEND ; il++ )
     59    {
     60        const Int_t y = il*40;
     61
     62        TBox  *newbox = new TBox (650, y-500, 700, y-460 );
     63        TText *newtxt = new TText(720, y-480, text );
     64
     65        const Float_t lvl = 50. / kITEMS_LEGEND * il;
     66
     67        newbox->SetFillColor( GetColor(lvl) );
     68
     69        sprintf ( text, "%5.1f", lvl ) ;
     70
     71        newtxt->SetTextSize (0.025) ;
     72        newtxt->SetTextAlign(12) ;
     73
     74        (*fLegend) [il] = newbox;
     75        (*fLegText)[il] = newtxt;
     76    }
     77}
    7478
    7579MCamDisplay::~MCamDisplay()
    7680{
    77   delete fPixels ;
    78 } 
     81    delete fPixels ;
     82}
    7983
    8084
    8185void MCamDisplay::Init()
    8286{
    83 
    84   // Set the right colors
    85  
    86   gStyle->SetPalette(1, 0) ;
    87 
    88   if ( ! gPad ) new TCanvas("display", "MAGIC display", 0, 0, 650, 500) ;
    89  
    90   for (Int_t i=0; i< fNbPixels; i++)
    91     {
    92       ( (MHexagon*) fPixels->At(i))->Draw() ;
    93     }
    94 
    95   for (Int_t i=0; i< ITEMS_LEGEND; i++)
    96     {
    97      
    98       ( (TBox*) fLegend->At(i))->Draw() ;
    99 
    100       ( (TText*) fLegText->At(i))->Draw() ;
    101     }
    102  
     87    //
     88    // Set the right colors
     89    //
     90    gStyle->SetPalette(1, 0) ;
     91
     92    //
     93    // if no canvas is yet existing to draw into, create a new one
     94    //
     95    if ( !gPad ) new TCanvas("display", "MAGIC display", 0, 0, 650, 500) ;
     96
     97    //
     98    // draw all pixels of the camera
     99    //
     100    for (Int_t i=0; i< fNbPixels; i++)
     101        (*this)[i].Draw();
     102
     103    //
     104    // draw legend
     105    //
     106    for (Int_t i=0; i< kITEMS_LEGEND; i++)
     107    {
     108        GetBox(i)->Draw();
     109        GetText(i)->Draw();
     110    }
    103111}
    104112
     
    108116  //
    109117
    110   //  check if there a pad exists
    111 
    112   if ( ! gPad ) Init() ;
    113 
    114   gPad->Range (-600, -600, 900, 600) ;
    115   gPad->SetFillColor(22) ;
    116 
    117   //
    118  
    119   gPad->Modified() ;
    120   gPad->Update() ;
    121 
    122   //gPad->Update() ;
     118    //
     119    //  check if there a pad exists, if not create one
     120    //
     121    if ( !gPad ) Init() ;
     122
     123    //
     124    // set init values
     125    //
     126    gPad->Range (-600, -600, 900, 600) ;
     127    gPad->SetFillColor(22) ;
     128
     129    //
     130    // mark pad as modified and update screen
     131    //
     132    gPad->Modified() ;
     133    gPad->Update() ;
    123134
    124135
    125 void MCamDisplay::Draw( MCerPhotEvt *event)
    126 {
    127 
    128   // loop over all pixels in the MCerPhotEvt and
    129   // determine the Pixel Id and the content
    130 
    131   Reset() ;
    132 
    133   //  if the autoscale is true, set the values for the range for
    134   //  each event
    135  
    136   if ( fAutoScale == kTRUE )
    137     {
    138       fMinPhe = event->GetMinimumPhoton() ;
    139       fMaxPhe = event->GetMaximumPhoton() ;
    140 
    141       if ( fMaxPhe < 20. ) fMaxPhe = 20. ;
    142 
    143 
    144       UpdateLegend() ;
    145     } 
    146 
    147   //   update the picture
    148 
    149   for (Int_t i=0 ; i<event->GetNbPixels() ; i++ )
    150     {
    151       if ( event->IsPixelUsed(i) == kTRUE )
    152         ( (MHexagon*) fPixels->At( event->GetPixelId(i) ))->SetFillColor( GetColor(event->GetPhotons(i))) ;
    153    
    154     }
    155  
    156   Draw() ;
    157  
     136void MCamDisplay::DrawPhotNum( MCerPhotEvt *event)
     137{
     138
     139    //
     140    // loop over all pixels in the MCerPhotEvt and
     141    // determine the Pixel Id and the content
     142    //
     143    Reset() ;
     144
     145    //
     146    //  if the autoscale is true, set the values for the range for
     147    //  each event
     148    //
     149    if ( fAutoScale )
     150    {
     151        fMinPhe = event->GetMinNumPhotons() ;
     152        fMaxPhe = event->GetMaxNumPhotons() ;
     153
     154        if (fMaxPhe < 20.)
     155            fMaxPhe = 20. ;
     156
     157        UpdateLegend() ;
     158    }
     159
     160    //
     161    //   update the colors in the picture
     162    //
     163    const Int_t entries = event->GetNbPixels();
     164
     165    for (Int_t i=0 ; i<entries; i++ )
     166    {
     167        MCerPhotPix &pix = (*event)[i];
     168
     169        if (!pix.IsPixelUsed())
     170            continue;
     171
     172        SetPixColor(pix);
     173    }
     174
     175    //
     176    // update the picture
     177    //
     178    Draw() ;
    158179
    159180
    160 void MCamDisplay::DrawError( MCerPhotEvt *event)
    161 {
    162   //
    163 
    164   // loop over all pixels in the MCerPhotEvt and
    165   // determine the Pixel Id and the content
    166   Reset() ;
    167 
    168   for (Int_t i=0 ; i<event->GetNbPixels() ; i++ )
    169     {
    170       ( (MHexagon*) fPixels->At( event->GetPixelId(i) ))->SetFillColor( GetColor(event->GetErrorPhot(i)) ) ;
    171     }
    172  
    173   Draw() ;
    174  
     181void MCamDisplay::DrawPhotErr( MCerPhotEvt *event)
     182{
     183    //
     184    // reset the all pixel colors to a default value
     185    //
     186    Reset() ;
     187
     188    //
     189    // loop over all pixels in the MCerPhotEvt and
     190    // determine the Pixel Id and the content
     191    //
     192    const Int_t entries = event->GetNbPixels() ;
     193
     194    for (Int_t i=0 ; i<entries; i++ )
     195    {
     196        MCerPhotPix &pix = (*event)[i];
     197
     198        SetPixColor(pix);
     199    }
     200
     201    //
     202    // update display
     203    //
     204    Draw() ;
    175205
    176206
     
    178208void MCamDisplay::Reset()
    179209{
    180   for ( Int_t i=0 ; i< fNbPixels ; i++  )
    181     {
    182       ( (MHexagon*) fPixels->At(i))->SetFillColor(10) ;
    183     }
    184 
     210    //
     211    // reset the all pixel colors to a default value
     212    //
     213    for ( Int_t i=0 ; i< fNbPixels ; i++ )
     214        (*this)[i].SetFillColor(10) ;
    185215}
    186216
    187 Int_t MCamDisplay::GetColor(Float_t wert )
    188 {
    189   //   Here we calculate the color index for the current value.
    190   //   The color index is defined with the class TStyle and the
    191   //   Color palette inside. We use the command gStyle->SetPalette(1,0)
    192   //   for the display. So we have to convert the value "wert" into
    193   //   a color index that fits the color palette.
    194   //   The range of the color palette is defined by the values fMinPhe
    195   //   and fMaxRange. Between this values we have 50 color index, starting
    196   //   with 0 up to 49.
    197   //
    198 
    199   //   first treat the over- and under-flows
    200 
    201   if ( wert >= fMaxPhe )
    202     return gStyle->GetColorPalette( 49 )   ;
    203 
    204   if ( wert <= fMinPhe )
    205     return gStyle->GetColorPalette( 0 )  ;
    206 
    207   // calculate the color index
    208 
    209   Int_t ColIndex ;
    210 
    211   ColIndex =  (Int_t) wert ;
    212  
    213   ColIndex =  (Int_t) ( .5 + ( (wert-fMinPhe) * 49. / (fMaxPhe-fMinPhe) ) ) ;
    214 
    215   return (gStyle->GetColorPalette(ColIndex) ) ;
    216 
    217 }
    218 
     217Int_t MCamDisplay::GetColor(Float_t val)
     218{
     219    //
     220    //   Here we calculate the color index for the current value.
     221    //   The color index is defined with the class TStyle and the
     222    //   Color palette inside. We use the command gStyle->SetPalette(1,0)
     223    //   for the display. So we have to convert the value "wert" into
     224    //   a color index that fits the color palette.
     225    //   The range of the color palette is defined by the values fMinPhe
     226    //   and fMaxRange. Between this values we have 50 color index, starting
     227    //   with 0 up to 49.
     228    //
     229
     230    //
     231    //   first treat the over- and under-flows
     232    //
     233    const Float_t maxcolidx = 49.0;
     234
     235    if (val >= fMaxPhe )
     236        return gStyle->GetColorPalette(maxcolidx);
     237
     238    if (val <= fMinPhe )
     239        return gStyle->GetColorPalette( 0 );
     240
     241    //
     242    // calculate the color index
     243    //
     244    const Float_t ratio  = (val-fMinPhe) / (fMaxPhe-fMinPhe);
     245    const Int_t   colidx = (Int_t)(maxcolidx*ratio + .5) ;
     246
     247    return gStyle->GetColorPalette(colidx) ;
     248}
    219249
    220250void MCamDisplay::UpdateLegend()
    221 {
    222   //    change the text on the legend according to the range of the
    223   //    Display
    224  
    225   char text[100] ;
    226  
    227   Float_t x, y, wert,  help ;
    228  
    229   help = 50./ITEMS_LEGEND ; 
    230  
    231   for (Int_t il=0; il < ITEMS_LEGEND; il++)
    232     {
    233       wert = fMinPhe + (il*help)/50 * (fMaxPhe-fMinPhe) ;
    234      
    235       sprintf ( text, "%5.1f", wert ) ;
    236      
    237       x = ( (TText*) fLegText->At(il))->GetX () ;
    238       y = ( (TText*) fLegText->At(il))->GetY () ;
    239       ( (TText*) fLegText->At(il))->SetText (x, y,  text ) ;
    240     } 
    241  
    242 }
     251{
     252    //
     253    //    change the text on the legend according to the range of the
     254    //    Display
     255    //
     256
     257    char text[10] ;
     258
     259    for (Int_t il=0; il < kITEMS_LEGEND; il++)
     260    {
     261        const Float_t val = fMinPhe + (Float_t)il/kITEMS_LEGEND * (fMaxPhe-fMinPhe) ;
     262
     263        sprintf(text, "%5.1f", val);
     264
     265        TText &txt = *GetText(il);
     266
     267        txt.SetText(txt.GetX(), txt.GetY(), text) ;
     268    }
     269}
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.h

    r602 r653  
    22#define MCAMDISPLAY_H
    33
    4 #include <iostream>
     4#ifndef MAGIC_H
     5#include "MAGIC.h"
     6#endif
     7#ifndef MHEXAGON_H
     8#include "MHexagon.h"
     9#endif
     10#ifndef MCERPHOTPIX_H
     11#include "MCerPhotPix.h"
     12#endif
     13#ifndef MCERPHOTEVT_H
     14#include "MCerPhotEvt.h"
     15#endif
     16#ifndef ROOT_TClonesArray
     17#include <TClonesArray.h>
     18#endif
    519
    6 #include "MAGIC.h"
    7 
    8 #define   ITEMS_LEGEND         25
    9 
    10 class TClonesArray ;
    11 class MCerPhotEvt  ;
     20class TClonesArray ;
     21class MCerPhotEvt  ;
     22class TBox;
     23class TText;
    1224
    1325class MCamDisplay : public TObject
    1426{
    1527 private:
    16   Bool_t        fAutoScale ;  //  indicating the autoscale function
     28  Bool_t        fAutoScale ;   //!  indicating the autoscale function
    1729 
    18   Int_t         fNbPixels ;   //
    19   TClonesArray  *fPixels   ;  //!
     30  Int_t         fNbPixels ;    //!
     31  TClonesArray  *fPixels   ;   //!
    2032
    21   Float_t       fMinPhe ;     //  The minimal number of Phe
    22   Float_t       fMaxPhe ;     //  The maximum number of Phe
     33  Float_t       fMinPhe ;      //!  The minimal number of Phe
     34  Float_t       fMaxPhe ;      //!  The maximum number of Phe
    2335
    2436  TClonesArray  *fLegend  ;    //!
    2537  TClonesArray  *fLegText ;    //!
     38
     39  TBox *GetBox(Int_t i)   { return (TBox*) fLegend->At(i); }
     40  TText *GetText(Int_t i) { return (TText*)fLegText->At(i); }
     41
     42  void SetPixColor(MCerPhotPix &pix)
     43  {
     44      (*this)[pix.GetPixId()].SetFillColor( GetColor(pix.GetNumPhotons()));
     45  }
    2646
    2747 public:
     
    3555  void Draw(Option_t *option = "" ) ;
    3656
    37   void Draw( MCerPhotEvt *event) ;
    38   void DrawError( MCerPhotEvt *event) ;
     57  void DrawPhotNum( MCerPhotEvt *event) ;
     58  void DrawPhotErr( MCerPhotEvt *event) ;
    3959
    4060  void Reset() ;
     61
     62  MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
    4163
    4264  Int_t GetColor( Float_t wert ) ;
     
    4971    }
    5072
    51   //Int_t    GetNbPixels() ;
    52  
    53   ClassDef(MCamDisplay, 1)              // Base (abstract) class for a task
     73  ClassDef(MCamDisplay, 1) // Display the magic camera
    5474};
    5575
  • trunk/MagicSoft/Mars/mgui/MCamNeighbor.cc

    r603 r653  
    11#include "MCamNeighbor.h"
    22
    3 #include <stdlib.h>
    4 
    5 ClassImp(MCamNeighbor) 
     3#include "MLog.h"
     4
     5ClassImp(MCamNeighbor)
    66
    77MCamNeighbor::MCamNeighbor()
     
    341341  { 269,    270,    328,    330,    394,    395} ,
    342342  { 217,    270,    271,    329,    395,    396} ,
    343   { 271,    332,    396,    397,    432,  -9999} ,
    344   { 271,    272,    331,    333,    397,  -9999} ,
    345   { 272,    273,    332,    334,    398,  -9999} ,
    346   { 273,    274,    333,    335,    398,  -9999} ,
    347   { 274,    275,    334,    336,    399,  -9999} ,
    348   { 275,    276,    335,    337,    399,  -9999} ,
    349   { 276,    277,    336,    338,    400,  -9999} ,
    350   { 277,    278,    337,    339,    400,  -9999} ,
    351   { 278,    279,    338,    340,    401,  -9999} ,
    352   { 279,    280,    339,    341,    401,  -9999} ,
    353   { 280,    281,    340,    342,    402,  -9999} ,
    354   { 281,    341,    343,    402,    403,  -9999} ,
    355   { 281,    282,    342,    344,    403,  -9999} ,
    356   { 282,    283,    343,    345,    404,  -9999} ,
    357   { 283,    284,    344,    346,    404,  -9999} ,
    358   { 284,    285,    345,    347,    405,  -9999} ,
    359   { 285,    286,    346,    348,    405,  -9999} ,
    360   { 286,    287,    347,    349,    406,  -9999} ,
    361   { 287,    288,    348,    350,    406,  -9999} ,
    362   { 288,    289,    349,    351,    407,  -9999} ,
    363   { 289,    290,    350,    352,    407,  -9999} ,
    364   { 290,    291,    351,    353,    408,  -9999} ,
    365   { 291,    352,    354,    408,    409,  -9999} ,
    366   { 291,    292,    353,    355,    409,  -9999} ,
    367   { 292,    293,    354,    356,    410,  -9999} ,
    368   { 293,    294,    355,    357,    410,  -9999} ,
    369   { 294,    295,    356,    358,    411,  -9999} ,
    370   { 295,    296,    357,    359,    411,  -9999} ,
    371   { 296,    297,    358,    360,    412,  -9999} ,
    372   { 297,    298,    359,    361,    412,  -9999} ,
    373   { 298,    299,    360,    362,    413,  -9999} ,
    374   { 299,    300,    361,    363,    413,  -9999} ,
    375   { 300,    301,    362,    364,    414,  -9999} ,
    376   { 301,    363,    365,    414,    415,  -9999} ,
    377   { 301,    302,    364,    366,    415,  -9999} ,
    378   { 302,    303,    365,    367,    416,  -9999} ,
    379   { 303,    304,    366,    368,    416,  -9999} ,
    380   { 304,    305,    367,    369,    417,  -9999} ,
    381   { 305,    306,    368,    370,    417,  -9999} ,
    382   { 306,    307,    369,    371,    418,  -9999} ,
    383   { 307,    308,    370,    372,    418,  -9999} ,
    384   { 308,    309,    371,    373,    419,  -9999} ,
    385   { 309,    310,    372,    374,    419,  -9999} ,
    386   { 310,    311,    373,    375,    420,  -9999} ,
    387   { 311,    374,    376,    420,    421,  -9999} ,
    388   { 311,    312,    375,    377,    421,  -9999} ,
    389   { 312,    313,    376,    378,    422,  -9999} ,
    390   { 313,    314,    377,    379,    422,  -9999} ,
    391   { 314,    315,    378,    380,    423,  -9999} ,
    392   { 315,    316,    379,    381,    423,  -9999} ,
    393   { 316,    317,    380,    382,    424,  -9999} ,
    394   { 317,    318,    381,    383,    424,  -9999} ,
    395   { 318,    319,    382,    384,    425,  -9999} ,
    396   { 319,    320,    383,    385,    425,  -9999} ,
    397   { 320,    321,    384,    386,    426,  -9999} ,
    398   { 321,    385,    387,    426,    427,  -9999} ,
    399   { 321,    322,    386,    388,    427,  -9999} ,
    400   { 322,    323,    387,    389,    428,  -9999} ,
    401   { 323,    324,    388,    390,    428,  -9999} ,
    402   { 324,    325,    389,    391,    429,  -9999} ,
    403   { 325,    326,    390,    392,    429,  -9999} ,
    404   { 326,    327,    391,    393,    430,  -9999} ,
    405   { 327,    328,    392,    394,    430,  -9999} ,
    406   { 328,    329,    393,    395,    431,  -9999} ,
    407   { 329,    330,    394,    396,    431,  -9999} ,
    408   { 271,    330,    331,    395,    432,  -9999} ,
     343  { 271,    332,    396,    397,    432,  -1} ,
     344  { 271,    272,    331,    333,    397,  -1} ,
     345  { 272,    273,    332,    334,    398,  -1} ,
     346  { 273,    274,    333,    335,    398,  -1} ,
     347  { 274,    275,    334,    336,    399,  -1} ,
     348  { 275,    276,    335,    337,    399,  -1} ,
     349  { 276,    277,    336,    338,    400,  -1} ,
     350  { 277,    278,    337,    339,    400,  -1} ,
     351  { 278,    279,    338,    340,    401,  -1} ,
     352  { 279,    280,    339,    341,    401,  -1} ,
     353  { 280,    281,    340,    342,    402,  -1} ,
     354  { 281,    341,    343,    402,    403,  -1} ,
     355  { 281,    282,    342,    344,    403,  -1} ,
     356  { 282,    283,    343,    345,    404,  -1} ,
     357  { 283,    284,    344,    346,    404,  -1} ,
     358  { 284,    285,    345,    347,    405,  -1} ,
     359  { 285,    286,    346,    348,    405,  -1} ,
     360  { 286,    287,    347,    349,    406,  -1} ,
     361  { 287,    288,    348,    350,    406,  -1} ,
     362  { 288,    289,    349,    351,    407,  -1} ,
     363  { 289,    290,    350,    352,    407,  -1} ,
     364  { 290,    291,    351,    353,    408,  -1} ,
     365  { 291,    352,    354,    408,    409,  -1} ,
     366  { 291,    292,    353,    355,    409,  -1} ,
     367  { 292,    293,    354,    356,    410,  -1} ,
     368  { 293,    294,    355,    357,    410,  -1} ,
     369  { 294,    295,    356,    358,    411,  -1} ,
     370  { 295,    296,    357,    359,    411,  -1} ,
     371  { 296,    297,    358,    360,    412,  -1} ,
     372  { 297,    298,    359,    361,    412,  -1} ,
     373  { 298,    299,    360,    362,    413,  -1} ,
     374  { 299,    300,    361,    363,    413,  -1} ,
     375  { 300,    301,    362,    364,    414,  -1} ,
     376  { 301,    363,    365,    414,    415,  -1} ,
     377  { 301,    302,    364,    366,    415,  -1} ,
     378  { 302,    303,    365,    367,    416,  -1} ,
     379  { 303,    304,    366,    368,    416,  -1} ,
     380  { 304,    305,    367,    369,    417,  -1} ,
     381  { 305,    306,    368,    370,    417,  -1} ,
     382  { 306,    307,    369,    371,    418,  -1} ,
     383  { 307,    308,    370,    372,    418,  -1} ,
     384  { 308,    309,    371,    373,    419,  -1} ,
     385  { 309,    310,    372,    374,    419,  -1} ,
     386  { 310,    311,    373,    375,    420,  -1} ,
     387  { 311,    374,    376,    420,    421,  -1} ,
     388  { 311,    312,    375,    377,    421,  -1} ,
     389  { 312,    313,    376,    378,    422,  -1} ,
     390  { 313,    314,    377,    379,    422,  -1} ,
     391  { 314,    315,    378,    380,    423,  -1} ,
     392  { 315,    316,    379,    381,    423,  -1} ,
     393  { 316,    317,    380,    382,    424,  -1} ,
     394  { 317,    318,    381,    383,    424,  -1} ,
     395  { 318,    319,    382,    384,    425,  -1} ,
     396  { 319,    320,    383,    385,    425,  -1} ,
     397  { 320,    321,    384,    386,    426,  -1} ,
     398  { 321,    385,    387,    426,    427,  -1} ,
     399  { 321,    322,    386,    388,    427,  -1} ,
     400  { 322,    323,    387,    389,    428,  -1} ,
     401  { 323,    324,    388,    390,    428,  -1} ,
     402  { 324,    325,    389,    391,    429,  -1} ,
     403  { 325,    326,    390,    392,    429,  -1} ,
     404  { 326,    327,    391,    393,    430,  -1} ,
     405  { 327,    328,    392,    394,    430,  -1} ,
     406  { 328,    329,    393,    395,    431,  -1} ,
     407  { 329,    330,    394,    396,    431,  -1} ,
     408  { 271,    330,    331,    395,    432,  -1} ,
    409409  { 331,    332,    398,    432,    433,    434} ,
    410   { 333,    334,    397,    399,    434,  -9999} ,
    411   { 335,    336,    400,    435,    436,  -9999} ,
    412   { 337,    338,    399,    401,    437,  -9999} ,
    413   { 339,    340,    400,    402,    438,  -9999} ,
     410  { 333,    334,    397,    399,    434,  -1} ,
     411  { 335,    336,    400,    435,    436,  -1} ,
     412  { 337,    338,    399,    401,    437,  -1} ,
     413  { 339,    340,    400,    402,    438,  -1} ,
    414414  { 341,    342,    401,    403,    438,    439} ,
    415415  { 342,    343,    402,    404,    440,    441} ,
    416   { 344,    345,    403,    441,    442,  -9999} ,
    417   { 346,    347,    404,    442,    443,  -9999} ,
    418   { 348,    349,    405,    443,    444,  -9999} ,
    419   { 350,    351,    406,    444,    445,  -9999} ,
     416  { 344,    345,    403,    441,    442,  -1} ,
     417  { 346,    347,    404,    442,    443,  -1} ,
     418  { 348,    349,    405,    443,    444,  -1} ,
     419  { 350,    351,    406,    444,    445,  -1} ,
    420420  { 352,    353,    407,    409,    445,    446} ,
    421421  { 353,    354,    408,    410,    447,    448} ,
    422   { 355,    356,    409,    411,    448,  -9999} ,
    423   { 357,    358,    410,    412,    449,  -9999} ,
    424   { 359,    360,    411,    450,    451,  -9999} ,
    425   { 361,    362,    412,    414,    452,  -9999} ,
     422  { 355,    356,    409,    411,    448,  -1} ,
     423  { 357,    358,    410,    412,    449,  -1} ,
     424  { 359,    360,    411,    450,    451,  -1} ,
     425  { 361,    362,    412,    414,    452,  -1} ,
    426426  { 363,    364,    413,    415,    452,    453} ,
    427427  { 364,    365,    414,    416,    454,    455} ,
    428   { 366,    367,    415,    417,    455,  -9999} ,
    429   { 368,    369,    418,    456,    457,  -9999} ,
    430   { 370,    371,    417,    419,    458,  -9999} ,
    431   { 372,    373,    418,    420,    459,  -9999} ,
     428  { 366,    367,    415,    417,    455,  -1} ,
     429  { 368,    369,    418,    456,    457,  -1} ,
     430  { 370,    371,    417,    419,    458,  -1} ,
     431  { 372,    373,    418,    420,    459,  -1} ,
    432432  { 374,    375,    419,    421,    459,    460} ,
    433433  { 375,    376,    420,    422,    461,    462} ,
    434   { 377,    378,    421,    462,    463,  -9999} ,
    435   { 379,    380,    422,    463,    464,  -9999} ,
    436   { 381,    382,    423,    464,    465,  -9999} ,
    437   { 383,    384,    424,    465,    466,  -9999} ,
     434  { 377,    378,    421,    462,    463,  -1} ,
     435  { 379,    380,    422,    463,    464,  -1} ,
     436  { 381,    382,    423,    464,    465,  -1} ,
     437  { 383,    384,    424,    465,    466,  -1} ,
    438438  { 385,    386,    425,    427,    466,    467} ,
    439439  { 386,    387,    426,    428,    468,    469} ,
    440   { 388,    389,    427,    429,    469,  -9999} ,
    441   { 390,    391,    428,    430,    470,  -9999} ,
    442   { 392,    393,    429,    471,    472,  -9999} ,
    443   { 394,    395,    430,    432,    473,  -9999} ,
     440  { 388,    389,    427,    429,    469,  -1} ,
     441  { 390,    391,    428,    430,    470,  -1} ,
     442  { 392,    393,    429,    471,    472,  -1} ,
     443  { 394,    395,    430,    432,    473,  -1} ,
    444444  { 331,    396,    397,    431,    473,    474} ,
    445   { 397,    434,    474,    475,    476,  -9999} ,
     445  { 397,    434,    474,    475,    476,  -1} ,
    446446  { 397,    398,    433,    435,    476,    477} ,
    447447  { 398,    399,    434,    436,    477,    478} ,
     
    449449  { 400,    401,    436,    438,    479,    480} ,
    450450  { 401,    402,    437,    439,    480,    481} ,
    451   { 402,    438,    440,    481,    482,  -9999} ,
    452   { 403,    439,    441,    483,    484,  -9999} ,
     451  { 402,    438,    440,    481,    482,  -1} ,
     452  { 403,    439,    441,    483,    484,  -1} ,
    453453  { 403,    404,    440,    442,    484,    485} ,
    454454  { 404,    405,    441,    443,    485,    486} ,
     
    456456  { 406,    407,    443,    445,    487,    488} ,
    457457  { 407,    408,    444,    446,    488,    489} ,
    458   { 408,    445,    447,    489,    490,  -9999} ,
    459   { 409,    446,    448,    491,    492,  -9999} ,
     458  { 408,    445,    447,    489,    490,  -1} ,
     459  { 409,    446,    448,    491,    492,  -1} ,
    460460  { 409,    410,    447,    449,    492,    493} ,
    461461  { 410,    411,    448,    450,    493,    494} ,
     
    463463  { 412,    413,    450,    452,    495,    496} ,
    464464  { 413,    414,    451,    453,    496,    497} ,
    465   { 414,    452,    454,    497,    498,  -9999} ,
    466   { 415,    453,    455,    499,    500,  -9999} ,
     465  { 414,    452,    454,    497,    498,  -1} ,
     466  { 415,    453,    455,    499,    500,  -1} ,
    467467  { 415,    416,    454,    456,    500,    501} ,
    468468  { 416,    417,    455,    457,    501,    502} ,
     
    470470  { 418,    419,    457,    459,    503,    504} ,
    471471  { 419,    420,    458,    460,    504,    505} ,
    472   { 420,    459,    461,    505,    506,  -9999} ,
    473   { 421,    460,    462,    507,    508,  -9999} ,
     472  { 420,    459,    461,    505,    506,  -1} ,
     473  { 421,    460,    462,    507,    508,  -1} ,
    474474  { 421,    422,    461,    463,    508,    509} ,
    475475  { 422,    423,    462,    464,    509,    510} ,
     
    477477  { 424,    425,    464,    466,    511,    512} ,
    478478  { 425,    426,    465,    467,    512,    513} ,
    479   { 426,    466,    468,    513,    514,  -9999} ,
    480   { 427,    467,    469,    515,    516,  -9999} ,
     479  { 426,    466,    468,    513,    514,  -1} ,
     480  { 427,    467,    469,    515,    516,  -1} ,
    481481  { 427,    428,    468,    470,    516,    517} ,
    482482  { 428,    429,    469,    471,    517,    518} ,
     
    484484  { 430,    431,    471,    473,    519,    520} ,
    485485  { 431,    432,    472,    474,    520,    521} ,
    486   { 432,    433,    473,    521,    522,  -9999} ,
    487   { 433,    476,    522,    523,    524,  -9999} ,
     486  { 432,    433,    473,    521,    522,  -1} ,
     487  { 433,    476,    522,    523,    524,  -1} ,
    488488  { 433,    434,    475,    477,    524,    525} ,
    489489  { 434,    435,    476,    478,    525,    526} ,
     
    492492  { 437,    438,    479,    481,    528,    529} ,
    493493  { 438,    439,    480,    482,    529,    530} ,
    494   { 439,    481,    483,    530,    531,  -9999} ,
    495   { 440,    482,    484,    532,    533,  -9999} ,
     494  { 439,    481,    483,    530,    531,  -1} ,
     495  { 440,    482,    484,    532,    533,  -1} ,
    496496  { 440,    441,    483,    485,    533,    534} ,
    497497  { 441,    442,    484,    486,    534,    535} ,
     
    500500  { 444,    445,    487,    489,    537,    538} ,
    501501  { 445,    446,    488,    490,    538,    539} ,
    502   { 446,    489,    491,    539,    540,  -9999} ,
    503   { 447,    490,    492,    541,    542,  -9999} ,
     502  { 446,    489,    491,    539,    540,  -1} ,
     503  { 447,    490,    492,    541,    542,  -1} ,
    504504  { 447,    448,    491,    493,    542,    543} ,
    505505  { 448,    449,    492,    494,    543,    544} ,
     
    508508  { 451,    452,    495,    497,    546,    547} ,
    509509  { 452,    453,    496,    498,    547,    548} ,
    510   { 453,    497,    499,    548,    549,  -9999} ,
    511   { 454,    498,    500,    550,    551,  -9999} ,
     510  { 453,    497,    499,    548,    549,  -1} ,
     511  { 454,    498,    500,    550,    551,  -1} ,
    512512  { 454,    455,    499,    501,    551,    552} ,
    513513  { 455,    456,    500,    502,    552,    553} ,
     
    516516  { 458,    459,    503,    505,    555,    556} ,
    517517  { 459,    460,    504,    506,    556,    557} ,
    518   { 460,    505,    507,    557,    558,  -9999} ,
    519   { 461,    506,    508,    559,    560,  -9999} ,
     518  { 460,    505,    507,    557,    558,  -1} ,
     519  { 461,    506,    508,    559,    560,  -1} ,
    520520  { 461,    462,    507,    509,    560,    561} ,
    521521  { 462,    463,    508,    510,    561,    562} ,
     
    524524  { 465,    466,    511,    513,    564,    565} ,
    525525  { 466,    467,    512,    514,    565,    566} ,
    526   { 467,    513,    515,    566,    567,  -9999} ,
    527   { 468,    514,    516,    568,    569,  -9999} ,
     526  { 467,    513,    515,    566,    567,  -1} ,
     527  { 468,    514,    516,    568,    569,  -1} ,
    528528  { 468,    469,    515,    517,    569,    570} ,
    529529  { 469,    470,    516,    518,    570,    571} ,
     
    532532  { 472,    473,    519,    521,    573,    574} ,
    533533  { 473,    474,    520,    522,    574,    575} ,
    534   { 474,    475,    521,    575,    576,  -9999} ,
    535   { 475,    524,    576,  -9999,  -9999,  -9999} ,
    536   { 475,    476,    523,    525,  -9999,  -9999} ,
    537   { 476,    477,    524,    526,  -9999,  -9999} ,
    538   { 477,    478,    525,    527,  -9999,  -9999} ,
    539   { 478,    479,    526,    528,  -9999,  -9999} ,
    540   { 479,    480,    527,    529,  -9999,  -9999} ,
    541   { 480,    481,    528,    530,  -9999,  -9999} ,
    542   { 481,    482,    529,    531,  -9999,  -9999} ,
    543   { 482,    530,    532,  -9999,  -9999,  -9999} ,
    544   { 483,    531,    533,  -9999,  -9999,  -9999} ,
    545   { 483,    484,    532,    534,  -9999,  -9999} ,
    546   { 484,    485,    533,    535,  -9999,  -9999} ,
    547   { 485,    486,    534,    536,  -9999,  -9999} ,
    548   { 486,    487,    535,    537,  -9999,  -9999} ,
    549   { 487,    488,    536,    538,  -9999,  -9999} ,
    550   { 488,    489,    537,    539,  -9999,  -9999} ,
    551   { 489,    490,    538,    540,  -9999,  -9999} ,
    552   { 490,    539,    541,  -9999,  -9999,  -9999} ,
    553   { 491,    540,    542,  -9999,  -9999,  -9999} ,
    554   { 491,    492,    541,    543,  -9999,  -9999} ,
    555   { 492,    493,    542,    544,  -9999,  -9999} ,
    556   { 493,    494,    543,    545,  -9999,  -9999} ,
    557   { 494,    495,    544,    546,  -9999,  -9999} ,
    558   { 495,    496,    545,    547,  -9999,  -9999} ,
    559   { 496,    497,    546,    548,  -9999,  -9999} ,
    560   { 497,    498,    547,    549,  -9999,  -9999} ,
    561   { 498,    548,    550,  -9999,  -9999,  -9999} ,
    562   { 499,    549,    551,  -9999,  -9999,  -9999} ,
    563   { 499,    500,    550,    552,  -9999,  -9999} ,
    564   { 500,    501,    551,    553,  -9999,  -9999} ,
    565   { 501,    502,    552,    554,  -9999,  -9999} ,
    566   { 502,    503,    553,    555,  -9999,  -9999} ,
    567   { 503,    504,    554,    556,  -9999,  -9999} ,
    568   { 504,    505,    555,    557,  -9999,  -9999} ,
    569   { 505,    506,    556,    558,  -9999,  -9999} ,
    570   { 506,    557,    559,  -9999,  -9999,  -9999} ,
    571   { 507,    558,    560,  -9999,  -9999,  -9999} ,
    572   { 507,    508,    559,    561,  -9999,  -9999} ,
    573   { 508,    509,    560,    562,  -9999,  -9999} ,
    574   { 509,    510,    561,    563,  -9999,  -9999} ,
    575   { 510,    511,    562,    564,  -9999,  -9999} ,
    576   { 511,    512,    563,    565,  -9999,  -9999} ,
    577   { 512,    513,    564,    566,  -9999,  -9999} ,
    578   { 513,    514,    565,    567,  -9999,  -9999} ,
    579   { 514,    566,    568,  -9999,  -9999,  -9999} ,
    580   { 515,    567,    569,  -9999,  -9999,  -9999} ,
    581   { 515,    516,    568,    570,  -9999,  -9999} ,
    582   { 516,    517,    569,    571,  -9999,  -9999} ,
    583   { 517,    518,    570,    572,  -9999,  -9999} ,
    584   { 518,    519,    571,    573,  -9999,  -9999} ,
    585   { 519,    520,    572,    574,  -9999,  -9999} ,
    586   { 520,    521,    573,    575,  -9999,  -9999} ,
    587   { 521,    522,    574,    576,  -9999,  -9999} ,
    588   { 522,    523,    575,  -9999,  -9999,  -9999}  } ;
    589 
     534  { 474,    475,    521,    575,    576,  -1} ,
     535  { 475,    524,    576,  -1,  -1,  -1} ,
     536  { 475,    476,    523,    525,  -1,  -1} ,
     537  { 476,    477,    524,    526,  -1,  -1} ,
     538  { 477,    478,    525,    527,  -1,  -1} ,
     539  { 478,    479,    526,    528,  -1,  -1} ,
     540  { 479,    480,    527,    529,  -1,  -1} ,
     541  { 480,    481,    528,    530,  -1,  -1} ,
     542  { 481,    482,    529,    531,  -1,  -1} ,
     543  { 482,    530,    532,  -1,  -1,  -1} ,
     544  { 483,    531,    533,  -1,  -1,  -1} ,
     545  { 483,    484,    532,    534,  -1,  -1} ,
     546  { 484,    485,    533,    535,  -1,  -1} ,
     547  { 485,    486,    534,    536,  -1,  -1} ,
     548  { 486,    487,    535,    537,  -1,  -1} ,
     549  { 487,    488,    536,    538,  -1,  -1} ,
     550  { 488,    489,    537,    539,  -1,  -1} ,
     551  { 489,    490,    538,    540,  -1,  -1} ,
     552  { 490,    539,    541,  -1,  -1,  -1} ,
     553  { 491,    540,    542,  -1,  -1,  -1} ,
     554  { 491,    492,    541,    543,  -1,  -1} ,
     555  { 492,    493,    542,    544,  -1,  -1} ,
     556  { 493,    494,    543,    545,  -1,  -1} ,
     557  { 494,    495,    544,    546,  -1,  -1} ,
     558  { 495,    496,    545,    547,  -1,  -1} ,
     559  { 496,    497,    546,    548,  -1,  -1} ,
     560  { 497,    498,    547,    549,  -1,  -1} ,
     561  { 498,    548,    550,  -1,  -1,  -1} ,
     562  { 499,    549,    551,  -1,  -1,  -1} ,
     563  { 499,    500,    550,    552,  -1,  -1} ,
     564  { 500,    501,    551,    553,  -1,  -1} ,
     565  { 501,    502,    552,    554,  -1,  -1} ,
     566  { 502,    503,    553,    555,  -1,  -1} ,
     567  { 503,    504,    554,    556,  -1,  -1} ,
     568  { 504,    505,    555,    557,  -1,  -1} ,
     569  { 505,    506,    556,    558,  -1,  -1} ,
     570  { 506,    557,    559,  -1,  -1,  -1} ,
     571  { 507,    558,    560,  -1,  -1,  -1} ,
     572  { 507,    508,    559,    561,  -1,  -1} ,
     573  { 508,    509,    560,    562,  -1,  -1} ,
     574  { 509,    510,    561,    563,  -1,  -1} ,
     575  { 510,    511,    562,    564,  -1,  -1} ,
     576  { 511,    512,    563,    565,  -1,  -1} ,
     577  { 512,    513,    564,    566,  -1,  -1} ,
     578  { 513,    514,    565,    567,  -1,  -1} ,
     579  { 514,    566,    568,  -1,  -1,  -1} ,
     580  { 515,    567,    569,  -1,  -1,  -1} ,
     581  { 515,    516,    568,    570,  -1,  -1} ,
     582  { 516,    517,    569,    571,  -1,  -1} ,
     583  { 517,    518,    570,    572,  -1,  -1} ,
     584  { 518,    519,    571,    573,  -1,  -1} ,
     585  { 519,    520,    572,    574,  -1,  -1} ,
     586  { 520,    521,    573,    575,  -1,  -1} ,
     587  { 521,    522,    574,    576,  -1,  -1} ,
     588  { 522,    523,    575,  -1,  -1,  -1}  } ;
    590589
    591590  for (Int_t ip=0; ip<577; ip++)
    592     for (Int_t in=0; in<6; in++)
    593       fNN[ip][in] = help[ip][in] ; 
    594 
    595 
     591      for (Int_t in=0; in<6; in++)
     592          fNN[ip][in] = help[ip][in];
    596593}
    597594
    598 Int_t MCamNeighbor::GetNN(Int_t pix, Int_t inn )
     595Int_t MCamNeighbor::GetNN(Int_t pix, Int_t inn)
    599596{
    600   // return the number of one neighbor
    601 
    602   if ( pix >= 577 ) {
    603     cout << "ERROR GetNN -> pixel out of range" << endl  ;
    604     exit (123) ;
    605   }
    606  
    607   if ( inn >= 6 ) {
    608     cout << "ERROR GetNN -> not more than 6 neighbors" << endl  ;
    609     exit (123) ;
    610   }
    611  
    612   return fNN[pix][inn] ;
     597    // return the number of one neighbor
     598
     599    if ( pix >= 577 )
     600    {
     601        gLog << "WARNING: GetNN -> pixel out of range" << endl;
     602        return -1;
     603    }
     604
     605    if ( inn >= 6 )
     606    {
     607        gLog << "WARNING: GetNN -> not more than 6 neighbors" << endl;
     608        return -1;
     609    }
     610
     611    return fNN[pix][inn] ;
    613612}
    614613
    615614void MCamNeighbor::CheckPixel(Int_t  pix)
    616615{
    617   cout << " Pixel " << pix << " has neighbors " ;
    618   for (Int_t i=0; i<6; i++ )
    619     cout << fNN[pix][i] << "/" ;
    620   cout << endl ;
    621    
     616  gLog << " Pixel " << pix << " has neighbors " ;
     617
     618  gLog << fNN[pix][0];
     619
     620  for (Int_t i=1; i<6; i++ )
     621      if (fNN[pix][i] >= 0)
     622          gLog << ", " << fNN[pix][i];
     623
     624  gLog << endl ;
     625
    622626}
    623627
    624 void MCamNeighbor::Print()
     628void MCamNeighbor::Print(Option_t *)
    625629{
    626   for (Int_t i=0; i<577; i++ ) {
    627    
    628     cout << " Pixel " << i  ;
    629 
    630     for (Int_t j=0; j<6; j++ ) {
    631       cout << " ->" << fNN[i][j] ;
    632     }
    633     cout << endl ;
    634 
    635   }
     630    for (Int_t i=0; i<577; i++ )
     631    {
     632        gLog << " Pixel " << i << ":";
     633
     634        for (Int_t j=0; j<6; j++ )
     635            gLog << " " << fNN[i][j];
     636
     637        gLog << endl;
     638    }
    636639}
  • trunk/MagicSoft/Mars/mgui/MCamNeighbor.h

    r597 r653  
    22#define MCAMNEIGHBOR_H
    33
    4 #include <iostream>
    5 
     4#ifndef MAGIC_H
    65#include "MAGIC.h"
     6#endif
    77
    88class MCamNeighbor
     
    1818  Int_t GetNN(Int_t pix, Int_t inn) ;
    1919  void CheckPixel(Int_t pix) ;
    20   void Print() ;
     20  void Print(Option_t *opt=NULL) ;
    2121
    22   ClassDef(MCamNeighbor, 1)             //
     22  ClassDef(MCamNeighbor, 1) // Conatins the neighbors in the magic camera
    2323} ;
    2424
  • trunk/MagicSoft/Mars/mgui/MHexagon.cc

    r589 r653  
    1 #include <stdlib.h>
    2 #include <fstream.h>
    3 #include <iostream.h>
    4 
    5 #include "TROOT.h"
    6 #include "TVirtualPad.h"
    7 #include "TMath.h"
    8 
    9 #include "MHexagon.h"
    10 
     1//
     2//  The class MHexagon is needed for the Event Display of
     3//  MAGIC.
     4//
     5#include "MHexagon.h"
     6
     7#include <TVirtualPad.h>  // gPad
     8
     9#include "MGeomPix.h"     // GetX
    1110
    1211ClassImp(MHexagon)
    1312
    14   //
    15   //  The class MHexagon is needed for the Event Display of
    16   //  MAGIC.
    17 
    18 
    19 
    20 MHexagon::MHexagon() : TObject(), TAttLine(), TAttFill()
     13MHexagon::MHexagon()
    2114{
    2215  //   default constructor for MHexagon
     
    2417}
    2518
    26 MHexagon::MHexagon(Float_t x, Float_t y, Float_t d ) : TObject(), TAttLine(), TAttFill(0, 1001)
     19MHexagon::MHexagon(Float_t x, Float_t y, Float_t d )
     20 : TAttFill(0, 1001), fX(x), fY(y), fD(d)
    2721{
    2822  //    normal constructor for MHexagon
    29   fX = x ;
    30   fY = y ;
    31   fD = d ;
    32 
    33 }
     23}
     24
     25MHexagon::MHexagon(MGeomPix &pix)
     26 : TAttFill(0, 1001)
     27{
     28  //    normal constructor for MHexagon
     29   fX = pix.GetX();
     30   fY = pix.GetY();
     31   fD = pix.GetR();
     32}
     33
    3434MHexagon::MHexagon( const MHexagon &hexagon)
    3535{
     
    4141{
    4242  //     default destructor for MHexagon
    43 
    4443
    4544
     
    4746{
    4847  //     copy this hexagon to hexagon
    49 
    50   TObject::Copy  ( obj ) ;
    51   TAttLine::Copy (((MHexagon&) obj ) ) ;
    52   TAttFill::Copy (((MHexagon&) obj ) ) ;
    53  
    54   ((MHexagon&) obj).fX = fX ;
    55   ((MHexagon&) obj).fY = fY ;
    56   ((MHexagon&) obj).fD = fD ;     
    57 }
    58 Int_t MHexagon::DistancetoPrimitive( Int_t px, Int_t py )
    59 {
    60   //   compute the distance of a point (px,py) to the Hexagon
    61   //   this functions needed for graphical primitives, that
    62   //   means without this function you are not able to interact
    63   //   with the graphical primitive with the mouse!!!
    64   //
    65   //   All calcutations are running in pixel coordinates
    66  
    67   //       compute the distance of the Point to the center of the Hexagon
    68 
    69   Int_t  pxhex = gPad->XtoAbsPixel( fX ) ;
    70   Int_t  pyhex = gPad->YtoAbsPixel( fY ) ;
    71 
    72   Double_t DistPointHexagon = TMath::Sqrt( Double_t ((pxhex-px)*(pxhex-px) + (pyhex-py)*(pyhex-py))) ;
    73   Double_t cosa = TMath::Abs(px-pxhex) / DistPointHexagon ;
    74   Double_t sina = TMath::Abs(py-pyhex) / DistPointHexagon ;
     48    TObject::Copy  ( obj ) ;
     49    TAttLine::Copy (((MHexagon&) obj ) ) ;
     50    TAttFill::Copy (((MHexagon&) obj ) ) ;
     51
     52    ((MHexagon&) obj).fX = fX ;
     53    ((MHexagon&) obj).fY = fY ;
     54    ((MHexagon&) obj).fD = fD ;
     55}
     56Int_t MHexagon::DistancetoPrimitive( Int_t px, Int_t py )
     57{
     58    //   compute the distance of a point (px,py) to the Hexagon
     59    //   this functions needed for graphical primitives, that
     60    //   means without this function you are not able to interact
     61    //   with the graphical primitive with the mouse!!!
     62    //
     63    //   All calcutations are running in pixel coordinates
     64
     65    //       compute the distance of the Point to the center of the Hexagon
     66
     67  const Int_t  pxhex = gPad->XtoAbsPixel( fX ) ;
     68  const Int_t  pyhex = gPad->YtoAbsPixel( fY ) ;
     69
     70  const Double_t DistPointHexagon = TMath::Sqrt( Double_t ((pxhex-px)*(pxhex-px) + (pyhex-py)*(pyhex-py))) ;
     71  const Double_t cosa = TMath::Abs(px-pxhex) / DistPointHexagon ;
     72  const Double_t sina = TMath::Abs(py-pyhex) / DistPointHexagon ;
    7573
    7674  //       comput the distance to pixel border
    7775 
    78   Double_t   dx = fD * cosa / 2 ;
    79   Double_t   dy = fD * sina / 2 ;
    80  
    81   Double_t   xborder = fX + dx ;
    82   Double_t   yborder = fY + dy ;
    83 
    84   Int_t  pxborder = gPad->XtoAbsPixel( xborder ) ;
    85   Int_t  pyborder = gPad->YtoAbsPixel( yborder ) ;
    86  
    87   Double_t DistBorderHexagon = TMath::Sqrt( Double_t ((pxborder-pxhex)*(pxborder-pxhex)+(pyborder-pyhex)*(pyborder-pyhex))) ; 
     76  const Double_t   dx = fD * cosa / 2 ;
     77  const Double_t   dy = fD * sina / 2 ;
     78 
     79  const Double_t   xborder = fX + dx ;
     80  const Double_t   yborder = fY + dy ;
     81
     82  const Int_t  pxborder = gPad->XtoAbsPixel( xborder ) ;
     83  const Int_t  pyborder = gPad->YtoAbsPixel( yborder ) ;
     84 
     85  const Double_t DistBorderHexagon = TMath::Sqrt( Double_t ((pxborder-pxhex)*(pxborder-pxhex)+(pyborder-pyhex)*(pyborder-pyhex))) ; 
    8886 
    8987 
     
    9189  //       here in the first implementation is just circle inside
    9290
    93   if ( DistBorderHexagon <  DistPointHexagon )
    94     return 999999 ;
    95   else   
    96     //  return Int_t ( DistBorderHexagon - DistPointHexagon ) ;
    97     return 0 ;
     91  return DistBorderHexagon <  DistPointHexagon ? 999999 : 0;
    9892}
    9993
     
    147141  //     list this hexagon with its attributes
    148142  TROOT::IndentLevel() ;
    149   printf ("%s:  X= %f  Y= %f R= %f \n", GetName, fX, fY, fD ) ;
     143  printf ("%s:  X= %f  Y= %f R= %f \n", GetName(), fX, fY, fD ) ;
    150144}
    151145
     
    164158  const Int_t np =  6 ;
    165159 
    166   Float_t dx[np+1] = { .5   , 0.    , -.5   , -.5   , 0.    ,  .5   , .5    } ;
    167   Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 } ;
     160  const Float_t dx[np+1] = { .5   , 0.    , -.5   , -.5   , 0.    ,  .5   , .5    } ;
     161  const Float_t dy[np+1] = { .2886,  .5772,  .2886, -.2886, -.5772, -.2886, .2886 } ;
    168162
    169163  static Float_t x[np+1], y[np+1] ;
     
    189183{
    190184  //     print/dump this hexagon with its attributes
    191   printf ("Ellipse:  X= %f  Y= %f R= %f ", fX, fY, fD ) ; 
     185  printf ("Ellipse:  X= %f  Y= %f R= %f ", fX, fY, fD ) ;
    192186 
    193187  if ( GetLineColor() != 1 ) printf (" Color=%d", GetLineColor() ) ;
  • trunk/MagicSoft/Mars/mgui/MHexagon.h

    r609 r653  
    2222#endif
    2323
     24class MGeomPix;
     25
    2426class MHexagon : public TObject, public TAttLine, public TAttFill
    2527{
     
    3335 
    3436  MHexagon() ;
    35   MHexagon(Float_t x, Float_t y, Float_t d ) ;
     37  MHexagon(Float_t x, Float_t y, Float_t d ) ;
     38  MHexagon(MGeomPix &pix);
    3639  MHexagon( const MHexagon &hexagon) ;
    3740  virtual ~MHexagon() ;
Note: See TracChangeset for help on using the changeset viewer.