Changeset 1434


Ignore:
Timestamp:
07/25/02 09:14:36 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1425 r1434  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/07/23: Thomas Bretz
     4
     5   * mgui/MineSweeper.cc, mgui/MCamDisplay.cc:
     6     - fixed a bug which could caused the destructor of the created canvas
     7       not to be called if the object was deleted.
     8
     9   * mgui/MCamDisplay.h:
     10     - some reordering
     11
     12   * mgui/MHexagon.cc:
     13     - return the correct distance to primitive
     14     - do a sanity check in DistancetoPrimitive
     15
     16   * mhist/HistLinkDef.h:
     17     - added missing classes
     18
     19
     20
     21 2002/07/23: Wolfgang Wittek, Thomas Bretz
     22
     23   * manalysis/MHillas.cc, manalysis/MHillasSrc.cc:
     24     - replaced algorithms by the ones from the corresponding TDAS note
     25     - made results of calculations (hopefully) more accurate
     26     - added some output warnings and sanity checks
     27     - changed the default parameters in the Reset function
     28
     29   * manalysis/MHillasSrc.[h,cc]:
     30     - added fCosDeltaAlpha
     31     - made Calc returning a Bool_t
     32
     33   * manalysis/MHillasSrcCalc.cc:
     34     - make use of the return value of MHillasSrc::Calc
     35
     36
    237
    338 2002/07/22: Abelardo Moralejo
     
    843   * macros/MagicHillas.C:
    944     -added example on how to use MCerPhotCalc2
     45
     46
    1047
    1148 2002/07/22: Thomas Bretz
  • trunk/MagicSoft/Mars/NEWS

    r1408 r1434  
    22
    33 *** Version 0.8
     4
     5   - added all subdirectories as Include-Paths for ACLIC (s. rootlogon.C)
    46
    57   - changed trigrate.C: now it calculates the pure NSB triggers from
     
    2123     (MMultiDimDistCalc, multidimdist.C, MHMatrix)
    2224
    23    - Changed the Alpha range according to TDAS 02-03 to [-90°,90°]
    24 
    2525   - Added a camera display displaying the pixel numbers to the
    2626     event display gui.
     
    3434   - Added the number of used and core pixels after image cleaning
    3535     to MHillas
     36
     37   - Changed the algorithm used in MHillas according to TDAS 02-03
     38
     39   - Changed the Alpha range according to TDAS 02-03 to [-90°,90°]
     40
     41   - Changed the algorithm used in MHillasSrc according to TDAS 02-03
     42
     43   - Added fCosDeltaAlpha to MHillasSrc
    3644
    3745   - Fixed a bug in the table describing the Next Neighbours of the
  • trunk/MagicSoft/Mars/manalysis/MHillas.cc

    r1394 r1434  
    1919!   Author(s): Harald Kornmayer 1/2001
    2020!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
     21!   Author(s): Wolfgang Wittek  6/2002 <mailto:wittek@mppmu.mpg.de>
    2122!
    2223!   Copyright: MAGIC Software Development, 2000-2002
     
    3536// Version 1:
    3637// ----------
    37 // fLength   major axis of ellipse
    38 // fWidth    minor axis
    39 // fDelta    angle of major axis wrt x-axis
    40 // fSize     total sum of pixels
    41 // fMeanX    x of center of ellipse
    42 // fMeanY    y of center of ellipse
     38// fLength   [mm]       major axis of ellipse
     39// fWidth    [mm]       minor axis
     40// fDelta    [rad]      angle of major axis with x-axis
     41//                      by definition the major axis is pointing into
     42//                      the hemisphere x>0, thus -pi/2 < delta < pi/2
     43// fSize     [#CerPhot] total sum of pixels
     44// fMeanX    [mm]       x of center of ellipse
     45// fMeanY    [mm]       y of center of ellipse
    4346//
    4447// Version 2:
     
    9194// --------------------------------------------------------------------------
    9295//
     96// Initializes the values with defaults. For the default values see the
     97// source code.
     98//
    9399void MHillas::Reset()
    94100{
    95     fLength = 0;
    96     fWidth  = 0;
    97     fDelta  = 0;
     101    fLength = -1;
     102    fWidth  = -1;
     103    fDelta  =  0;
    98104
    99105    fSize   = -1;
     
    122128    *fLog << " - Length   [mm]  = " << fLength << endl;
    123129    *fLog << " - Width    [mm]  = " << fWidth  << endl;
     130    *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
     131    *fLog << " - Size     [1]   = " << fSize   << " #CherPhot"   << endl;
    124132    *fLog << " - Meanx    [mm]  = " << fMeanX  << endl;
    125133    *fLog << " - Meany    [mm]  = " << fMeanY  << endl;
    126     *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
    127134    *fLog << " - atg(y/x) [deg] = " << atg     << endl;
    128     *fLog << " - Size     [1]   = " << fSize   << " #CherPhot"   << endl;
    129135}
    130136
     
    207213// Calculate the image parameters from a Cherenkov photon event
    208214// assuming Cher.photons/pixel and pixel coordinates are given
     215// In case you don't call Calc from within an eventloop make sure, that
     216// you call the Reset member function before.
    209217//
    210218Bool_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
    211219{
    212     // FIXME: MHillas::Calc is rather slow at the moment because it loops
    213     //    unnecessarily over all pixels in all its loops (s.MImgCleanStd)
    214     //    The speed could be improved very much by using Hash-Tables
    215     //    (linked lists, see THashTable and THashList, too)
    216     //
    217 
    218220    const UInt_t npixevt = evt.GetNumPixels();
    219221
     
    222224    //
    223225    if (npixevt <= 2)
     226    {
     227        *fLog << warn << "MHillas::Calc: Event has less than two pixels... skipped." << endl;
    224228        return kFALSE;
     229    }
    225230
    226231    //
    227232    // calculate mean value of pixel coordinates and fSize
    228233    // -----------------------------------------------------
     234    //
     235    // Because this are only simple sums of roughly 600 values
     236    // with an accuracy less than three digits there should not
     237    // be any need to use double precision (Double_t) for the
     238    // calculation of fMeanX, fMeanY and fSize.
    229239    //
    230240    fMeanX = 0;
     
    235245    fNumCorePixels = 0;
    236246
    237     //
    238     // FIXME! npix should be retrieved from MCerPhotEvt
    239     //
    240247    for (UInt_t i=0; i<npixevt; i++)
    241248    {
     
    247254        const MGeomPix &gpix = geom[pix.GetPixId()];
    248255
    249         const float nphot = pix.GetNumPhotons();
     256        const Float_t nphot = pix.GetNumPhotons();
     257
     258        if (nphot==0)
     259            *fLog << warn << GetDescriptor() << ": Pixel #" << pix.GetPixId() << " has no photons." << endl;
    250260
    251261        fSize  += nphot;                             // [counter]
     
    260270
    261271    //
    262     // sanity check
    263     //
    264     if (fSize==0 || fNumUsedPixels<=2)
     272    // sanity checks
     273    //
     274    if (fSize==0)
     275    {
     276        *fLog << warn << GetDescriptor() << ": Event has zero cerenkov photons... skipped." << endl;
    265277        return kFALSE;
     278    }
     279
     280    if (fNumUsedPixels<3)
     281    {
     282        *fLog << warn << GetDescriptor() << ": Event has less than 3 used pixels... skipped." << endl;
     283        return kFALSE;
     284    }
    266285
    267286    fMeanX /= fSize;                                 // [mm]
     
    270289    //
    271290    // calculate 2nd moments
    272     // -------------------
    273     //
    274     float corrxx=0;                                  // [m^2]
    275     float corrxy=0;                                  // [m^2]
    276     float corryy=0;                                  // [m^2]
     291    // ---------------------
     292    //
     293    // To make sure that the more complicated sum is evaluated as
     294    // accurate as possible (because it is needed for more
     295    // complicated calculations (see below) we calculate it using
     296    // double prcision.
     297    //
     298    Double_t corrxx=0;                               // [m^2]
     299    Double_t corrxy=0;                               // [m^2]
     300    Double_t corryy=0;                               // [m^2]
    277301
    278302    for (UInt_t i=0; i<npixevt; i++)
     
    284308
    285309        const MGeomPix &gpix = geom[pix.GetPixId()];
    286         const float dx = gpix.GetX() - fMeanX;       // [mm]
    287         const float dy = gpix.GetY() - fMeanY;       // [mm]
    288 
    289         const float nphot = pix.GetNumPhotons();     // [#phot]
     310
     311        const Float_t dx = gpix.GetX() - fMeanX;     // [mm]
     312        const Float_t dy = gpix.GetY() - fMeanY;     // [mm]
     313
     314        const Float_t nphot = pix.GetNumPhotons();   // [#phot]
    290315
    291316        corrxx += nphot * dx*dx;                     // [mm^2]
     
    295320
    296321    //
     322    // If corrxy=0 (which should never happen, because fSize>0) we
     323    // cannot calculate Length and Width. The calculation failed
     324    // and returnes kFALSE
     325    //
     326    if (corrxy==0)
     327    {
     328        *fLog << warn << GetDescriptor() << ": Event has CorrXY==0... skipped." << endl;
     329        return kFALSE;
     330    }
     331
     332    //
    297333    // calculate the basic Hillas parameters: orientation and size of axes
    298334    // -------------------------------------------------------------------
    299335    //
    300     const float d = (corryy - corrxx)/(corrxy*2);
    301 
    302     fDelta = atan(d + sqrt(d*d + 1));
    303 
    304     fCosDelta = cos(fDelta);   // need these in derived classes
    305     fSinDelta = sin(fDelta);   // like MHillasExt
    306 
    307     float axis1 = ( fCosDelta*fSinDelta*corrxy*2 + fCosDelta*fCosDelta*corrxx + fSinDelta*fSinDelta*corryy) / fSize; // [mm^2]
    308     float axis2 = (-fCosDelta*fSinDelta*corrxy*2 + fSinDelta*fSinDelta*corrxx + fCosDelta*fCosDelta*corryy) / fSize; // [mm^2]
    309  
     336    // fDelta is the angle between the major axis of the ellipse and
     337    //  the x axis. It is independent of the position of the ellipse
     338    //  in the camera it has values between -pi/2 and pi/2 degrees
     339    //
     340    const Double_t d0   = corryy - corrxx;
     341    const Double_t d1   = corrxy*2;
     342    const Double_t d2   = d0 + sqrt(d0*d0 + d1*d1);
     343    const Double_t tand = d2 / d1;
     344
     345    fDelta = atan(tand);
     346
     347    const Double_t s2 = tand*tand+1;
     348    const Double_t s  = sqrt(s2);
     349
     350    fCosDelta =  1.0/s;   // need these in derived classes
     351    fSinDelta = tand/s;   // like MHillasExt
     352
     353    Double_t axis1 = (tand*tand*corryy + d2 + corrxx)/s2/fSize;
     354    Double_t axis2 = (tand*tand*corrxx - d2 + corryy)/s2/fSize;
     355
     356    //
     357    // fLength^2 is the second moment along the major axis of the ellipse
     358    // fWidth^2  is the second moment along the minor axis of the ellipse
     359    //
     360    // From the algorithm we get: fWidth <= fLength is always true
     361    //
    310362    // very small numbers can get negative by rounding
    311     if (axis1 < 0) axis1=0;
    312     if (axis2 < 0) axis2=0;
    313 
    314     fLength = sqrt(axis1);  // [mm]
    315     fWidth  = sqrt(axis2);  // [mm]
     363    //
     364    fLength = axis1<0 ? 0 : sqrt(axis1);  // [mm]
     365    fWidth  = axis2<0 ? 0 : sqrt(axis2);  // [mm]
    316366
    317367    SetReadyToSave();
     
    322372// --------------------------------------------------------------------------
    323373//
     374/*
    324375void MHillas::AsciiRead(ifstream &fin)
    325376{
     
    331382    fin >> fMeanY;
    332383}
    333 
     384*/
    334385// --------------------------------------------------------------------------
    335386/*
  • trunk/MagicSoft/Mars/manalysis/MHillas.h

    r1394 r1434  
    1515private:
    1616    // for description see MHillas.cc
    17     Float_t   fLength;   // [mm]        major axis of ellipse
    18     Float_t   fWidth;    // [mm]        minor axis of ellipse
    19     Float_t   fDelta;    // [rad]       angle of major axis with x-axis
    20     Float_t   fSize;     // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
    21     Float_t   fMeanX;    // [mm]        x-coordinate of center of ellipse
    22     Float_t   fMeanY;    // [mm]        y-coordinate of center of ellipse
     17    Float_t fLength;        // [mm]        major axis of ellipse
     18    Float_t fWidth;         // [mm]        minor axis of ellipse
     19    Float_t fDelta;         // [rad]       angle of major axis with x-axis
     20    Float_t fSize;          // [#CerPhot]  sum of content of all pixels (number of Cherenkov photons)
     21    Float_t fMeanX;         // [mm]        x-coordinate of center of ellipse
     22    Float_t fMeanY;         // [mm]        y-coordinate of center of ellipse
    2323
    24     Float_t   fSinDelta; //! [1] sin of Delta (to be used in derived classes)
    25     Float_t   fCosDelta; //! [1] cos of Delta (to be used in derived classes)
     24    Float_t fSinDelta;      //! [1] sin of Delta (to be used in derived classes)
     25    Float_t fCosDelta;      //! [1] cos of Delta (to be used in derived classes)
    2626
    2727    Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
    2828    Short_t fNumCorePixels; // number of core pixels
    2929
    30     TEllipse *fEllipse;  //! Graphical Object to Display Ellipse
     30    TEllipse *fEllipse;     //! Graphical Object to Display Ellipse
    3131
    3232protected:
     
    6262    Int_t GetNumCorePixels() const { return fNumCorePixels; }
    6363
    64     virtual void AsciiRead(ifstream &fin);
     64    //virtual void AsciiRead(ifstream &fin);
    6565    //virtual void AsciiWrite(ofstream &fout) const;
    6666
  • trunk/MagicSoft/Mars/manalysis/MHillasSrc.cc

    r1350 r1434  
    1919!   Author(s): Harald Kornmayer 1/2001
    2020!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
     21!   Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
    2122!
    2223!   Copyright: MAGIC Software Development, 2000-2002
     
    3233//
    3334//    source-dependent image parameters
    34 // fAlpha    angle between major axis and line source-to-center
    35 // fDist     distance from source to center of ellipse
     35//
     36// Version 1:
     37// ----------
     38//  fAlpha          angle between major axis and line source-to-center
     39//  fDist           distance from source to center of ellipse
     40//
     41// Version 2:
     42// ----------
     43//  fHeadTail
     44//
     45// Version 3:
     46// ----------
     47//  fCosDeltaLenth  cosine of angle between d and a, where
     48//                   - d is the vector from the source position to the
     49//                     center of the ellipse
     50//                   - a is a vector along the main axis of the ellipse
    3651//
    3752/////////////////////////////////////////////////////////////////////////////
     
    5772}
    5873
     74void MHillasSrc::Reset()
     75{
     76    fDist          = -1;
     77    fAlpha         =  0;
     78    fHeadTail      =  0;
     79    fCosDeltaAlpha =  0;
     80}
     81
    5982// --------------------------------------------------------------------------
    6083//
    61 //  calculation of source-dependent parameters
     84//  Calculation of source-dependent parameters
     85//  In case you don't call Calc from within an eventloop make sure, that
     86//  you call the Reset member function before.
    6287//
    63 void MHillasSrc::Calc(const MHillas *hillas)
     88Bool_t MHillasSrc::Calc(const MHillas *hillas)
    6489{
    65     const Double_t mx = hillas->GetMeanX();        // [mm]
    66     const Double_t my = hillas->GetMeanY();        // [mm]
     90    fHillas = hillas;
    6791
    68     const Double_t sx = mx - fSrcPos->GetX();      // [mm]
    69     const Double_t sy = my - fSrcPos->GetY();      // [mm]
     92    const Double_t mx   = GetMeanX();            // [mm]
     93    const Double_t my   = GetMeanY();            // [mm]
    7094
    71     const Double_t sd = sin(hillas->GetDelta());   // [1]
    72     const Double_t cd = cos(hillas->GetDelta());   // [1]
     95    const Double_t sx   = mx - fSrcPos->GetX();  // [mm]
     96    const Double_t sy   = my - fSrcPos->GetY();  // [mm]
    7397
     98    const Double_t sd   = sin(GetDelta());       // [1]
     99    const Double_t cd   = cos(GetDelta());       // [1]
    74100
    75     fHeadTail = cd*sx + sd*sy;                     // [mm]
    76     fDist     = sqrt(sx*sx + sy*sy);               // [mm]
    77     fAlpha    = atan((cd*sy - sd*sx)/fHeadTail);   // [rad]
    78     fAlpha   *= kRad2Deg;                          // [deg]
     101    const Double_t tand = tan(GetDelta());       // [1]
    79102
    80     fHillas   = hillas;
     103    fHeadTail = cd*sx + sd*sy;                   // [mm]
     104
     105    //
     106    // Distance from source position to center of ellipse.
     107    // If the distance is 0 distance, Alpha is not specified.
     108    // The calculation has failed and returnes kFALSE.
     109    //
     110    Double_t dist = sqrt(sx*sx + sy*sy);         // [mm]
     111
     112    if (dist==0)
     113    {
     114        *fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
     115        return kFALSE;
     116    }
     117
     118    fDist = dist;
     119                                                 // [mm]
     120    //
     121    // Calculate Alpha and Cosda = cos(d,a)
     122    // The sign of Cosda will be used for quantities containing
     123    // a head-tail information
     124    //
     125    const Double_t arg = (sy-tand*sx) / (fDist*sqrt(tand*tand+1));
     126
     127    fAlpha         = asin(arg)*kRad2Deg;        // [deg]
     128    fCosDeltaAlpha = fHeadTail/fDist;           // [1]
    81129
    82130    SetReadyToSave();
     131
     132    return kTRUE;
    83133}
    84134
     
    87137    *fLog << all;
    88138    *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
    89     *fLog << " - Dist     = " << fDist     << " mm"  << endl;
    90     *fLog << " - Alpha    = " << fAlpha    << " deg" << endl;
    91     *fLog << " - HeadTail = " << fHeadTail << " mm"  << endl;
     139    *fLog << " - Dist          [mm]  = " << fDist << endl;
     140    *fLog << " - Alpha         [deg] = " << fAlpha << endl;
     141    *fLog << " - HeadTail      [mm]  = " << fHeadTail << endl;
     142    *fLog << " - CosDeltaAlpha       = " << fCosDeltaAlpha << endl;
    92143}
    93144
     
    96147// overloaded MParContainer to read MHillasSrc from an ascii file
    97148//
     149/*
    98150void MHillasSrc::AsciiRead(ifstream &fin)
    99151{
     
    102154    fin >> fHeadTail;
    103155}
    104 
     156*/
    105157// -----------------------------------------------------------------------
    106158//
  • trunk/MagicSoft/Mars/manalysis/MHillasSrc.h

    r1237 r1434  
    1414    const MSrcPosCam *fSrcPos; //! Source position in the camere
    1515
    16     Float_t fAlpha;    // [deg]  angle of major axis with vector to src
    17     Float_t fDist;     // [mm]   distance from src to center of ellipse
    18     Float_t fHeadTail; // [mm]
     16    Float_t fAlpha;         // [deg]  angle of major axis with vector to src
     17    Float_t fDist;          // [mm]   distance between src and center of ellipse
     18    Float_t fHeadTail;      // [mm]
     19    Float_t fCosDeltaAlpha; // [1]    cosine of angle between d and a
    1920
    2021public:
     
    2425    const MSrcPosCam *GetSrcPos() const   { return fSrcPos; }
    2526
    26     Float_t GetLength()   const  { return fHillas->GetLength(); }
    27     Float_t GetWidth()    const  { return fHillas->GetWidth(); }
    28     Float_t GetDelta()    const  { return fHillas->GetDelta(); }
    29     Float_t GetSize()     const  { return fHillas->GetSize(); }
    30     Float_t GetMeanX()    const  { return fHillas->GetMeanX(); }
    31     Float_t GetMeanY()    const  { return fHillas->GetMeanY(); }
    32     Float_t GetAlpha()    const  { return fAlpha; }
    33     Float_t GetDist()     const  { return fDist; }
    34     Float_t GetHeadTail() const  { return fHeadTail; }
     27    void Reset();
     28
     29    Float_t GetLength()        const { return fHillas->GetLength(); }
     30    Float_t GetWidth()         const { return fHillas->GetWidth(); }
     31    Float_t GetDelta()         const { return fHillas->GetDelta(); }
     32    Float_t GetSize()          const { return fHillas->GetSize(); }
     33    Float_t GetMeanX()         const { return fHillas->GetMeanX(); }
     34    Float_t GetMeanY()         const { return fHillas->GetMeanY(); }
     35    Float_t GetAlpha()         const { return fAlpha; }
     36    Float_t GetDist()          const { return fDist; }
     37    Float_t GetHeadTail()      const { return fHeadTail; }
     38    Float_t GetCosDeltaAlpha() const { return fCosDeltaAlpha; }
    3539
    3640    void Print(Option_t *opt=NULL) const;
    3741
    38     virtual void Calc(const MHillas *hillas);
     42    virtual Bool_t Calc(const MHillas *hillas);
    3943
    40     virtual void AsciiRead(ifstream &fin);
     44    //virtual void AsciiRead(ifstream &fin);
    4145    //virtual void AsciiWrite(ofstream &fout) const;
    4246
    43     ClassDef(MHillasSrc, 2) // Container to hold source position dependant parameters
     47    ClassDef(MHillasSrc, 3) // Container to hold source position dependant parameters
    4448};
    4549
    46 /*
    47  Version 1: fAlpha, fDist
    48  Version 2: fAlpha, fDist, fSign
    49  */
    50 
    5150#endif
  • trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc

    r1211 r1434  
    9191Bool_t MHillasSrcCalc::Process()
    9292{
    93     fHillasSrc->Calc(fHillas);
    94 
    95     return kTRUE;
     93    return fHillasSrc->Calc(fHillas) ? kTRUE : kCONTINUE;
    9694}
    9795
  • trunk/MagicSoft/Mars/mgui/MineSweeper.h

    r1423 r1434  
    4141    enum
    4242    {
    43 //        kBlack     =  1,      // schwarz
    44 //        kWhite     = 10,
    4543        kHidden    = 50,
    4644        kIsVisible = BIT(15),
    4745        kHasBomb   = BIT(16),
    4846        kHasFlag   = BIT(17),
    49         kUserBits  = 0x0000ff00, // 14-23 are allowed
    50 
     47        kUserBits  = 0x0000ff00 // 14-23 are allowed
    5148    };
    5249
Note: See TracChangeset for help on using the changeset viewer.