Ignore:
Timestamp:
04/24/02 18:02:11 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MH3.cc

    r1284 r1299  
    6363#include <TH2.h>
    6464#include <TH3.h>
     65#include <TProfile.h>
     66#include <TProfile2D.h>
    6567#include <TPad.h>
    6668#include <TCanvas.h>
     
    7375#include "MParList.h"
    7476
     77#include "MDataChain.h"
     78
    7579ClassImp(MH3);
    7680
     
    8084// description see the class description above.
    8185//
    82 MH3::MH3(const char *memberx) : fDimension(1)
     86MH3::MH3(const char *memberx)
     87    : fDimension(1)
    8388{
    8489    fHist = new TH1F;
    8590
    86     fDataMember[0] = memberx;
     91    fData[0] = new MDataChain(memberx);
     92    fData[1] = NULL;
     93    fData[2] = NULL;
    8794
    8895    fName  = "MH3";
     
    103110// description above.
    104111//
    105 MH3::MH3(const char *memberx, const char *membery) : fDimension(2)
     112MH3::MH3(const char *memberx, const char *membery)
     113    : fDimension(2)
    106114{
    107115    fHist = new TH2F;
    108116
    109     fDataMember[0] = memberx;
    110     fDataMember[1] = membery;
     117    fData[0] = new MDataChain(memberx);
     118    fData[1] = new MDataChain(membery);
     119    fData[2] = NULL;
    111120
    112121    fName  = "MH3";
     
    127136// description see the class description above.
    128137//
    129 MH3::MH3(const char *memberx, const char *membery, const char *memberz) : fDimension(3)
     138MH3::MH3(const char *memberx, const char *membery, const char *memberz)
     139    : fDimension(3)
    130140{
    131141    fHist = new TH3F;
    132142
    133     fDataMember[0] = memberx;
    134     fDataMember[1] = membery;
    135     fDataMember[2] = memberz;
     143    fData[0] = new MDataChain(memberx);
     144    fData[1] = new MDataChain(membery);
     145    fData[2] = new MDataChain(memberz);
    136146
    137147    fName  = "MH3";
    138148    fTitle = "Container for a 3D Mars Histogram";
     149
     150    fHist->SetDirectory(NULL);
    139151
    140152    fScale[0] = 1;
     
    150162{
    151163    delete fHist;
    152 }
    153 
    154 // --------------------------------------------------------------------------
    155 //
    156 // Trys to determin the TMethodCall corresponding to the num-axis
    157 // corresponding data member.
    158 //
    159 Bool_t MH3::GetMethodCall(const MParList *plist, Int_t num)
    160 {
    161     TString cname(fDataMember[num]);
    162     TString mname(fDataMember[num]);
    163 
    164     const char *dot = strrchr(cname, '.');
    165 
    166     if (dot)
    167     {
    168         const int pos = dot-cname;
    169 
    170         cname.Remove(pos);
    171         mname.Remove(0, pos+1);
    172     }
    173 
    174     fObject[num] = (MParContainer*)plist->FindObject(cname);
    175     if (!fObject[num])
    176     {
    177         *fLog << err << "Object '" << cname << "' not in parameter list... aborting." << endl;
    178         return kFALSE;
    179     }
    180 
    181     fMethodCall[num] = fObject[num]->GetterMethod(mname);
    182 
    183     return fMethodCall[num] ? kTRUE : kFALSE;
    184 }
    185 
     164
     165    for (int i=0; i<3; i++)
     166        if (fData[i])
     167            delete fData[i];
     168}
    186169
    187170// --------------------------------------------------------------------------
     
    208191            return kFALSE;
    209192        }
    210         fHist->SetZTitle(fName+"Z");
    211         if (!GetMethodCall(plist, 2))
     193        fHist->SetZTitle(fData[2]->GetTitle());
     194        if (!fData[2]->PreProcess(plist))
    212195            return kFALSE;
    213196    case 2:
     
    218201            return kFALSE;
    219202        }
    220         fHist->SetYTitle(fName+"Y");
    221         if (!GetMethodCall(plist, 1))
     203        fHist->SetYTitle(fData[1]->GetTitle());
     204        if (!fData[1]->PreProcess(plist))
    222205            return kFALSE;
    223206    case 1:
     
    228211            return kFALSE;
    229212        }
    230         fHist->SetXTitle(fName+"X");
    231         if (!GetMethodCall(plist, 0))
     213        fHist->SetXTitle(fData[0]->GetTitle());
     214        if (!fData[0]->PreProcess(plist))
    232215            return kFALSE;
    233216    }
     
    279262// --------------------------------------------------------------------------
    280263//
    281 // Returns the value corresponding to the data member of the given object
    282 //
    283 Bool_t MH3::GetValue(Int_t num, Double_t &v)
    284 {
    285     switch (fMethodCall[num]->ReturnType())
    286     {
    287     case TMethodCall::kLong:
    288         Long_t l;
    289         fMethodCall[num]->Execute(fObject[num], l); // FIXME: const, root
    290         v = fScale[num]*l;
    291         return kTRUE;
    292 
    293     case TMethodCall::kDouble:
    294         fMethodCall[num]->Execute(fObject[num], v); // FIXME: const, root
    295         v *= fScale[num];
    296         return kTRUE;
    297 
    298     default:
    299         *fLog << err << "DataMember "  << fDataMember[num] << " of ";
    300         *fLog << fObject[num]->GetName() << " neither int nor float... abort." << endl;
    301         return kFALSE;
    302     }
    303 }
    304 
    305 // --------------------------------------------------------------------------
    306 //
    307264// Fills the one, two or three data members into our histogram
    308265//
    309266Bool_t MH3::Fill(const MParContainer *par)
    310267{
    311     Double_t x, y, z;
     268    Double_t x=0;
     269    Double_t y=0;
     270    Double_t z=0;
    312271
    313272    switch (fDimension)
    314273    {
    315274    case 3:
    316         if (!GetValue(2, z))
    317             return kFALSE;
     275        z = fData[2]->GetValue()*fScale[2];
    318276    case 2:
    319         if (!GetValue(1, y))
    320             return kFALSE;
     277        y = fData[1]->GetValue()*fScale[1];
    321278    case 1:
    322         if (!GetValue(0, x))
    323             return kFALSE;
     279        x = fData[0]->GetValue()*fScale[0];
    324280    }
    325281
     
    359315    fHist->DrawCopy(opt);
    360316
     317    TString str(opt);
     318    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
     319    {
     320        TProfile *p = ((TH2*)fHist)->ProfileX();
     321        p->Draw("same");
     322        p->SetBit(kCanDelete);
     323    }
     324    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
     325    {
     326        TProfile *p = ((TH2*)fHist)->ProfileY();
     327        p->Draw("same");
     328        p->SetBit(kCanDelete);
     329    }
     330
    361331    c.Modified();
    362332    c.Update();
     
    378348    fHist->Draw(opt);
    379349
     350    TString str(opt);
     351    if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)
     352    {
     353        TProfile *p = ((TH2*)fHist)->ProfileX();
     354        p->Draw("same");
     355        p->SetBit(kCanDelete);
     356    }
     357    if (str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)
     358    {
     359        TProfile *p = ((TH2*)fHist)->ProfileY();
     360        p->Draw("same");
     361        p->SetBit(kCanDelete);
     362    }
     363
    380364    gPad->Modified();
    381365    gPad->Update();
  • trunk/MagicSoft/Mars/mhist/MH3.h

    r1283 r1299  
    1111class TH1;
    1212class TMethodCall;
     13class MDataChain;
    1314
    1415class MH3 : public MH
     
    2122    TString fDataMember[3];        // Data member which should be filled into the histogram x
    2223
    23     MParContainer *fObject[3];     // Object from which the data is filled
    24     TMethodCall   *fMethodCall[3]; // Method call to get the data from the object
     24    MDataChain *fData[3];     // Object from which the data is filled
    2525
    2626    Double_t fScale[3];
    27 
    28     Bool_t GetValue(Int_t num, Double_t &v);
    29     Bool_t GetMethodCall(const MParList *plist, Int_t num);
    3027
    3128public:
  • trunk/MagicSoft/Mars/mhist/Makefile

    r1283 r1299  
    2222#  connect the include files defined in the config.mk file
    2323#
    24 INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc -I../mgui
     24INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc -I../mgui -I../mdata
    2525
    2626#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.