Changeset 1203


Ignore:
Timestamp:
01/21/02 20:52:12 (23 years ago)
Author:
rkb
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
10 added
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1192 r1203  
    11                                                                  -*-*- END -*-*-
     2
     3 2002/01/19: Thomas Bretz
     4 
     5   * mbase/MParContainer.cc:
     6     - generalized virtual function AsciiWrite
     7   
     8   * changed to fit new MHillas inhertance model:
     9     - manalysis/MHillas.[h,cc]
     10     - manalysis/MHillasCalc.[h,cc]
     11     - mhist/MHHillas.[h,cc]
     12     - mhist/MHStarMap.[h,cc]
     13
     14   * added to fit new MHillas inhertance model:
     15     - manalysis/MSrcPosCam.[h,cc]
     16     - manalysis/MHillasSrc.[h,cc]
     17     - manalysis/MHillasSrcCalc.[h,cc]
     18     - manalysis/MHillasExt.[h,cc]
     19     - mhist/MHHillasSrc.[h,cc]
     20
     21   * manalysis/MCerPhotEvt.[cc,h]:
     22     - introduced weighting with pixel size in GetNumPhotonsMin
     23     - introduced weighting with pixel size in GetNumPhotonsMax
     24
     25   * mgui/MCamDisplay.cc:
     26     - weight the displayed color with the pixel size
     27
     28
     29
    230 2002/01/18: Thomas Bretz
    331 
  • trunk/MagicSoft/Mars/NEWS

    r1190 r1203  
    33 *** Version 0.7
    44 
     5   - Ascii Output can now also be used for parameter containers which
     6     doesn't overload MParCointainer::AsciiWrite
     7
     8   - replaced old MHillas by a new structure which allows you to extend
     9     the parameters stored in MHillas very easily.
     10
     11   - Added classes to handle source dependancy of image parameters.
     12
    513   - Added container (MBinning) to have a standard input for the binning
    614     in different histograms (eg. the Energy bins should be the same in
  • trunk/MagicSoft/Mars/manalysis/AnalysisLinkDef.h

    r1151 r1203  
    2121#pragma link C++ class MMcPedestalNSBAdd+;
    2222
     23#pragma link C++ class MSrcPosCam+;
    2324#pragma link C++ class MHillas+;
     25#pragma link C++ class MHillasSrc+;
     26#pragma link C++ class MHillasSrcCalc+;
     27#pragma link C++ class MHillasExt+;
    2428#pragma link C++ class MHillasCalc+;
    2529
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r1081 r1203  
    3232
    3333#include "MLog.h"
     34
     35#include "MGeomCam.h"
     36#include "MGeomPix.h"
     37
    3438#include "MHexagon.h"
    3539
     
    148152// --------------------------------------------------------------------------
    149153//
    150 // get the minimum number of photons of all valid pixels in the list
    151 //
    152 Float_t MCerPhotEvt::GetNumPhotonsMin() const
     154// get the minimum number of photons  of all valid pixels in the list
     155// If you specify a geometry the number of photons is weighted with the
     156// area of the pixel
     157//
     158Float_t MCerPhotEvt::GetNumPhotonsMin(const MGeomCam *geom) const
    153159{
    154160    if (fNumPixels <= 0)
    155161        return -5.;
    156162
     163    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
     164
    157165    Float_t minval = (*this)[0].GetNumPhotons();
    158166
    159167    for (UInt_t i=1; i<fNumPixels; i++)
    160168    {
    161         const Float_t testval = (*this)[i].GetNumPhotons();
     169        const MCerPhotPix &pix = (*this)[i];
     170
     171        Float_t testval = pix.GetNumPhotons();
     172
     173        if (geom)
     174            testval *= A0/(*geom)[pix.GetPixId()].GetA();
    162175
    163176        if (testval < minval)
     
    171184//
    172185// get the maximum number of photons of all valid pixels in the list
    173 //
    174 Float_t MCerPhotEvt::GetNumPhotonsMax() const
     186// If you specify a geometry the number of photons is weighted with the
     187// area of the pixel
     188//
     189Float_t MCerPhotEvt::GetNumPhotonsMax(const MGeomCam *geom) const
    175190{
    176191    if (fNumPixels <= 0)
    177192        return 50.;
    178193
     194    const Float_t A0 = geom ? (*geom)[0].GetA() : 0;
    179195    Float_t maxval = (*this)[0].GetNumPhotons();
    180196
    181197    for (UInt_t i=1; i<fNumPixels; i++)
    182198    {
    183         const Float_t testval = (*this)[i].GetNumPhotons();
     199        const MCerPhotPix &pix = (*this)[i];
     200
     201        Float_t testval = pix.GetNumPhotons();
     202
     203        if (geom)
     204            testval *= A0/(*geom)[pix.GetPixId()].GetA();
    184205
    185206        if (testval > maxval)
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r1083 r1203  
    99#endif
    1010
     11class MGeomCam;
    1112class MCerPhotPix;
    1213
     
    3435    Bool_t  IsPixelCore    (Int_t id) const;
    3536
    36     Float_t GetNumPhotonsMin() const;
    37     Float_t GetNumPhotonsMax() const;
     37    Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
     38    Float_t GetNumPhotonsMax(const MGeomCam *geom=NULL) const;
    3839
    3940    MCerPhotPix &operator[](int i)       { return *(MCerPhotPix*)(fPixels->UncheckedAt(i)); }
  • trunk/MagicSoft/Mars/manalysis/MHillas.cc

    r1081 r1203  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
    19 !   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
     18!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@uni-sw.gwdg.de>
     19!   Author(s): Harald Kornmayer 1/2001
     20!   Author(s): Rudolf Bock     10/2001 <mailto:Rudolf.Bock@cern.ch>
    2021!
    2122!   Copyright: MAGIC Software Development, 2000-2001
     
    2526
    2627/////////////////////////////////////////////////////////////////////////////
    27 //                                                                         //
    28 // MHillas                                                                 //
    29 //                                                                         //
    30 // Storage Container for the Hillas parameter                              //
    31 //                                                                         //
    32 // FIXME: - Here everybody should find an explanation of the parameters    //
    33 //        - using boooleans for fIsPixelUsed, fIsPixelCore, ... is rather  //
    34 //          slow because you have to loop over all pixels in any loop.     //
    35 //          There could be a huge speed improvement using Hash Tables      //
    36 //          (linked lists, see THashTable and THashList, too)              //
    37 //                                                                         //
     28//
     29// MHillas
     30//
     31// Storage Container for image parameters
     32//
     33//    basic image parameters
     34// fLength   major axis of ellipse
     35// fWidth    minor axis
     36// fDelta    angle of major axis wrt x-axis
     37// fSize     total sum of pixels
     38// fMeanx    x of center of ellipse
     39// fMeany    y of center of ellipse
     40//
    3841/////////////////////////////////////////////////////////////////////////////
    3942#include "MHillas.h"
    4043
    41 #include <math.h>
    4244#include <fstream.h>
    4345
     
    5153
    5254#include "MLog.h"
     55#include "MLogManip.h"
    5356
    5457ClassImp(MHillas);
     
    6164{
    6265    fName  = name  ? name  : "MHillas";
    63     fTitle = title ? title : "Storage container for Hillas parameter of one event";
     66    fTitle = title ? title : "Storage container for image parameters of one event";
    6467
    6568    Reset();
    6669    // FIXME: (intelligent) initialization of values missing
     70
     71    fEllipse = new TEllipse;
    6772}
    6873
     
    7681}
    7782
     83// --------------------------------------------------------------------------
     84//
    7885void MHillas::Reset()
    7986{
    80     fAlpha  = 0;
    81     fTheta  = 0;
     87    fLength = 0;
    8288    fWidth  = 0;
    83     fLength = 0;
     89    fDelta = 0;
    8490    fSize   = 0;
    85     fDist   = 0;
     91    fMeanx  = 0;
     92    fMeany  = 0;
    8693
    8794    Clear();
     
    94101void MHillas::Print(Option_t *) const
    95102{
    96     *fLog << "Hillas Parameter: " << GetDescriptor() << endl;
    97     *fLog << " - Alpha  = " << fabs(fAlpha) << " deg" << endl;
    98     *fLog << " - Width  = " << fWidth  << " mm"       << endl;
    99     *fLog << " - Length = " << fLength << " mm"       << endl;
    100     *fLog << " - Size   = " << fSize   << " #CerPhot" << endl;
    101     *fLog << " - Dist   = " << fDist   << " mm"       << endl;
     103    Double_t atg = atan2(fMeany, fMeanx)*kRad2Deg;
     104
     105    if (atg<0)
     106        atg += 180;
     107
     108    *fLog << all;
     109    *fLog << "Basic Image Parameters (" << GetName() << ")" << endl;
     110    *fLog << " - Length   [mm]  = " << fLength << endl;
     111    *fLog << " - Width    [mm]  = " << fWidth  << endl;
     112    *fLog << " - Meanx    [mm]  = " << fMeanx  << endl;
     113    *fLog << " - Meany    [mm]  = " << fMeany  << endl;
     114    *fLog << " - Delta    [deg] = " << fDelta*kRad2Deg << endl;
     115    *fLog << " - atg(y/x) [deg] = " << atg     << endl;
     116    *fLog << " - Size     [1]   = " << fSize   << " #CherPhot"   << endl;
    102117}
    103118
    104119/*
    105 // --------------------------------------------------------------------------
     120// -----------------------------------------------------------
    106121//
    107122// call the Paint function of the Ellipse if a TEllipse exists
    108123//
    109124void MHillas::Paint(Option_t *)
     125{
     126     fEllipse->SetLineWidth(2);
     127     fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
     128                            0, 360, fDelta*kRad2Deg+180);
     129}
     130*/
     131
     132// --------------------------------------------------------------------------
     133//
     134// Instead of adding MHillas itself to the Pad
     135// (s. AppendPad in TObject) we create an ellipse,
     136// which is added to the Pad by its Draw function
     137// You can remove it by deleting the Ellipse Object
     138// (s. Clear() )
     139//
     140void MHillas::Draw(Option_t *opt)
     141{
     142
     143    Clear();
     144
     145    fEllipse = new TEllipse(fMeanx, fMeany, fLength, fWidth,
     146                            0, 360, fDelta*kRad2Deg+180);
     147
     148    fEllipse->SetLineWidth(2);
     149    fEllipse->Draw();
     150
     151    /*
     152     fEllipse->SetPhimin();
     153     fEllipse->SetPhimax();
     154     fEllipse->SetR1(fLength);
     155     fEllipse->SetR2(fWidth);
     156     fEllipse->SetTheta(fDelta*kRad2Deg+180);
     157     fEllipse->SetX1(fMeanx);
     158     fEllipse->SetY1(fMeany);
     159
     160     fEllipse->SetLineWidth(2);
     161     fEllipse->PaintEllipse(fMeanx, fMeany, fLength, fWidth,
     162                            0, 360, fDelta*kRad2Deg+180);
     163
     164      AppendPad(opt);
     165
     166     // This is from TH1
     167     TString opt = option;
     168     opt.ToLower();
     169     if (gPad && !opt.Contains("same")) {
     170        //the following statement is necessary in case one attempts to draw
     171        //a temporary histogram already in the current pad
     172      if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this);
     173      gPad->Clear();
     174      }
     175      */
     176}
     177
     178// --------------------------------------------------------------------------
     179//
     180// If a TEllipse object exists it is deleted
     181//
     182void MHillas::Clear(Option_t *)
    110183{
    111184    if (!fEllipse)
    112185        return;
    113186
    114     fEllipse->Paint();
    115 }
    116 */
    117 
    118 // --------------------------------------------------------------------------
    119 //
    120 // Instead of adding MHillas itself to the Pad
    121 // (s. AppendPad in TObject) we create an ellipse,
    122 // which is added to the Pad by it's Draw function
    123 // You can remove it by deleting the Ellipse Object
    124 // (s. Clear() )
    125 //
    126 void MHillas::Draw(Option_t *opt)
    127 {
    128     Clear();
    129 
    130     fEllipse = new TEllipse(cos(fTheta)*fDist, sin(fTheta)*fDist,
    131                             fLength, fWidth,
    132                             0, 360, fTheta*kRad2Deg+fAlpha-180);
    133 
    134     fEllipse->SetLineWidth(2);
    135     fEllipse->Draw();
    136     //AppendPad(opt);
    137 
    138     /*
    139      This is from TH1
    140      TString opt = option;
    141    opt.ToLower();
    142    if (gPad && !opt.Contains("same")) {
    143       //the following statement is necessary in case one attempts to draw
    144       //a temporary histogram already in the current pad
    145       if (TestBit(kCanDelete)) gPad->GetListOfPrimitives()->Remove(this);
    146       gPad->Clear();
    147    }
    148    AppendPad(opt.Data());
    149    */
    150 }
    151 
    152 // --------------------------------------------------------------------------
    153 //
    154 // If a TEllipse object exists it is deleted
    155 //
    156 void MHillas::Clear(Option_t *)
    157 {
    158     if (!fEllipse)
    159         return;
    160 
    161187    delete fEllipse;
    162188
     
    164190}
    165191
    166 // --------------------------------------------------------------------------
    167 //
    168 // Calculate the Hillas parameters from a cerenkov photon event
    169 // (The calcualtion is some kind of two dimentional statistics)
    170 //
    171 //   FIXME: MHillas::Calc is rather slow at the moment because it loops
    172 //          unnecessarily over all pixels in all its loops (s.MImgCleanStd)
    173 //          The speed could be improved very much by using Hash-Tables
    174 //          (linked lists, see THashTable and THashList, too)
     192
     193// --------------------------------------------------------------------------
     194//
     195// Calculate the image parameters from a Cherenkov photon event
     196// assuming Cher.photons/pixel and pixel coordinates are given
    175197//
    176198Bool_t MHillas::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
    177199{
    178     const UInt_t nevt = evt.GetNumPixels();
     200    // FIXME: MHillas::Calc is rather slow at the moment because it loops
     201    //    unnecessarily over all pixels in all its loops (s.MImgCleanStd)
     202    //    The speed could be improved very much by using Hash-Tables
     203    //    (linked lists, see THashTable and THashList, too)
     204    //
     205
     206    const UInt_t npixevt = evt.GetNumPixels();
    179207
    180208    //
    181209    // sanity check
    182210    //
    183     if (nevt <= 2)
     211    if (npixevt <= 2)
    184212        return kFALSE;
    185213
    186214    //
    187     // calculate mean valu of pixels
    188     //
    189     float xmean =0;
    190     float ymean =0;
    191 
    192     fSize = 0;
     215    // calculate mean value of pixel coordinates and fSize
     216    // -----------------------------------------------------
     217    //
     218    fMeanx = 0;
     219    fMeany = 0;
     220    fSize  = 0;
    193221
    194222    //
     
    196224    //
    197225    UShort_t npix=0;
    198     for (UInt_t i=0; i<nevt; i++)
     226    for (UInt_t i=0; i<npixevt; i++)
    199227    {
    200228        const MCerPhotPix &pix = evt[i];
     
    207235        const float nphot = pix.GetNumPhotons();
    208236
    209         fSize += nphot;
    210         xmean += nphot * gpix.GetX(); // [mm]
    211         ymean += nphot * gpix.GetY(); // [mm]
     237        fSize  += nphot;                             // [counter]
     238        fMeanx += nphot * gpix.GetX();              // [mm]
     239        fMeany += nphot * gpix.GetY();              // [mm]
    212240
    213241        npix++;
     
    220248        return kFALSE;
    221249
    222     xmean /= fSize; // [mm]
    223     ymean /= fSize; // [mm]
    224 
    225     //
    226     // calculate sdev
    227     //
    228     float sigmaxx=0;
    229     float sigmaxy=0;
    230     float sigmayy=0;
    231 
    232     for (UInt_t i=0; i<nevt; i++)
     250    fMeanx /= fSize;                                 // [mm]
     251    fMeany /= fSize;                                 // [mm]
     252
     253    //
     254    // calculate 2nd moments
     255    // -------------------
     256    //
     257    float corrxx=0;                                  // [m^2]
     258    float corrxy=0;                                  // [m^2]
     259    float corryy=0;                                  // [m^2]
     260
     261    for (UInt_t i=0; i<npixevt; i++)
    233262    {
    234263        const MCerPhotPix &pix = evt[i];
     
    238267
    239268        const MGeomPix &gpix = geom[pix.GetPixId()];
    240 
    241         const float dx = gpix.GetX() - xmean;
    242         const float dy = gpix.GetY() - ymean;
    243 
    244         const float nphot = pix.GetNumPhotons();
    245 
    246         sigmaxx += nphot * dx*dx; // [mm^2]
    247         sigmaxy += nphot * dx*dy; // [mm^2]
    248         sigmayy += nphot * dy*dy; // [mm^2]
     269        const float dx = gpix.GetX() - fMeanx;       // [mm]
     270        const float dy = gpix.GetY() - fMeany;       // [mm]
     271
     272        const float nphot = pix.GetNumPhotons();     // [#phot]
     273
     274        corrxx += nphot * dx*dx;                     // [mm^2]
     275        corrxy += nphot * dx*dy;                     // [mm^2]
     276        corryy += nphot * dy*dy;                     // [mm^2]
    249277    }
    250278
    251279    //
    252     // check for orientation
    253     //
    254     const float theta = atan(sigmaxy/(sigmaxx-sigmayy)*2)/2;
    255 
    256     float c = cos(theta); // [1]
    257     float s = sin(theta); // [1]
    258 
    259     //
    260     // calculate the length of the two axis
    261     //
    262     float axis1 =  2.0*c*s*sigmaxy + c*c*sigmaxx + s*s*sigmayy; // [mm^2]
    263     float axis2 = -2.0*c*s*sigmaxy + s*s*sigmaxx + c*c*sigmayy; // [mm^2]
    264 
    265     axis1 /= fSize; // [mm^2]
    266     axis2 /= fSize; // [mm^2]
    267 
    268     //
    269     // check for numerical negatives
    270     // (very small number can get negative by chance)
    271     //
     280    // calculate the basic Hillas parameters: orientation and size of axes
     281    // -------------------------------------------------------------------
     282    //
     283    const float d = corryy - corrxx;
     284
     285    fDelta = atan2(d + sqrt(d*d + corrxy*corrxy*4), corrxy*2);
     286
     287    fCosDelta = cos(fDelta);   // need these in derived classes
     288    fSinDelta = sin(fDelta);   // like MHillasExt
     289
     290    float axis1 = ( fCosDelta*fSinDelta*corrxy*2 + fCosDelta*fCosDelta*corrxx + fSinDelta*fSinDelta*corryy) / fSize; // [mm^2]
     291    float axis2 = (-fCosDelta*fSinDelta*corrxy*2 + fSinDelta*fSinDelta*corrxx + fCosDelta*fCosDelta*corryy) / fSize; // [mm^2]
     292 
     293    // very small numbers can get negative by rounding
    272294    if (axis1 < 0) axis1=0;
    273     if (axis2 < 0) axis2=0;
    274 
    275     //
    276     // calculate the main Hillas parameters
    277     //
    278     // fLength, fWidth describes the two axis of the ellipse
    279     // fAlpha is the angle between the length-axis and the center
    280     //    of the camera
    281     // fDist is the distance between the center of the camera and the
    282     //    denter of the ellipse
    283     //
    284     const int rotation = axis1<axis2;
    285 
    286     fLength = rotation ? sqrt(axis2) : sqrt(axis1);  // [mm]
    287     fWidth  = rotation ? sqrt(axis1) : sqrt(axis2);  // [mm]
    288 
    289     const float a = c*xmean + s*ymean;
    290     const float b = c*ymean - s*xmean;
    291 
    292     fAlpha  = rotation ? atan(a/b) : atan(-b/a);     // [rad]
    293     fAlpha *= kRad2Deg;                              // [deg]
    294 
    295     fDist   = sqrt(xmean*xmean + ymean*ymean);       // [mm]
    296 
    297     fTheta  = atan(ymean/xmean);                     // [rad]
    298     if (xmean<0) fTheta += kPI;                      // [rad]
     295    if (axis2 < 0) axis2=0;
     296
     297    fLength = sqrt(axis1);  // [mm]
     298    fWidth  = sqrt(axis2);  // [mm]
    299299
    300300    SetReadyToSave();
     
    303303}
    304304
     305// --------------------------------------------------------------------------
     306//
    305307void MHillas::AsciiRead(ifstream &fin)
    306308{
    307     fin >> fAlpha;
    308     fin >> fTheta;
     309    fin >> fLength;
    309310    fin >> fWidth;
    310     fin >> fLength;
     311    fin >> fDelta;
    311312    fin >> fSize;
    312     fin >> fDist;
    313 }
    314 
     313    fin >> fMeanx;
     314    fin >> fMeany;
     315}
     316
     317// --------------------------------------------------------------------------
     318//
    315319void MHillas::AsciiWrite(ofstream &fout) const
    316320{
    317     fout << fAlpha << " ";
    318     fout << fTheta << " ";
    319     fout << fWidth << " ";
    320321    fout << fLength << " ";
    321     fout << fSize << " ";
    322     fout << fDist << endl;
    323 }
     322    fout << fWidth  << " ";
     323    fout << fDelta  << " ";
     324    fout << fSize   << " ";
     325    fout << fMeanx  << " ";
     326    fout << fMeany;
     327}
  • trunk/MagicSoft/Mars/manalysis/MHillas.h

    r1018 r1203  
    1414{
    1515private:
    16     Float_t fAlpha;     // [deg] Angle between the length axis of the ellipse and the camera center
    17     Float_t fTheta;     // [rad] Angle between the x axis and the center of the ellipse
    18     Float_t fWidth;     // [mm]  Width of the ellipse
    19     Float_t fLength;    // [mm]  Length of the ellipse
    20     Float_t fSize;      // [#CerPhot] Size of the ellipse
    21     Float_t fDist;      // [mm] Distance of the ellipse COM from the camera center
     16    // 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
    2223
    23     TEllipse *fEllipse; //! Graphical Object to Display Ellipse
     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)
     26
     27    TEllipse *fEllipse;  //! Graphical Object to Display Ellipse
     28
     29protected:
     30    //
     31    // This is only for calculations in derived classes because
     32    // we don't want to read/write this data members
     33    //
     34    Float_t GetCosDelta() const { return fCosDelta; }
     35    Float_t GetSinDelta() const { return fSinDelta; }
    2436
    2537public:
     
    2941    void Reset();
    3042
    31     Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
     43    virtual Bool_t Calc(const MGeomCam &geom, const MCerPhotEvt &pix);
    3244
    33     void Print(Option_t *opt=NULL) const;
    34     void Draw(Option_t *opt=NULL);
    35     //void Paint(Option_t *opt=NULL);
     45    virtual void Print(Option_t *opt=NULL) const;
     46    virtual void Draw(Option_t *opt=NULL);
     47    //virtual void Paint(Option_t *);
    3648
    37     void Clear(Option_t *opt=NULL);
     49    virtual void Clear(Option_t *opt=NULL);
    3850
    39     Float_t GetAlpha() const  { return fAlpha; }
     51    Float_t GetLength() const { return fLength; }
    4052    Float_t GetWidth() const  { return fWidth; }
    41     Float_t GetLength() const { return fLength; }
    42     Float_t GetDist() const   { return fDist; }
     53    Float_t GetDelta() const  { return fDelta; }
    4354    Float_t GetSize() const   { return fSize; }
    44     Float_t GetTheta() const  { return fTheta; }
     55    Float_t GetMeanX() const  { return fMeanx; }
     56    Float_t GetMeanY() const  { return fMeany; }
    4557
    46     void AsciiRead(ifstream &fin);
    47     void AsciiWrite(ofstream &fout) const;
     58    virtual void AsciiRead(ifstream &fin);
     59    virtual void AsciiWrite(ofstream &fout) const;
    4860
    4961    ClassDef(MHillas, 1) // Storage Container for Hillas Parameter
     
    5163
    5264#endif
    53 
  • trunk/MagicSoft/Mars/manalysis/MHillasCalc.cc

    r1081 r1203  
    5454// Default constructor.
    5555//
    56 MHillasCalc::MHillasCalc(const char *name, const char *title)
     56MHillasCalc::MHillasCalc(const char *hil, const char *name, const char *title)
    5757{
    5858    fName  = name  ? name  : "MHillasCalc";
    5959    fTitle = title ? title : "Task to calculate Hillas parameters";
     60
     61    fHilName = hil;
    6062}
    6163
     
    8284    }
    8385
    84     fHillas = (MHillas*)pList->FindCreateObj("MHillas");
     86    fHillas = (MHillas*)pList->FindCreateObj(fHilName);
    8587    if (!fHillas)
    8688        return kFALSE;
  • trunk/MagicSoft/Mars/manalysis/MHillasCalc.h

    r1014 r1203  
    2424          MHillas     *fHillas;     // ouput container to store result
    2525
     26    TString fHilName;
    2627public:
    27     MHillasCalc(const char *name=NULL, const char *title=NULL);
     28    MHillasCalc(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
    2829
    2930    Bool_t PreProcess(MParList *pList);
  • trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc

    r1081 r1203  
    194194//
    195195//   Look for the boundary pixels around the core pixels
    196 //   if a pixel has more than 2.5 (clean level 2) sigma, and
     196//   if a pixel has more than 2.5 (clean level 2.5) sigma, and
    197197//   a core neigbor it is declared as used.
    198198//
  • trunk/MagicSoft/Mars/manalysis/Makefile

    r1151 r1203  
    3434           MMcPedestalNSBAdd.cc \
    3535           MImgCleanStd.cc \
     36           MSrcPosCam.cc \
    3637           MHillas.cc \
     38           MHillasExt.cc \
    3739           MHillasCalc.cc \
     40           MHillasSrc.cc \
     41           MHillasSrcCalc.cc \
    3842           MCerPhotCalc.cc \
    3943           MCerPhotEvt.cc \
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1080 r1203  
    3737#include "MParContainer.h"
    3838
     39#include <fstream.h>     // ofstream, AsciiWrite
     40
    3941#include <TClass.h>      // IsA
    4042#include <TROOT.h>       // TROOT::Identlevel
     43#include <TMethodCall.h> // TMethodCall, AsciiWrite
     44#include <TDataMember.h> // TDataMember, AsciiWrite
    4145#include <TVirtualPad.h> // gPad
    4246
     
    211215//
    212216//  If you want to use Ascii-Input/-Output (eg. MWriteAsciiFile) of a
    213 //  container, overload this function.
     217//  container, you may overload this function. If you don't overload it
     218//  the data member of a class are written to the file in the order of
     219//  appearance in the class header (be more specfic: root dictionary)
     220//  Only data members which are of integer (Bool_t, Int_t, ...) or
     221//  floating point (Float_t, Double_t, ...) type are written.
    214222//
    215223void MParContainer::AsciiWrite(ofstream &fout) const
    216224{
    217     *fLog << warn << "To use the the ascii output of " << GetName();
    218     *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
    219 }
     225    // *fLog << warn << "To use the the ascii output of " << GetName();
     226    // *fLog << " you have to overload " << ClassName() << "::AsciiWrite." << endl;
     227
     228    TDataMember *data = NULL;
     229
     230    TIter Next(IsA()->GetListOfDataMembers());
     231    while ((data=(TDataMember*)Next()))
     232    {
     233        if (!data->IsPersistent())
     234            continue;
     235
     236        /*const*/ TMethodCall *call = data->GetterMethod(); //FIXME: Root
     237        if (!call)
     238            continue;
     239
     240        switch (call->ReturnType())
     241        {
     242        case TMethodCall::kLong:
     243            Long_t l;
     244            call->Execute((void*)this, l); // FIXME: const, root
     245            fout << l << " ";
     246            continue;
     247
     248        case TMethodCall::kDouble:
     249            Double_t d;
     250            call->Execute((void*)this, d); // FIXME: const, root
     251            fout << d << " ";
     252            continue;
     253
     254        case TMethodCall::kOther:
     255            /* someone may want to enhance this? */
     256            continue;
     257        }
     258    }
     259}
  • trunk/MagicSoft/Mars/mbase/MReadMarsFile.cc

    r1172 r1203  
    114114    if (fRun->Process())
    115115    {
    116         TString name(GetFileName());
    117         name.Remove(0, name.Last('/')+1);
    118 
    119         *fLog << inf << "MReadMarsFile: Switching to '" << name << "' ";
     116        *fLog << inf << "MReadMarsFile: Switching to '" << GetFileName() << "' ";
    120117        *fLog << "(before event #" << GetEventNum()-1 << ")" << endl;
    121118
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r1192 r1203  
    407407    if (!fNumEntries)
    408408    {
    409         *fLog << warn << dbginf << "No entries found in file(s)." << endl;
     409        *fLog << warn << dbginf << "No entries found in file(s)" << endl;
    410410        return kFALSE;
    411411    }
     
    692692//  Return the name of the file we are actually reading from.
    693693//
    694 const char *MReadTree::GetFileName() const
    695 {
    696     return fChain->GetFile()->GetName();
     694TString MReadTree::GetFileName() const
     695{
     696    const TFile *file = fChain->GetFile();
     697
     698    if (!file)
     699        return TString("<unknown>");
     700
     701    TString name(file->GetName());
     702    name.Remove(0, name.Last('/')+1);
     703    return name;
    697704}
    698705
  • trunk/MagicSoft/Mars/mbase/MReadTree.h

    r1114 r1203  
    5858    UInt_t GetEntries() const  { return fNumEntries; }
    5959
    60     const char *GetFileName() const;
     60    TString GetFileName() const;
    6161
    6262    virtual void   AddNotify(TObject *obj);
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.cc

    r1082 r1203  
    1111
    1212#include "MHexagon.h"
     13
     14#include "MGeomPix.h"
    1315#include "MGeomCam.h"
    1416
     
    2729    : fAutoScale(kTRUE), fMinPhe(-2), fMaxPhe(50), fW(0), fH(0), fDrawingPad(NULL)
    2830{
     31    fGeomCam = geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
     32
    2933    //
    3034    //  create the hexagons of the display
     
    8084    delete fLegend;
    8185    delete fLegText;
    82 }
    83 
    84 inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix)
    85 {
    86     (*this)[pix.GetPixId()].SetFillColor(GetColor(pix.GetNumPhotons()));
     86
     87    delete fGeomCam;
     88}
     89
     90inline void MCamDisplay::SetPixColor(const MCerPhotPix &pix, const Int_t i)
     91{
     92    //
     93    // Fixme: Divide pnum by the (real) area of the pixel
     94    //
     95
     96    const Float_t ratio = (*fGeomCam)[0].GetA()/(*fGeomCam)[i].GetA();
     97    const Float_t pnum  = ratio*pix.GetNumPhotons();
     98
     99    (*this)[pix.GetPixId()].SetFillColor(GetColor(pnum));
    87100}
    88101
     
    221234    if (fAutoScale)
    222235    {
    223         fMinPhe = event->GetNumPhotonsMin();
    224         fMaxPhe = event->GetNumPhotonsMax();
     236        fMinPhe = event->GetNumPhotonsMin(fGeomCam);
     237        fMaxPhe = event->GetNumPhotonsMax(fGeomCam);
    225238
    226239        if (fMaxPhe < 20.)
     
    242255            continue;
    243256
    244         SetPixColor(pix);
     257        SetPixColor(pix, i);
    245258    }
    246259
  • trunk/MagicSoft/Mars/mgui/MCamDisplay.h

    r1023 r1203  
    2121{
    2222private:
     23    MGeomCam      *fGeomCam;     // pointer to camera geometry
     24
    2325    Bool_t         fAutoScale;   // indicating the autoscale function
    2426
     
    4244    MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }
    4345
    44     void  SetPixColor(const MCerPhotPix &pix);
     46    void  SetPixColor(const MCerPhotPix &pix, const Int_t i);
    4547    Int_t GetColor(Float_t wert);
    4648
  • trunk/MagicSoft/Mars/mhist/HistLinkDef.h

    r1015 r1203  
    1111#pragma link C++ class MHFadcPix+;
    1212#pragma link C++ class MHHillas+;
     13#pragma link C++ class MHHillasSrc+;
    1314#pragma link C++ class MHStarMap+;
    1415#pragma link C++ class MHMcEnergy+;
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r1082 r1203  
    4545// --------------------------------------------------------------------------
    4646//
    47 // Setup four histograms for Alpha, Width, Length and Dist
     47// Setup four histograms for Width, Length
    4848//
    4949MHHillas::MHHillas (const char *name, const char *title)
     
    6060    // connect all the histogram with the container fHist
    6161    //
    62     fAlpha  = new TH1F("Alpha [deg]", "Alpha of Hillas",   90, 0,  90);
    6362    fWidth  = new TH1F("Width [mm]",  "Width of Hillas",  100, 0, 300);
    6463    fLength = new TH1F("Length [mm]", "Length of Hillas", 100, 0, 300);
    65     fDist   = new TH1F("Dist [mm]",   "Dist of Hillas",   100, 0, 300);
    6664
    67     fAlpha->SetDirectory(NULL);
    6865    fLength->SetDirectory(NULL);
    69     fDist->SetDirectory(NULL);
    7066    fWidth->SetDirectory(NULL);
    7167
    72     fAlpha->GetXaxis()->SetTitle("\\alpha [\\circ]");
    7368    fLength->GetXaxis()->SetTitle("Length [mm]");
    74     fDist->GetXaxis()->SetTitle("Dist [mm]");
    7569    fWidth->GetXaxis()->SetTitle("Width [mm]");
    7670
    77     fAlpha->GetYaxis()->SetTitle("Counts");
    7871    fLength->GetYaxis()->SetTitle("Counts");
    79     fDist->GetYaxis()->SetTitle("Counts");
    8072    fWidth->GetYaxis()->SetTitle("Counts");
    8173}
     
    8779MHHillas::~MHHillas()
    8880{
    89     delete fAlpha;
    9081    delete fWidth;
    9182    delete fLength;
    92     delete fDist;
    9383}
    9484
     
    10292    const MHillas &h = *(MHillas*)par;
    10393
    104     fAlpha ->Fill(fabs(h.GetAlpha()));
    10594    fWidth ->Fill(h.GetWidth());
    10695    fLength->Fill(h.GetLength());
    107     fDist  ->Fill(h.GetDist());
    10896}
    10997
     
    118106TObject *MHHillas::DrawClone(Option_t *opt) const
    119107{
    120     TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
    121     c->Divide(2, 2);
     108    TCanvas *c = MakeDefCanvas("Hillas", "Histograms of Hillas Parameters",
     109                               350, 500);
     110    c->Divide(1, 2);
    122111
    123112    gROOT->SetSelectedPad(NULL);
     
    127116    //
    128117    c->cd(1);
    129     fAlpha->DrawCopy();
     118    fLength->DrawCopy();
    130119
    131120    c->cd(2);
    132     fLength->DrawCopy();
    133 
    134     c->cd(3);
    135     fDist->DrawCopy();
    136 
    137     c->cd(4);
    138121    fWidth->DrawCopy();
    139122
     
    153136{
    154137    if (!gPad)
    155         MakeDefCanvas("Hillas", "Histograms of Hillas Parameters");
     138        MakeDefCanvas("Hillas", "Histograms of Hillas Parameters", 350, 500);
    156139
    157     gPad->Divide(2,2);
     140    gPad->Divide(1, 2);
    158141
    159142    gPad->cd(1);
    160     fAlpha->Draw();
     143    fLength->Draw();
    161144
    162145    gPad->cd(2);
    163     fLength->Draw();
    164 
    165     gPad->cd(3);
    166     fDist->Draw();
    167 
    168     gPad->cd(4);
    169146    fWidth->Draw();
    170147
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1015 r1203  
    1212{
    1313private:
    14     TH1F *fAlpha;
    1514    TH1F *fWidth;
    1615    TH1F *fLength;
    17     TH1F *fDist;
    1816
    1917public:
    20      MHHillas(const char *name=NULL, const char *title=NULL);
     18    MHHillas(const char *name=NULL, const char *title=NULL);
    2119    ~MHHillas();
    2220
    2321    void Fill(const MParContainer *par);
    2422
    25     TH1F *GetHistAlpha()  { return fAlpha; }
    2623    TH1F *GetHistWidth()  { return fWidth; }
    2724    TH1F *GetHistLength() { return fLength; }
    28     TH1F *GetHistDist()   { return fDist; }
    2925
    3026    void Draw(Option_t *opt=NULL);
     
    3531
    3632#endif
    37 
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r1082 r1203  
    4747// Create the star map histogram
    4848//
    49 MHStarMap::MHStarMap (const char *name, const char *title)
     49MHStarMap::MHStarMap(const char *name, const char *title)
    5050{
    5151    //
     
    7272    fStarMap->SetDirectory(NULL);
    7373
    74     fStarMap->SetXTitle("x/mm");
    75     fStarMap->SetYTitle("y/mm");
     74    fStarMap->SetXTitle("x [mm]");
     75    fStarMap->SetYTitle("y [mm]");
    7676    fStarMap->SetZTitle("Counts");
    7777}
     
    9595    const MHillas &h = *(MHillas*)par;
    9696
    97     const float dist  = h.GetDist();
    98     const float theta = h.GetTheta();
    99     const float alpha = h.GetAlpha()/kRad2Deg;
    100 
    101     const float m = tan(theta+alpha-kPI);
    102     const float t = dist*(sin(theta)-cos(theta)*m);
     97    const float delta = h.GetDelta();
     98
     99    const float m = tan(delta);
     100    const float t = m*h.GetMeanX()-h.GetMeanY();
    103101
    104102    if (m>-1 && m<1)
     
    211209    gPad->Update();
    212210}
    213 
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r1015 r1203  
    2020
    2121public:
    22      MHStarMap(const char *name=NULL, const char *title=NULL);
     22    MHStarMap(const char *name=NULL, const char *title=NULL);
    2323    ~MHStarMap();
    2424
     
    3434
    3535#endif
    36 
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1052 r1203  
    3030SRCFILES = MFillH.cc \
    3131           MH.cc \
    32            MHFadcPix.cc \
     32        MHFadcPix.cc \
    3333           MHFadcCam.cc \
    3434           MHHillas.cc \
     35           MHHillasSrc.cc \
    3536           MHStarMap.cc \
    3637           MHMcCollectionArea.cc \
     
    5354
    5455# @endcode
    55 
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcEvt.cxx

    r1101 r1203  
    22
    33#include <iostream.h>
     4#include <fstream.h>
    45
    56
     
    162163
    163164
     165void MMcEvt::AsciiWrite(ofstream &fout) const
     166{
     167    fout << fEnergy << " ";
     168    fout << fTheta ;
     169}
    164170
    165171void MMcEvt::Print(Option_t *Option) const {
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcEvt.hxx

    r1193 r1203  
    4343             UInt_t, UInt_t, UInt_t, UInt_t, UInt_t, UInt_t ) ;
    4444
     45  virtual void AsciiWrite(ofstream &fout) const;
    4546
    4647  void Print(Option_t *opt=NULL) const;
Note: See TracChangeset for help on using the changeset viewer.