Changeset 4358 for trunk/MagicSoft


Ignore:
Timestamp:
06/28/04 16:34:45 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/macros/starfield.C

    r4343 r4358  
     1/* ======================================================================== *\
     2!
     3! *
     4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
     5! * Software. It is distributed to you in the hope that it can be a useful
     6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
     7! * It is distributed WITHOUT ANY WARRANTY.
     8! *
     9! * Permission to use, copy, modify and distribute this software and its
     10! * documentation for any purpose is hereby granted without fee,
     11! * provided that the above copyright notice appear in all copies and
     12! * that both that copyright notice and this permission notice appear
     13! * in supporting documentation. It is provided "as is" without express
     14! * or implied warranty.
     15! *
     16!
     17!
     18!   Author(s): Thomas Bretz 5/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!
     20!   Copyright: MAGIC Software Development, 2000-2004
     21!
     22!
     23\* ======================================================================== */
     24
     25///////////////////////////////////////////////////////////////////////////
     26//
     27// starfield.C
     28// ===========
     29//
     30// This is a macro demonstrating how to use Mars to display a starfield.
     31// It also is a tutorial for MAstroCatalog and MAstroCamera.
     32//
     33// For more details on this classes see the class-reference.
     34//
     35// If you want to display stars in a camera you need the camera geometry
     36// and the mirror definition. You can get this either from a Monte Carlo
     37// file containing both or create your MGeomCam object manually and
     38// read a magic.def file which you will find in the camera simulation
     39// program.
     40//
     41///////////////////////////////////////////////////////////////////////////
     42
    143void ReadSetup(TString fname, MAstroCamera &cam)
    244{
     
    1355    cam.SetMirrors(*config->GetMirrors());
    1456    cam.SetGeom(*geom);
     57
     58    /* Alternative:
     59
     60     MGeomCamMagic geom;
     61     cam.SetGeom(geom);
     62     cam.SetMirrors("magic.def");
     63     */
    1564}
    1665
  • trunk/MagicSoft/Mars/mastro/MAstroCatalog.cc

    r4213 r4358  
    3030//  THIS IMPLEMENTATION IS PRELIMINARY AND WILL BE MERGED WITH
    3131//  SOME PARTS OF THE DRIVE SOFTWARE SOON!
     32//
     33//
     34//  Catalogs:
     35//  ---------
     36//
     37//  To be able to use this class you need a catalog file suppored by
     38//  MAstroCatalog.
     39//  Catalog files can be found at
     40//  http://magic.astro.uni-wuerzburg.de/mars/catalogs.html
     41//  You must copy the file into the directory from which you start your macro
     42//  or give an abolute path loading the catalog.
    3243//
    3344//
     
    106117//   - a derived class is missing which supports all astrometrical
    107118//     correction (base on slalib and useable in Cosy)
     119//   - Implement a general loader for heasarc catlogs, see
     120//     http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
    108121//
    109122//////////////////////////////////////////////////////////////////////////////
     
    517530// to a file outname. This files will contain an apropriate compressed
    518531// file format. You can read such files again using ReadCompressed.
     532//
     533// FIXME: A General loader for heasarc catlogs is missing, see
     534//        http://heasarc.gsfc.nasa.gov/W3Browse/star-catalog/
    519535//
    520536Int_t MAstroCatalog::ReadHeasarcPPM(TString catalog, TString outname)
  • trunk/MagicSoft/Mars/mbase/MTime.cc

    r3969 r4358  
    7777
    7878#include "MLog.h"
     79#include "MLogManip.h"
     80
    7981#include "MAstro.h"
    8082
     
    504506    GetTime(h, m, s, ms);
    505507
    506     *fLog << GetDescriptor() << ": ";
     508    *fLog << all << GetDescriptor() << ": ";
    507509    *fLog << GetString() << Form(" (+%dns)", fNanoSec) << endl;
    508510}
  • trunk/MagicSoft/Mars/mfit/MTFitLoop.cc

    r3582 r4358  
    4747#include "MTFitLoop.h"
    4848
     49#include <TArrayD.h>
    4950#include <TMinuit.h>
    5051#include <TStopwatch.h>
    5152
    5253#include "MParList.h"
     54#include "MTaskList.h"
     55#include "MEvtLoop.h"
     56
     57#include "MParameters.h"
     58
    5359#include "MRead.h"
    54 #include "MEvtLoop.h"
    5560
    5661#include "MLog.h"
    5762#include "MLogManip.h"
     63
     64ClassImp(MTFitLoop);
     65
     66using namespace std;
    5867
    5968//------------------------------------------------------------------------
     
    7483    MParList *plist = fEvtLoop->GetParList();
    7584
    76     MParameterD   *eval = (MParameterD*)plist->FindCreateObj("MParameterD", fFitParameter);
    77     MParContainer *pars = plist->FindObject(fParametersName);
     85    MParameterD   *eval = (MParameterD*)  plist->FindCreateObj("MParameterD", fFitParameter);
     86    MParContainer *pars = (MParContainer*)plist->FindObject(fParametersName);
    7887
    7988    MRead *read = (MRead*)plist->FindObject("MTaskList")->FindObject("MRead");
     
    104113    if (fDebug>=0)
    105114    {
    106         *fLog << inf << "Set: ";
    107         for (Int_t i=0; i<7; i++)
     115        *fLog << inf << "Set(" << gMinuit->fMaxpar << "): ";
     116        for (Int_t i=0; i<gMinuit->fMaxpar; i++)
    108117            *fLog << par[i] << " ";
    109118        *fLog << endl;
     
    129138}
    130139
    131 MTFitLoop::MTFitLoop()
     140MTFitLoop::MTFitLoop(Int_t num) : fNum(num), fMaxIterations(1000)
    132141{
    133142    fDebug     = -1;
     
    135144}
    136145
    137 void MTFitLoop::Optimize(MEvtLoop &loop)
     146void MTFitLoop::Optimize(MEvtLoop &loop, TArrayD &pars)
    138147{
    139148    *fLog << inf << "Event loop was setup" << endl;
    140     MParList *parlist = loop->GetParList();
     149    MParList *parlist = loop.GetParList();
    141150    if (!parlist)
    142151        return;
    143152
    144     MParContainer *pars = plist->FindObject(fParametersName);
    145     if (!pars)
    146         return;
    147 
    148     fEvtLoop = evtloop;
    149 
    150     MParContainer &parameters = *pars;
     153//    MParContainer *pars = (MParContainer*)parlist->FindObject(fParametersName);
     154//    if (!pars)
     155//        return;
     156
     157    fEvtLoop = &loop;
     158
     159//    MParContainer &parameters = *pars;
    151160
    152161    TMinuit *minsave = gMinuit;
    153162
    154     gMinuit = new TMinuit(parameters.GetSize());
     163    gMinuit = new TMinuit(pars.GetSize());
    155164    gMinuit->SetPrintLevel(-1);
     165    gMinuit->SetMaxIterations(fMaxIterations);
    156166
    157167    gMinuit->SetFCN(fcn);
     
    164174     // less than 0.001*[tolerance]*UP (see [SET ERRordef]).");
    165175     //
    166     if (gMinuit->SetErrorDef(1000))
     176    if (gMinuit->SetErrorDef(1))
    167177    {
    168178        *fLog << err << dbginf << "SetErrorDef failed." << endl;
     
    173183    // Set starting values and step sizes for parameters
    174184    //
    175     for (Int_t i=0; i<parameters.GetSize(); i++)
     185    for (Int_t i=0; i<pars.GetSize(); i++)
    176186    {
    177187        TString name = "par[";
    178188        name += i;
    179189        name += "]";
    180         Double_t vinit = parameters[i];
    181         Double_t step  = fabs(parameters[i]/3);
     190        Double_t vinit = pars[i];
     191        Double_t step  = fabs(pars[i]/3);
    182192
    183193        Double_t limlo = 0; // limlo=limup=0: no limits
     
    192202    }
    193203
    194     for (int i=0; i<parameters.GetSize(); i++)
    195         if (i<fFixParams.GetSize() && fFixParams[i]!=0)
     204    for (int i=0; i<pars.GetSize() && i<fFixedParams.GetSize(); i++)
     205        if (fFixedParams[i]!=0)
    196206            gMinuit->FixParameter(i);
    197         else
    198             gMinuit->Release(i);
    199207
    200208    // Now ready for minimization step:
     
    217225    // Update values of fA, fB:
    218226    //
    219     for (Int_t i=0; i<parameters.GetSize(); i++)
     227    for (Int_t i=0; i<pars.GetSize(); i++)
    220228    {
    221229        Double_t x1, x2;
    222230        gMinuit->GetParameter(i,x1,x2);
    223         parameters[i] = x1;
    224         cout << i << ": " << parameters[i] << endl;
    225     }
    226 
    227     list.SetVariables(parameters);
     231        pars[i] = x1;
     232        cout << i << ": " << pars[i] << endl;
     233    }
     234
     235    //list.SetVariables(pars);
    228236
    229237    gMinuit = minsave;
  • trunk/MagicSoft/Mars/mfit/MTFitLoop.h

    r3582 r4358  
    2828    TArrayC   fFixedParams;
    2929
     30    Int_t fNum;
     31    Int_t fMaxIterations;
     32
    3033public:
    31     MTFitLoop();
     34    MTFitLoop(const Int_t num=0);
    3235
    33     void Optimize(MEvtLoop &loop);
     36    void Optimize(MEvtLoop &loop, TArrayD &pars);
    3437
    3538    void SetNameParameters(const char *parm) { fParametersName = parm; }
     
    3740
    3841    void SetFixedParameters(const TArrayC &c) { fFixedParams = c; }
     42    void SetMaxIterations(Int_t maxiter=500) {fMaxIterations = maxiter;} // for debugging
    3943
    4044    void SetDebug(Int_t n)     { fDebug = n; }
  • trunk/MagicSoft/Mars/mhist/MHFalseSource.cc

    r3788 r4358  
    233233{
    234234    return MMath::SignificanceLiMaSigned(s, b);
    235     /*
    236      const Double_t lima = MMath::SignificanceLiMa(s, b);
    237      return lima<0 ? 0 : lima;
    238      */
    239235}
    240236
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.cc

    r4022 r4358  
    525525// --------------------------------------------------------------------------
    526526//
    527 // Make sure, that you skip the whole event. This function only skips a part
    528 // of the event - see MRawRead::SkipEvent
    529 //
    530 void MRawEvtData::SkipEvt(istream &fin)
     527// Return the size in bytes of one event data block
     528//
     529Int_t MRawEvtData::GetNumBytes() const
    531530{
    532531    const UShort_t nlo  = fRunHeader->GetNumSamplesLoGain();
     
    534533    const UShort_t npic = fRunHeader->GetNumPixInCrate();
    535534
    536     fin.seekg((nhi+nlo)*npic, ios::cur);
     535    return (nhi+nlo)*npic;
     536}
     537
     538// --------------------------------------------------------------------------
     539//
     540// Make sure, that you skip the whole event. This function only skips a part
     541// of the event - see MRawRead::SkipEvent
     542//
     543void MRawEvtData::SkipEvt(istream &fin)
     544{
     545    fin.seekg(GetNumBytes(), ios::cur);
    537546}
    538547
  • trunk/MagicSoft/Mars/mraw/MRawEvtData.h

    r3800 r4358  
    4343    void InitArrays(Bool_t flag=kFALSE);
    4444    void DeleteArrays();
     45
     46    Int_t GetNumBytes() const;
    4547
    4648public:
Note: See TracChangeset for help on using the changeset viewer.