Ignore:
Timestamp:
11/04/03 11:32:57 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgeom
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r2236 r2463  
    3232// interface of how to acccess the geometry information.
    3333//
     34//
     35// Version 1:
     36// ----------
     37//  - first implementation
     38//
     39// Version 2:
     40// ----------
     41//  - added fPixRatio
     42//  - added fPixRatioSqrt
     43//
     44//
    3445///////////////////////////////////////////////////////////////////////
    3546#include "MGeomCam.h"
     
    5970//
    6071MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title)
    61     : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), fPixels(npix)
     72    : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), fPixels(npix), fPixRatio(npix), fPixRatioSqrt(npix)
    6273{
    6374    fName  = name  ? name  : "MGeomCam";
     
    8798// --------------------------------------------------------------------------
    8899//
     100// Calculate and fill the arrays storing the ratio of the area of a pixel
     101// i to the pixel 0 and its square root.
     102// The precalculation is done for speed reasons. Having an event the
     103// ratio would be calculated at least once for each pixel which is
     104// an enormous amount of numerical calculations, which are time
     105// consuming and which can be avoided doing the precalculation.
     106//
     107void MGeomCam::CalcPixRatio()
     108{
     109    const Double_t a0 = (*this)[0].GetA();
     110
     111    for (UInt_t i=0; i<fNumPixels; i++)
     112    {
     113        fPixRatio[i] = a0/(*this)[i].GetA();
     114        fPixRatioSqrt[i] = TMath::Sqrt(fPixRatio[i]);
     115    }
     116}
     117
     118// --------------------------------------------------------------------------
     119//
    89120//  Set the kIsOuterRing flag for all pixels which have a outermost pixel
    90121//  as Next Neighbor and don't have the kIsOutermostRing flag itself.
     
    103134{
    104135    fNumSectors = 0;
     136
     137    for (UInt_t i=0; i<fNumPixels; i++)
     138    {
     139        const UInt_t s = (*this)[i].GetSector();
     140
     141        if (s>fNumSectors)
     142            fNumSectors = s;
     143    }
     144
     145    fNumSectors++;
     146}
     147
     148// --------------------------------------------------------------------------
     149//
     150// Calculate the maximum radius of the camera. This is ment for GUI layout.
     151//
     152void MGeomCam::CalcMaxRadius()
     153{
     154    fMaxRadius = 0;
    105155
    106156    for (UInt_t i=0; i<fNumPixels; i++)
    107157    {
    108158        const MGeomPix &pix = (*this)[i];
    109         const UInt_t s = pix.GetSector();
    110 
    111         if (s>fNumSectors)
    112             fNumSectors = s;
    113     }
    114 
    115     fNumSectors++;
    116 }
    117 
    118 // --------------------------------------------------------------------------
    119 //
    120 // Calculate the maximum radius of the camera. This is ment for GUI layout.
    121 //
    122 void MGeomCam::CalcMaxRadius()
    123 {
    124     fMaxRadius = 0;
    125 
    126     for (UInt_t i=0; i<fNumPixels; i++)
    127     {
    128         const MGeomPix &pix = (*this)[i];
    129159
    130160        const Float_t x = pix.GetX();
     
    147177Float_t MGeomCam::GetPixRatio(UInt_t i) const
    148178{
    149     return i<fNumPixels ? (*this)[0].GetA()/(*this)[i].GetA() : 0;
     179    // Former: (*this)[0].GetA()/(*this)[i].GetA();
     180    // The const_cast is necessary to support older root version
     181    return i<fNumPixels ? const_cast<TArrayF&>(fPixRatio)[i] : 0;
     182}
     183
     184// --------------------------------------------------------------------------
     185//
     186//  returns the square root of the ratio of the area of the pixel with
     187//  index 0 to the pixel with the specified index i. 0 Is returned if
     188//  the index argument is out of range.
     189//
     190Float_t MGeomCam::GetPixRatioSqrt(UInt_t i) const
     191{
     192    // The const_cast is necessary to support older root version
     193    return i<fNumPixels ? const_cast<TArrayF&>(fPixRatioSqrt)[i] : 0;
    150194}
    151195
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r2236 r2463  
    88#include <TObjArray.h>
    99#endif
     10#ifndef ROOT_TArrayF
     11#include <TArrayF.h>
     12#endif
    1013
    1114class MGeomPix;
     
    1417{
    1518private:
    16     UInt_t    fNumPixels;  // Number of pixels in this camera
    17     Float_t   fMaxRadius;  // maximum radius of the camera (eg. for GUI layout)
     19    UInt_t    fNumPixels;    // Number of pixels in this camera
     20    Float_t   fMaxRadius;    // maximum radius of the camera (eg. for GUI layout)
    1821
    19     Float_t   fCamDist;    // [m] Average distance of the camera from the mirror
    20     Float_t   fConvMm2Deg; // conversion factor to convert mm in the camera plain into degrees
     22    Float_t   fCamDist;      // [m] Average distance of the camera from the mirror
     23    Float_t   fConvMm2Deg;   // conversion factor to convert mm in the camera plain into degrees
    2124
    22     TObjArray fPixels;     // Array of singel pixels storing the geometry
     25    TObjArray fPixels;       // Array of singel pixels storing the geometry
    2326
    24     UInt_t    fNumSectors; // Number of sectors
     27    TArrayF   fPixRatio;     // Array storing the ratio between size of pixel idx and pixel 0 (for speed reasons)
     28    TArrayF   fPixRatioSqrt; // Array storing the square root ratio between size of pixel idx and pixel 0 (for speed reasons)
     29
     30    UInt_t    fNumSectors;   // Number of sectors
    2531
    2632protected:
     33    void CalcPixRatio();
    2734    void CalcMaxRadius();
    2835    void CalcNumSectors();
     
    4249    UInt_t  GetNumSectors() const { return fNumSectors; }
    4350    Float_t GetPixRatio(UInt_t i) const;
     51    Float_t GetPixRatioSqrt(UInt_t i) const;
    4452
    4553    MGeomPix &operator[](Int_t i);
     
    4856    virtual void Print(Option_t *opt=NULL) const;
    4957
    50     ClassDef(MGeomCam, 1)  // Geometry base class for the camera
     58    ClassDef(MGeomCam, 2)  // Geometry base class for the camera
    5159};
    5260
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc

    r2236 r2463  
    5858    CalcNumSectors();
    5959    CalcMaxRadius();
     60    CalcPixRatio();
    6061}
    6162
  • trunk/MagicSoft/Mars/mgeom/MGeomCamCT1Daniel.cc

    r2441 r2463  
    4646#include <math.h>     // floor
    4747
    48 /*
    49  #include "MLog.h"
    50  #include "MLogManip.h"
    51  */
    52 
    5348#include "MGeomPix.h"
    5449
     
    6055//  CreateCam and CreateNN
    6156//
    62 //MGeomCamCT1::MGeomCamCT1(const char *name)
    63 //    : MGeomCam(127, 4.88, name, "Geometry information of CT1 camera")
    64 // This is the geometry as used by Daniel :
    6557MGeomCamCT1Daniel::MGeomCamCT1Daniel(const char *name)
    6658    : MGeomCam(127, 4.8129, name, "Geometry information of CT1 camera")
     
    7062    CalcNumSectors();
    7163    CalcMaxRadius();
     64    CalcPixRatio();
    7265}
    7366
  • trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000.cc

    r2236 r2463  
    4848//
    4949MGeomCamECO1000::MGeomCamECO1000(const char *name)
    50     : MGeomCam(577, 17, name, "Geometry information of Magic Camera")
     50    : MGeomCam(577, 34.5, name, "Geometry information of Magic Camera")
    5151{
    5252    CreateCam();
     
    5454    CalcNumSectors();
    5555    CalcMaxRadius();
     56    CalcPixRatio();
    5657}
    5758
  • trunk/MagicSoft/Mars/mgeom/MGeomCamECO1000HG.cc

    r2236 r2463  
    5858    CalcNumSectors();
    5959    CalcMaxRadius();
     60    CalcPixRatio();
    6061}
    6162
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc

    r2236 r2463  
    3434#include "MGeomCamMagic.h"
    3535
    36 /*
    37  #include "MLog.h"
    38  #include "MLogManip.h"
    39  */
    40 
    4136#include "MGeomPix.h"
    4237
     
    5348    CreateCam();
    5449    CreateNN();
     50    CalcPixRatio();
    5551    CalcNumSectors();
    5652    CalcMaxRadius();
     53    CalcPixRatio();
    5754}
    5855
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagic919.cc

    r2277 r2463  
    3434#include "MGeomCamMagic919.h"
    3535
    36 /*
    37  #include "MLog.h"
    38  #include "MLogManip.h"
    39  */
    40 
    4136#include "MGeomPix.h"
    4237
     
    5550    CreateNN();
    5651    CalcMaxRadius();
     52    CalcPixRatio();
    5753}
    5854
  • trunk/MagicSoft/Mars/mgeom/MGeomCamMagicHG.cc

    r2236 r2463  
    3434#include "MGeomCamMagicHG.h"
    3535
    36 /*
    37  #include "MLog.h"
    38  #include "MLogManip.h"
    39  */
    40 
    4136#include "MGeomPix.h"
    4237
     
    5550    CalcNumSectors();
    5651    CalcMaxRadius();
     52    CalcPixRatio();
    5753}
    5854
  • trunk/MagicSoft/Mars/mgeom/MGeomCorsikaCT.cc

    r2283 r2463  
    6666
    6767}
    68 
    69 
    70 
    71 
    72 
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.cc

    r2236 r2463  
    3535// MGeomPix.
    3636//
     37//
     38// Version 1:
     39// ----------
     40//  - first implementation
     41//
     42// Version 2:
     43// ----------
     44//  - added fA
     45//
     46//
    3747// FIXME: According to an agreement we have to change the name 'Id'
    3848//        to 'idx'
     
    5262using namespace std;
    5363
     64const Float_t MGeomPix::gsTan60 = tan(60/kRad2Deg);
     65
    5466// --------------------------------------------------------------------------
    5567//
    5668// Initializes one pixel
    5769//
    58 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s) : fX(x), fY(y), fD(r), fSector(s)
     70MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s)
    5971{
    6072    //  default constructor
    61 }
    62 
    63 // --------------------------------------------------------------------------
    64 //
    65 // Return the area of the pixel. A hexagonal shape is assumed.
    66 //
    67 Float_t MGeomPix::GetA() const
    68 {
    69     return fD*fD*tan(60/kRad2Deg);
     73    Set(x, y, r, s);
    7074}
    7175
     
    126130        << "  y= " << fY
    127131        << "  d= " << fD
     132        << "  A= " << fA
    128133        << endl ;
    129134}
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r2236 r2463  
    1111{
    1212private:
     13    static const Float_t gsTan60; // tan(60/kRad2Deg);
     14
    1315    enum {
    1416        kIsInOutermostRing = BIT(22),
    1517        kIsInOuterRing     = BIT(23),
    1618        kUserBits          = 0x1fc000 // 14-21 are allowed
    17 
    1819    };
    1920
    20     Float_t fX;  // [mm] the x coordinate of the center
    21     Float_t fY;  // [mm] the y coordinate of the center
    22     Float_t fD;  // [mm] the d coordinate of the pixel (dist between two parallel sides)
     21    Float_t fX;            // [mm]   the x coordinate of the center
     22    Float_t fY;            // [mm]   the y coordinate of the center
     23    Float_t fD;            // [mm]   the d coordinate of the pixel (dist between two parallel sides)
     24    Float_t fA;            // [mm^2] Area of the pixel
    2325
    2426    Byte_t  fNumNeighbors; // number of valid neighbors
    2527    Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)
    2628
    27     UInt_t fSector; // Number of sector the pixels corresponds to
     29    UInt_t fSector;        // Number of sector the pixels corresponds to
    2830
    2931public:
     
    3234    void Print(Option_t *opt=NULL) const;
    3335
    34     void Set(Float_t x, Float_t y, Float_t d, UInt_t s=0) { fX=x; fY=y; fD=d; fSector=s; }
     36    void Set(Float_t x, Float_t y, Float_t d, UInt_t s=0) { fX=x; fY=y; fD=d; fA=d*d*gsTan60; fSector=s; }
    3537
    3638    void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1,
     
    3840
    3941    void CheckOuterRing(const MGeomCam &cam);
    40     /*
    41      void SetX(Float_t x) { fX = x; }
    42      void SetY(Float_t y) { fY = y; }
    43      void SetD(Float_t d) { fD = d; }
    44      void SetSector(UInt_t s) { fSector = s; }
    45      */
    4642
    4743    Float_t GetX() const  { return fX; }
     
    5046    UInt_t  GetSector() const { return fSector; }
    5147
    52     Float_t GetA() const;
     48    Float_t GetA() const { return fA; /*fD*fD*gsTan60;*/ }
    5349
    5450    Byte_t  GetNumNeighbors() const { return fNumNeighbors; }
Note: See TracChangeset for help on using the changeset viewer.