Changeset 9219 for trunk/MagicSoft


Ignore:
Timestamp:
01/14/09 12:31:37 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9218 r9219  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2009/01/14 Thomas Bretz
     22
     23   * readraw.cc:
     24     - check first whether the file exist before adding the extension
     25
     26   * mbase/MMath.[h,cc]:
     27     - added function to Re-sort an array
     28
     29   * mfileio/MReadMarsFile.cc, mfileio/MWriteRootFile.cc:
     30     - Improved output
     31
     32   * mfileio/MWriteRootFile.cc:
     33     - fixed a problem which prevented to open more than one /dev/null
     34       devices independantly
     35
     36   * mgeom/MGeomCam.cc:
     37     - cosmetics
     38
     39   * mgeom/MGeomCamDwarf.h:
     40     - fixed a typo in an ifdef
     41
     42   * mgeom/MGeomPix.[h,cc]:
     43     - added funtion to return positon as TVector2
     44     - slightly improved the algorithm to check IsInside
     45     - fixed the conditional signs for the orientation of pixels
     46       in GetDirection
     47
     48   * mmain/MEventDisplay.cc:
     49     - Give different names to the MPedestalSubtract tasks
     50     - fixed buttons
     51     - call AddGeometryTags after ReInit to allow reading new geometries in
     52       ReInit
     53
     54   * mmc/MMcEvtBasic.h:
     55     - added a new primary type kNightSky
     56
     57   * mraw/MRawEvtPixelIter.h:
     58     - replaced type of the number of bytes by UInt_t
     59
     60   * mraw/MRawRunHeader.h:
     61     - allow to validate the magic-number from outside (for MCs)
     62
     63
    2064
    2165 2009/01/12 Daniel Hoehne-Moench
  • trunk/MagicSoft/Mars/mbase/MMath.cc

    r9195 r9219  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.42 2008-12-21 18:09:49 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.43 2009-01-14 12:31:36 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    324324Double_t MMath::MedianDev(Long64_t n, const Long64_t *a) { Double_t med; return MedianDevImp(n, a, med); }
    325325
     326// ------------------------------------------------------------------------
     327//
     328// Re-sort an array. Intsead of returning an index (like TMath::Sort)
     329// the array contents are sorted.
     330//
     331template <class Size, class Element> void MMath::ReSortImp(Size n, Element *a, Bool_t down)
     332{
     333    Element *cpy = new Element[n];
     334    Int_t   *pos = new Int_t[n];
     335
     336    memcpy(cpy, a, n*sizeof(Element));
     337
     338    TMath::Sort(n, a, pos, down);
     339
     340    Int_t *idx = pos;
     341
     342    for (Element *ptr=a; ptr<a+n; ptr++)
     343        *ptr = cpy[*idx++];
     344
     345    delete cpy;
     346    delete pos;
     347}
     348
     349void MMath::ReSort(Long64_t n, Short_t  *a, Bool_t down) { ReSortImp(n, a, down); }
     350void MMath::ReSort(Long64_t n, Int_t    *a, Bool_t down) { ReSortImp(n, a, down); }
     351void MMath::ReSort(Long64_t n, Float_t  *a, Bool_t down) { ReSortImp(n, a, down); }
     352void MMath::ReSort(Long64_t n, Double_t *a, Bool_t down) { ReSortImp(n, a, down); }
     353
    326354// --------------------------------------------------------------------------
    327355//
  • trunk/MagicSoft/Mars/mbase/MMath.h

    r8989 r9219  
    1717{
    1818    Double_t GaussProb(Double_t x, Double_t sigma=1, Double_t mean=0);
     19
     20    template <class Size, class Element> void ReSortImp(Size n, Element *a, Bool_t down=kFALSE);
     21    void ReSort(Long64_t n, Short_t  *a, Bool_t down=kFALSE);
     22    void ReSort(Long64_t n, Int_t    *a, Bool_t down=kFALSE);
     23    void ReSort(Long64_t n, Float_t  *a, Bool_t down=kFALSE);
     24    void ReSort(Long64_t n, Double_t *a, Bool_t down=kFALSE);
    1925
    2026    template <class Size, class Element> Double_t MedianDevImp(Size n, const Element *a) { Double_t med; return MedianDevImp(n, a, med); }
  • trunk/MagicSoft/Mars/mfileio/MReadMarsFile.cc

    r8253 r9219  
    201201    if (!rawheader->IsValid())
    202202    {
    203         *fLog << warn << "WARNING - The run header read from the file is invalid." << endl;
     203        *fLog << warn << "WARNING - The run header (MRawRunHeader) read from the file returns not IsValid()." << endl;
    204204        *fLog << "          Please check if the file contents are ok." << endl;
    205205        rawheader->Print("header");
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r9186 r9219  
    122122    }
    123123
    124     if (!file)
     124    if (!file || TString(name)=="/dev/null")
    125125    {
    126126        file = new TFile(name, option, title, comp);
     
    760760    {
    761761        *fLog << err << "ERROR - MWriteRootFile::ChangeFile... something went terribly wrong!" << endl;
     762        *fLog <<        "        fname: " << fname << endl;
    762763        *fLog <<        "        Please start debugging!" << endl;
    763764        return kFALSE;
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r8921 r9219  
    517517    // search for the neighbor in the given direction
    518518    //
    519     int i;
    520     for (i=0; i<pix.GetNumNeighbors(); i++)
     519    for (int i=0; i<pix.GetNumNeighbors(); i++)
    521520        if (GetDirection(idx, pix.GetNeighbor(i))==dir)
    522521            return pix.GetNeighbor(i);
  • trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.h

    r9148 r9219  
    1 #ifndef MARS_MGeomCamDwqarf
     1#ifndef MARS_MGeomCamDwarf
    22#define MARS_MGeomCamDwarf
    33
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.cc

    r8923 r9219  
    5555
    5656#include <TMath.h>
     57#include <TVector2.h>
    5758
    5859#include "MLog.h"
     
    7778    Set(x, y, r, s, a);
    7879    SetNeighbors();
     80}
     81
     82// --------------------------------------------------------------------------
     83//
     84// Return position as TVector2(fX, fY)
     85//
     86TVector2 MGeomPix::GetP() const
     87{
     88    return TVector2(fX, fY);
    7989}
    8090
     
    186196    // more, rotated with respect to that one by +- 60 degrees.
    187197    //
    188     if (TMath::Abs(dx)*2>fD)
     198    if (TMath::Abs(dx)>fD/2)
    189199        return kFALSE;
    190200
     
    194204    const static Double_t sin60 = TMath::Sin(60/kRad2Deg);
    195205
    196     const Double_t dx2 = dx*cos60 + dy*sin60;
    197     if  (TMath::Abs(dx2)*2>fD)
     206    const Double_t dxc = dx*cos60;
     207    const Double_t dys = dy*sin60;
     208
     209    if  (TMath::Abs(dxc + dys)>fD/2)
    198210        return kFALSE;
    199211
    200     const Double_t dx3 = dx*cos60 - dy*sin60;
    201     if (TMath::Abs(dx3)*2>fD)
     212    if (TMath::Abs(dxc - dys)>fD/2)
    202213        return kFALSE;
    203214
     
    218229    const Double_t y2 = pix.GetY();
    219230
    220     if (x1>=x2 && y1>y2) return kRightTop;
    221     if (x1>=x2 && y1<y2) return kRightBottom;
    222     if (x1<=x2 && y1>y2) return kLeftTop;
    223     if (x1<=x2 && y1<y2) return kLeftBottom;
    224     if (x1>x2)           return kRight;
    225     if (x1<x2)           return kLeft;
     231    if (x1<=x2 && y1<y2) return kRightTop;
     232    if (x1<=x2 && y1>y2) return kRightBottom;
     233    if (x1>=x2 && y1<y2) return kLeftTop;
     234    if (x1>=x2 && y1>y2) return kLeftBottom;
     235    if (x1<x2)           return kRight;
     236    if (x1>x2)           return kLeft;
     237
     238    cout << -1 << endl;
    226239
    227240    return -1;
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r8923 r9219  
    77
    88class MGeomCam;
     9class TVector2;
    910
    1011class MGeomPix : public MParContainer
     
    7778    UInt_t  GetSector() const { return fSector; }
    7879
     80    TVector2 GetP() const;
     81
    7982    Float_t GetDist() const;
    8083    Float_t GetDist(const MGeomPix &pix) const;
  • trunk/MagicSoft/Mars/mmain/MEventDisplay.cc

    r9017 r9219  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.65 2008-07-20 14:21:39 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MEventDisplay.cc,v 1.66 2009-01-14 12:31:36 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    334334        MCalibrationPatternDecode *decode = new MCalibrationPatternDecode;
    335335
    336         MPedestalSubtract *pedsub1  = new MPedestalSubtract;
    337         MPedestalSubtract *pedsub2  = new MPedestalSubtract;
     336        MPedestalSubtract *pedsub1  = new MPedestalSubtract("PedSubstract1");
     337        MPedestalSubtract *pedsub2  = new MPedestalSubtract("PedSubstract2");
    338338        pedsub2->SetNamePedestalCam();
    339339
     
    678678void MEventDisplay::ShowHide()
    679679{
    680     TGCheckButton *but1 = (TGCheckButton*)fList->FindWidget(kShowMuon);
    681     TGCheckButton *but2 = (TGCheckButton*)fList->FindWidget(kShowImgPar);
     680    TGCheckButton *but1 = (TGCheckButton*)fList->FindWidget(kShowImgPar);
     681    TGCheckButton *but2 = (TGCheckButton*)fList->FindWidget(kShowMuon);
    682682
    683683    const Bool_t imgpar = but1 && but1->IsDown();
     
    722722        for (int j=0;j<n; j++)
    723723            if (obj[j])
     724            {
    724725                if (state[j] && !list->FindObject(obj[j]))
    725726                    list->Add(obj[j]);
    726                 else
     727                if (!state[j] && list->FindObject(obj[j]))
    727728                    list->Remove(obj[j]);
     729            }
    728730
    729731        gPad->Modified(kTRUE);
     
    744746
    745747    //
    746     // Add Geometry tab
     748    // Now read event...
     749    //
     750    // FIXME: Can we safely replace ReadinEvent() by RedinEvent(1)?
     751    ReadinEvent();
     752
     753    //
     754    // After ReInit (MGeomCam might be read from RunHeaders): Add Geometry tab
    747755    //
    748756    AddGeometryTabs();
    749 
    750     //
    751     // Now read event...
    752     //
    753     // FIXME: Can we safly replace ReadinEvent() by RedinEvent(1)?
    754     ReadinEvent();
    755 
    756757
    757758    MReadTree *reader = (MReadTree*)fEvtLoop->FindTask("MRead");
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h

    r8571 r9219  
    3030    UShort_t  fNumEntry;
    3131
    32     Byte_t fNumBytesHiGain;   //!
    33     Byte_t fNumBytesLoGain;   //!
     32    UInt_t fNumBytesHiGain;   //!
     33    UInt_t fNumBytesLoGain;   //!
    3434
    3535    UShort_t fNumBytesPerSample; //!
     
    7979    }
    8080
    81     Byte_t GetNumBytes() const { return fNumBytesHiGain+fNumBytesLoGain; }
     81    UInt_t GetNumBytes() const { return fNumBytesHiGain+fNumBytesLoGain; }
    8282
    8383    Bool_t HasLoGain() const { return fNumBytesLoGain>0; }
  • trunk/MagicSoft/Mars/mraw/MRawRunHeader.h

    r9212 r9219  
    107107    void SetObservation(const char mode[60], const char proj[100]);
    108108    void SetNumEvents(UInt_t num);
     109    void SetValidMagicNumber() { fMagicNumber=kMagicNumber; }
    109110
    110111    // This is to get the numbers...
  • trunk/MagicSoft/Mars/readraw.cc

    r9141 r9219  
    105105
    106106    //
     107    // Initialize Non-GUI (batch) mode
     108    //
     109    gROOT->SetBatch();
     110
     111    //
    107112    // This is to make argv[i] more readable insidethe code
    108113    //
    109114    TString kNamein = arg.GetArgumentStr(0);
    110115 
    111     if (!kNamein.EndsWith(".root"))
    112         kNamein += ".root";
    113 
    114     //
    115     // Initialize Non-GUI (batch) mode
    116     //
    117     gROOT->SetBatch();
    118 
    119116    //
    120117    // check whether the given files are OK.
     
    122119    if (gSystem->AccessPathName(kNamein, kFileExists))
    123120    {
    124         gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
    125         return 2;
     121        if (!kNamein.EndsWith(".root"))
     122            kNamein += ".root";
     123
     124        if (gSystem->AccessPathName(kNamein, kFileExists))
     125        {
     126            gLog << err << "Sorry, the input file '" << kNamein << "' doesn't exist." << endl;
     127            return 2;
     128        }
    126129    }
    127130
  • trunk/MagicSoft/include-Classes/MMcFormat/MMcEvtBasic.h

    r8765 r9219  
    1212    enum ParticleId_t
    1313    {
    14         kUNDEFINED = -1,
    15         kGAMMA     =  1,
    16         kPOSITRON  =  2,
    17         kELECTRON  =  3,
    18         kANTIMUON  =  5,
    19         kMUON      =  6,
    20         kPI0       =  7,
    21         kNEUTRON   = 13,
    22         kPROTON  =   14,
    23         kHELIUM  =  402,
    24         kOXYGEN  = 1608,
    25         kIRON    = 5626
     14        kUNDEFINED  = -1,
     15        kGAMMA      =  1,
     16        kPOSITRON   =  2,
     17        kELECTRON   =  3,
     18        kANTIMUON   =  5,
     19        kMUON       =  6,
     20        kPI0        =  7,
     21        kNEUTRON    = 13,
     22        kPROTON   =   14,
     23        kHELIUM   =  402,
     24        kOXYGEN   = 1608,
     25        kIRON     = 5626,
     26        kNightSky = 9999
    2627    };
    2728
     
    6566      case kOXYGEN:   return "Oxygen";
    6667      case kIRON:     return "Iron";
     68      case kNightSky: return "NSB";
    6769      }
    6870
     
    8688      case kOXYGEN:   return "O";
    8789      case kIRON:     return "Fe";
     90      case kNightSky: return "\\gamma_{NSB}";
    8891      }
    8992
Note: See TracChangeset for help on using the changeset viewer.