Ignore:
Timestamp:
06/10/05 13:10:09 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhbase
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhbase/MBinning.cc

    r6954 r7142  
    261261//  lo: lowest edge
    262262//  hi: highest edge
    263 //  type: "lin" <default>, "log", "cos" (without quotationmarks)
     263//  type: "lin" <default>, "log", "cos", "asin" (without quotationmarks)
    264264//  title: Whatever the title might be
    265265//
     
    296296        str.Remove(0, pos);
    297297        str = str.Strip(TString::kBoth);
    298         if (typ!=(TString)"lin" && typ!=(TString)"log" && typ!=(TString)"cos")
     298        if (typ!=(TString)"lin" && typ!=(TString)"log" && typ!=(TString)"cos" && typ!=(TString)"asin")
    299299        {
    300300            *fLog << warn << GetDescriptor() << "::SetEdges: Type " << typ << " unknown... ignored." << endl;
     
    384384        return;
    385385    }
     386    if (o.Contains("asin", TString::kIgnoreCase))
     387    {
     388        SetEdgesASin(nbins, lo, up);
     389        return;
     390    }
    386391    if (o.Contains("cos", TString::kIgnoreCase))
    387392    {
     
    420425    const Axis_t ud = up/kRad2Deg;
    421426
    422     const Double_t binsize = (cos(ld)-cos(ud))/nbins;
     427    const Double_t cld = ld<0 ? cos(ld)-1 : 1-cos(ld);
     428    const Double_t cud = ud<0 ? cos(ud)-1 : 1-cos(ud);
     429
     430    SetEdgesASin(nbins, ld, ud);
     431    /*
     432    const Double_t binsize = (cld-cud)/nbins;
    423433    fEdges.Set(nbins+1);
    424434    for (int i=0; i<=nbins; i++)
    425         fEdges[i] = acos(cos(ld)-binsize*i)*kRad2Deg;
     435    {
     436        const Double_t a = cld-binsize*i;
     437        fEdges[i] = a<0 ? -acos(1+a)*kRad2Deg : acos(1-a)*kRad2Deg;
     438        cout << a << " " << fEdges[i] << endl;
     439    }
     440
     441    fType = kIsCosinic;*/
     442}
     443
     444// --------------------------------------------------------------------------
     445//
     446// Specify the number of bins <nbins> (not the number of edges), the
     447// lowest [deg] <lo> and highest [deg] <up> Edge (of your histogram)
     448//
     449void MBinning::SetEdgesASin(const Int_t nbins, Axis_t lo, Axis_t up)
     450{
     451    const Double_t binsize = nbins<=0 ? 0 : (up-lo)/nbins;
     452    fEdges.Set(nbins+1);
     453    for (int i=0; i<=nbins; i++)
     454    {
     455        const Double_t a = binsize*i + lo;
     456        fEdges[i] = a<0 ? -acos(1+a)*kRad2Deg : acos(1-a)*kRad2Deg;
     457    }
    426458
    427459    fType = kIsCosinic;
     
    543575    {
    544576        type = GetEnvValue(env, prefix, "Type", "lin");
    545         if (type!=(TString)"lin" && type!=(TString)"log" && type!=(TString)"cos")
     577        if (type!=(TString)"lin" && type!=(TString)"log" && type!=(TString)"cos" && type!=(TString)"acos")
    546578        {
    547579            *fLog << warn << GetDescriptor() << "::ReadEnv - WARNING: Type is not lin, log nor cos... assuming lin." << endl;
  • trunk/MagicSoft/Mars/mhbase/MBinning.h

    r6958 r7142  
    6666    void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up);
    6767    void SetEdgesCos(const Int_t nbins, const Axis_t lo, Axis_t up);
     68    void SetEdgesASin(const Int_t nbins, Axis_t lo, Axis_t up);
    6869
    6970    Int_t FindLoEdge(Double_t val) const
Note: See TracChangeset for help on using the changeset viewer.