NS_IMETHODIMP
nsHTMLGroupboxAccessible::GetRelationByType(PRUint32 aRelationType,
                                            nsIAccessibleRelation **aRelation)
{
  nsresult rv = nsHyperTextAccessibleWrap::GetRelationByType(aRelationType,
                                                             aRelation);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aRelationType == nsIAccessibleRelation::RELATION_LABELLED_BY) {
    // No override for label, so use <legend> for this <fieldset>
    return nsRelUtils::
      AddTargetFromContent(aRelationType, aRelation, GetLegend());
  }

  return NS_OK;
}
nsresult
nsHTMLGroupboxAccessible::GetNameInternal(nsAString& aName)
{
  nsresult rv = nsAccessible::GetNameInternal(aName);
  NS_ENSURE_SUCCESS(rv, rv);

  if (!aName.IsEmpty())
    return NS_OK;

  nsIContent *legendContent = GetLegend();
  if (legendContent) {
    return nsTextEquivUtils::
      AppendTextEquivFromContent(this, legendContent, &aName);
  }

  return NS_OK;
}
Esempio n. 3
0
/*------------------------------------------------------------------------*/
int sci_plot2d(char* fname, void *pvApiCtx)
{
    SciErr sciErr;

    int* piAddrl1 = NULL;
    double* l1 = NULL;
    int* piAddrl2 = NULL;
    double* l2 = NULL;
    double* lt = NULL;
    int iTypel1 = 0;
    int iTypel2 = 0;
    int lw = 0;

    int m1 = 0, n1 = 0, m2 = 0, n2 = 0;
    int test = 0, i = 0, j = 0, iskip = 0;
    int frame_def = 8;
    int *frame = &frame_def;
    int axes_def = 1;
    int *axes = &axes_def;

    /* F.Leray 18.05.04 : log. case test*/
    int size_x = 0, size_y = 0;
    char dataflag = 0;

    char* logFlags = NULL;
    int* style = NULL;
    double* rect = NULL;
    char* strf = NULL;
    char* legend = NULL;
    int* nax = NULL;
    BOOL flagNax = FALSE;
    char strfl[4];
    BOOL freeStrf = FALSE;

    rhs_opts opts[] =
    {
        { -1, "axesflag", -1, 0, 0, NULL},
        { -1, "frameflag", -1, 0, 0, NULL},
        { -1, "leg", -1, 0, 0, NULL},
        { -1, "logflag", -1, 0, 0, NULL},
        { -1, "nax", -1, 0, 0, NULL},
        { -1, "rect", -1, 0, 0, NULL},
        { -1, "strf", -1, 0, 0, NULL},
        { -1, "style", -1, 0, 0, NULL},
        { -1, NULL, -1, 0, 0, NULL}
    };

    if (nbInputArgument(pvApiCtx) == 0)
    {
        sci_demo(fname, pvApiCtx);
        return 0;
    }

    CheckInputArgument(pvApiCtx, 1, 9);

    iskip = 0;
    if (getOptionals(pvApiCtx, fname, opts) == 0)
    {
        ReturnArguments(pvApiCtx);
        return 0;
    }

    if (checkInputArgumentType(pvApiCtx, 1, sci_strings))
    {
        /* logflags */
        GetLogflags(pvApiCtx, fname, 1, opts, &logFlags);
        iskip = 1;
    }

    if (FirstOpt(pvApiCtx) == 2 + iskip)                                /** plot2d([loglags,] y, <opt_args>); **/
    {
        sciErr = getVarAddressFromPosition(pvApiCtx, 1 + iskip, &piAddrl2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl2, &iTypel2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // the argument can be a matrix of doubles or other
        // If it is not a matrix of doubles, call overload
        if (iTypel2 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(1);
            return 0;
        }

        if (m2 == 1 && n2 > 1)
        {
            m2 = n2;
            n2 = 1;
        }

        m1 = m2;
        n1 = n2;

        sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n1, &l1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            Scierror(999, _("%s: Memory allocation error.\n"), fname);
            return 1;
        }

        for (i = 0; i < m2 ; ++i)
        {
            for (j = 0 ; j < n2 ;  ++j)
            {
                *(l1 + i + m2 * j) = (double) i + 1;
            }
        }
    }
    else if (FirstOpt(pvApiCtx) >= 3 + iskip)     /** plot2d([loglags,] x, y[, style [,...]]); **/
    {
        /* x */
        sciErr = getVarAddressFromPosition(pvApiCtx, 1 + iskip, &piAddrl1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl1, &iTypel1);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // x can be a matrix of doubles or other
        // If x is not a matrix of doubles, call overload
        if (iTypel1 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl1, &m1, &n1, &l1);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(1);
            return 0;
        }

        /* y */
        sciErr = getVarAddressFromPosition(pvApiCtx, 2 + iskip, &piAddrl2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        sciErr = getVarType(pvApiCtx, piAddrl2, &iTypel2);
        if (sciErr.iErr)
        {
            printError(&sciErr, 0);
            return 1;
        }

        // y can be a matrix of doubles or other
        // If y is not a matrix of doubles, call overload
        if (iTypel2 == sci_matrix)
        {

            // Retrieve a matrix of double at position 1 + iskip.
            sciErr = getMatrixOfDouble(pvApiCtx, piAddrl2, &m2, &n2, &l2);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2 + iskip);
                return 1;
            }
        }
        else
        {
            OverLoad(2);
            return 0;
        }

        test = (m1 * n1 == 0) ||
               ((m1 == 1 || n1 == 1) && (m2 == 1 || n2 == 1) && (m1 * n1 == m2 * n2))  ||
               ((m1 == m2) && (n1 == n2)) ||
               ((m1 == 1 && n1 == m2) || (n1 == 1 && m1 == m2));
        //CheckDimProp
        if (!test)
        {
            Scierror(999, _("%s: Wrong size for input arguments: Incompatible sizes.\n"), fname);
            return 1;
        }

        if (m1 * n1 == 0)
        {
            /* default x=1:n */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m2, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *(lt + i + m2 * j) = (double) i + 1;
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 || n1 == 1) && (m2 != 1 && n2 != 1))
        {
            /* a single x vector for mutiple columns for y */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m2, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *(lt + i + m2 * j) = *(l1 + i);
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 && n1 == 1) && (n2 != 1))
        {
            /* a single y row vector  for a single x */
            sciErr = allocMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, m1, n2, &lt);
            if (sciErr.iErr)
            {
                printError(&sciErr, 0);
                Scierror(999, _("%s: Memory allocation error.\n"), fname);
                return 1;
            }

            for (j = 0 ; j < n2 ;  ++j)
            {
                lt[j] = *l1;
            }
            n1 = n2;
            l1 = lt;
        }
        else
        {
            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            if (m1 == 1 && n1 > 1)
            {
                m1 = n1;
                n1 = 1;
            }
        }
    }
    else
    {
        Scierror(999, _("%s: Wrong number of mandatory input arguments. At least %d expected.\n"), fname, 1);
        return 0;
    }

    if (n1 == -1 || n2 == -1 || m1 == -1 || m2 == -1)
    {
        Scierror(999, _("%s: Wrong size for input arguments #%d and #%d.\n"), fname, 1, 2); /* @TODO : detail error */
        return 0;
    }

    sciGetStyle(pvApiCtx, fname, 3 + iskip, n1, opts, &style);
    GetStrf(pvApiCtx, fname, 4 + iskip, opts, &strf);
    GetLegend(pvApiCtx, fname, 5 + iskip, opts, &legend);
    GetRect(pvApiCtx, fname, 6 + iskip, opts, &rect);
    GetNax(pvApiCtx, 7 + iskip, opts, &nax, &flagNax);

    if (iskip == 0)
    {
        GetLogflags(pvApiCtx, fname, 8, opts, &logFlags);
    }

    freeStrf = !isDefStrf(strf);

    // Check strf [0-1][0-8][0-5]
    if (!isDefStrf(strf) && (strlen(strf) != 3 || strf[0] < '0' || strf[0] > '1' || strf[1] < '0' || strf[1] > '8' || strf[2] < '0' || strf[2] > '5'))
    {
        Scierror(999, _("%s: Wrong value for strf option: %s.\n"), fname, strf);
        if (freeStrf)
        {
            freeAllocatedSingleString(strf);
        }
        return -1;
    }

    if (isDefStrf(strf))
    {
        strcpy(strfl, DEFSTRFN);

        strf = strfl;
        if (!isDefRect(rect))
        {
            strfl[1] = '7';
        }
        if (!isDefLegend(legend))
        {
            strfl[0] = '1';
        }

        GetOptionalIntArg(pvApiCtx, fname, 9, "frameflag", &frame, 1, opts);
        if (frame != &frame_def)
        {
            if (*frame >= 0 && *frame <= 8)
            {
                strfl[1] = (char)(*frame + 48);
            }
            else
            {
                Scierror(999, _("%s: Wrong value for frameflag option.\n"), fname);
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                return -1;
            }
        }

        GetOptionalIntArg(pvApiCtx, fname, 9, "axesflag", &axes, 1, opts);
        if (axes != &axes_def)
        {
            if ((*axes >= 0 && *axes <= 5) || *axes == 9)
            {
                strfl[2] = (char)(*axes + 48);
            }
            else
            {
                Scierror(999, _("%s: Wrong value for axesflag option.\n"), fname);
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                return -1;
            }
        }
    }

    /* Make a test on log. mode : available or not depending on the bounds set by Rect arg. or xmin/xmax :
       Rect case :
       - if the min bound is strictly posivite, we can use log. mode
       - if not, send error message
       x/y min/max case:
       - we find the first strictly positive min bound in Plo2dn.c ?? */

    switch (strf[1])
    {
        case '0':
            /* no computation, the plot use the previous (or default) scale */
            break;
        case '1' :
        case '3' :
        case '5' :
        case '7':
            /* based on Rect arg */
            if (rect[0] > rect[2] || rect[1] > rect[3])
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Impossible status min > max in x or y rect data.\n"), fname);
                return -1;
            }

            if (rect[0] <= 0. && logFlags[1] == 'l') /* xmin */
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Bounds on x axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1;
            }

            if (rect[1] <= 0. && logFlags[2] == 'l') /* ymin */
            {
                if (freeStrf)
                {
                    freeAllocatedSingleString(strf);
                }
                Scierror(999, _("%s: Bounds on y axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1;
            }

            break;
        case '2' :
        case '4' :
        case '6' :
        case '8':
        case '9':
            /* computed from the x/y min/max */
            if ((int)strlen(logFlags) < 1)
            {
                dataflag = 'g';
            }
            else
            {
                dataflag = logFlags[0];
            }

            switch (dataflag)
            {
                case 'e' :
                    size_x = (m1 != 0) ? 2 : 0;
                    break;
                case 'o' :
                    size_x = m1;
                    break;
                case 'g' :
                default  :
                    size_x = (n1 * m1);
                    break;
            }

            if (size_x != 0)
            {
                if (logFlags[1] == 'l' && sciFindStPosMin((l1), size_x) <= 0.0)
                {
                    if (freeStrf)
                    {
                        freeAllocatedSingleString(strf);
                    }
                    Scierror(999, _("%s: At least one x data must be strictly positive to compute the bounds and use logarithmic mode.\n"), fname);
                    return -1;
                }
            }

            size_y = (n1 * m1);

            if (size_y != 0)
            {
                if (logFlags[2] == 'l' && sciFindStPosMin((l2), size_y) <= 0.0)
                {
                    if (freeStrf)
                    {
                        freeAllocatedSingleString(strf);
                    }
                    Scierror(999, _("%s: At least one y data must be strictly positive to compute the bounds and use logarithmic mode\n"), fname);
                    return -1;
                }
            }

            break;
    }

    // open a figure if none already exists
    getOrCreateDefaultSubwin();

    Objplot2d (1, logFlags, (l1), (l2), &n1, &m1, style, strf, legend, rect, nax, flagNax);

    // Allocated by sciGetStyle (get_style_arg function in GetCommandArg.c)
    FREE(style);

    if (freeStrf)
    {
        freeAllocatedSingleString(strf);
    }

    AssignOutputVariable(pvApiCtx, 1) = 0;
    ReturnArguments(pvApiCtx);
    return 0;
}
//////---------- channel: 0==muon dijet, 1== electron dijet
/////                     2==muon  boosted,   3== electron boosted
void makeATGCLimitDataCards(int channel) {

//   const Int_t bins = 8; 
//   const Float_t dm_min = 200.; 
//   const Float_t dm_max = 600.;

  Int_t bins = 7; 
  Float_t dm_min = 100.; 
  Float_t dm_max = 275.;
  if(channel>1) { bins = 15; dm_min = 200.; dm_max = 800; }

  Int_t binsmc = (int)(10*(dm_max - dm_min)); // units of 0.1GeV, set up for smearing post-binning!

  domu = true;
  if(channel==1 || channel==3) domu = false;

 
  TString outfile = (domu?TString("mu"):TString("el"))+ 
    (channel<2?TString("dijet"):TString("boosted"));
  TFile* outputForLimit = TFile::Open(outfile+".root", "recreate");


  TString cutsDijet("(W_pt<200.) && (dijetPt>70.) && (abs(JetPFCor_Eta[0])<2.4) && (abs(JetPFCor_Eta[1])<2.4) && (abs(JetPFCor_Eta[0]-JetPFCor_Eta[1])<1.5) &&(abs(JetPFCor_dphiMET[0])>0.4) &&(W_mt>30.) &&(JetPFCor_Pt[0]>40.) &&(JetPFCor_Pt[1]>35.) &&(JetPFCor_Pt[2]<30.) &&(JetPFCor_bDiscriminatorCSV[0]<0.244) &&(JetPFCor_bDiscriminatorCSV[1]<0.244) && (Mass2j_PFCor>70. && Mass2j_PFCor<100.)");



  // Do not put jet pt in the cut string here, since it is going to be smeared
  TString cutsMerged("(vbf_event==0) && (W_pt>200.) &&(abs(GroomedJet_CA8_eta[0])<2.4)&&(ggdboostedWevt==1) && (GroomedJet_CA8_deltaphi_METca8jet[0]>2.0) && (GroomedJet_CA8_deltaR_lca8jet[0]>1.57) && (numPFCorJetBTags<1) && (GroomedJet_CA8_tau2tau1[0]<0.55) && (GroomedJet_CA8_mass_pr[0]>70. && GroomedJet_CA8_mass_pr[0]<100.)");

  // && (GroomedJet_CA8_deltaR_lca8jet[1]<-900 || GroomedJet_CA8_deltaR_lca8jet[1]>7.0)

  TString        lepton_cut = "(event_met_pfmet >30) && (W_electron_pt>35.)";
  if(channel==0) lepton_cut = "(event_met_pfmet >25) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>25.)";
  if(channel==1) lepton_cut = "(event_met_pfmet >30) && (W_electron_pt>30.)";
  if(channel==2) lepton_cut = "(event_met_pfmet >50) &&(abs(W_muon_eta)<2.1) && (W_muon_pt>30.)";
  if(channel==3) lepton_cut = "(event_met_pfmet >70) && (W_electron_pt>35.)";

  TString And = " && ";

  TString jet_cut = cutsDijet;
  TString jetptcut,mcjetptcut;

  if(channel>1) jet_cut = cutsMerged;

  char* observable = "dijetPt";
  char* mcobservable = "dijetPt";
  char* xtitle = "p_{T}^{jj} [GeV]"; 
  double jetptcutval;
  if(channel>1) {
    double jetthresh = 80;

    /*observable = 
      "(GroomedJet_CA8_pt[0]>jetthresh)+\
      (GroomedJet_CA8_pt[1]>jetthresh)+\
      (GroomedJet_CA8_pt[2]>jetthresh)+\
      (GroomedJet_CA8_pt[3]>jetthresh)+\
      (GroomedJet_CA8_pt[4]>jetthresh)+\
      (GroomedJet_CA8_pt[5]>jetthresh)";*/

    mcobservable = "GroomedJet_CA8_pt_smeared[0]";
    //mcobservable = "GroomedJet_CA8_pt[0]";
    observable = "GroomedJet_CA8_pt[0]";
    jetptcutval = 200.;
    jetptcut   = Form("(%s > %f)",  observable,jetptcutval);
    mcjetptcut = Form("(%s > %f)",mcobservable,jetptcutval);
    xtitle = "p_{T}^{j} [GeV]";
  }


  TCut mccut( TString("(effwt*puwt)*(")+ lepton_cut+And+jet_cut+And+mcjetptcut + TString(")") );
  TCut datacut( TString("(") + lepton_cut+And+jet_cut+And+jetptcut + TString(")") );
  //TCut the_cut( TString("(effwt*puwt)*(")+ lepton_cut+And+jet_cut+And+jetptcut + TString(")") );

  // for combining ttbar files
  TString mttstr
    ("sqrt((W_top_E+W_atop_E)^2 -(W_top_px+W_atop_px)^2 -(W_top_py+W_atop_py)^2 -(W_top_pz+W_atop_pz)^2)");

  // weight default sample by 1 for mtt<700, by half above for adding the high mtt samples
  TCut mttwt(TString("(")+mttstr+TString("<700)?1.0:0.5"));

  InstantiateTrees();


  //th1data  = new TH1D("th1data",  "th1data",  bins, ptbins_boosted); // bins, dm_min, dm_max);
  th1data  = new TH1D("th1data",  "th1data",  bins, dm_min, dm_max);
  th1data->Sumw2();
  th1data->SetMarkerStyle(20);
  th1data->SetMarkerSize(1.25);
  th1data->SetLineWidth(2);
  th1data->SetMinimum(0.0);

  TString drawstr = TString(observable)+TString(">>th1data");

  cout <<
    TString("treedata->Draw(\"")+drawstr+TString("\", \"")+
    TString((const char*)datacut)+TString("\", \"goff\")") << endl;

  treedata->Draw(drawstr, datacut, "goff");

  // ------- Get WW/WZ ------- 
  th1wwlo = new TH1D("th1wwlo", "th1wwlo", bins, dm_min, dm_max);
  th1wwhi = new TH1D("th1wwhi", "th1wwhi", bins, dm_min, dm_max);
  th1ww   = new TH1D("th1ww", "th1ww", bins, dm_min, dm_max);
  th1wzlo = new TH1D("th1wzlo", "th1wzlo", bins, dm_min, dm_max);
  th1wzhi = new TH1D("th1wzhi", "th1wzhi", bins, dm_min, dm_max);
  th1wz   = new TH1D("th1wz", "th1wz", bins, dm_min, dm_max);
  //th1wz = new TH1D("th1wz", "th1wz", bins, ptbins_boosted);
  th1wwlo->Sumw2();
  th1wwhi->Sumw2();
  th1wzlo->Sumw2();
  th1wzhi->Sumw2();
  th1wz->Sumw2();

  fillMChisto(th1wwlo,treewwlo,mcobservable,mccut);
  fillMChisto(th1wwhi,treewwhi,mcobservable,mccut);
  fillMChisto(th1wzlo,treewzlo,mcobservable,mccut);
  fillMChisto(th1wzhi,treewzhi,mcobservable,mccut);

  // ------- Get ttbar ------- 
  th1Top   = new TH1D("th1Top", "th1Top", bins, dm_min, dm_max);
  th1toplo = new TH1D("th1toplo", "th1toplo", bins, dm_min, dm_max);
  th1topmd = new TH1D("th1topmd", "th1topmd", bins, dm_min, dm_max);
  th1tophi = new TH1D("th1tophi", "th1tophi", bins, dm_min, dm_max);

  //th1Top = new TH1D("th1Top", "th1Top", bins, ptbins_boosted);
  th1Top->Sumw2();
  th1toplo->Sumw2();
  th1topmd->Sumw2();
  th1tophi->Sumw2();

  fillMChisto(th1toplo,treettblo,mcobservable,mttwt*mccut);
  fillMChisto(th1topmd,treettbmd,mcobservable,mccut);
  fillMChisto(th1tophi,treettbhi,mcobservable,mccut);

    // ------- Get WJets ------- 
  th1wjlo  = new TH1D("th1wjlo",  "th1wjlo",  bins, dm_min, dm_max);
  th1wjhi  = new TH1D("th1wjhi",  "th1wjhi",  bins, dm_min, dm_max);
  th1wjets = new TH1D("th1wjets", "th1wjets", bins, dm_min, dm_max);
  th1wjlo->Sumw2();
  th1wjhi->Sumw2();

  fillMChisto(th1wjlo,treewjlo,mcobservable,mccut);
  fillMChisto(th1wjhi,treewjhi,mcobservable,mccut);

  //th1wjets  = new TH1D("th1wjets",  "th1wjets", bins, ptbins_boosted);

  // ------- Get QCD ------- 
  //th1qcd = new TH1D("th1qcd", "th1qcd", bins, dm_min, dm_max);
  //th1qcd = new TH1D("th1qcd", "th1qcd", bins, ptbins_boosted);
  //th1qcd->Sumw2();
  //treeqcd->Draw(TString(observable)+TString(">>th1qcd"), mccut, "goff");

  // ------- Get Z+Jets ------- 
  //th1zjets = new TH1D("th1zjets", "th1zjets", bins, dm_min, dm_max);
  //th1zjets->Sumw2();
  //treezj->Draw(TString(observable)+TString(">>th1zjets"), mccut, "goff");


  // ------- Get Single top ------- 
  th1stops = new TH1D("th1stops", "th1stops", bins, dm_min, dm_max);
  th1stopt = new TH1D("th1stopt", "th1stopt", bins, dm_min, dm_max);
  th1stoptw = new TH1D("th1stoptw", "th1stoptw", bins, dm_min, dm_max);
  //th1stops = new TH1D("th1stops", "th1stops", bins, ptbins_boosted);
  //th1stopt = new TH1D("th1stopt", "th1stopt", bins, ptbins_boosted);
  //th1stoptw = new TH1D("th1stoptw", "th1stoptw", bins, ptbins_boosted);
  th1stops->Sumw2();
  th1stopt->Sumw2();
  th1stoptw->Sumw2();
  
  fillMChisto(th1stops,treests,mcobservable,mccut);
  fillMChisto(th1stopt,treestt,mcobservable,mccut);
  fillMChisto(th1stoptw,treestw,mcobservable,mccut);
 
  th1stopps = new TH1D("th1stopps", "th1stopps", bins, dm_min, dm_max);
  th1stoppt = new TH1D("th1stoppt", "th1stoppt", bins, dm_min, dm_max);
  th1stopptw = new TH1D("th1stopptw", "th1stopptw", bins, dm_min, dm_max);
  //th1stopps = new TH1D("th1stopps", "th1stopps", bins, ptbins_boosted);
  //th1stoppt = new TH1D("th1stoppt", "th1stoppt", bins, ptbins_boosted);
  //th1stopptw = new TH1D("th1stopptw", "th1stopptw", bins, ptbins_boosted);
  th1stopps->Sumw2();
  th1stoppt->Sumw2();
  th1stopptw->Sumw2();

  fillMChisto(th1stopps,tree64,mcobservable,mccut);
  fillMChisto(th1stoppt,tree65,mcobservable,mccut);
  fillMChisto(th1stopptw,tree66,mcobservable,mccut);

  // ---- Scale the histos ---- 
  ScaleHistos(channel);

#if 0    
  // ---- Make smooth diboson shape ----------
  TH1D* th1wvclone = (TH1D *)th1wv->Clone("th1wvclone");
  float tmin = 200.0;
  if(channel>1) tmin = 300.0;
  gaus2 = new TF1("gaus2","gaus", tmin, 1000000000.);
  th1wvclone->Fit(gaus2,"I0","");
#endif
    
  // ---- Empty histograms for display/plotting ---- 
  SetupEmptyHistogram(bins, dm_min, dm_max, xtitle);
  //SetupEmptyHistogram(bins, ptbins_boosted, xtitle);
  
  // ---- Sum all backgrounds ----------
  TH1D* th1wv_no_overflow = (TH1D *)th1wv->Clone("th1wv_no_overflow");
  SumAllBackgrounds();

#if 1
  // ---- Get signal histogram ----------
  TCut wwsigratio= GetSigRatioFunction(mcobservable);
  TCut wzsigratio= GetSigRatioFunction(mcobservable,"wz");
  
  TCut wwsigcut = mccut*wwsigratio;
  TCut wzsigcut = mccut*wzsigratio;
  
  wwatgc4Display = new TH1D("wwatgc4Display","wwatgc4Display",bins,dm_min,dm_max);
  wzatgc4Display = new TH1D("wzatgc4Display","wzatgc4Display",bins,dm_min,dm_max);
  //wwatgc4Display = new TH1D("wwatgc4Display","wwatgc4Display",bins,ptbins_boosted);
  
  drawstr = TString(mcobservable)+TString(">>wwatgc4Display");

  cout <<
    TString("wwtree->Draw(\"")+drawstr+TString("\", \"")+
    TString((const char*)wwsigcut)+TString("\", \"goff\")") << endl;

  TH1D *th1wwlosc = new TH1D("sigwwlo","sigwwlo",bins,dm_min,dm_max);
  TH1D *th1wwhisc = new TH1D("sigwwhi","sigwwhi",bins,dm_min,dm_max);
  TH1D *th1wzlosc = new TH1D("sigwzlo","sigwzlo",bins,dm_min,dm_max);
  TH1D *th1wzhisc = new TH1D("sigwzhi","sigwzhi",bins,dm_min,dm_max);

  fillMChisto(th1wwlosc,treewwlo,mcobservable,wwsigcut,false);
  fillMChisto(th1wwhisc,treewwhi,mcobservable,wwsigcut,false);
  fillMChisto(th1wzlosc,treewzlo,mcobservable,wzsigcut,false);
  fillMChisto(th1wzhisc,treewzhi,mcobservable,wzsigcut,false);

  th1wwlosc->Scale(WW_scale_lo);
  th1wwhisc->Scale(WW_scale_hi);

  th1wzlosc->Scale(WZ_scale_lo);
  th1wzhisc->Scale(WZ_scale_hi);

  // stitch the two histograms together into one, post-smearing.
  for (int ibin=1;ibin<=wwatgc4Display->GetNbinsX();ibin++) {
    if (wwatgc4Display->GetBinLowEdge(ibin)<stitchwwgev) {
      wwatgc4Display->SetBinContent(ibin,th1wwlosc->GetBinContent(ibin));
      wwatgc4Display->SetBinError  (ibin,th1wwlosc->GetBinError  (ibin));
    } else {
      wwatgc4Display->SetBinContent(ibin,th1wwhisc->GetBinContent(ibin));
      wwatgc4Display->SetBinError  (ibin,th1wwhisc->GetBinError  (ibin));
    }
  }

  wwatgc4Display->Scale(WW_scale_NLO * (domu ? intLUMIinvpb_mu : intLUMIinvpb_el));

  // stitch the two WZ histograms together into one, post-smearing.
  for (int ibin=0;ibin<=wzatgc4Display->GetNbinsX()+1;ibin++) {
    if (wzatgc4Display->GetBinLowEdge(ibin)<stitchwzgev) {
      wzatgc4Display->SetBinContent(ibin,th1wzlosc->GetBinContent(ibin));
      wzatgc4Display->SetBinError  (ibin,th1wzlosc->GetBinError  (ibin));
    } else {
      wzatgc4Display->SetBinContent(ibin,th1wzhisc->GetBinContent(ibin));
      wzatgc4Display->SetBinError  (ibin,th1wzhisc->GetBinError  (ibin));
    }
  }

  wzatgc4Display->Scale(WZ_scale_NLO * (domu ? intLUMIinvpb_mu : intLUMIinvpb_el));

  cout << "wwatgc4Display nentries = " << wwatgc4Display->GetEntries() << endl;

  // ----- need to subtract the diboson contribution 
  wwatgc4Display->SetLineWidth(2);
  wwatgc4Display->SetLineColor(1);
  wwatgc4Display->SetFillColor(0);

  // ----- need to subtract the diboson contribution 
  wzatgc4Display->SetLineWidth(2);
  wzatgc4Display->SetLineColor(1);
  wzatgc4Display->SetFillColor(0);
  wzatgc4Display->SetLineStyle(2);

  //-------- Add overflow bin ----------------
  AddOverflowBin(wwatgc4Display);
  AddOverflowBin(wzatgc4Display);
  
#endif

  // ---- Compose the stack ----------
  THStack* hs = new THStack("hs","MC contribution");
  //hs->Add(th1zjets); 
 //hs->Add(th1qcd);
  hs->Add(th1Top);
  hs->Add(th1wjets);
  hs->Add(th1wv);  // add WW in with backgrounds for display only
  hs->Add(wwatgc4Display);
  hs->Add(wzatgc4Display);



  // ---- Stack for shape systematics Up ----------
  double bkgd_norm_fracerror = domu ? mu_bkgd_norm_error : el_bkgd_norm_error;
  double sig_norm_fracerror = domu ? mu_sig_norm_error : el_sig_norm_error;

  cout << "Background normalization fractional systematic = " << bkgd_norm_fracerror << endl;
  cout << "Signal     normalization fractional systematic = " << sig_norm_fracerror << endl;

  //TF1* formScaleUp = new TF1("formScaleUp", "1.0+0.4*log(x/5)", dm_min, dm_max);
  //TF1* formScaleDn = new TF1("formScaleDn", "1.0-0.2*log(x/5)", dm_min, dm_max);
  TF1* formScaleUp = new TF1("formScaleUp", Form("1.0+%f",bkgd_norm_fracerror), dm_min, dm_max);
  TF1* formScaleDn = new TF1("formScaleDn", Form("1.0-%f",bkgd_norm_fracerror), dm_min, dm_max);

  systUp = (TH1D*) th1wjets->Clone("systUp");
  systUp->Multiply(formScaleUp);
  //systUp->Add(th1zjets);
  //systUp->Add(th1qcd);
  systUp->Add(th1Top);
  systUp->SetFillColor(0);
  systUp->SetLineStyle(2);
  systUp->SetLineColor(2);
  systUp->SetLineWidth(3);

  // ---- Stack for shape systematics Down ----------
  systDown = (TH1D*) th1wjets->Clone("systDown");
  systDown->Multiply(formScaleDn);
  //systDown->Add(th1zjets);
  //systDown->Add(th1qcd);
  systDown->Add(th1Top);
  systDown->SetFillColor(0);
  systDown->SetLineWidth(3);
  systDown->SetLineStyle(2);
  systDown->SetLineColor(2);

  /////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  ///////////////////////////////////////////////////////////
  

  // ------- Setup the canvas ------- 
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);
  // gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadLeftMargin(0.15);
  // gStyle->SetPadRightMargin(0.2);
  gStyle->SetPadBottomMargin(0.3);
  // gStyle->SetErrorX(0.5);

  TCanvas* c1 = new TCanvas("dijetPt", "", 10,10, 500, 500);

  TPad *d1, *d2;
  c1->Divide(1,2,0,0);
  d1 = (TPad*)c1->GetPad(1);
  d1->SetPad(0.01,0.30,0.95,0.99);
  d2 = (TPad*)c1->GetPad(2);
  d2->SetPad(0.01,0.02,0.95,0.30);
  d1->cd();

  gPad->SetBottomMargin(0.005);

  gPad->SetTopMargin(0.1);
  gPad->SetRightMargin(0.04);
  // gPad->SetLeftMargin(0.14);


  // Draw it all
  double ymax= 5000000.;
  double ymin= 7.0;
  if(channel>1) { 
    ymax= 3000.;
    ymin= 0.10;
  }

  th1totempty->GetYaxis()->SetRangeUser(ymin, ymax);
  th1data->GetYaxis()->SetRangeUser(ymin, ymax);
  th1totempty->Draw();
  hs->Draw("samehist");
  for (int i=1;i<=th1tot->GetNbinsX();i++)
    {
      double val = th1tot->GetBinContent(i); // / (ptbins_boosted[i]-ptbins_boosted[i-1]);
      double err = fabs(th1tot->GetBinError(i)); // / (ptbins_boosted[i]-ptbins_boosted[i-1]);
      TBox *b = new TBox(th1tot->GetBinLowEdge(i),
			 val-err,th1tot->GetBinLowEdge(i+1),val+err);
      b->SetLineColor(1);
      b->SetFillColor(1);
      b->SetFillStyle(3001);
      b->SetLineStyle(3001);	 
      b->Draw();
    }
  //data2draw->Draw("esame");

#ifndef BLINDED
  th1data->Draw("esame");
#endif

  cmspre(); 
  // Set up the legend
  TLegend* Leg = GetLegend(channel);   
  Leg->Draw();  
  gPad->SetLogy();
  gPad->RedrawAxis();

  d2->cd();
  gPad->SetTopMargin(0.02);
  gPad->SetRightMargin(0.04);
  gPad->SetFrameBorderSize(0);
  gPad->SetBottomMargin(0.45);
  gPad->SetTickx();

  th1emptyclone->Draw();
#ifndef BLINDED
  hhratio->Draw("esame");
  //hhratioUp->Draw("hist lsame");
  //hhratioDown->Draw("hist lsame");
#endif
  TLine *line; line = new TLine(dm_min,1.0,dm_max,1.0);
  line->SetLineStyle(1);
  line->SetLineWidth(1);
  line->SetLineColor(1);
  line->Draw();

  //gPad->WaitPrimitive();
  c1->Modified();
  c1->Update();

  c1->Print(TString("OutDir/")+outfile
#ifdef BLINDED
	    +TString("_fatjetPt_blinded.png")
#else
	    +TString("_fatjetPt_unblinded.png")
#endif
	    );

  c1->SaveAs(TString("OutDir/") + outfile
#ifdef BLINDED
	     +TString("_fatjetPt_blinded.pdf")
#else
	     +TString("_fatjetPt_unblinded.pdf")
#endif
	     );
  c1->SaveAs(TString("OutDir/") + outfile
#ifdef BLINDED
	     +TString("_fatjetPt_blinded.root")
#else
	     +TString("_fatjetPt_unblinded.root")
#endif
	     );
   

  ///// -------------------------------//////

  if(saveDataCards_) {
    outputForLimit->cd();
    th1data->SetName("data_obs");     th1data->Write("data_obs");
    th1tot->SetName("background");    th1tot->Write("background");
    th1ww->SetName("ww");             th1ww->Write("ww");
    th1ww->SetName("wz");             th1wz->Write("wz");
    th1wv->SetName("diboson");        th1wv->Write("diboson");

    th1wv_no_overflow->Write("th1wv_no_overflow");
    char* tempname = "background_backshapeUp";
    if(channel==0) tempname = "background_mudijet_backshapeUp";
    if(channel==1) tempname = "background_eldijet_backshapeUp";
    if(channel==2) tempname = "background_muboosted_backshapeUp";
    if(channel==3) tempname = "background_elboosted_backshapeUp";
    systUp->SetName(tempname);
    systUp->Write(tempname);
    tempname = "background_backshapeDown";
    if(channel==0) tempname = "background_mudijet_backshapeDown";
    if(channel==1) tempname = "background_eldijet_backshapeDown";
    if(channel==2) tempname = "background_muboosted_backshapeDown";
    if(channel==3) tempname = "background_elboosted_backshapeDown";
    systDown->SetName(tempname);
    systDown->Write(tempname);

    outputForLimit->Close();

  } ///// close if saveDataCards_

    //delete th1wvclone;
}
Esempio n. 5
0
/*--------------------------------------------------------------------------*/
int sci_fec(char *fname, void *pvApiCtx)
{
    SciErr sciErr;
    int m1 = 0, n1 = 0, m2 = 0, n2 = 0, m3 = 0, n3 = 0, m4 = 0, n4 = 0, mn1 = 0;

    static rhs_opts opts[] =
    {
        { -1, "colminmax", -1, 0, 0, NULL},
        { -1, "colout", -1, 0, 0, NULL},
        { -1, "leg", -1, 0, 0, NULL},
        { -1, "mesh", -1, 0, 0, NULL},
        { -1, "nax", -1, 0, 0, NULL},
        { -1, "rect", -1, 0, 0, NULL},
        { -1, "strf", -1, 0, 0, NULL},
        { -1, "zminmax", -1, 0, 0, NULL},
        { -1, NULL, -1, 0, 0, NULL}
    };

    char* strf      = NULL;
    char strfl[4];
    char* legend    = NULL;
    double* rect    = NULL;
    double* zminmax = NULL;
    int* colminmax  = NULL;
    int* nax        = NULL;
    int* colOut     = NULL;
    BOOL flagNax    = FALSE;
    BOOL withMesh   = FALSE;

    int* piAddr1 = NULL;
    int* piAddr2 = NULL;
    int* piAddr3 = NULL;
    int* piAddr4 = NULL;

    double* l1 = NULL;
    double* l2 = NULL;
    double* l3 = NULL;
    double* l4 = NULL;

    if (nbInputArgument(pvApiCtx) <= 0)
    {
        sci_demo(fname, pvApiCtx);
        return 0;
    }

    CheckInputArgument(pvApiCtx, 4, 12);

    if (getOptionals(pvApiCtx, fname, opts) == 0)
    {
        ReturnArguments(pvApiCtx);
        return 0;
    }

    if (FirstOpt(pvApiCtx) < 5)
    {
        Scierror(999, _("%s: Misplaced optional argument: #%d must be at position %d.\n"), fname, 1, 5);
        return -1;
    }

    //get variable address
    sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr1);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 1;
    }

    // Retrieve a matrix of double at position 1.
    sciErr = getMatrixOfDouble(pvApiCtx, piAddr1, &m1, &n1, &l1);
    if (sciErr.iErr)
    {
        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 1);
        printError(&sciErr, 0);
        return 1;
    }

    //get variable address
    sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr2);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 1;
    }

    // Retrieve a matrix of double at position 2.
    sciErr = getMatrixOfDouble(pvApiCtx, piAddr2, &m2, &n2, &l2);
    if (sciErr.iErr)
    {
        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 2);
        printError(&sciErr, 0);
        return 1;
    }

    //CheckSameDims
    if (m1 != m2 || n1 != n2)
    {
        Scierror(999, _("%s: Wrong size for input argument #%d: %d-by-%d matrix expected.\n"), fname, 1, m1, n1);
        return 1;
    }


    //get variable address
    sciErr = getVarAddressFromPosition(pvApiCtx, 3, &piAddr3);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 1;
    }

    // Retrieve a matrix of double at position 3.
    sciErr = getMatrixOfDouble(pvApiCtx, piAddr3, &m3, &n3, &l3);
    if (sciErr.iErr)
    {
        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 3);
        printError(&sciErr, 0);
        return 1;
    }

    if (n3 < 5)
    {
        Scierror(999, _("%s: Wrong number of columns for input argument #%d: at least %d expected.\n"), fname, 3, 5);
        return 0;
    }
    // remove number and flag
    n3 -= 2;

    //get variable address
    sciErr = getVarAddressFromPosition(pvApiCtx, 4, &piAddr4);
    if (sciErr.iErr)
    {
        printError(&sciErr, 0);
        return 1;
    }

    // Retrieve a matrix of double at position 4.
    sciErr = getMatrixOfDouble(pvApiCtx, piAddr4, &m4, &n4, &l4);
    if (sciErr.iErr)
    {
        Scierror(202, _("%s: Wrong type for argument #%d: A real expected.\n"), fname, 4);
        printError(&sciErr, 0);
        return 1;
    }


    if (m1 * n1 == 0 || m3 == 0)
    {
        AssignOutputVariable(pvApiCtx, 1) = 0;
        ReturnArguments(pvApiCtx);
        return 0;
    }

    GetStrf(pvApiCtx, fname, 5, opts, &strf);
    GetLegend(pvApiCtx, fname, 6, opts, &legend);
    GetRect(pvApiCtx, fname, 7, opts, &rect);
    GetNax(pvApiCtx, 8, opts, &nax, &flagNax);
    GetZminmax(pvApiCtx, fname, 9, opts, &zminmax);
    GetColminmax(pvApiCtx, fname, 10, opts, &colminmax);
    GetColOut(pvApiCtx, fname, 11, opts, &colOut);
    GetWithMesh(pvApiCtx, fname, 12, opts, &withMesh);

    getOrCreateDefaultSubwin();

    if (isDefStrf (strf))
    {
        strcpy(strfl, DEFSTRFN);

        strf = strfl;
        if (!isDefRect(rect))
        {
            strfl[1] = '7';
        }
        if (!isDefLegend(legend))
        {
            strfl[0] = '1';
        }
    }
    mn1 = m1 * n1;

    Objfec ((l1), (l2), (l3), (l4), &mn1, &m3, &n3, strf, legend, rect, nax, zminmax, colminmax, colOut, withMesh, flagNax);

    AssignOutputVariable(pvApiCtx, 1) = 0;
    ReturnArguments(pvApiCtx);

    return 0;
}
Esempio n. 6
0
/*------------------------------------------------------------------------*/
int sci_plot2d( char * fname, unsigned long fname_len )
{

    int m1 = 0, n1 = 0, l1 = 0, m2 = 0, n2 = 0, l2 = 0, lt = 0;
    int test = 0, i = 0, j = 0, iskip = 0;
    int frame_def = 8;
    int *frame = &frame_def;
    int axes_def = 1;
    int *axes = &axes_def;

    /* F.Leray 18.05.04 : log. case test*/
    int size_x = 0, size_y = 0;
    double xd[2];
    char dataflag = 0;

    char   * logFlags = NULL  ;
    int    * style    = NULL  ;
    double * rect     = NULL  ;
    char   * strf     = NULL  ;
    char   * legend   = NULL  ;
    int    * nax      = NULL  ;
    BOOL     flagNax  = FALSE ;
    char strfl[4];

    static rhs_opts opts[] = { { -1, "axesflag", "?", 0, 0, 0},
        { -1, "frameflag", "?", 0, 0, 0},
        { -1, "leg", "?", 0, 0, 0},
        { -1, "logflag", "?", 0, 0, 0},
        { -1, "nax", "?", 0, 0, 0},
        { -1, "rect", "?", 0, 0, 0},
        { -1, "strf", "?", 0, 0, 0},
        { -1, "style", "?", 0, 0, 0},
        { -1, NULL, NULL, 0, 0, 0}
    };

    if (Rhs == 0)
    {
        sci_demo(fname, fname_len);
        return 0;
    }

    CheckRhs(1, 9);

    iskip = 0;
    if ( get_optionals(fname, opts) == 0)
    {
        PutLhsVar();
        return 0 ;
    }

    if (GetType(1) == sci_strings)
    {
        /* logflags */
        GetLogflags( fname, 1, opts, &logFlags ) ;
        iskip = 1;
    }

    if (FirstOpt() == 2 + iskip)       				/** plot2d([loglags,] y, <opt_args>); **/
    {
        GetRhsVar(1 + iskip, MATRIX_OF_DOUBLE_DATATYPE, &m2, &n2, &l2);

        if (m2 == 1 && n2 > 1)
        {
            m2 = n2;
            n2 = 1;
        }
        m1 = m2;
        n1 = n2;
        CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE,  &m1, &n1, &l1);

        for (i = 0; i < m2 ; ++i)
        {
            for (j = 0 ; j < n2 ;  ++j)
            {
                *stk( l1 + i + m2 * j) = (double) i + 1;
            }
        }
    }
    else if (FirstOpt() >= 3 + iskip)     /** plot2d([loglags,] x, y[, style [,...]]); **/
    {

        /* x */
        GetRhsVar(1 + iskip, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1);

        /* y */
        GetRhsVar(2 + iskip, MATRIX_OF_DOUBLE_DATATYPE, &m2, &n2, &l2);

        test = (m1 * n1 == 0) ||
               ((m1 == 1 || n1 == 1) && (m2 == 1 || n2 == 1) && (m1 * n1 == m2 * n2))  ||
               ((m1 == m2) && (n1 == n2)) ||
               ((m1 == 1 && n1 == m2) || (n1 == 1 && m1 == m2));
        CheckDimProp(1 + iskip, 2 + iskip, !test);

        if (m1 * n1 == 0)
        {
            /* default x=1:n */
            CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE,  &m2, &n2, &lt);
            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *stk( lt + i + m2 * j) = (double) i + 1;
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 || n1 == 1) && (m2 != 1 && n2 != 1) )
        {
            /* a single x vector for mutiple columns for y */
            CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE,  &m2, &n2, &lt);
            for (i = 0; i < m2 ; ++i)
            {
                for (j = 0 ; j < n2 ;  ++j)
                {
                    *stk( lt + i + m2 * j) = *stk(l1 + i);
                }
            }
            m1 = m2;
            n1 = n2;
            l1 = lt;
        }
        else if ((m1 == 1 && n1 == 1) && (n2 != 1) )
        {
            /* a single y row vector  for a single x */
            CreateVar(Rhs + 1, MATRIX_OF_DOUBLE_DATATYPE,  &m1, &n2, &lt);
            for (j = 0 ; j < n2 ;  ++j)
            {
                *stk( lt + j ) = *stk(l1);
            }
            n1 = n2;
            l1 = lt;
        }
        else
        {
            if (m2 == 1 && n2 > 1)
            {
                m2 = n2;
                n2 = 1;
            }
            if (m1 == 1 && n1 > 1)
            {
                m1 = n1;
                n1 = 1;
            }
        }
    }
    else
    {
        Scierror(999, _("%s: Wrong number of mandatory input arguments. At least %d expected.\n"), fname, 1);
        return 0;
    }

    if (n1 == -1 || n2 == -1 || m1 == -1 || m2 == -1)
    {
        Scierror(999, _("%s: Wrong size for input arguments #%d and #%d.\n"), fname, 1, 2); /* @TODO : detail error */
        return 0;
    }

    sciGetStyle( fname, 3 + iskip, n1, opts, &style ) ;

    GetStrf( fname, 4 + iskip, opts, &strf ) ;

    GetLegend( fname, 5 + iskip, opts, &legend );

    GetRect( fname, 6 + iskip, opts, &rect );

    GetNax( 7 + iskip, opts, &nax, &flagNax ) ;

    if (iskip == 0)
    {
        GetLogflags( fname, 8, opts, &logFlags ) ;
    }

    if ( isDefStrf( strf ) )
    {
        strcpy(strfl, DEFSTRFN);

        strf = strfl;
        if ( !isDefRect( rect ) )
        {
            strfl[1] = '7';
        }
        if ( !isDefLegend( legend ) )
        {
            strfl[0] = '1';
        }

        GetOptionalIntArg(fname, 9, "frameflag", &frame, 1, opts);
        if ( frame != &frame_def )
        {
            strfl[1] = (char)(*frame + 48);
        }

        GetOptionalIntArg(fname, 9, "axesflag", &axes, 1, opts);

        if (axes != &axes_def)
        {
            strfl[2] = (char)(*axes + 48);
        }
    }

    /* Make a test on log. mode : available or not depending on the bounds set by Rect arg. or xmin/xmax :
    Rect case :
    - if the min bound is strictly posivite, we can use log. mode
    - if not, send error message
    x/y min/max case:
    - we find the first strictly positive min bound in Plo2dn.c ?? */

    switch (strf[1])
    {
        case '0':
            /* no computation, the plot use the previous (or default) scale */
            break;
        case '1' :
        case '3' :
        case '5' :
        case '7':
            /* based on Rect arg */
            if ( rect[0] > rect[2] || rect[1] > rect[3])
            {
                Scierror(999, _("%s: Impossible status min > max in x or y rect data.\n"), fname);
                return -1;
            }

            if ( rect[0] <= 0. && logFlags[1] == 'l') /* xmin */
            {
                Scierror(999, _("%s: Bounds on x axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1 ;
            }

            if ( rect[1] <= 0. && logFlags[2] == 'l') /* ymin */
            {
                Scierror(999, _("%s: Bounds on y axis must be strictly positive to use logarithmic mode.\n"), fname);
                return -1 ;
            }

            break;
        case '2' :
        case '4' :
        case '6' :
        case '8':
        case '9':
            /* computed from the x/y min/max */
            if ( (int)strlen(logFlags) < 1)
            {
                dataflag = 'g' ;
            }
            else
            {
                dataflag = logFlags[0];
            }

            switch ( dataflag )
            {
                case 'e' :
                    xd[0] = 1.0;
                    xd[1] = (double)m1;
                    size_x = (m1 != 0) ? 2 : 0 ;
                    break;
                case 'o' :
                    size_x = m1;
                    break;
                case 'g' :
                default  :
                    size_x = (n1 * m1) ;
                    break;
            }

            if (size_x != 0)
            {
                if (logFlags[1] == 'l' && sciFindStPosMin(stk(l1), size_x) <= 0.0 )
                {
                    Scierror(999, _("%s: At least one x data must be strictly positive to compute the bounds and use logarithmic mode.\n"), fname);
                    return -1 ;
                }
            }

            size_y = (n1 * m1) ;

            if (size_y != 0)
            {
                if ( logFlags[2] == 'l' && sciFindStPosMin(stk(l2), size_y) <= 0.0 )
                {
                    Scierror(999, _("%s: At least one y data must be strictly positive to compute the bounds and use logarithmic mode\n"), fname);
                    return -1 ;
                }
            }

            break;
    }

    // open a figure if none already exists
    getOrCreateDefaultSubwin();
    Objplot2d (1, logFlags, stk(l1), stk(l2), &n1, &m1, style, strf, legend, rect, nax, flagNax);

    LhsVar(1) = 0;
    PutLhsVar();
    return 0;
}