Changeset 9186 for trunk


Ignore:
Timestamp:
12/02/08 11:23:24 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9185 r9186  
    2323   * mbase/MStatusDisplay.[h,cc], mbase/MEvtLoop.cc:
    2424     - added Pause and Single Step option
     25
     26   * mcorsika/MCorsikaEvtHeader.[h,cc], mcorsika/MCorsikaRead.[h,cc].,
     27     mcorsika/MCorsikaRunHeader.[h,cc]:
     28     - moved filling of run header from first event header to
     29       MCorsikaRunHeader
     30
     31   * mfileio/MWriteRootFile.cc:
     32     - improved a check in the constructor if no filename is given
     33
     34   * mhbase/MH.cc:
     35     - make SetBinning also work for TProfile2D
     36
     37   * mhist/MHCamera.[h,cc]:
     38     - added functions to return the number of used pixels
     39
     40   * mjobs/MDataSet.cc, mjobs/MSequence.cc:
     41     - improved by using new GetEnvValue3
     42
     43   * mbase/MParContainer.[h,cc]:
     44     - added new member function GetEnvValue3 which is more flexible
     45       in the number of leading zeroes within a resource name
    2546
    2647
  • trunk/MagicSoft/Mars/NEWS

    r9181 r9186  
    4949     displayed values. (tabs.php) These plots are linked from the DB
    5050     websites and the wiki.
     51
     52 ;statusdisplay
     53
     54   * The ''Loop'' entry in the menu bar now contains an option to pause
     55     the loop and to process single events.
    5156
    5257 ;merpp
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r9025 r9186  
    10901090// --------------------------------------------------------------------------
    10911091//
     1092// This is a wrapper which checks the resource file for an id containing
     1093// a %d with different numbers of leading zeros (1 to 8).
     1094//
     1095// If athe entries in the resource file are not unambiguous a warning
     1096// is printed.
     1097//
     1098TString MParContainer::GetEnvValue3(const TEnv &env, const TString &prefix, TString id, UInt_t num) const
     1099{
     1100    id.ReplaceAll("%d", "%%0%dd");
     1101
     1102    TString rc;
     1103    for (int i=1; i<9; i++)
     1104    {
     1105        const TString form = Form(id.Data(), i);
     1106        const TString res  = Form(form.Data(), num);
     1107
     1108        const TString str  = GetEnvValue2(env, prefix, res, "");
     1109
     1110        if (str.IsNull())
     1111            continue;
     1112
     1113        if (rc.IsNull())
     1114            rc = str;
     1115        else
     1116            *fLog << warn << "Entry " << res << " ambigous (was also found with less leading zeros)... ignored." << endl;
     1117    }
     1118
     1119    return rc;
     1120}
     1121
     1122// --------------------------------------------------------------------------
     1123//
    10921124// If object to remove is fDisplay set fDisplay to NULL.
    10931125// If object to remove is fLog     set fLog     to NULL.
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r9035 r9186  
    149149    const char *GetEnvValue2(const TEnv &env, const TString &prefix, const TString &postfix, const char *dflt, Bool_t print=kFALSE) const;
    150150
     151    TString     GetEnvValue3(const TEnv &env, const TString &prefix, TString id, UInt_t num) const;
     152
    151153    MParContainer *GetNewObject(const char *name, const char *base) const;
    152154    MParContainer *GetNewObject(const char *name, TClass *base=MParContainer::Class()) const;
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.cc

    r9182 r9186  
    3737
    3838#include "MMcEvt.hxx"
    39 #include "MCorsikaRunHeader.h"
    4039
    4140ClassImp(MCorsikaEvtHeader);
     
    7877// return FALSE if there is no  header anymore, else TRUE
    7978//
    80 Int_t MCorsikaEvtHeader::ReadEvt(std::istream &fin, MCorsikaRunHeader &header)
     79Int_t MCorsikaEvtHeader::ReadEvt(std::istream &fin)
    8180{
    8281    char evth[4];
     
    125124    fX =  f[117];
    126125    fY = -f[97];
    127 
     126/*
    128127    if (fEvtNumber==1)
    129128    {
     
    138137        header.Print();
    139138    }
    140 
     139 */
    141140    fin.seekg(1088-273*4, ios::cur);
    142141
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaEvtHeader.h

    r9182 r9186  
    1313//class ifstream;
    1414#include <iosfwd>
    15 
    16 class MCorsikaRunHeader;
    1715
    1816class MCorsikaEvtHeader : public MParContainer
     
    5755    Float_t GetY() const { return fY; }
    5856
    59     Int_t ReadEvt(istream& fin, MCorsikaRunHeader &header);    // read in event header block
     57    Int_t  ReadEvt(istream& fin);    // read in event header block
    6058    Bool_t ReadEvtEnd(istream& fin); // read in event end block
    6159
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaRead.cc

    r9182 r9186  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2007
     18!   Author(s): Thomas Bretz  11/2008 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: Software Development, 2000-2008
    2121!
    2222!
     
    2626//
    2727//  MCorsikaRead
    28 //
    29 //  This tasks reads the raw binary file like specified in the TDAS???
    30 //  and writes the data in the corresponding containers which are
    31 //  either retrieved from the parameter list or created and added.
    32 //
    33 //  Use SetInterleave() if you don't want to read all events, eg
    34 //    SetInterleave(5) reads only each 5th event.
    3528//
    3629//  Input Containers:
     
    3831//
    3932//  Output Containers:
    40 //   MCorsikaRunHeader, MCorsikaEvtHeader, MCorsikaEvtData, MCorsikaCrateArray, MCorsikaEvtTime
     33//   MCorsikaRunHeader
     34//   MCorsikaEvtHeader
     35//   MPhotonEvent
    4136//
    4237//////////////////////////////////////////////////////////////////////////////
     
    5146#include "MLogManip.h"
    5247
    53 //#include "MZlib.h"
    54 //#include "MTime.h"
    5548#include "MParList.h"
    5649#include "MStatusDisplay.h"
     
    5952#include "MCorsikaEvtHeader.h"
    6053
    61 //#include "MPhotonData.h"
    6254#include "MPhotonEvent.h"
    6355
     
    10395//
    10496MCorsikaRead::MCorsikaRead(const char *fname, const char *name, const char *title)
    105     : fRunHeader(0), fEvtHeader(0), fEvent(0), fEvtData(0), fForceMode(kFALSE),
     97    : fRunHeader(0), fEvtHeader(0), fEvent(0), /*fEvtData(0),*/ fForceMode(kFALSE),
    10698    fFileNames(0), fNumFile(0), fNumEvents(0), fNumTotalEvents(0),
    10799    fIn(0), fParList(0)
     
    212204
    213205    const char *expname = gSystem->ExpandPathName(name);
    214     fIn = new fstream(expname);
     206    fIn = new ifstream(expname);
    215207
    216208    const Bool_t noexist = !(*fIn);
     
    245237    if (!fRunHeader->ReadEvt(*fIn))
    246238        return kERROR;
    247 
    248     if (!(*fIn))
    249     {
    250         *fLog << err << "Error: Accessing file '" << name << "'" << endl;
    251         return kERROR;
    252     }
     239//    if (!fEvtHeader->ReadRunHeader(*fIn, *fRunHeader))
     240//        return kERROR;
    253241
    254242    const streampos pos = fIn->tellg();
    255 
    256243    if (!ReadEvtEnd())
    257244        return kERROR;
    258 
    259245    fIn->seekg(pos, ios::beg);
    260246
     
    267253    //  We print it after the first event was read because
    268254    //  we still miss information which is stored in the event header?!?
    269     //if (print)
    270     //    fRunHeader->Print();
     255    if (print)
     256        fRunHeader->Print();
    271257
    272258    if (!fParList)
     
    386372        return kFALSE;
    387373
    388     fEvtData = (MPhotonData*)pList->FindCreateObj("MPhotonData");
    389     if (!fEvtData)
    390         return kFALSE;
    391 
    392374    fEvent = (MPhotonEvent*)pList->FindCreateObj("MPhotonEvent");
    393375    if (!fEvent)
    394376        return kFALSE;
    395377
    396     //*fLog << inf << "Maintaining " << fEvent->GetClassName() << " found in MCorsikaEvent." << endl;
    397 
    398378    *fLog << inf << "Calculating number of total events..." << flush;
    399379    if (!CalcNumTotalEvents())
     
    419399    // if there is no next event anymore stop eventloop
    420400    //
    421     Int_t rc = fEvtHeader->ReadEvt(fin, *fRunHeader); //read event header block
     401    Int_t rc = fEvtHeader->ReadEvt(fin); //read event header block
    422402    if (!rc)
    423403        return kFALSE;
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaRead.h

    r9182 r9186  
    1212class MCorsikaRunHeader;
    1313class MCorsikaEvtHeader;
    14 class MPhotonData;
    1514class MPhotonEvent;
    1615
     
    1817{
    1918private:
    20     MCorsikaRunHeader  *fRunHeader;  // run header information container to fill from file
    21     MCorsikaEvtHeader  *fEvtHeader;  // event header information container to fill from file
     19    MCorsikaRunHeader *fRunHeader;  // run header information container to fill from file
     20    MCorsikaEvtHeader *fEvtHeader;  // event header information container to fill from file
    2221    MPhotonEvent      *fEvent;      // event information
    23     MPhotonData       *fEvtData;    // raw evt data information container to fill from file
    2422
    25     Bool_t          fForceMode;     // Force mode skipping defect events
     23    Bool_t          fForceMode;     // Force mode skipping defect RUNE
    2624
    2725    TList    *fFileNames;      // list of file names
     
    3028    UInt_t    fNumTotalEvents; //! total number of events in all files
    3129
    32     fstream *fIn;             //! input stream (file to read from)
     30    ifstream *fIn;             //! input stream (file to read from)
    3331
    3432    MParList *fParList;        //! tasklist to call ReInit from
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.cc

    r9182 r9186  
    170170    fin.seekg(1020, ios::cur);     // skip the remaining data of this block
    171171
    172     return kTRUE;
     172    // -------------------- Read first event header -------------------
     173
     174    char evth[4];
     175    fin.read(evth, 4);
     176    if (memcmp(evth, "EVTH", 4))
     177    {
     178        *fLog << err << "ERROR - Wrong identifier: EVTH expected." << endl;
     179        return kFALSE;
     180    }
     181
     182    Float_t g[273];
     183    fin.read((char*)&g, 273*4);
     184    if (fin.eof())
     185        return kFALSE;
     186
     187    fin.seekg(-274*4, ios::cur);
     188
     189    const Int_t n = TMath::Nint(g[96]);
     190    if (n!=1)
     191    {
     192        *fLog << err << "ERROR - Currently only one impact parameter per event is supported." << endl;
     193        return kFALSE;
     194    }
     195
     196    //fImpactMax = g[86];
     197
     198    fZdMin = g[79];
     199    fZdMax = g[80];
     200    fAzMin = 180-g[81];
     201    fAzMax = 180-g[82];
     202
     203    fViewConeInnerAngle = g[151];
     204    fViewConeOuterAngle = g[152];
     205
     206    return kTRUE;;
    173207}
    174208
  • trunk/MagicSoft/Mars/mcorsika/MCorsikaRunHeader.h

    r9182 r9186  
    3333    Float_t  fAzMax;                     // [rad] Azimuth (north=0; west=90)
    3434
     35    //Float_t  fImpactMax;              // [cm] Maximum simulated impact
     36
    3537    Float_t fViewConeInnerAngle;      // [deg]
    3638    Float_t fViewConeOuterAngle;      // [deg]
     
    4850    Float_t GetAzMax() const { return fAzMax; }
    4951
     52    //Float_t GetImpactMax() const { return fImpactMax; }
     53
     54    Float_t GetViewConeOuterAngle() const { return fViewConeOuterAngle; }
     55
    5056    UInt_t GetNumEvents() const { return fNumEvents; }
    5157
  • trunk/MagicSoft/Mars/mfileio/MWriteRootFile.cc

    r9036 r9186  
    224224    // If no name is given we open the TFile in some kind of dummy mode...
    225225    //
    226     if (!fname)
     226    TString str(fname);
     227    if (str.IsNull())
    227228    {
    228229        fOut = new TFile("/dev/null", "READ", ftitle, comp);
     
    231232    }
    232233
    233     TString str(fname);
    234234    if (!str.EndsWith(".root", TString::kIgnoreCase))
    235235        str += ".root";
  • trunk/MagicSoft/Mars/mhbase/MH.cc

    r9153 r9186  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.40 2008-11-11 11:42:13 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.41 2008-12-02 11:22:15 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    352352    y.SetTimeFormat(tfy);
    353353#else
    354     h->SetBins(bx.GetNumBins(), bx.GetEdges(),
    355                by.GetNumBins(), by.GetEdges());
     354    if (h->InheritsFrom(TProfile2D::Class()))
     355    {
     356        h->SetBins(bx.GetNumBins(), 0, 1,
     357                   by.GetNumBins(), 0, 1);
     358
     359        h->SetBinsLength();
     360
     361        x.Set(bx.GetNumBins(), bx.GetEdges());
     362        y.Set(by.GetNumBins(), by.GetEdges());
     363    }
     364    else
     365        h->SetBins(bx.GetNumBins(), bx.GetEdges(),
     366                   by.GetNumBins(), by.GetEdges());
    356367#endif
    357368
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r8988 r9186  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.109 2008-06-30 09:36:38 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.110 2008-12-02 11:22:19 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    363363}
    364364
     365UInt_t MHCamera::GetNumUsedSector(const TArrayI &sector, const TArrayI &aidx) const
     366{
     367    if (fNcells<=1)
     368        return 0;
     369
     370    Int_t n=0;
     371 
     372    for (int i=0; i<fNcells-2; i++)
     373    {
     374        if (!IsUsed(i) || !MatchSector(i, sector, aidx))
     375            continue;
     376
     377        if (TestBit(kProfile) && fBinEntries[i+1]==0)
     378            continue;
     379        n++;
     380    }
     381
     382    // return Median of the profile data
     383    return n;
     384}
     385
    365386// ------------------------------------------------------------------------
    366387//
  • trunk/MagicSoft/Mars/mhist/MHCamera.h

    r8988 r9186  
    11/* ======================================================================== *\
    2 !  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.65 2008-06-30 09:36:38 tbretz Exp $
     2!  $Name: not supported by cvs2svn $:$Id: MHCamera.h,v 1.66 2008-12-02 11:22:19 tbretz Exp $
    33\* ======================================================================== */
    44#ifndef MARS_MHCamera
     
    133133    void   SetUsed(Int_t idx)      { SETBIT(fUsed[idx], kIsUsed); }
    134134    void   SetAllUsed()            { fUsed.Reset(BIT(kIsUsed)); }
     135
     136    UInt_t GetNumUsedSector(const TArrayI &sector, const TArrayI &aidx) const;
     137    UInt_t GetNumUsed() const { return GetNumUsedSector(TArrayI(), TArrayI()); }
     138    UInt_t GetNumUsedSector(Int_t sector, Int_t aidx) const
     139    {
     140        return GetNumUsedSector(TArrayI(1, &sector), TArrayI(1, &aidx));
     141    }
     142
    135143
    136144    Int_t Fill(Axis_t x, Axis_t y, Stat_t w);
  • trunk/MagicSoft/Mars/mjobs/MDataSet.cc

    r9017 r9186  
    291291    for (int i=0; i<num.GetSize(); i++)
    292292    {
    293         const TString seqid = Form("Sequence%08d", num[i]);
    294 
    295         TString name = GetEnvValue2(env, prefix, Form("%s.File",    seqid.Data()), "");
    296         TString dir  = GetEnvValue2(env, prefix, Form("%s.Dir",     seqid.Data()), "");
    297         TString excl = GetEnvValue2(env, prefix, Form("%s.Exclude", seqid.Data()), "");
     293        TString name = GetEnvValue3(env, prefix, "Sequence%d.File",    num[i]);
     294        TString dir  = GetEnvValue3(env, prefix, "Sequence%d.Dir",     num[i]);
     295        TString excl = GetEnvValue3(env, prefix, "Sequence%d.Exclude", num[i]);
    298296
    299297        // Set default sequence file and dir name
  • trunk/MagicSoft/Mars/mjobs/MSequence.cc

    r9057 r9186  
    300300    TPRegexp regexp("([0-9]*:[0-9]+|[0-9]+(:[0-9]*)?)( +|$)");
    301301
    302     TString files = GetEnvValue2(*env, prefix, Form("Run%08d", run), "");
     302    TString files = GetEnvValue3(*env, prefix, "Run%d", run);
    303303    if (files.IsNull())
    304304    {
Note: See TracChangeset for help on using the changeset viewer.