Changeset 5429 for trunk


Ignore:
Timestamp:
11/18/04 15:35:43 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5428 r5429  
    2626     - fixed a bug in the handling of kUsePed which caused the MTaskEnv
    2727       to be set incorrectly
     28
     29   * mfbase/MFEventSelector2.[h,cc]:
     30     - added possibility to set a propability distribution
     31
     32   * mgeom/MGeomCam.[h,cc]:
     33     - enhanced the Print function
     34     - fixed the Clone function for the class being MGeomCam
     35     - made InitGeometry public to support unsupported geometries
     36
     37   * mgeom/MGeomPix.h:
     38     - added Copy function
     39
     40   * mhbase/MH3.[h,cc]:
     41     - added a constructor taking a TH1 as argument
    2842
    2943
  • trunk/MagicSoft/Mars/mfbase/MFEventSelector2.cc

    r5366 r5429  
    150150//     variable(s) of interest and the binnings)
    151151//
    152 
    153152MFEventSelector2::MFEventSelector2(MH3 &hist, const char *name, const char *title)
    154153: fHistOrig(NULL), fHistNom(&hist), fHistRes(NULL),
    155154  fDataX(hist.GetRule('x')), fDataY(hist.GetRule('y')),
    156   fDataZ(hist.GetRule('z')), fNumMax(-1)
     155  fDataZ(hist.GetRule('z')), fNumMax(-1), fHistIsProbability(kFALSE)
    157156{
    158157    fName  = name  ? (TString)name  : gsDefName;
     
    384383    }
    385384
    386     MRead *read = (MRead*)tasklist->FindObject("MRead");
    387     if (!read)
    388     {
    389         *fLog << err << "MRead not found... abort." << endl;
    390         return kFALSE;
    391     }
    392 
    393385    if (!PreProcessData(parlist))
    394386        return kFALSE;
     387
     388    fHistNom->SetTitle(fHistIsProbability ? "ProbabilityDistribution" : "Users Nominal Distribution");
     389
     390    if (fHistIsProbability)
     391        return kTRUE;
    395392
    396393    InitHistogram(fHistOrig);
    397394    InitHistogram(fHistRes);
    398395
    399     fHistNom->SetTitle("Users Nominal Distribution");
    400396    fHistOrig->SetTitle("Primary Distribution");
    401397    fHistRes->SetTitle("Resulting Distribution");
     
    407403
    408404    // Generate primary distribution
     405    MRead *read = (MRead*)tasklist->FindObject("MRead");
     406    if (!read)
     407    {
     408        *fLog << err << "MRead not found... abort." << endl;
     409        return kFALSE;
     410    }
     411
    409412    if (!ReadDistribution(*read))
    410413        return kFALSE;
     
    445448
    446449    return rc;
     450}
     451
     452Bool_t MFEventSelector2::SelectProb(Int_t ibin) const
     453{
     454    //
     455    // If value is outside histogram range, accept event
     456    //
     457    return ibin<0 ? kTRUE : fHistNom->GetHist().GetBinContent(ibin) > gRandom->Uniform();
    447458}
    448459
     
    462473    const Double_t valz=fDataZ.GetValue();
    463474
     475    const Int_t ibin = fHistNom->FindFixBin(valx, valy, valz)-1;
     476
    464477    // Get corresponding bin number and check
    465478    // whether a selection should be made
    466     fResult = Select(fHistNom->FindFixBin(valx, valy, valz)-1);
     479    fResult = fHistIsProbability ? Select(ibin) : SelectProb(ibin);
    467480
    468481    fCounter[fResult ? 1 : 0]++;
     
    481494    if (GetNumExecutions()>0)
    482495    {
    483       *fLog << inf << endl;
    484       *fLog << GetDescriptor() << " execution statistics:" << endl;
    485       *fLog << dec << setfill(' ');
    486       *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
    487             << (int)(fCounter[0]*100/GetNumExecutions())
    488             << "%) Events not selected" << endl;
    489 
    490       *fLog << " " << fCounter[0] << " ("
    491             << (int)(fCounter[1]*100/GetNumExecutions())
    492             << "%) Events selected" << endl;
    493       *fLog << endl;
     496        *fLog << inf << endl;
     497        *fLog << GetDescriptor() << " execution statistics:" << endl;
     498        *fLog << dec << setfill(' ');
     499        *fLog << " " << setw(7) << fCounter[1] << " (" << setw(3)
     500              << (int)(fCounter[0]*100/GetNumExecutions())
     501              << "%) Events not selected" << endl;
     502
     503        *fLog << " " << fCounter[0] << " ("
     504              << (int)(fCounter[1]*100/GetNumExecutions())
     505              << "%) Events selected" << endl;
     506        *fLog << endl;
    494507    }
    495508
  • trunk/MagicSoft/Mars/mfbase/MFEventSelector2.h

    r3330 r5429  
    4242
    4343    Bool_t fResult;
     44    Bool_t fHistIsProbability;
    4445    Int_t  fCounter[2];
    4546
     
    4950    Bool_t PreProcessData(MParList *parlist);
    5051    Bool_t Select(Int_t bin);
     52    Bool_t SelectProb(Int_t bin) const;
    5153
    5254    Int_t PreProcess(MParList *parlist);
     
    6163
    6264    void SetNumMax(Long_t max=-1) { fNumMax = max; }
     65    void SetHistIsProbability(Bool_t b=kTRUE) { fHistIsProbability=b; }
    6366    Bool_t IsExpressionTrue() const { return fResult; }
    6467
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r5144 r5429  
    285285    //
    286286    *fLog << all << " Number of Pixels (" << GetTitle() << "): " << fNumPixels << endl;
     287    *fLog << " Number of Sectors: " << GetNumSectors() << "  Area-Indices: " << GetNumAreas() << endl;
     288    *fLog << " Min.Radius: " << GetMinRadius() << "  Max.Radius: " << GetMaxRadius() << endl;
    287289
    288290    fPixels.Print();
     
    296298TObject *MGeomCam::Clone(const char *newname) const
    297299{
     300    if (IsA()==MGeomCam::Class())
     301    {
     302        MGeomCam *cam = new MGeomCam(fNumPixels, fCamDist);
     303        for (UInt_t i=0; i<fNumPixels; i++)
     304            (*this)[i].Copy((*cam)[i]);
     305        cam->InitGeometry();
     306        return cam;
     307    }
     308
    298309    return (TObject*)IsA()->New();
    299310}
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r3777 r5429  
    3939    void CalcNumAreas();
    4040    void InitOuterRing();
    41     void InitGeometry()
    42     {
    43         CalcNumSectors();
    44         CalcNumAreas();
    45         CalcMaxRadius();
    46         CalcPixRatio();
    47         InitOuterRing();
    48     }
    4941
    5042
     
    5951    // the use of some camera files from the 0.7 beta version in which the
    6052    // array containing pixel ratios is not initialized.
     53    void InitGeometry()
     54    {
     55        CalcNumSectors();
     56        CalcNumAreas();
     57        CalcMaxRadius();
     58        CalcPixRatio();
     59        InitOuterRing();
     60    }
    6161
    6262    Float_t GetCameraDist() const { return fCamDist; }
  • trunk/MagicSoft/Mars/mgeom/MGeomPix.h

    r4826 r5429  
    3333public:
    3434    MGeomPix(Float_t x=0, Float_t y=0, Float_t d=0, UInt_t s=0, UInt_t aidx=0);
     35
     36    void Copy(TObject &obj) const
     37    {
     38        MGeomPix &pix = (MGeomPix&)obj;
     39        pix.fX = fX;
     40        pix.fY = fY;
     41        pix.fD = fD;
     42        pix.fA = fA;
     43        pix.fNumNeighbors = fNumNeighbors;
     44        pix.fSector = fSector;
     45        pix.fAidx = fAidx;
     46        for (int i=0; i<6; i++)
     47            pix.fNeighbors[i] = fNeighbors[i];
     48    }
    3549
    3650    void Print(Option_t *opt=NULL) const;
  • trunk/MagicSoft/Mars/mhbase/MH3.cc

    r5300 r5429  
    166166}
    167167
     168MH3::MH3(const TH1 &h1) : fDimension(1)
     169{
     170    if (h1.InheritsFrom(TH3::Class()))
     171        fDimension = 3;
     172    if (h1.InheritsFrom(TH2::Class()))
     173        fDimension = 2;
     174
     175    fData[0] = NULL;
     176    fData[1] = NULL;
     177    fData[2] = NULL;
     178
     179    switch (fDimension)
     180    {
     181    case 3:
     182        fData[2] = new MDataChain(h1.GetZaxis()->GetTitle());
     183    case 2:
     184        fData[1] = new MDataChain(h1.GetYaxis()->GetTitle());
     185    case 1:
     186        fData[0] = new MDataChain(h1.GetXaxis()->GetTitle());
     187    }
     188
     189    fName  = gsDefName;
     190    fTitle = gsDefTitle;
     191
     192    fHist = (TH1*)h1.Clone();
     193    fHist->SetDirectory(NULL);
     194
     195    fScale[0] = 1;
     196    fScale[1] = 1;
     197    fScale[2] = 1;
     198}
     199
    168200// --------------------------------------------------------------------------
    169201//
  • trunk/MagicSoft/Mars/mhbase/MH3.h

    r4933 r5429  
    3939public:
    4040    MH3(const unsigned int dim=0);
     41    MH3(const TH1 &h1);
    4142    MH3(const char *memberx);
    4243    MH3(const char *memberx, const char *membery);
Note: See TracChangeset for help on using the changeset viewer.