Ignore:
Timestamp:
02/10/09 20:00:10 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
2 edited

Legend:

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

    r9308 r9312  
    9191//
    9292MHCamEvent::MHCamEvent(const char *name, const char *title)
    93 : fSum(NULL), fEvt(NULL), fType(0), fErrorSpread(kTRUE), fErrorRelative(kFALSE),
     93: fSum(NULL), fErr(NULL), fEvt(NULL), fType(0), fErrorSpread(kTRUE), fErrorRelative(kFALSE),
    9494fThreshold(0), fUseThreshold(0)
    9595{
     
    104104//
    105105MHCamEvent::MHCamEvent(Int_t type, const char *name, const char *title)
    106 : fSum(NULL), fEvt(NULL), fType(type), fErrorSpread(kTRUE), fErrorRelative(kFALSE),
     106: fSum(NULL), fErr(NULL), fEvt(NULL), fType(type), fErrorSpread(kTRUE), fErrorRelative(kFALSE),
    107107fThreshold(0), fUseThreshold(0)
    108108{
     
    120120    if (fSum)
    121121        delete fSum;
     122}
     123
     124Bool_t MHCamEvent::InitGeom(const MParList &plist)
     125{
     126    MGeomCam *cam = (MGeomCam*)plist.FindObject(fNameGeom, "MGeomCam");
     127    if (!cam)
     128    {
     129        *fLog << err << fNameGeom << " [MGeomCam] not found... abort." << endl;
     130        return kFALSE;
     131    }
     132
     133    // combine name
     134    const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
     135
     136    fSum->SetGeometry(*cam, name+";avg");
     137    if (fTitle!=gsDefTitle)
     138        fSum->SetTitle(fTitle);
     139    if (!fTitle.Contains(";"))
     140        fSum->SetYTitle("a.u.");
     141
     142    if (fErr)
     143        fErr->SetGeometry(*fSum->GetGeometry(), fErr->GetName(), fErr->GetTitle());
     144
     145    return kTRUE;
    122146}
    123147
     
    142166    }
    143167
    144     MGeomCam *cam = (MGeomCam*)plist->FindObject(fNameGeom, "MGeomCam");
    145     if (!cam)
    146     {
    147         *fLog << err << fNameGeom << " [MGeomCam] not found... abort." << endl;
     168    fSum->Reset();
     169
     170    fNumReInit = 0;
     171
     172    if (!InitGeom(*plist))
    148173        return kFALSE;
    149     }
    150 
    151     // combine name
    152     const TString name = fNameEvt.IsNull() ? fName : fNameEvt;
    153 
    154     fSum->Reset();
    155     fSum->SetGeometry(*cam, name+";avg");
    156 
    157     if (fTitle!=gsDefTitle)
    158         fSum->SetTitle(fTitle);
    159     if (!fTitle.Contains(";"))
    160         fSum->SetYTitle("a.u.");
     174
    161175    if (fUseThreshold!=kCollectMin && fUseThreshold!=kCollectMax)
    162176        fSum->SetBit(MHCamera::kProfile);
     
    169183// --------------------------------------------------------------------------
    170184//
     185// The geometry read from the RunHeaders might have changed. This does not
     186// effect anything in PreProcess. So we set a new geometry. We don't move
     187// this away from PreProcess to support also loops without calling ReInit.
     188//
     189Bool_t MHCamEvent::ReInit(MParList *plist)
     190{
     191    return fNumReInit++==0 ? InitGeom(*plist) : kTRUE;
     192}
     193
     194
     195// --------------------------------------------------------------------------
     196//
    171197// Fill the histograms with data from a MCamEvent-Container.
    172198//
     
    250276}
    251277
     278TString MHCamEvent::Format(const char *ext) const
     279{
     280    TString n = fSum->GetName();
     281
     282    const Ssiz_t pos = n.Last(';');
     283    if (pos<0)
     284        return "";
     285
     286    n  = n(0, pos);
     287    n += ";";
     288    n += ext;
     289    return n;
     290}
     291
    252292void MHCamEvent::Paint(Option_t *)
    253293{
     
    255295
    256296    pad->cd(2);
    257     if (gPad->FindObject(MString::Format("%s;proj", fName.Data())))
    258     {
    259         TH1 *h=fSum->Projection(MString::Format("%s;proj", fName.Data()));
     297    if (gPad->FindObject(Format("proj")))
     298    {
     299        TH1 *h=fSum->Projection(Format("proj"));
    260300        if (h->GetMaximum()>0)
    261301            gPad->SetLogy();
     
    263303
    264304    pad->cd(5);
    265     if (gPad->FindObject(MString::Format("%s;rad", fName.Data())))
    266         fSum->RadialProfile(MString::Format("%s;rad", fName.Data()));
     305    if (gPad->FindObject(Format("rad")))
     306        fSum->RadialProfile(Format("rad"));
    267307
    268308    pad->cd(6);
    269     if (gPad->FindObject(MString::Format("%s;az", fName.Data())))
    270         fSum->AzimuthProfile(MString::Format("%s;az", fName.Data()));
     309    if (gPad->FindObject(Format("az")))
     310        fSum->AzimuthProfile(Format("az"));
    271311
    272312    pad->cd(4);
    273313    gPad->cd(1);
    274     MHCamera *cam = (MHCamera*)gPad->FindObject(MString::Format("%s;err", fName.Data()));
     314    MHCamera *cam = (MHCamera*)gPad->FindObject(Format("err"));
    275315    if (cam)
    276316        cam->SetCamContent(*fSum, fErrorRelative ? 1 : 2);
     
    300340    p->Draw();
    301341    p->cd();
    302     TH1 *h = fSum->Projection(MString::Format("%s;proj", fName.Data()), 50);
     342    TH1 *h = fSum->Projection(Format("proj"), 50);
    303343    h->SetTitle("Projection");
    304344    h->SetBit(kCanDelete);
     
    328368        e += "/v_{i}";
    329369
    330     MHCamera *cam = new MHCamera(*fSum->GetGeometry());
    331     cam->SetName(MString::Format("%s;err", fName.Data()));
    332     cam->SetTitle(e);
    333     cam->SetYTitle(fSum->GetYaxis()->GetTitle());
    334     cam->SetCamContent(*fSum, fErrorRelative ? 1 : 2);
    335     cam->SetBit(kCanDelete);
    336     cam->Draw();
     370    fErr = new MHCamera(*fSum->GetGeometry());
     371    fErr->SetName(Format("err"));
     372    fErr->SetTitle(e);
     373    fErr->SetYTitle(fSum->GetYaxis()->GetTitle());
     374    fErr->SetCamContent(*fSum, fErrorRelative ? 1 : 2);
     375    fErr->SetBit(kMustCleanup);
     376    fErr->SetBit(kCanDelete);
     377    fErr->Draw();
    337378
    338379    pad->cd();
     
    343384    p->Draw();
    344385    p->cd();
    345     h = (TH1*)fSum->RadialProfile(MString::Format("%s;rad", fName.Data()), 20);
     386    h = (TH1*)fSum->RadialProfile(Format("rad"), 20);
    346387    h->SetTitle("Radial Profile");
    347388    h->SetBit(kCanDelete|TH1::kNoStats);
     
    355396    p->Draw();
    356397    p->cd();
    357     h = (TH1*)fSum->AzimuthProfile(MString::Format("%s;az", fName.Data()), 30);
     398    h = (TH1*)fSum->AzimuthProfile(Format("az"), 30);
    358399    h->SetTitle("Azimuth Profile");
    359400    h->SetBit(kCanDelete|TH1::kNoStats);
     
    361402}
    362403
     404
     405void MHCamEvent::RecursiveRemove(TObject *obj)
     406{
     407    if (obj==fErr)
     408        fErr = 0;
     409}
  • trunk/MagicSoft/Mars/mhist/MHCamEvent.h

    r9308 r9312  
    1717protected:
    1818    MHCamera  *fSum;       // storing the sum
     19    MHCamera  *fErr;       //! storing the err
    1920    MCamEvent *fEvt;       //! the current event
    2021
     
    2930    Char_t fUseThreshold;  // Use a threshold? Which direction has it?
    3031
    31     void Init(const char *name, const char *title);
     32    Int_t fNumReInit;      //!
     33
     34    TString Format(const char *ext) const;
     35
     36    void   Init(const char *name, const char *title);
     37    Bool_t InitGeom(const MParList &plist);
    3238
    3339    Bool_t SetupFill(const MParList *pList);
     40    Bool_t ReInit(MParList *plist);
    3441    Int_t  Fill(const MParContainer *par, const Stat_t w=1);
    3542
     
    6269    void SetErrorRelative(Bool_t b=kTRUE) { fErrorRelative = b; }
    6370
     71    void RecursiveRemove(TObject *obj);
     72
    6473    ClassDef(MHCamEvent, 2) // Histogram to sum camera events
    6574};
Note: See TracChangeset for help on using the changeset viewer.