Changeset 9578 for trunk


Ignore:
Timestamp:
05/05/10 09:51:51 (15 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r9576 r9578  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2010/05/05 Thomas Bretz
     22
     23   * mastro/MAstro.cc:
     24     - fixed AngularDistance (called a non existing function and
     25       the compiler didn't complain)
     26
     27   * mbase/MParContainer.[h,cc]:
     28     - added static function Overwrites (previously in MTask)
     29
     30   * mbase/MStatusDisplay.[h,cc]:
     31     - allow writing a MStatusDisplay without writing a MStatusArray
     32       (therefore added SeveAsPlainRoot)
     33     - improved reading of files just containing canvases and objects
     34
     35   * mbase/MTask.[h,cc]:
     36     - moved code from Overwrites to a static function in MParContainer
     37
     38   * msimcamera/MSimCalibrationSignal.cc:
     39     - changed distribution of signal from Gauss to Poissonian
     40
    2041
    2142 2010/04/22 Thomas Bretz
  • trunk/MagicSoft/Mars/mastro/MAstro.cc

    r9314 r9578  
    376376Double_t MAstro::AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1)
    377377{
    378     TVector3 v0(1);
    379     v0.Rotate(phi0, theta0);
    380 
    381     TVector3 v1(1);
    382     v1.Rotate(phi1, theta1);
    383 
    384     return v0.Angle(v1);
     378    // v1 = theta0/phi0 --> theta0 / 0
     379    // v2 = theta1/phi1 --> theta1 / phi1-phi0
     380    // acos(alpha) = v1*v2/|v1||v2|    |v1|*|v2|=1
     381    const Double_t sin2 = TMath::Sin(theta0)*TMath::Sin(theta1);
     382    const Double_t cos2 = TMath::Cos(theta0)*TMath::Cos(theta1);
     383
     384    return TMath::ACos(sin2*TMath::Cos(phi1-phi0) + cos2);
     385    /*
     386     TVector3 v0;
     387     v0.SetMagThetaPhi(1, theta0, phi0);
     388
     389     TVector3 v1;
     390     v1.SetMagThetaPhi(1, theta0, phi0);
     391
     392     return v0.Angle(v1);
     393     */
    385394}
    386395
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r9302 r9578  
    237237// --------------------------------------------------------------------------
    238238//
     239// Check down to base whether the class given in the argument
     240// overwrites the function given by name.
     241//
     242// This function calls itself recursively. If you want to call it,
     243// leave out the argument.
     244//
     245Bool_t MParContainer::Overwrites(const TClass *base, const TObject &obj, const char *name, TClass *cls)
     246{
     247    if (!cls)
     248        cls = obj.IsA();
     249
     250    //
     251    // Check whether we reached the base class MTask
     252    //
     253    if (cls==base)
     254        return kFALSE;
     255
     256    //
     257    // Check whether the class cls overwrites Process
     258    //
     259    if (cls->GetMethodAny(name))
     260        return kTRUE;
     261
     262    //
     263    // If the class itself doesn't overload it check all it's base classes
     264    //
     265    TBaseClass *basecls=NULL;
     266    TIter NextBase(cls->GetListOfBases());
     267    while ((basecls=(TBaseClass*)NextBase()))
     268    {
     269        if (Overwrites(base, obj, name, basecls->GetClassPointer()))
     270            return kTRUE;
     271    }
     272
     273    return kFALSE;
     274}
     275
     276
     277// --------------------------------------------------------------------------
     278//
    239279//  Return a unique name for this container. It is created from
    240280//  the container name and the unique Id. (This is mostly used
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r9186 r9578  
    8282    static const TString GetDescriptor(const TObject &o);
    8383
     84    static Bool_t Overwrites(const TClass *base, const TObject &obj, const char *name, TClass *cls=NULL);
     85
    8486    virtual const TString GetDescriptor() const;
    8587    virtual const TString GetUniqueName() const;
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc

    r9574 r9578  
    278278    savemenu->AddEntry(MString::Format("%s&C",    fname.Data()), kFileSaveAsC);
    279279    savemenu->AddEntry(MString::Format("%s&root", fname.Data()), kFileSaveAsRoot);
     280    savemenu->AddEntry(MString::Format("%s&root (plain)", fname.Data()), kFileSaveAsPlainRoot);
    280281    savemenu->Associate(this);
    281282
     
    17231724        return kTRUE;
    17241725
     1726    case kFileSaveAsPlainRoot:
     1727        SaveAsPlainRoot(kTRUE);
     1728        return kTRUE;
     1729
    17251730    case kFilePrint:
    17261731        PrintPS();
     
    17771782    case kTabSaveAsC:
    17781783        SaveAsC(fTab->GetCurrent());
     1784        return kTRUE;
     1785
     1786    case kTabSaveAsPlainRoot:
     1787        SaveAsPlainRoot(fTab->GetCurrent());
    17791788        return kTRUE;
    17801789
     
    22762285    }
    22772286
     2287    // The first entry in the list is a TNamed which is expected to
     2288    // contain the status display title.
    22782289    fTitle = o->GetTitle();
    22792290
     
    23122323    //
    23132324    // If no status display was found with this name try to find canvases
    2314     // in the file and display them instead.
     2325    // in the file and display them instead.
    23152326    //
    23162327    if (n==0)
    23172328    {
     2329        // Either read the title from the file or create our own
     2330        TNamed *n=0;
     2331        gFile->GetObject("Title", n); // FIXME: Is the list allowed to take ownership?
     2332        list.Add(n ? n : new TNamed(GetName(), GetTitle()));
     2333
    23182334        const Bool_t store = TH1::AddDirectoryStatus();
    23192335        TH1::AddDirectory(kFALSE);
     
    23252341            TCanvas *c=0;
    23262342            gFile->GetObject(key->GetName(), c);
     2343
     2344            // If key doesn't correspond to a TCanvas create a new canvas
     2345            // and draw the object itself instead.
    23272346            if (!c)
    23282347            {
    2329                 AddTab(key->GetName(), key->GetTitle());
    23302348                TObject *obj = gFile->Get(key->GetName());
    2331                 obj->SetBit(kCanDelete);
    2332                 obj->Draw();
     2349
     2350                if (MParContainer::Overwrites(TObject::Class(), *obj, "Draw") ||
     2351                    MParContainer::Overwrites(TObject::Class(), *obj, "Paint"))
     2352                {
     2353                    AddTab(key->GetName(), key->GetTitle());
     2354                    obj->SetBit(kCanDelete);
     2355                    obj->Draw();
     2356                }
     2357                // FIXME: Is the object deleted?
    23332358                continue;
    23342359            }
    23352360
    2336             if (list.GetEntries()==0)
    2337                 list.Add(new TNamed(GetName(), GetTitle()));
    2338 
     2361            // Add teh canvas to the list
    23392362            c->SetTitle(gFile->GetName());
    23402363            list.Add(c);
     
    23432366        TH1::AddDirectory(store);
    23442367
    2345         if (list.GetEntries()==0)
     2368        if (list.GetEntries()<=1)
    23462369        {
    2347             *fLog << warn << "MStatusDisplay::Read: No objects read from " << gFile->GetName() << endl;
     2370            *fLog << warn << "MStatusDisplay::Read: No drawable objects read from " << gFile->GetName() << endl;
    23482371            return 0;
    23492372        }
    23502373
    2351         *fLog << inf << "MStatusDisplay: " << list.GetEntries() << " canvases directly read from file." << endl;
     2374        *fLog << inf << "MStatusDisplay: " << list.GetEntries()-1 << " canvases directly read from file." << endl;
    23522375    }
    23532376
     
    23582381        return 0;
    23592382    }
    2360 
    23612383
    23622384    if (n==0)
     
    24232445    }
    24242446
    2425     MStatusArray list;
    2426 
    2427     // Be careful: So far Display() assumes that it is the first entry in the list
    2428     TNamed named;
    2429     named.SetTitle(fTitle);
    2430     list.Add(&named);
    2431 
    2432     FillArray(list, num);
    2433 
    2434     const Int_t n = list.Write(name, kSingleKey);
    2435 
    2436     //*fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl;
     2447    Int_t n = 0; // Number of keys written
     2448
     2449    TNamed named("Title", fTitle.Data());
     2450
     2451    if (TString(option)=="plain")
     2452    {
     2453        // Get canvas range to store
     2454        Int_t from, to;
     2455        GetCanvasRange(from, to, num);
     2456
     2457        n += named.Write();
     2458
     2459        TCanvas *c;
     2460        for (int i=from; i<to; i++)
     2461            if ((c = GetCanvas(i)))
     2462                n += c->Write();
     2463    }
     2464    else
     2465    {
     2466        // Be careful: So far Display() assumes that the TNamed
     2467        // is the first entry in the list
     2468        MStatusArray list;
     2469        list.Add(&named);
     2470
     2471        FillArray(list, num);
     2472
     2473        n += list.Write(name, kSingleKey);
     2474    }
     2475
     2476    *fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl;
    24372477
    24382478    return n;
     
    30293069// --------------------------------------------------------------------------
    30303070//
    3031 // In case of num<0 all tabs are written into the PS file. If num>0
     3071// In case of num<0 all tabs are written into a root file. As plain
     3072// TCanvas objects if plain==kTRUE otherwise in a MStatusArray. If num>0
    30323073// the canvas in the corresponding tab is written to the file.
    30333074// Name is the name of the file (with or without extension).
     
    30353076// Returns the number of keys written.
    30363077//
    3037 // To write all tabs you can also use SaveAsPS(name)
    3038 //
    3039 Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name)
     3078// To write all tabs you can also use SaveAsRoot(name)
     3079//
     3080Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name, Bool_t plain)
    30403081{
    30413082    num = InitWriteDisplay(num, name, "root");
     
    30453086    TFile *fsave = gFile;
    30463087    TFile file(name, "RECREATE", GetTitle(), 9);
    3047     const Int_t keys = Write(num);
     3088    const Int_t keys = Write(num, plain ? "plain" : "");
    30483089    gFile = fsave;
    30493090
  • trunk/MagicSoft/Mars/mbase/MStatusDisplay.h

    r9185 r9578  
    4949        kFileSaveAsPS, kFileSaveAsPDF, kFileSaveAsSVG, kFileSaveAsRoot,
    5050        kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, kFileSaveAsXPM,
    51         kFileSaveAsBMP, kFileSaveAsCSV, kFileSaveAsTIFF,
     51        kFileSaveAsBMP, kFileSaveAsCSV, kFileSaveAsTIFF, kFileSaveAsPlainRoot,
    5252        kFileSaveAsXML, kFileSaveAsC, kFilePrint, kFilePrinterName,
    5353        kFileClose, kFileExit, kFileReset,
     
    5858        kTabSaveAsRoot, kTabSaveAsPNG, kTabSaveAsGIF, kTabSaveAsJPG,
    5959        kTabSaveAsXPM, kTabSaveAsBMP, kTabSaveAsCSV, kTabSaveAsTIFF,
    60         kTabSaveAsXML, kTabSaveAsC,
     60        kTabSaveAsXML, kTabSaveAsC, kTabSaveAsPlainRoot,
    6161        kTabPrint, kTabNext, kTabPrevious, kTabRemove,
    6262        // kSize
     
    253253     Bool_t SaveAsC(TString name="")    { return SaveAsC(-1, name); }
    254254     Int_t  SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); }
     255     Int_t  SaveAsPlainRoot(TString name="") { return SaveAsRoot(-1, name, kTRUE); }
    255256     Int_t  SaveAs(TString name)        { return SaveAs(-1, name); }
    256257
     
    271272     Bool_t SaveAsXML(Int_t num, TString name="")  { return SaveAsImage(num, name, TImage::kXml); }
    272273     Bool_t SaveAsC(Int_t num, TString name="");
    273      Int_t  SaveAsRoot(Int_t num, TString name="");
     274     Int_t  SaveAsRoot(Int_t num, TString name="", Bool_t plain=kFALSE);
     275     Int_t  SaveAsPlainRoot(Int_t num, TString name="") { return SaveAsRoot(num, name, kTRUE); }
    274276     Int_t  SaveAs(Int_t num, TString name);
    275277
  • trunk/MagicSoft/Mars/mbase/MTask.cc

    r9336 r9578  
    505505}
    506506
    507 // --------------------------------------------------------------------------
    508 //
    509 // Check whether the class given in the argument overwrites MTask::Process.
    510 // This function calls itself recursively. If you want to call it,
    511 // leave out the argument.
    512 //
    513 Bool_t MTask::Overwrites(const char *name, TClass *cls) const
    514 {
    515     if (!cls)
    516         cls = IsA();
    517 
    518     //
    519     // Check whether we reached the base class MTask
    520     //
    521     if (cls==MTask::Class())
    522         return kFALSE;
    523 
    524     //
    525     // Check whether the class cls overwrites Process
    526     //
    527     if (cls->GetMethodAny(name))
    528         return kTRUE;
    529 
    530     //
    531     // If the class itself doesn't overload it check all it's base classes
    532     //
    533     TBaseClass *base=NULL;
    534     TIter NextBase(cls->GetListOfBases());
    535     while ((base=(TBaseClass*)NextBase()))
    536     {
    537         if (Overwrites(name, base->GetClassPointer()))
    538             return kTRUE;
    539     }
    540 
    541     return kFALSE;
    542 }
    543 
    544507void MTask::SetDisplay(MStatusDisplay *d)
    545508{
  • trunk/MagicSoft/Mars/mbase/MTask.h

    r9336 r9578  
    7979
    8080    const TList *GetListOfBranches() const { return fListOfBranches; }
    81     Bool_t Overwrites(const char *name, TClass *cls=NULL) const;
     81    Bool_t Overwrites(const char *name, TClass *cls=NULL) const { return MParContainer::Overwrites(MTask::Class(), *this, name, cls); }
    8282
    8383    // Filter functions
  • trunk/MagicSoft/Mars/msimcamera/MSimCalibrationSignal.cc

    r9425 r9578  
    6161
    6262#include "MGeomCam.h"
    63 #include "MParSpline.h"
    6463#include "MTriggerPattern.h"
    6564
     
    6968#include "MPhotonEvent.h"
    7069#include "MPhotonData.h"
     70
     71#include "MParSpline.h"
    7172
    7273ClassImp(MSimCalibrationSignal);
     
    197198        {
    198199            // FIXME: Scale number of photons with the pixel size!
    199             const Int_t num = TMath::Nint(gRandom->Gaus(fNumPhotons, fNumPhotons/10));
     200            const Int_t num = gRandom->Poisson(fNumPhotons);
    200201
    201202            // FIXME: How does the distribution look like? Poissonian?
Note: See TracChangeset for help on using the changeset viewer.