Changeset 9385 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
03/04/09 18:46:07 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9383 r9385  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20 2009/03/04 Thomas Bretz
     21
     22   * datacenter/macros/plotdb.C:
     23     - updated some binnings
     24
     25   * mgeom/GeomLinkDef.h:
     26     - added MGeomCamMagicII
     27
     28   * mgeom/MGeom.[h,cc]:
     29     - added option to set position
     30     - removed DistanceToPrimitive, use IsInside instead
     31
     32   * mgeom/MGeomCam.[h,cc]:
     33     - added a virtual function to CreateNN
     34     - added a workaround after reading by calling CreateNN
     35       because with the last changes the pixel indices get lost
     36
     37   * mgeom/MGeomCamCT1.[h,cc]:
     38     - now derives from MGeomCamDwarf
     39     - accordingly increased version number
     40
     41   * mgeom/MGeomCamDwarf.[h,cc]:
     42     - removed Clone -> now in MGeomCam
     43
     44   * mgeom/MGeomCamMagic.[h,cc]:
     45     - added MGeomCamMagicII <preliminary>
     46
     47   * mgeom/MGeomCamSquare.[h,cc]:
     48     - removed creation of next neighbors -> now automatic
     49
     50   * mgeom/MGeomPix.[h,cc]:
     51     - added rotation angle in terms of cos(phi) and sin(phi)
     52     - rotate in PaintPrimitive
     53     - adapted IsInside accordingly
     54
     55   * mgeom/MGeomRectangle.[h,cc]:
     56     - if only width is given assume a square
     57     - make sure that the box is correctly painted for all root versions
     58     - fixed distance to farthest point
     59
     60   * mgui/MHexagon.[h,cc]:
     61     - removed obsolete dependence on MGeomPix
     62
     63   * mhist/MHCamera.cc, mtools/MagicJam.cc:
     64     - replaced DistanceToPrimitive by IsInside
     65
     66   * mjobs/MJSimulation.cc:
     67     - replaced accidental _I_ in file names by _Y_
     68
     69   * mreport/MReportCC.[h,cc]:
     70     - added version >=200809030
     71     - improved modularity of code
     72
     73
     74
    2075 2009/03/03 Thomas Bretz
    2176
  • trunk/MagicSoft/Mars/NEWS

    r9369 r9385  
    3434
    3535   * added support for Arehucas Version >= 200812140
     36
     37   * added support for Arehucas Version >= 200809030
    3638
    3739 ;mars
  • trunk/MagicSoft/Mars/datacenter/macros/plotdb.C

    r9282 r9385  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.54 2009-01-29 09:24:30 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: plotdb.C,v 1.55 2009-03-04 18:45:26 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    559559    plot.Plot("Calibration.fArrTimeMeanInner", 0, 40.0, 0.1);
    560560    plot.SetDescription("RMS Arrival Time inner Camera;\\sigma_{T,I} [sl]", "RmsArrTmI");
    561     plot.Plot("Calibration.fArrTimeRmsInner",  0, 4.5, 0.01);
     561    plot.Plot("Calibration.fArrTimeRmsInner",  0, 6.5, 0.01);
    562562    plot.SetDescription("Number of unsuitable pixels inner Camera;N_{I}", "UnsuitI");
    563563    plot.Plot("Calibration.fUnsuitableInner",  0, 75, 1);
     
    616616    plot.Plot("Star.fPSF",                     0,  30, 0.5);
    617617    plot.SetDescription("Muon Calibration Ratio Data/MC;r [1]", "MuonCal");
    618     plot.Plot("Star.fRatio",                   0, 200, 0.5);
     618    plot.Plot("Star.fRatio",                   50, 150, 0.5);
    619619    plot.SetDescription("Muon Rate after Muon Cuts;R [Hz]");
    620620    plot.Plot("Star.fMuonRate",                0, 2.0, 0.05);
     
    627627    plot.Plot("Star.fInhomogeneity",           0, 100, 1);
    628628    plot.SetDescription("Camera Spark Rate;R [Hz]", "Sparks");
    629     plot.Plot("Star.fSparkRate",               0.075, 2.425, 0.05);
     629    plot.Plot("Star.fSparkRate",               0.075, 7.425, 0.05);
    630630    plot.SetDescription("Relative effective on time;T_{eff}/T_{obs} [ratio]", "RelTime");
    631631    plot.Plot("Star.fEffOnTime/Sequences.fRunTime",    0.006, 1.506, 0.01);
  • trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h

    r9369 r9385  
    1818#pragma link C++ class MGeomCamDwarf+;
    1919#pragma link C++ class MGeomCamMagic+;
     20#pragma link C++ class MGeomCamMagicII+;
    2021#pragma link C++ class MGeomCamSquare+;
    2122//#pragma link C++ class MGeomCamMagicHG+;
  • trunk/MagicSoft/Mars/mgeom/MGeom.cc

    r9368 r9385  
    6969}
    7070
     71void MGeom::SetP(const TVector2 &v)
     72{
     73    fX = v.X();
     74    fY = v.Y();
     75}
     76
    7177// --------------------------------------------------------------------------
    7278//
     
    125131    //   information about a pixel
    126132    gLog << all << MParContainer::GetDescriptor(*this) << ":  x/y=" << fX << "/" << fY << "mm ";
    127     gLog << "A= " << fA << "mm² (";
     133    gLog << "A= " << fA << "mm" << UTF8::kSquare << " (";
    128134    for (int i=0; i<fNumNeighbors; i++)
    129135        gLog << fNeighbors[i] << (i<fNumNeighbors-1?",":"");
     
    191197    const Double_t y = gPad->AbsPixeltoY(py);
    192198
    193     return TMath::Nint(DistanceToPrimitive(x, y));
    194 }
     199    return IsInside(x, y) ? -1 : 999999;
     200}
     201
  • trunk/MagicSoft/Mars/mgeom/MGeom.h

    r9368 r9385  
    4040    UInt_t fAidx;          // Area index of the pixel
    4141
    42 private:
     42protected:
    4343    Byte_t  fNumNeighbors; // number of valid neighbors
    4444    Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
     
    6868
    6969    void Set(Float_t x, Float_t y, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fSector=s; fAidx=aidx; }
     70    void SetP(Float_t x, Float_t y) { fX=x; fY=y; }
     71    void SetP(const TVector2 &v);
    7072
    7173    void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
     
    99101    Int_t  GetDirection(const MGeom &pix) const;
    100102
    101     virtual Float_t DistanceToPrimitive(Float_t px, Float_t py) const = 0;
    102103    Int_t DistancetoPrimitive(Int_t px, Int_t py);
    103104
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r9374 r9385  
    9797}
    9898
     99
     100// --------------------------------------------------------------------------
     101//
     102// To make sure that everything is correctly initialized when
     103// cloned we call InitGeometry after cloning. This repairs
     104// a few I/O problems mainly with files written with older
     105// MARS versions (see also StreamerWorkaround)
     106//
     107TObject *MGeomCam::Clone(const char *newname) const
     108{
     109    MGeomCam *clone = (MGeomCam*)MParContainer::Clone(newname);
     110    clone->InitGeometry();
     111    return clone;
     112}
     113
    99114// --------------------------------------------------------------------------
    100115//
     
    551566// --------------------------------------------------------------------------
    552567//
     568//  This fills the next neighbor information from a table into the pixel
     569//  objects. An overloaded function must call SortNeighbors()
     570//  at the end.
     571//
     572// All pixel swith a center withing 1.75*GetT() are considered neiighbors,
     573// Only six neighbors are allowed.
     574//
     575void MGeomCam::CreateNN()
     576{
     577    TArrayI nn(6);
     578
     579    for (UInt_t i=0; i<GetNumPixels(); i++)
     580    {
     581        MGeom &pix = (*this)[i];
     582
     583        Int_t k = 0;
     584        nn.Reset(-1);
     585
     586        for (UInt_t j=0; j<GetNumPixels(); j++)
     587        {
     588            if (i==j)
     589                continue;
     590
     591            if (pix.GetDist((*this)[j])>pix.GetT()*1.75)
     592                continue;
     593
     594            if (k==6)
     595            {
     596                *fLog << err << "ERROR - MGeomCam::CreateNN: Pixel " << j << " has too many neighbors." << endl;
     597                break;
     598            }
     599
     600            nn[k++] = j;
     601        }
     602
     603        pix.SetNeighbors(nn[0], nn[1], nn[2], nn[3], nn[4], nn[5]);
     604    }
     605
     606    SortNeighbors();
     607}
     608
     609// --------------------------------------------------------------------------
     610//
    553611// This workaround reproduces (as much as possible) the contents
    554612// of fPixels which got lost writing MGeomCam in which the
     
    560618// MUST call this function after reading.
    561619//
     620// Furthermore since we moved all contents of MGeomPix to its
     621// new base class the contents of fNeighbors is not read anymore
     622// although all other contents is read correctly. Therefore we have
     623// top recreate the neighbor table.
     624//
    562625void MGeomCam::StreamerWorkaround()
    563626{
    564     if (fNumPixels==0 || !fPixels.IsEmpty())
     627    if (fNumPixels==0)
    565628        return;
    566629
    567     TObject *cam = (TObject*)IsA()->New();
     630
     631    if (!fPixels.IsEmpty())
     632    {
     633        CreateNN();
     634        return;
     635    }
     636
     637    const TObject *cam = (TObject*)IsA()->New();
    568638    cam->Copy(*this);
    569639    delete cam;
     
    592662}
    593663
     664// --------------------------------------------------------------------------
     665//
     666// This deletes the pixel i and sets it to a clone of pix.
     667// If i>=fNumPixels it is just ignored.
     668//
    594669void MGeomCam::SetAt(UInt_t i, const MGeom &pix)
    595670{
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r9369 r9385  
    4747    void CalcNumAreas();
    4848    void InitOuterRing();
     49
     50    virtual void CreateNN();
     51
     52protected:
    4953    void SortNeighbors();
    5054
     
    5357    MGeomCam(const MGeomCam &cam) { cam.Copy(*this); }
    5458
     59    TObject *Clone(const char *name="") const;
    5560    void Copy(TObject &o) const;
    5661
     
    6570    void InitGeometry()
    6671    {
     72        CreateNN();
    6773        CalcNumSectors();
    6874        CalcNumAreas();
     
    7076        CalcPixRatio();
    7177        InitOuterRing();
    72         SortNeighbors();
    7378    }
    7479
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc

    r9369 r9385  
    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
    2019!
    21 !   Copyright: MAGIC Software Development, 2000-2003
     20!   Copyright: MAGIC Software Development, 2000-2009
    2221!
    2322!
     
    3231// is calculated (for Algorithm see CreateCam
    3332//
     33// Class Version 2:
     34// ----------------
     35//  - derived from MGeoMCamDwarf
     36//
    3437////////////////////////////////////////////////////////////////////////////
     38
    3539#include "MGeomCamCT1.h"
    36 
    37 #include <math.h>     // floor
    38 
    39 /*
    40  #include "MLog.h"
    41  #include "MLogManip.h"
    42  */
    43 
    44 #include "MGeomPix.h"
    45 
    46 ClassImp(MGeomCamCT1);
    47 
    48 // --------------------------------------------------------------------------
    49 //
    50 //  CT1 camera has 127 pixels. For geometry and Next Neighbor info see
    51 //  CreateCam and CreateNN
    52 //
    53 MGeomCamCT1::MGeomCamCT1(const char *name)
    54     : MGeomCam(127, 4.88, name, "Geometry information of CT1 camera")
    55 {
    56     CreateCam();
    57     CreateNN();
    58     InitGeometry();
    59 }
    60 
    61 // --------------------------------------------------------------------------
    62 //
    63 //  Create Next Neighbors: Fill the NN Info into the pixel objects.
    64 //
    65 void MGeomCamCT1::CreateNN()
    66 {
    67     const Short_t nn[127][6] = {       // Neighbors of #
    68       {  1,   2,   3,   4,   5,   6},  // 0
    69       {  0,   2,   6,   7,   8,  18},
    70       {  0,   1,   3,   8,   9,  10},
    71       {  0,   2,   4,  10,  11,  12},
    72       {  0,   3,   5,  12,  13,  14},
    73       {  0,   4,   6,  14,  15,  16},
    74       {  0,   1,   5,  16,  17,  18},
    75       {  1,   8,  18,  19,  20,  36},
    76       {  1,   2,   7,   9,  20,  21},
    77       {  2,   8,  10,  21,  22,  23},
    78       {  2,   3,   9,  11,  23,  24},  // 10
    79       {  3,  10,  12,  24,  25,  26},
    80       {  3,   4,  11,  13,  26,  27},
    81       {  4,  12,  14,  27,  28,  29},
    82       {  4,   5,  13,  15,  29,  30},
    83       {  5,  14,  16,  30,  31,  32},
    84       {  5,   6,  15,  17,  32,  33},
    85       {  6,  16,  18,  33,  34,  35},
    86       {  1,   6,   7,  17,  35,  36},
    87       {  7,  20,  36,  37,  38,  60},
    88       {  7,   8,  19,  21,  38,  39},  // 20
    89       {  8,   9,  20,  22,  39,  40},
    90       {  9,  21,  23,  40,  41,  42},
    91       {  9,  10,  22,  24,  42,  43},
    92       { 10,  11,  23,  25,  43,  44},
    93       { 11,  24,  26,  44,  45,  46},
    94       { 11,  12,  25,  27,  46,  47},
    95       { 12,  13,  26,  28,  47,  48},
    96       { 13,  27,  29,  48,  49,  50},
    97       { 13,  14,  28,  30,  50,  51},
    98       { 14,  15,  29,  31,  51,  52},  // 30
    99       { 15,  30,  32,  52,  53,  54},
    100       { 15,  16,  31,  33,  54,  55},
    101       { 16,  17,  32,  34,  55,  56},
    102       { 17,  33,  35,  56,  57,  58},
    103       { 17,  18,  34,  36,  58,  59},
    104       {  7,  18,  19,  35,  59,  60},
    105       { 19,  38,  60,  61,  62,  90},
    106       { 19,  20,  37,  39,  62,  63},
    107       { 20,  21,  38,  40,  63,  64},
    108       { 21,  22,  39,  41,  64,  65},  // 40
    109       { 22,  40,  42,  65,  66,  67},
    110       { 22,  23,  41,  43,  67,  68},
    111       { 23,  24,  42,  44,  68,  69},
    112       { 24,  25,  43,  45,  69,  70},
    113       { 25,  44,  46,  70,  71,  72},
    114       { 25,  26,  45,  47,  72,  73},
    115       { 26,  27,  46,  48,  73,  74},
    116       { 27,  28,  47,  49,  74,  75},
    117       { 28,  48,  50,  75,  76,  77},
    118       { 28,  29,  49,  51,  77,  78},  // 50
    119       { 29,  30,  50,  52,  78,  79},
    120       { 30,  31,  51,  53,  79,  80},
    121       { 31,  52,  54,  80,  81,  82},
    122       { 31,  32,  53,  55,  82,  83},
    123       { 32,  33,  54,  56,  83,  84},
    124       { 33,  34,  55,  57,  84,  85},
    125       { 34,  56,  58,  85,  86,  87},
    126       { 34,  35,  57,  59,  87,  88},
    127       { 35,  36,  58,  60,  88,  89},
    128       { 19,  36,  37,  59,  89,  90},  // 60
    129       { 37,  62,  90,  91,  92, 126},
    130       { 37,  38,  61,  63,  92,  93},
    131       { 38,  39,  62,  64,  93,  94},
    132       { 39,  40,  63,  65,  94,  95},
    133       { 40,  41,  64,  66,  95,  96},
    134       { 41,  65,  67,  96,  97,  98},
    135       { 41,  42,  66,  68,  98,  99},
    136       { 42,  43,  67,  69,  99, 100},
    137       { 43,  44,  68,  70, 100, 101},
    138       { 44,  45,  69,  71, 101, 102},  // 70
    139       { 45,  70,  72, 102, 103, 104},
    140       { 45,  46,  71,  73, 104, 105},
    141       { 46,  47,  72,  74, 105, 106},
    142       { 47,  48,  73,  75, 106, 107},
    143       { 48,  49,  74,  76, 107, 108},
    144       { 49,  75,  77, 108, 109, 110},
    145       { 49,  50,  76,  78, 110, 111},
    146       { 50,  51,  77,  79, 111, 112},
    147       { 51,  52,  78,  80, 112, 113},
    148       { 52,  53,  79,  81, 113, 114},  // 80
    149       { 53,  80,  82, 114, 115, 116},
    150       { 53,  54,  81,  83, 116, 117},
    151       { 54,  55,  82,  84, 117, 118},
    152       { 55,  56,  83,  85, 118, 119},
    153       { 56,  57,  84,  86, 119, 120},
    154       { 57,  85,  87, 120, 121, 122},
    155       { 57,  58,  86,  88, 122, 123},
    156       { 58,  59,  87,  89, 123, 124},
    157       { 59,  60,  88,  90, 124, 125},
    158       { 37,  60,  61,  89, 125, 126},  // 90
    159       { 61,  92, 126,  -1,  -1,  -1},
    160       { 61,  62,  91,  93,  -1,  -1},
    161       { 62,  63,  92,  94,  -1,  -1},
    162       { 63,  64,  93,  95,  -1,  -1},
    163       { 64,  65,  94,  96,  -1,  -1},
    164       { 65,  66,  95,  97,  -1,  -1},
    165       { 66,  96,  98,  -1,  -1,  -1},
    166       { 66,  67,  97,  99,  -1,  -1},
    167       { 67,  68,  98, 100,  -1,  -1},
    168       { 68,  69,  99, 101,  -1,  -1},  // 100
    169       { 69,  70, 100, 102,  -1,  -1},
    170       { 70,  71, 101, 103,  -1,  -1},
    171       { 71, 102, 104,  -1,  -1,  -1},
    172       { 71,  72, 103, 105,  -1,  -1},
    173       { 72,  73, 104, 106,  -1,  -1},
    174       { 73,  74, 105, 107,  -1,  -1},
    175       { 74,  75, 106, 108,  -1,  -1},
    176       { 75,  76, 107, 109,  -1,  -1},
    177       { 76, 108, 110,  -1,  -1,  -1},
    178       { 76,  77, 109, 111,  -1,  -1},  // 110
    179       { 77,  78, 110, 112,  -1,  -1},
    180       { 78,  79, 111, 113,  -1,  -1},
    181       { 79,  80, 112, 114,  -1,  -1},
    182       { 80,  81, 113, 115,  -1,  -1},
    183       { 81, 114, 116,  -1,  -1,  -1},
    184       { 81,  82, 115, 117,  -1,  -1},
    185       { 82,  83, 116, 118,  -1,  -1},
    186       { 83,  84, 117, 119,  -1,  -1},
    187       { 84,  85, 118, 120,  -1,  -1},
    188       { 85,  86, 119, 121,  -1,  -1},  // 120
    189       { 86, 120, 122,  -1,  -1,  -1},
    190       { 86,  87, 121, 123,  -1,  -1},
    191       { 87,  88, 122, 124,  -1,  -1},
    192       { 88,  89, 123, 125,  -1,  -1},
    193       { 89,  90, 124, 126,  -1,  -1},
    194       { 61,  90,  91, 125,  -1,  -1}   // 126
    195   };
    196 
    197   for (Int_t i=0; i<127; i++)
    198       (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
    199                               nn[i][3], nn[i][4], nn[i][5]);
    200 }
    201 
    202 // --------------------------------------------------------------------------
    203 //
    204 //  Calculate the geometry information of CT1 and fill this information
    205 //  into the pixel objects.
    206 //
    207 void MGeomCamCT1::CreateCam()
    208 {
    209     //
    210     // fill the geometry class with the coordinates of the CT1 camera
    211     //
    212     //*fLog << inf << " Create CT1 geometry " << endl;
    213 
    214     //
    215     // this algorithm is from Martin Kestel originally
    216     // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz
    217    
    218     const Float_t diameter = 21;    // units are mm
    219     const Float_t kS32  = sqrt(3)/2;
    220 
    221     //
    222     //  add the first pixel to the list
    223     //
    224     Int_t pixnum = 1;
    225 
    226     SetAt(0, MGeomPix(0, 0, diameter));
    227 
    228     for (Int_t ring=1; ring<7; ring++)
    229     {
    230         //
    231         // calc. coords for this ring counting from the
    232         // starting number to the ending number
    233         //
    234         for (int i=0; i<ring; i++)
    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));
    257     }
    258 }
    259 
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.h

    r1436 r9385  
    22#define MARS_MGeomCamCT1
    33
    4 #ifndef MARS_MGeomCam
    5 #include "MGeomCam.h"
     4#ifndef MARS_MGeomCamDwarf
     5#include "MGeomCamDwarf.h"
    66#endif
    77
    8 class MGeomCamCT1 : public MGeomCam
     8class MGeomCamCT1 : public MGeomCamDwarf
    99{
    10 private:
     10public:
     11    MGeomCamCT1(const char *name=NULL) : MGeomCamDwarf(6, 21, 4.88, name)
     12    {
     13        SetTitle("Geometry information of HEGRA CT1 Camera");
     14    }
    1115
    12     void CreateCam();
    13     void CreateNN();
    14 
    15 public:
    16 
    17     MGeomCamCT1(const char *name=NULL);
    18 
    19     ClassDef(MGeomCamCT1, 1)            // Geometry class for the CT1 camera
     16    ClassDef(MGeomCamCT1, 2) // Geometry class for the CT1 camera
    2017};
    2118
  • trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.cc

    r9369 r9385  
    6363{
    6464    CreateCam(21, 9.5);
    65     CreateNN();
    6665    InitGeometry();
    6766}
     
    7776{
    7877    CreateCam(diameter, diameter<=0 ? rad : rad/diameter);
    79     CreateNN();
    8078    InitGeometry();
    8179}
     
    9189{
    9290    CreateCam(diameter, rings);
    93     CreateNN();
    9491    InitGeometry();
    95 }
    96 
    97 // --------------------------------------------------------------------------
    98 //
    99 //  Create a clone of this container. This is very easy, because we
    100 //  simply have to create a new object of the same type.
    101 //
    102 TObject *MGeomCamDwarf::Clone(const char *newname) const
    103 {
    104     MGeomCam *cam = new MGeomCam(*this);
    105     cam->InitGeometry();
    106     return cam;
    10792}
    10893
     
    136121Double_t MGeomCamDwarf::CalcXY(Int_t dir, Int_t ring, Int_t i, Double_t &x, Double_t &y)
    137122{
    138     const Double_t kSqrt32 = MGeomPix::gsTan60/2;
     123    const Double_t kSqrt32 = MGeomPix::gsSin60;
    139124
    140125    switch (dir)
     
    308293    }
    309294}
    310 
    311 // --------------------------------------------------------------------------
    312 //
    313 //  This fills the next neighbor information from a table into the pixel
    314 //  objects.
    315 //
    316 void MGeomCamDwarf::CreateNN()
    317 {
    318     TArrayI nn(6);
    319 
    320     for (UInt_t i=0; i<GetNumPixels(); i++)
    321     {
    322         MGeomPix &pix = static_cast<MGeomPix&>((*this)[i]);
    323 
    324         Int_t k = 0;
    325         nn.Reset(-1);
    326 
    327         for (UInt_t j=0; j<GetNumPixels(); j++)
    328         {
    329             if (i==j)
    330                 continue;
    331 
    332             if (pix.GetDist((*this)[j])<pix.GetD()*1.5)
    333                 nn[k++] = j;
    334         }
    335 
    336         pix.SetNeighbors(nn[0], nn[1], nn[2], nn[3], nn[4], nn[5]);
    337     }
    338 }
  • trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.h

    r9259 r9385  
    1818    void  CreateCam(Double_t diameter, Double_t rad);
    1919    void  CreateCam(Double_t diameter, Int_t rings);
    20     void  CreateNN();
    2120
    2221public:
     
    2625    MGeomCamDwarf(const char *name=NULL);
    2726
    28     TObject *Clone(const char *newname) const;
    29 
    3027    Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const;
    3128
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc

    r9369 r9385  
    4747{
    4848    CreateCam();
    49     CreateNN();
    5049    InitGeometry();
    5150}
     
    6160{
    6261    CreateCam();
    63     CreateNN();
    6462    InitGeometry();
    6563}
     
    7775    // z is defined from the mirror (0) to the camera (z>0).
    7876    // Thus we just propagate to the focal plane (z=fDist)
    79     //p -= 1700./u.Z()*u;
    8077    p.PropagateZ(u, GetCameraDist()*100);
    8178
     
    248245        -034.641                                                                         // 576
    249246    };
    250 /*
    251     const Float_t dtemp[577] = {
    252         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   0
    253         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //   8
    254         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  16
    255         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  24
    256         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  32
    257         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  40
    258         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  48
    259         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  56
    260         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  64
    261         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  72
    262         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  80
    263         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  88
    264         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  //  96
    265         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 104
    266         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 112
    267         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 120
    268         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 128
    269         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 136
    270         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 144
    271         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 152
    272         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 160
    273         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 168
    274         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 176
    275         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 184
    276         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 192
    277         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 200
    278         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 208
    279         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 216
    280         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 224
    281         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 232
    282         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 240
    283         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 248
    284         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 256
    285         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 264
    286         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 272
    287         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 280
    288         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 288
    289         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 296
    290         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 304
    291         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 312
    292         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 320
    293         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 328
    294         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 336
    295         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 344
    296         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 352
    297         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 360
    298         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 368
    299         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 376
    300         30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00,  // 384
    301         30.00, 30.00, 30.00, 30.00, 30.00, 60.00, 60.00, 60.00,  // 392
    302         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 400
    303         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 408
    304         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 416
    305         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 424
    306         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 432
    307         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 440
    308         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 448
    309         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 456
    310         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 464
    311         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 472
    312         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 480
    313         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 488
    314         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 496
    315         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 504
    316         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 512
    317         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 520
    318         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 528
    319         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 536
    320         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 544
    321         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 552
    322         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 560
    323         60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00,  // 568
    324         60.00  };                                                // 576
    325 */
     247
    326248    const Byte_t sector[577] = {
    327249        0, 1, 2, 3, 4, 5, 6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
     
    955877        (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],
    956878                                nn[i][3], nn[i][4], nn[i][5]);
     879
     880    SortNeighbors();
    957881}
     882
     883// --------------------------------------------------------------------------
     884//
     885//  Magic camera has 913 pixels. For geometry and Next Neighbor info see
     886//  CreateCam and CreateNN
     887//
     888MGeomCamMagicII::MGeomCamMagicII(const char *name)
     889    : MGeomCamDwarf(475., 30, 17, name)
     890{
     891    SetTitle("Geometry information of Magic II Camera");
     892    Rotate();
     893}
     894
     895// --------------------------------------------------------------------------
     896//
     897//  Magic II camera has 913 pixels. For geometry and Next Neighbor info see
     898//  CreateCam and CreateNN. You can give the distance dist from
     899//  the mirror center to the focal plane.
     900//
     901MGeomCamMagicII::MGeomCamMagicII(Double_t dist, const char *name)
     902    : MGeomCamDwarf(475., 30, dist, name)
     903{
     904    SetTitle("Geometry information of Magic II Camera");
     905    Rotate();
     906}
     907
     908// --------------------------------------------------------------------------
     909//
     910// Rotate all pixels by 30deg
     911//
     912void MGeomCamMagicII::Rotate()
     913{
     914    const Double_t phi = 30*TMath::DegToRad();
     915
     916    const TVector2 v(TMath::Cos(phi), TMath::Sin(phi));
     917
     918    for (UInt_t i=0; i<GetNumPixels(); i++)
     919    {
     920        MGeomPix &pix = static_cast<MGeomPix&>(operator[](i));
     921
     922        pix.SetP(pix.GetP()*v, pix.GetP()^v);
     923        pix.SetPhi(phi);
     924    }
     925}
     926
     927// --------------------------------------------------------------------------
     928//
     929// Check if the photon which is flying along the trajectory u has passed
     930// (or will pass) the frame of the camera (and consequently get
     931// absorbed). The position p and direction u must be in the
     932// telescope coordinate frame, which is z parallel to the focal plane,
     933// x to the right and y upwards, looking from the mirror towards the camera.
     934//
     935Bool_t MGeomCamMagicII::HitFrame(MQuaternion p, const MQuaternion &u) const
     936{
     937    // z is defined from the mirror (0) to the camera (z>0).
     938    // Thus we just propagate to the focal plane (z=fDist)
     939    p.PropagateZ(u, GetCameraDist()*100);
     940
     941    return TMath::Abs(p.X())<65 && TMath::Abs(p.Y())<65;
     942}
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.h

    r9356 r9385  
    22#define MARS_MGeomCamMagic
    33
    4 #ifndef MARS_MGeomCam
    5 #include "MGeomCam.h"
     4#ifndef MARS_MGeomCamDwarf
     5#include "MGeomCamDwarf.h"
    66#endif
    77
     
    2121};
    2222
     23class MGeomCamMagicII : public MGeomCamDwarf
     24{
     25private:
     26    void Rotate();
     27
     28public:
     29    MGeomCamMagicII(const char *name=NULL);
     30    MGeomCamMagicII(Double_t dist, const char *name=NULL);
     31
     32    Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const;
     33
     34    ClassDef(MGeomCamMagicII, 1)                // Geometry class for the Magic camera
     35};
     36
    2337#endif
    2438
  • trunk/MagicSoft/Mars/mgeom/MGeomCamSquare.cc

    r9382 r9385  
    8989    for (Short_t x=0; x<nx; x++)
    9090        for (Short_t y=0; y<ny; y++)
    91         {
    92             const Short_t idx = x*ny+y;
    93 
    94             SetAt(idx, MGeomRectangle((0.5*nx-x)*diameter, (0.5*ny-y)*diameter, diameter));
    95 
    96             const Short_t n0 = x==nx-1 ? -1 : idx+ny;
    97             const Short_t n1 = x==0    ? -1 : idx-ny;
    98             const Short_t n2 = y==ny-1 ? -1 : idx+1;
    99             const Short_t n3 = y==0    ? -1 : idx-1;
    100 
    101             Short_t n[4] = { n0, n1, n2, n3 };
    102 
    103             // Sort -1's to the end
    104             MMath::ReSort(4, n, kTRUE);
    105 
    106             (*this)[idx].SetNeighbors(n[0], n[1], n[2], n[3]);
    107         }
     91            SetAt(x*ny+y, MGeomRectangle((0.5*nx-x)*diameter, (0.5*ny-y)*diameter, diameter));
    10892}
  • trunk/MagicSoft/Mars/mgeom/MGeomCamSquare.h

    r9383 r9385  
    1010private:
    1111    void CreateCam(Short_t x, Short_t y, Double_t diameter);
    12     void CreateNN();
    1312
    1413public:
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.cc

    r9370 r9385  
    7878// Initializes one pixel
    7979//
    80 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : MGeom(x, y, s, a)
     80MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a)
     81    : MGeom(x, y, s, a), fCosPhi(1), fSinPhi(0)
    8182{
    8283    SetD(r);
     
    8485}
    8586
     87void MGeomPix::SetPhi(Double_t phi)
     88{
     89    fCosPhi = TMath::Cos(phi);
     90    fSinPhi = TMath::Sin(phi);
     91}
     92
    8693// --------------------------------------------------------------------------
    8794//
     
    96103// ------------------------------------------------------------------------
    97104//
    98 // compute the distance of a point (px,py) to the Hexagon center in world
    99 // coordinates. Return -1 if inside.
    100 //
    101 Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const
    102 {
    103     //FIXME: Rotation phi missing!
     105// Implementation of PaintPrimitive drwaing a hexagonal pixel
     106//
     107void MGeomPix::PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy, Double_t scaled) const
     108{
     109    const_cast<TAttLine&>(line).Modify();  //Change line attributes only if necessary
     110    const_cast<TAttFill&>(fill).Modify();  //Change fill area attributes only if necessary
     111
     112    const Double_t fx       = fX*scalexy;
     113    const Double_t fy       = fY*scalexy;
     114    const Double_t fd       = fD*scaled;
     115
     116    const Double_t c        = fd*fCosPhi;
     117    const Double_t s        = fd*fSinPhi;
     118
     119    const Double_t gsCos60c = gsCos60*c;
     120    const Double_t gsCos60s = gsCos60*s;
     121
     122    const Double_t gsSin60c = gsSin60*c/3;
     123    const Double_t gsSin60s = gsSin60*s/3;
     124
     125    const Double_t gsTan30c = gsTan30*c;
     126    const Double_t gsTan30s = gsTan30*s;
     127
     128
     129    Double_t x[7] = {
     130         gsCos60c-gsSin60s,  -gsTan30s,  -gsCos60c-gsSin60s,
     131        -gsCos60c+gsSin60s,   gsTan30s,   gsCos60c+gsSin60s
     132    };
     133
     134    Double_t y[7] = {
     135         gsCos60s+gsSin60c,   gsTan30c,  -gsCos60s+gsSin60c,
     136        -gsCos60s-gsSin60c,  -gsTan30c,   gsCos60s-gsSin60c,
     137    };
     138
     139    for (Int_t i=0; i<6; i++)
     140    {
     141        // FIXME: Do not rotate fX/fY.
     142        //        Instead implement MGeomCam::Rotate or similar.
     143        x[i] += fx;
     144        y[i] += fy;
     145    }
     146
     147    x[6] = x[0];
     148    y[6] = y[0];
     149
     150    //
     151    //   paint the pixel
     152    //
     153    if (fill.GetFillColor())
     154        gPad->PaintFillArea(6, x, y);
     155
     156    if (line.GetLineStyle())
     157        gPad->PaintPolyLine(7, x, y);
     158}
     159
     160// ------------------------------------------------------------------------
     161//
     162// compute the distance of a point (px,py) to the Hexagon center in
     163// MGeomPix coordinates. Return kTRUE if inside.
     164//
     165Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const
     166{
     167
     168    //const Double_t disthex = 999999;//TMath::Sqrt(dx*dx + dy*dy);
     169
     170    const Double_t dh = fD/2;
    104171
    105172    //
    106173    //  compute the distance of the Point to the center of the Hexagon
    107174    //
    108     //const Double_t dx = px-fX;
    109     //const Double_t dy = py-fY;
    110 
    111     TVector2 v(px-fX, py-fY);
    112     // FIXME: fPhi or -fPhi?
    113     // v = v.Rotate(-fPhi);             // FIXME: Replace with a precalculates sin/cos vector
    114 
    115     const Double_t dx = v.X();
    116     const Double_t dy = v.Y();
    117 
    118     const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy);
     175    const Double_t dx = px-fX;
     176    const Double_t dy = py-fY;
     177
     178    // FIXME: Derotate
     179
     180    // DX = dx*cos(-phi) - dy*sin(-phi)
     181    // DY = dx*sin(-phi) + dy*cos(-phi)
     182
     183    const Double_t x =  dx*fCosPhi + dy*fSinPhi;
     184
     185    if (TMath::Abs(x) > dh)
     186        return kFALSE; // return disthex
     187
     188    const Double_t y = -dx*fSinPhi + dy*fCosPhi;
     189
     190    const Double_t xc = x*gsCos60;  // 1/2
     191    const Double_t ys = y*gsSin60;  // sqrt(3)/2
    119192
    120193    //
     
    125198    //
    126199
    127     if (TMath::Abs(dx) > fD/2)
    128       return disthex;
    129 
    130     const Double_t dx2 = dx*gsCos60 + dy*gsSin60;
    131 
    132     if  (TMath::Abs(dx2) > fD/2)
    133       return disthex;
    134 
    135     const Double_t dx3 = dx*gsCos60 - dy*gsSin60;
    136 
    137     if  (TMath::Abs(dx3) > fD/2)
    138       return disthex;
    139 
    140     return -1;
    141 }
    142 
    143 // ------------------------------------------------------------------------
    144 //
    145 // Implementation of PaintPrimitive drwaing a hexagonal pixel
    146 //
    147 void MGeomPix::PaintPrimitive(const TAttLine &fill, const TAttFill &line, Double_t scalexy, Double_t scaled) const
    148 {
    149     MHexagon hex;
    150 
    151     fill.Copy(hex);
    152     line.Copy(hex);
    153 
    154     hex.PaintHexagon(fX*scalexy, fY*scalexy, fD*scaled);
    155 }
    156 
    157 
    158 // ------------------------------------------------------------------------
    159 //
    160 // compute the distance of a point (px,py) to the Hexagon center in
    161 // MGeomPix coordinates. Return kTRUE if inside.
    162 //
    163 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const
    164 {
    165     //
    166     //  compute the distance of the Point to the center of the Hexagon
    167     //
    168     const Double_t dx = px-fX;
    169 
    170     //
    171     // Now check if point is outside of hexagon; just check x coordinate
    172     // in three coordinate systems: the default one, in which two sides of
    173     // the hexagon are paralel to the y axis (see camera displays) and two
    174     // more, rotated with respect to that one by +- 60 degrees.
    175     //
    176     if (TMath::Abs(dx)>fD/2)
    177         return kFALSE;
    178 
    179     const Double_t dy = py-fY;
    180 
    181     const static Double_t cos60 = TMath::Cos(60/kRad2Deg);
    182     const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
    183 
    184     const Double_t dxc = dx*cos60;
    185     const Double_t dys = dy*sin60;
    186 
    187     if  (TMath::Abs(dxc + dys)>fD/2)
    188         return kFALSE;
    189 
    190     if (TMath::Abs(dxc - dys)>fD/2)
    191         return kFALSE;
    192 
    193     return kTRUE;
     200    if  (TMath::Abs(xc + ys) > dh)
     201        return kFALSE; // return disthex
     202
     203    if  (TMath::Abs(xc - ys) > dh)
     204        return kFALSE; // return disthex
     205
     206    return kTRUE; // return -1
     207
     208
    194209}
    195210
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r9369 r9385  
    1818    Float_t fD;            // [mm]   the d coordinate of the pixel (dist between two parallel sides)
    1919
     20    Double_t fCosPhi;
     21    Double_t fSinPhi;
     22
     23    // Store fD*fCosPhi  ???
     24    // Store fD*fSinPhi  ???
     25    // Store array and check if initialized before needed?
     26
    2027public:
    2128    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=1, UInt_t s=0, UInt_t aidx=0);
     
    3239
    3340    void SetD(Float_t d=1) { fD=d; fA=d*d*gsTan60/2; }
     41    void SetPhi(Double_t phi=0);
    3442
    3543    Float_t GetD() const  { return fD; }         // Distance between two parallel sides
     
    3846
    3947    Bool_t  IsInside(Float_t px, Float_t py) const;
    40     Float_t DistanceToPrimitive(Float_t px, Float_t py) const;
    4148    void    PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const;
    4249
  • trunk/MagicSoft/Mars/mgeom/MGeomRectangle.cc

    r9368 r9385  
    3434#include <TBox.h>
    3535#include <TMath.h>
     36#include <TVirtualPad.h>
    3637
    3738#include "MLog.h"
     
    5051{
    5152    //  default constructor
    52     SetSize(w, h);
     53    SetSize(w, h<0 ? w : h);
    5354    SetNeighbors();
    5455}
     
    7273// ------------------------------------------------------------------------
    7374//
    74 // compute the distance of a point (px,py) to the Hexagon center in world
    75 // coordinates. Return -1 if inside.
    76 //
    77 Float_t MGeomRectangle::DistanceToPrimitive(Float_t px, Float_t py) const
    78 {
    79     return IsInside(px, py) ? -1 : 9999999;
    80 }
    81 
    82 // ------------------------------------------------------------------------
    83 //
    8475// Implementation of PaintPrimitive drwaing a rectangular pixel
    8576//
     
    9182    const Double_t y = fY*scalexy;
    9283
    93     TBox box;
     84    const_cast<TAttLine&>(line).Modify();  //Change line attributes only if necessary
     85    const_cast<TAttFill&>(fill).Modify();  //Change fill area attributes only if necessary
    9486
    95     fill.Copy(box);
    96     line.Copy(box);
    97 
    98     box.PaintBox(x-w, y-h, x+w, y+h, "l");
     87#if ROOT_VERSION_CODE < ROOT_VERSION(5,18,00)
     88    if (fill.GetFillColor())
     89        gPad->PaintBox(x-w, y-h, x+w, y+h);
     90    if (line.GetLineStyle())
     91        gPad->PaintBox(x-w, y-h, x+w, y+h, "s");
     92#else
     93    gPad->PaintBox(x-w, y-h, x+w, y+h, "l");
     94#endif
    9995}
    10096
     
    105101Float_t MGeomRectangle::GetT() const
    106102{
    107     return TMath::Hypot(fW, fH);
     103    return TMath::Hypot(fW, fH)/2;
    108104}
    109105
  • trunk/MagicSoft/Mars/mgeom/MGeomRectangle.h

    r9368 r9385  
    1313
    1414public:
    15     MGeomRectangle(Float_t x=0, Float_t y=0, Float_t w=1, Float_t h=1, UInt_t s=0, UInt_t aidx=0);
     15    MGeomRectangle(Float_t x=0, Float_t y=0, Float_t w=1, Float_t h=-1, UInt_t s=0, UInt_t aidx=0);
    1616
    1717    void Copy(TObject &obj) const
     
    3333
    3434    Bool_t  IsInside(Float_t px, Float_t py) const;
    35     Float_t DistanceToPrimitive(Float_t px, Float_t py) const;
    3635    void    PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const;
    3736
  • trunk/MagicSoft/Mars/mgui/MHexagon.cc

    r9235 r9385  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHexagon.cc,v 1.31 2009-01-21 14:34:48 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHexagon.cc,v 1.32 2009-03-04 18:45:26 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    4848
    4949#include "MMath.h"
    50 #include "MGeomPix.h"       // GetX
    5150
    5251ClassImp(MHexagon);
     
    7574: TAttLine(1, 1, 1), TAttFill(0, 1001), fX(x), fY(y), fD(d), fPhi(phi)
    7675{
    77 }
    78 
    79 // ------------------------------------------------------------------------
    80 //
    81 //    normal constructor for MHexagon
    82 //
    83 MHexagon::MHexagon(const MGeomPix &pix)
    84 : TAttLine(1, 1, 1), TAttFill(0, 1001), fPhi(0)
    85 {
    86     fX = pix.GetX();
    87     fY = pix.GetY();
    88     fD = pix.GetD();
    89 
    90     // fPhi = pix.GetPhi();
    9176}
    9277
  • trunk/MagicSoft/Mars/mgui/MHexagon.h

    r9235 r9385  
    2626#endif
    2727
    28 class MGeomPix;
    2928class TOrdCollection;
    3029
     
    5150    MHexagon();
    5251    MHexagon(Float_t x, Float_t y, Float_t d, Float_t phi=0);
    53     MHexagon(const MGeomPix &pix);
    5452    MHexagon(const MHexagon &hexagon);
    5553
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r9380 r9385  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.121 2009-03-03 13:32:00 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.122 2009-03-04 18:45:26 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    307307    for (Int_t idx=0; idx<fNcells-2; idx++)
    308308    {
    309         if ((*fGeomCam)[idx].DistanceToPrimitive(x, y)>0)
     309        if (!(*fGeomCam)[idx].IsInside(x, y))
    310310            continue;
    311311
     
    979979        gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg();
    980980
    981     TAttLine line;
     981    TAttLine line(kBlack, kSolid, 1);
    982982    TAttFill fill;
    983     line.SetLineStyle(kSolid);
    984     line.SetLineColor(kBlack);
    985983    for (Int_t i=0; i<fNcells-2; i++)
    986984    {
  • trunk/MagicSoft/Mars/mjobs/MJSimulation.cc

    r9374 r9385  
    442442    // FIXME: Pedestal and Calibration runs should get P and C
    443443    const TString rule1(Form("s/cer([0-9]+)/%s\\/00$1_R_MonteCarlo.root/", Esc(fPathOut).Data()));
    444     const TString rule2(Form("s/cer([0-9]+)/%s\\/00$1_I_MonteCarlo.root/", Esc(fPathOut).Data()));
     444    const TString rule2(Form("s/cer([0-9]+)/%s\\/00$1_Y_MonteCarlo.root/", Esc(fPathOut).Data()));
    445445    const TString rule3(Form("s/cer([0-9]+)/%s\\/00$1_D_MonteCarlo.root/", Esc(fPathOut).Data()));
    446446
  • trunk/MagicSoft/Mars/mreport/MReportCC.cc

    r9292 r9385  
    120120    str.Remove(0, len);
    121121
    122     if (ver>=200809030)
    123     {
    124         if (!CheckTag(str, "SCHEDULE "))
    125             return kFALSE;
    126 
    127         str = str.Strip(TString::kBoth);
    128 
    129         // [Sourcename] sourcecategory
    130         const Ssiz_t pos1 = str.First(' ');
    131         if (pos1<0)
     122    return kTRUE;
     123}
     124
     125// --------------------------------------------------------------------------
     126//
     127// Interprete SCHEDULE section of the CC-REPORT string
     128//
     129Bool_t MReportCC::InterpreteSchedule(TString &str)
     130{
     131    if (!CheckTag(str, "SCHEDULE "))
     132        return kFALSE;
     133
     134    str = str.Strip(TString::kBoth);
     135
     136    // [Sourcename] sourcecategory
     137    const Ssiz_t pos1 = str.First(' ');
     138    if (pos1<0)
     139    {
     140        *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
     141        return kFALSE;
     142    }
     143
     144    const TString str1 = str(0, pos1);
     145
     146    str.Remove(0, pos1);
     147    str = str.Strip(TString::kBoth);
     148
     149    if (!str1.IsDigit())
     150    {
     151        const Ssiz_t pos2 = str.First(' ');
     152        if (pos2<0)
    132153        {
    133154            *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
     
    135156        }
    136157
    137         const TString str1 = str(0, pos1);
    138 
    139         str.Remove(0, pos1);
    140         str = str.Strip(TString::kBoth);
    141 
    142         if (!str1.IsDigit())
     158        TString str2 = str(0, pos2);
     159
     160        str.Remove(0, pos2);
     161
     162        // Remove a leading minus. The negative numbers are error codes introduced
     163        // by Arehucas. It's only meant for the GRB monitor to change the priority
     164        // of its alerts.
     165        if (str2[0]=='-')
     166            str2.Remove(0, 1);
     167
     168        if (!str2.IsDigit())
    143169        {
    144             const Ssiz_t pos2 = str.First(' ');
    145             if (pos2<0)
    146             {
    147                 *fLog << warn << "WARNING - Wrong number of arguments (should be 1 or 2)." << endl;
    148                 return kFALSE;
    149             }
    150 
    151             TString str2 = str(0, pos2);
    152 
    153             str.Remove(0, pos2);
    154 
    155             // Remove a leading minus. The negative numbers are error codes introduced
    156             // by Arehucas. It's only meant for the GRB monitor to change the priority
    157             // of its alerts.
    158             if (str2[0]=='-')
    159                 str2.Remove(0, 1);
    160 
    161             if (!str2.IsDigit())
    162             {
    163                 *fLog << warn << "WARNING - Wrong type of second argument (obs. category): " << str2 << endl;
    164                 return kFALSE;
    165             }
     170            *fLog << warn << "WARNING - Wrong type of second argument (obs. category): " << str2 << endl;
     171            return kFALSE;
    166172        }
    167173    }
     174
     175    return kTRUE;
     176}
     177
     178
     179// --------------------------------------------------------------------------
     180//
     181// Interprete the part of the CC-Report with the MII Subsystem status'
     182//
     183Bool_t MReportCC::InterpreteStatusM2(TString &str)
     184{
     185    // Status of: DAQ, DominoCalibration, Drive, Starguider, CaCo,
     186    //            CaCo2 LID, CaCo sentinel, CaCo LV, CaCo2 HV, AMC, L2T,
     187    //            Domino, Readout, REC, DT, Readout cooling, calib
     188    //            %05.2f %05.2f Zd [deg], Az [deg]
     189
     190    // Remove the 18 tokens of the MAGIC II subsystem status
     191    for (int i=0; i<19; i++)
     192        str.Remove(0, str.First(' ')+1);
    168193
    169194    return kTRUE;
     
    185210    if (!InterpreteCC(str, ver))
    186211        return kCONTINUE;
     212
     213    if (ver>=200809030)
     214        if (!InterpreteSchedule(str))
     215            return kCONTINUE;
     216
     217    if (ver>=200902030)
     218        if (!InterpreteStatusM2(str))
     219            return kCONTINUE;
    187220
    188221    if (ver<200805190)
  • trunk/MagicSoft/Mars/mreport/MReportCC.h

    r8963 r9385  
    3131    Bool_t SetupReading(MParList &plist);
    3232    Bool_t InterpreteCC(TString &str, Int_t ver);
     33    Bool_t InterpreteSchedule(TString &str);
     34    Bool_t InterpreteStatusM2(TString &str);
    3335
    3436    // MReport
  • trunk/MagicSoft/Mars/mtools/MagicJam.cc

    r9369 r9385  
    162162    for (i=0; i<fNcells-2; i++)
    163163    {
    164         if ((*fGeomCam)[i].DistanceToPrimitive(px, py)>0)
    165             continue;
    166 
    167         return i;
     164        if ((*fGeomCam)[i].IsInside(px, py))
     165            return i;
    168166    }
    169167    return -1;
Note: See TracChangeset for help on using the changeset viewer.