Changeset 1283 for trunk/MagicSoft


Ignore:
Timestamp:
04/22/02 11:28:38 (23 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r1282 r1283  
    11                                                                  -*-*- END -*-*-
     2 2002/04/22: Thomas Bretz
     3
     4   * Makefile:
     5     - added a chapter how to compile mars using shared libraries
     6
     7   * NEWS:
     8     - updated
     9 
     10   * mfilter/MF.[h,cc]:
     11     - added
     12
     13   * mfilter/MFDataMember.[h,cc]:
     14     - added
     15
     16   * mhist/MH3.[h,cc]:
     17     - added
     18
     19   * mhist/MHHillasExt.[h,cc]:
     20     - added
     21     
     22   * macros/rootlogon.C:
     23     - added make() function
     24     - splitted rootlogon()
     25     
     26   * mbase/MFilterList.cc:
     27     - fixed a bug in the constructor
     28     - small changes to the print function
     29     
     30   * mbase/MParContainer.[h,cc]:
     31     - Added GetterMethod-Function
     32
     33   * mbase/MParList.cc:
     34     - Added a security check in case no def. constructor of the new class
     35       is available
     36     - changed print function
     37     
     38   * mbase/MReadTree.cc:
     39     - changed so that the class type of the branch is used for creation of
     40       a new object instead of its name
     41
     42   * mbase/MTaskList.[h,cc]:
     43     - fixed the check for the Process function. Only base classes
     44       of first order have been checked
     45       
     46   * mfilter/FilterLinkDef.h, mfilter/Makefile:
     47     - added MF, MFDataMember
     48
     49   * mhist/HistLinkDef.h, mhist/MFillH.cc:
     50     - added MH3, MHHillasExt
     51
     52   * mhist/MFillH.cc:
     53     - small changes
     54
     55   * mhist/MH.[h,cc]:
     56     - changed name handling in MakeDefCanvas to TString
     57
     58   * mhist/MHHillas.cc:
     59     - exchanged Get*axis()->SetTitle with Set*Title()
     60     
     61   * mhist/MHHillas.h:
     62     - made SetMm2Deg virtual (for MHHillasExt)
     63
     64   * mhist/MHStarMap.[h,cc]:
     65     - changed layout from mm to deg
     66
     67
    268
    369 2002/04/19: Thomas Bretz
     
    52118   * mmain/MDataCheck.cc:
    53119     - exchanged order in call to MFillH constructor
    54      - made eventloop infinity (only 300 events have been processed)
     120     - made eventloop infinite (only 300 events have been processed)
    55121
    56122   * mbase/MEvtLoop.h:
     
    117183       of the pixel is saved for all Camera pixels.
    118184     - Old files can still be read but becareful when one looks at the
    119        data member fPixelsFirst which is an array of diferent size for
     185       data member fPixelsFirst which is an array of different size for
    120186       the new and old files.
    121187     - ClassDef version upgraded to 2.
     
    179245     mhist/MHMcDifRate.[h,cc], mhist/MHMcIntRate.[h,cc]:
    180246     - added
    181      
     247
    182248   * mhist/Makefile, mhist/HistLinkDef.h:
    183249     - added MHMcEfficiencyEnergy and MHMcEfficiencyImpact
  • trunk/MagicSoft/Mars/Makefile

    r1217 r1283  
    6969# Use $(CXX) -v ... for a more verbose output
    7070#
     71#
     72#$(MARS_LIB)
     73$(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o
     74        @echo " Linking $(SOLIB) ..."
     75        $(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
     76        mv mars.so lib
     77
     78$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o)
     79        @echo " Linking $@ ..."
     80        $(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) MCint.o $(ROOTGLIBS) -o $@
     81
     82#
    7183# We could link mars.so instead of all libraries. This would need
    7284# some MBs less space on the HD. But this means, that the Shared
     
    7486# 'mars'
    7587#
    76 $(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o)
    77         @echo " Linking $@ ..."
    78         $(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) MCint.o $(ROOTGLIBS) -o $@
    79 
    80 $(SOLIB): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o
    81         @echo " Linking $(SOLIB) ..."
    82         $(CXX) -shared $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
    83         mv mars.so lib
     88#$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) $(SOLIB) MCint.o $(PROGRAMS:=.o)
     89#       @echo " Linking $@ ..."
     90#       $(CXX) $(CXXFLAGS) $@.o $(OBJS) lib/$(SOLIB)  MCint.o $(ROOTGLIBS) -o $@
    8491
    8592$(LIBRARIES):
  • trunk/MagicSoft/Mars/NEWS

    r1235 r1283  
    1717     hillas parameters)
    1818
    19    - replaced old MHillas by a new structure which allows you to extend
    20      the parameters stored in MHillas very easily.
     19   - Replaced old MHillas by a new structure which allows you to extend
     20     the parameters stored in MHillas very easily:
     21     see MHillas and MHillasExt
    2122
    22    - Added classes to handle source dependancy of image parameters.
     23   - Added classes to handle source dependancy of image parameters:
     24     see MHillasSrc
    2325
    2426   - Added container (MBinning) to have a standard input for the binning
     
    3032   - Added the flexible binning to the hillas histograms
    3133
    32    - Added a filter for the alpha parameter (MFilter)
     34   - Added a filter for the alpha parameter (MFAlpha)
    3335
    34    - it is now possible to write single data members of a class object to
     36   - It is now possible to write single data members of a class object to
    3537     an output stream instead of the whole container only
     38
     39   - Added a generalized filter for a data member:
     40     MFDataMember filter("MHillas.fWidth", '<', 0.5);
     41
     42   - Added a generalized Filter parser for more difficult filter rules
     43     MF filter("MHillas.fWidth<0.5 && MHillas.fLength>0.5");
     44
     45   - Added new Monte Carlo histograms:
     46     MHMcEnergyImpact and MHMcEfficiency
     47
     48   - Added many new histograms needed for the flux calculation.
     49
     50   - Added a generalized histograms which can fill and show up to three
     51     data members in either a one-, two- or three-dimensional histogram, eg:
     52     MH3 mh3("MHillas.fWidth", "MHillas.fLength");
    3653
    3754
  • trunk/MagicSoft/Mars/macros/rootlogon.C

    r1058 r1283  
    2323\* ======================================================================== */
    2424
     25Bool_t isloaded()
     26{
     27    TString str = gSystem->GetLibraries("*/mars.so");
    2528
    26 void rootlogon()
     29    return !str.IsNull();
     30}
     31
     32void unload()
    2733{
    28     cout << endl;
     34    if (!isloaded())
     35        return;
     36
     37    cout << "Unloading 'mars.so'... " << flush;
     38    if (gSystem->Unload("mars.so"))
     39        cout << "error." << endl;
     40    else
     41        cout << "done." << endl << endl;
     42}
     43
     44void load()
     45{
     46    if (isloaded())
     47        return;
    2948
    3049    cout << "Loading 'mars.so'... " << flush;
     
    4059
    4160    cout << endl;
     61}
     62
     63void make()
     64{
     65    unload();
     66
     67    if (gSystem->Exec("make"))
     68    {
     69        cout << "Error calling make..." << endl;
     70        return;
     71    }
     72
     73    load();
     74}
     75
     76void rootlogon()
     77{
     78    cout << endl;
     79
     80    load();
    4281
    4382    cout << "Welcome to the Mars Root environment." << endl;
     
    4584    cout << endl;
    4685}
    47 
  • trunk/MagicSoft/Mars/mbase/MFilterList.cc

    r1218 r1283  
    5959    TString str(type);
    6060
    61     if (str.CompareTo("OR", TString::kIgnoreCase)  || str.CompareTo("|"))
     61    if (!str.CompareTo("OR", TString::kIgnoreCase)  || !str.CompareTo("|"))
    6262        fFilterType = kEOr;
    63     if (str.CompareTo("XOR", TString::kIgnoreCase) || str.CompareTo("^"))
     63    if (!str.CompareTo("XOR", TString::kIgnoreCase) || !str.CompareTo("^"))
    6464        fFilterType = kEXor;
    65     if (str.CompareTo("LAND", TString::kIgnoreCase) || str.CompareTo("&&"))
     65    if (!str.CompareTo("LAND", TString::kIgnoreCase) || !str.CompareTo("&&"))
    6666        fFilterType = kELAnd;
    67     if (str.CompareTo("LOR", TString::kIgnoreCase) || str.CompareTo("||"))
     67    if (!str.CompareTo("LOR", TString::kIgnoreCase) || !str.CompareTo("||"))
    6868        fFilterType = kELOr;
    6969}
     
    180180    while ((filter=(MFilter*)Next()))
    181181        if (!filter->PreProcess(pList))
     182        {
     183            *fLog << err << "Error - Preprocessing Filter ";
     184            *fLog << filter->GetName() << " in " << fName << endl;
    182185            return kFALSE;
     186        }
    183187
    184188    return kTRUE;
     
    235239    const Bool_t verbose = str.Contains("V", TString::kIgnoreCase);
    236240
     241    //*fLog << all << "(" << GetName() << "=" << (int)fFilterType << ")";
     242
    237243    *fLog << all << "(";
    238244
     
    250256    }
    251257
    252     do
     258    filter->Print();
     259
     260    while ((filter=(MFilter*)Next()))
    253261    {
    254262        switch (fFilterType)
    255263        {
    256264        case kEAnd:
    257             *fLog << (verbose?" and ":"&");
     265            *fLog << (verbose?" and ":" & ");
    258266            break;
    259267
    260268        case kEOr:
    261             *fLog << (verbose?" or ":"|");
     269            *fLog << (verbose?" or ":" | ");
    262270            break;
    263271
    264272        case kEXor:
    265             *fLog << (verbose?" xor ":"^");
     273            *fLog << (verbose?" xor ":" ^ ");
    266274            break;
    267275
    268276        case kELAnd:
    269             *fLog << (verbose?" land ":"&&");
     277            *fLog << (verbose?" land ":" && ");
    270278            break;
    271279
    272280        case kELOr:
    273             *fLog << (verbose?" lor ":"||");
     281            *fLog << (verbose?" lor ":" || ");
    274282            break;
    275283        }
    276284
    277285        filter->Print();
    278     } while ((filter=(MFilter*)Next()));
     286    }
    279287
    280288    *fLog << ")" << flush;
    281289}
     290
  • trunk/MagicSoft/Mars/mbase/MParContainer.cc

    r1279 r1283  
    319319    return rc;
    320320}
     321
     322TMethodCall *MParContainer::GetterMethod(const char *name) const
     323{
     324    TClass *cls = IsA()->GetBaseDataMember(name);
     325    if (!cls)
     326    {
     327        *fLog << err << "No (base) class containing '" << name << "'." << endl;
     328        return NULL;
     329    }
     330
     331    TDataMember *member = cls->GetDataMember(name);
     332    if (!member)
     333    {
     334        *fLog << err << "Datamember '" << name << "' not in " << GetDescriptor() << endl;
     335        return NULL;
     336    }
     337
     338    TMethodCall *call = member->GetterMethod();
     339    if (!call)
     340    {
     341        *fLog << err << "Sorry, no getter method found for " << name << endl;
     342        return NULL;
     343    }
     344
     345    return call;
     346}
  • trunk/MagicSoft/Mars/mbase/MParContainer.h

    r1235 r1283  
    2424
    2525class TDataMember;
     26class TMethodCall;
    2627
    2728class MParContainer : public TObject
     
    6667    virtual void   SetReadyToSave(Bool_t flag=kTRUE) { fReadyToSave=flag; }
    6768
     69    TMethodCall *GetterMethod(const char *name) const;
     70
    6871    Bool_t WriteDataMember(ostream &out, const char *member, Double_t scale=1) const;
    6972    Bool_t WriteDataMember(ostream &out, const TDataMember *member, Double_t scale=1) const;
  • trunk/MagicSoft/Mars/mbase/MParList.cc

    r1211 r1283  
    380380    //
    381381    TClass *cls = gROOT->GetClass(cname);
    382 
    383382    if (!cls)
    384383    {
     
    394393    //
    395394    pcont = (MParContainer*)cls->New();
     395    if (!pcont)
     396    {
     397        *fLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
     398        return NULL;
     399    }
    396400
    397401    //
     
    424428void MParList::Print(Option_t *t) const
    425429{
    426     *fLog << all << GetDescriptor() << endl;
     430    *fLog << all << " " << GetDescriptor() << endl;
    427431    *fLog << setfill('-') << setw(strlen(GetDescriptor())+2) << "" << endl;
    428432    MParContainer *obj = NULL;
     
    572576    //
    573577    TClass *cls = gROOT->GetClass(cname);
    574 
    575578    if (!cls)
    576579    {
     
    602605        //
    603606        MParContainer *pcont = (MParContainer*)cls->New();
     607        if (pcont)
     608        {
     609            gLog << err << dbginf << "Cannot create new instance of class '" << cname << "' (Maybe no def. constructor)" << endl;
     610            return list;
     611        }
    604612
    605613        //
  • trunk/MagicSoft/Mars/mbase/MReadTree.cc

    r1211 r1283  
    458458        // check if object is existing in the list
    459459        //
    460         *pcont=pList->FindCreateObj(oname);
     460        *pcont=pList->FindCreateObj(branch->GetClassName(), oname);
    461461
    462462        if (!*pcont)
     
    466466            // we cannot proceed reading this branch
    467467            //
    468             *fLog << warn << dbginf << "Warning: Class '" << oname << "' not existing in dictionary. Branch skipped." << endl;
     468            *fLog << warn << dbginf << "Warning: Class '" << branch->GetClassName();
     469            *fLog << "' for " << oname << " not existing in dictionary. Branch skipped." << endl;
    469470            DisableSubBranches(branch);
    470471            continue;
     
    484485        //
    485486        fChain->SetBranchAddress(bname, pcont);
    486         *fLog << inf << "Master branch address " << bname << " setup for reading." << endl;
     487
     488        *fLog << inf << "Master branch address " << bname << " [";
     489        *fLog << branch->GetClassName() << "] setup for reading." << endl;
    487490
    488491        //*fLog << "Branch " << bname << " autodel: " << (int)branch->IsAutoDelete() << endl;
     
    568571//
    569572#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,06)
    570 //#include "../mraw/MRawEvtData.h"
    571573#include "MRawEvtData.h"
    572574#endif
  • trunk/MagicSoft/Mars/mbase/MTaskList.cc

    r1280 r1283  
    5858
    5959#include <TClass.h>
     60#include <TBaseClass.h>
    6061#include <TOrdCollection.h>
    6162
     
    259260// --------------------------------------------------------------------------
    260261//
     262// Check whether this task (or one of it's base classes) overloads
     263// MTask::Process. Only if this function is overloaded this task is
     264// added to the fTaskProcess-List. This makes the execution of the
     265// tasklist a little bit (only a little bit) faster, bacause tasks
     266// doing no Processing are not Processed.
     267//
     268Bool_t MTaskList::CheckClassForProcess(TClass *cls)
     269{
     270    //
     271    // Check whether the class itself overloads the Process function
     272    //
     273    if (cls->GetName()=="MTask")
     274        return kFALSE;
     275
     276    if (cls->GetMethodAny("Process"))
     277        return kTRUE;
     278
     279    //
     280    // If the class itself doesn't overload it check all it's base classes
     281    //
     282    TBaseClass *base=NULL;
     283    TIter NextBase(cls->GetListOfBases());
     284    while ((base=(TBaseClass*)NextBase()))
     285    {
     286        if (CheckClassForProcess(base->GetClassPointer()))
     287            return kTRUE;
     288    }
     289
     290    return kFALSE;
     291}
     292
     293// --------------------------------------------------------------------------
     294//
    261295//  do pre processing (before eventloop) of all tasks in the task-list
    262296//
    263 #include <TMethod.h>
    264 #include <TBaseClass.h>
    265297Bool_t MTaskList::PreProcess(MParList *pList)
    266298{
     
    283315    while ((task=(MTask*)Next()))
    284316    {
    285         *fLog << all << task->GetName() << "... " << flush;
    286 
    287         //
    288         // Check whether this task (or one of it's base classes) overloads
    289         // MTask::Process. Only if this function is overloaded this task is
    290         // added to the fTaskProcess-List. This makes the execution of the
    291         // tasklist a little bit (only a little bit) faster, bacause tasks
    292         // doing no Processing are not Processed.
    293         //
    294         TBaseClass *cls=NULL;
    295         TIter NextBase(task->IsA()->GetListOfBases());
    296         while ((cls=(TBaseClass*)NextBase()))
    297         {
    298             if (cls->GetName()=="MTask")
    299                 break;
    300 
    301             if (!cls->GetClassPointer()->GetMethodAny("Process"))
    302                 continue;
    303 
     317        if (CheckClassForProcess(task->IsA()))
    304318            fTasksProcess.Add(task);
    305             break;
    306         }
    307319
    308320        //
  • trunk/MagicSoft/Mars/mbase/MTaskList.h

    r1269 r1283  
    3030    enum { kIsOwner = BIT(14) };
    3131
    32     void Remove(MTask *task);
     32    void   Remove(MTask *task);
     33    Bool_t CheckClassForProcess(TClass *cls);
    3334
    3435public:
  • trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h

    r1210 r1283  
    55#pragma link off all functions;
    66
     7#pragma link C++ class MF+;
    78#pragma link C++ class MFAlpha+;
    89#pragma link C++ class MFTriggerLvl1+;
     10#pragma link C++ class MFDataMember+;
    911
    1012#endif
  • trunk/MagicSoft/Mars/mfilter/Makefile

    r1210 r1283  
    3232
    3333SRCFILES = MFTriggerLvl1.cc \
     34           MF.cc \
     35           MFDataMember.cc \
    3436           MFAlpha.cc
    3537
  • trunk/MagicSoft/Mars/mhist/HistLinkDef.h

    r1228 r1283  
    88
    99#pragma link C++ class MH+;
     10#pragma link C++ class MH3+;
    1011#pragma link C++ class MHFadcCam+;
    1112#pragma link C++ class MHFadcPix+;
    1213#pragma link C++ class MHHillas+;
    1314#pragma link C++ class MHHillasSrc+;
     15#pragma link C++ class MHHillasExt+;
    1416#pragma link C++ class MHStarMap+;
    1517#pragma link C++ class MHEnergyTime+;
  • trunk/MagicSoft/Mars/mhist/MFillH.cc

    r1211 r1283  
    238238        const TString name = ExtractName(fHName);
    239239
    240         TObject *obj = pList->FindCreateObj(cls, name);
     240        TObject *obj=NULL;
     241        if (cls==name)
     242            obj = pList->FindObject(fHName);
     243
     244        if (!obj)
     245            obj = pList->FindCreateObj(cls, name);
     246
    241247        if (!obj)
    242248            return kFALSE;
     
    277283    // list. If it could not be found we cannot proceed.
    278284    //
     285    if (fParContainerName.IsNull())
     286    {
     287        fParContainer = pList;
     288        return kTRUE;
     289    }
     290
    279291    fParContainer = (MParContainer*)pList->FindObject(fParContainerName);
    280292    if (fParContainer)
    281293        return kTRUE;
    282294
    283     *fLog << err << dbginf << fParContainerName << " [MParContainer] not found... aborting." << endl;
     295    *fLog << err << dbginf << "'" << fParContainerName << "' [MParContainer] not found... aborting." << endl;
    284296    return kFALSE;
    285297}
  • trunk/MagicSoft/Mars/mhist/MH.cc

    r1276 r1283  
    6666    //   set the name and title of this object
    6767    //
    68     fName  = name  ? name  : "MH" ;
    69     fTitle = title ? title : "Base class for Mars histograms" ;
     68    fName  = name  ? name  : "MH";
     69    fTitle = title ? title : "Base class for Mars histograms";
    7070}
    7171
     
    8383// number of all existing canvases plus one)
    8484//
    85 TCanvas *MH::MakeDefCanvas(const char *name, const char *title,
     85TCanvas *MH::MakeDefCanvas(TString name, const char *title,
    8686                           const UInt_t w, const UInt_t h)
    8787{
    8888    const TList *list = (TList*)gROOT->GetListOfCanvases();
    8989
    90     const char *def = name ? name : gROOT->GetDefCanvasName();
    91 
    92     TCanvas *c;
    93     if (list->FindObject(def))
    94     {
    95         const char *n = StrDup(Form("%s <%d>", def, list->GetSize()+1));
    96         c = new TCanvas(n, title, w, h);
    97         delete [] n;
    98     }
    99     else
    100         c = new TCanvas(def, title, w, h);
    101 
    102     return c;
     90    if (name.IsNull())
     91        name = gROOT->GetDefCanvasName();
     92
     93    if (list->FindObject(name))
     94        name += Form(" <%d>", list->GetSize()+1);
     95
     96    return new TCanvas(name, title, w, h);
    10397}
    10498
  • trunk/MagicSoft/Mars/mhist/MH.h

    r1207 r1283  
    2222    virtual Bool_t Fill(const MParContainer *par) = 0;
    2323
    24     static TCanvas *MakeDefCanvas(const char *name=NULL, const char *title="",
     24    static TCanvas *MakeDefCanvas(TString name="", const char *title="",
    2525                                  const UInt_t w=700, const UInt_t h=500);
    2626    static TCanvas *MakeDefCanvas(const TObject *obj,
  • trunk/MagicSoft/Mars/mhist/MHHillas.cc

    r1277 r1283  
    5353//
    5454MHHillas::MHHillas(const char *name, const char *title)
    55     : fMm2Deg(-1), fUseMmScale(kFALSE)
     55    : fMm2Deg(-1), fUseMmScale(kTRUE)
    5656{
    5757    //
     
    7272    fWidth->SetDirectory(NULL);
    7373
    74     fLength->GetXaxis()->SetTitle("Length [mm]");
    75     fWidth->GetXaxis()->SetTitle("Width [mm]");
    76 
    77     fLength->GetYaxis()->SetTitle("Counts");
    78     fWidth->GetYaxis()->SetTitle("Counts");
     74    fLength->SetXTitle("Length [mm]");
     75    fWidth->SetXTitle("Width [mm]");
     76
     77    fLength->SetYTitle("Counts");
     78    fWidth->SetYTitle("Counts");
    7979}
    8080
     
    119119    }
    120120
    121     fLength->GetXaxis()->SetTitle("Length [\\circ]");
    122     fWidth->GetXaxis()->SetTitle("Width [\\circ]");
    123 
    124     fMm2Deg = geom->GetConvMm2Deg();
     121    fLength->SetXTitle("Length [\\circ]");
     122    fWidth->SetXTitle("Width [\\circ]");
     123
     124    fMm2Deg     = geom->GetConvMm2Deg();
     125    fUseMmScale = kFALSE;
    125126
    126127    return kTRUE;
     
    189190    if (fUseMmScale)
    190191    {
    191         fLength->GetXaxis()->SetTitle("Length [mm]");
    192         fWidth->GetXaxis()->SetTitle("Width [mm]");
     192        fLength->SetXTitle("Length [mm]");
     193        fWidth->SetXTitle("Width [mm]");
    193194
    194195        fLength->Scale(1./fMm2Deg);
     
    197198    else
    198199    {
    199         fLength->GetXaxis()->SetTitle("Length [\\circ]");
    200         fWidth->GetXaxis()->SetTitle("Width [\\circ]");
     200        fLength->SetXTitle("Length [\\circ]");
     201        fWidth->SetXTitle("Width [\\circ]");
    201202
    202203        fLength->Scale(fMm2Deg);
  • trunk/MagicSoft/Mars/mhist/MHHillas.h

    r1263 r1283  
    77
    88class TH1F;
    9 class MHillas;
    109
    1110class MHHillas : public MH
     
    1514    TH1F *fLength;
    1615
     16protected:
    1717    Float_t fMm2Deg;
    1818
     
    2424
    2525    void SetMmScale(Bool_t mmscale=kTRUE);
    26     void SetMm2Deg(Float_t mmdeg);
     26    virtual void SetMm2Deg(Float_t mmdeg);
    2727
    2828    Bool_t SetupFill(const MParList *pList);
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r1263 r1283  
    3939#include <TCanvas.h>  // TCanvas
    4040
     41#include "MLog.h"
     42#include "MLogManip.h"
     43
     44#include "MParList.h"
     45
     46#include "MGeomCam.h"
    4147#include "MHillas.h"
     48#include "MBinning.h"
    4249
    4350ClassImp(MHStarMap);
     
    4855//
    4956MHStarMap::MHStarMap(const char *name, const char *title)
     57    : fMm2Deg(-1), fUseMmScale(kTRUE)
    5058{
    5159    //
     
    5765    //   set the name and title of this object
    5866    //
    59    
    6067    fName  = name  ? name  : "MHStarMap" ;
    6168    fTitle = title ? title : "Container for a Star Map" ;
     
    8895// --------------------------------------------------------------------------
    8996//
     97// Setup the Binning for the histograms automatically if the correct
     98// instances of MBinning (with the names 'BinningWidth' and 'BinningLength')
     99// are found in the parameter list
     100// Use this function if you want to set the conversion factor which
     101// is used to convert the mm-scale in the camera plain into the deg-scale
     102// used for histogram presentations. The conversion factor is part of
     103// the camera geometry. Please create a corresponding MGeomCam container.
     104//
     105Bool_t MHStarMap::SetupFill(const MParList *plist)
     106{
     107    const MGeomCam *geom = (MGeomCam*)plist->FindObject("MGeomCam");
     108    if (geom)
     109    {
     110        fMm2Deg = geom->GetConvMm2Deg();
     111        fUseMmScale = kFALSE;
     112
     113        fStarMap->SetXTitle("x [\\circ]");
     114        fStarMap->SetYTitle("y [\\circ]");
     115    }
     116
     117    const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap");
     118    if (!bins)
     119    {
     120        float r = geom ? geom->GetMaxRadius() : 600;
     121        r *= 2./3;
     122        if (!fUseMmScale)
     123            r *= fMm2Deg;
     124
     125        MBinning b;
     126        b.SetEdges(100, -r, r);
     127        SetBinning(fStarMap, &b, &b);
     128    }
     129    else
     130        SetBinning(fStarMap, bins, bins);
     131
     132    if (!geom)
     133    {
     134        *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
     135        return kTRUE;
     136    }
     137
     138    return kTRUE;
     139}
     140
     141// --------------------------------------------------------------------------
     142//
    90143// Fill the four histograms with data from a MHillas-Container.
    91144// Be careful: Only call this with an object of type MHillas
     
    98151
    99152    const float m = tan(delta);
    100     const float t = h.GetMeanY() - m*h.GetMeanX();
     153
     154    float t = h.GetMeanY() - m*h.GetMeanX();
     155
     156    if (!fUseMmScale)
     157        t *= fMm2Deg;
    101158
    102159    if (m>-1 && m<1)
    103         for (int x=-298; x<298; x+=4)
     160    {
     161        TAxis &axe = *fStarMap->GetXaxis();
     162
     163        const int N = axe.GetXbins()->GetSize();
     164        for (int i=0; i<N; i++)
    104165        {
     166            const float x = axe.GetBinCenter(i);
    105167            const float y = m*x+t;
    106168
    107169            fStarMap->Fill(x, y);
    108170        }
     171    }
    109172    else
    110         for (int y=-298; y<298; y+=4)
     173    {
     174        TAxis &axe = *fStarMap->GetYaxis();
     175
     176        const int N = axe.GetXbins()->GetSize();
     177        for (int i=0; i<N; i++)
    111178        {
     179            const float y = axe.GetBinCenter(i);
    112180            const float x = (y-t)/m;
    113181
    114182            fStarMap->Fill(x, y);
    115183        }
     184    }
    116185
    117186    return kTRUE;
     187}
     188
     189// --------------------------------------------------------------------------
     190//
     191// Use this function to setup your own conversion factor between degrees
     192// and millimeters. The conversion factor should be the one calculated in
     193// MGeomCam. Use this function with Caution: You could create wrong values
     194// by setting up your own scale factor.
     195//
     196void MHStarMap::SetMm2Deg(Float_t mmdeg)
     197{
     198    if (mmdeg<0)
     199    {
     200        *fLog << warn << dbginf << "Warning - Conversion factor < 0 - nonsense. Ignored." << endl;
     201        return;
     202    }
     203
     204    if (fMm2Deg>=0)
     205        *fLog << warn << dbginf << "Warning - Conversion factor already set. Overwriting" << endl;
     206
     207    fMm2Deg = mmdeg;
     208}
     209
     210// --------------------------------------------------------------------------
     211//
     212// With this function you can convert the histogram ('on the fly') between
     213// degrees and millimeters.
     214//
     215void MHStarMap::SetMmScale(Bool_t mmscale)
     216{
     217    if (fUseMmScale == mmscale)
     218        return;
     219
     220    if (fMm2Deg<0)
     221    {
     222        *fLog << warn << dbginf << "Warning - Sorry, no conversion factor for conversion available." << endl;
     223        return;
     224    }
     225
     226    if (fUseMmScale)
     227    {
     228        fStarMap->SetXTitle("x [mm]");
     229        fStarMap->SetYTitle("y [mm]");
     230
     231        fStarMap->Scale(1./fMm2Deg);
     232    }
     233    else
     234    {
     235        fStarMap->SetXTitle("x [\\circ]");
     236        fStarMap->SetYTitle("y [\\circ]");
     237
     238        fStarMap->Scale(1./fMm2Deg);
     239    }
     240
     241    fUseMmScale = mmscale;
    118242}
    119243
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r1207 r1283  
    1717    TH2F *fStarMap;
    1818
     19    Float_t fMm2Deg;
     20
     21    Bool_t fUseMmScale;
     22
    1923    void PrepareDrawing() const;
    2024
     
    2327    ~MHStarMap();
    2428
     29    void SetMmScale(Bool_t mmscale=kTRUE);
     30    void SetMm2Deg(Float_t mmdeg);
     31
     32    Bool_t SetupFill(const MParList *pList);
    2533    Bool_t Fill(const MParContainer *par);
    2634
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1228 r1283  
    3131           MBinning.cc \
    3232           MH.cc \
     33           MH3.cc \
    3334           MHFadcPix.cc \
    3435           MHFadcCam.cc \
    3536           MHHillas.cc \
    3637           MHHillasSrc.cc \
     38           MHHillasExt.cc \
    3739           MHStarMap.cc \
    3840           MHEnergyTime.cc \
Note: See TracChangeset for help on using the changeset viewer.