Minor modification to TCutG.cxx for ROOT 6

Ok i’m not sure if this fits here but here it goes

The new ROOT 6 now follows a more rigorous C++ standard, yet the saved cuts are still following ROOT 5 standards. Thus, once you save multiple cuts , e.g. cutsxxx.C, loading them in ROOT6, especially using a script, throw up plenty of warning etc. So after some investigation, I found that my making small modification to the TCutG.cxx file, all saved cut files now play nice in both ROOT 5 and ROOT 6. The modified bits is shown below

//______________________________________________________________________________
void TCutG::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
{
   // Save primitive as a C++ statement(s) on output stream out.

   char quote = '"';
   out<<"   "<<std::endl;
   if (gROOT->ClassSaved(TCutG::Class())) {
      out<<"   ";
   } else {
      out<<"   ";
   }
   out<<GetName()<<"= new TCutG("<<quote<<GetName()<<quote<<","<<fNpoints<<");"<<std::endl;
   out<<"   "<<GetName()<<"->SetVarX("<<quote<<GetVarX()<<quote<<");"<<std::endl;
   out<<"   "<<GetName()<<"->SetVarY("<<quote<<GetVarY()<<quote<<");"<<std::endl;
   out<<"   "<<GetName()<<"->SetTitle("<<quote<<GetTitle()<<quote<<");"<<std::endl;

   SaveFillAttributes(out,GetName(),0,1001);
   SaveLineAttributes(out,GetName(),1,1,1);
   SaveMarkerAttributes(out,GetName(),1,1,1);
   
   for (Int_t i=0;i<fNpoints;i++) {
     out<<"   "<<GetName()<<"->SetPoint("<<i<<","<<fX[i]<<","<<fY[i]<<");"<<std::endl;
   }
   out<<"   "<<GetName()<<"->Draw("
      <<quote<<option<<quote<<");"<<std::endl;
}

I just tried to generate a TCutg using the toolbar then I saved it as a C file. I macro I get is:

void c1()
{
//=========Macro generated from canvas: c1/c1
//=========  (Mon Apr  4 10:47:04 2016) by ROOT version6.07/07
   TCanvas *c1 = new TCanvas("c1", "c1",10,45,700,527);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetFrameBorderMode(0);
   
   TCutG *cutg = new TCutG("CUTG",6);
   cutg->SetVarX("");
   cutg->SetVarY("");
   cutg->SetTitle("Graph");
   cutg->SetFillColor(1);
   cutg->SetPoint(0,0.3137536,0.5936842);
   cutg->SetPoint(1,0.5372493,0.7368421);
   cutg->SetPoint(2,0.5716332,0.5136842);
   cutg->SetPoint(3,0.4326648,0.3178947);
   cutg->SetPoint(4,0.3137536,0.5978947);
   cutg->SetPoint(5,0.3137536,0.5936842);
   cutg->Draw("l");
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
   c1->ToggleToolBar();
}

When I execute it with ROOT I do not get any warning.

[quote=“couet”]I just tried to generate a TCutg using the toolbar then I saved it as a C file. I macro I get is:

When I execute it with ROOT I do not get any warning.[/quote]

I see that you are using 6.07/07 ?

I just compiled a stock version of 6.04/02 (just to make sure) and the cuts I produced using the TreeViewer are quite different

The first cut always have TCutG *:[code]{
//========= Macro generated from object: myCUT/Graph
//========= by ROOT version6.06/02

TCutG *cutg = new TCutG(“myCUT”,5);
cutg->SetVarX("");
cutg->SetVarY("");
cutg->SetTitle(“Graph”);
cutg->SetFillColor(1);
cutg->SetPoint(0,7.87529,18.3323);
cutg->SetPoint(1,20.8818,18.5717);
cutg->SetPoint(2,20.3717,6.28103);
cutg->SetPoint(3,7.1102,7.87722);
cutg->SetPoint(4,7.87529,18.3323);
cutg->Draw("");
}[/code]

subsequent cuts from the same session does not have TCutG *

[code]{
//========= Macro generated from object: HELLO/Graph
//========= by ROOT version6.06/02

cutg = new TCutG(“HELLO”,4);
cutg->SetVarX("");
cutg->SetVarY("");
cutg->SetTitle(“Graph”);
cutg->SetFillColor(1);
cutg->SetPoint(0,11.0886,16.3371);
cutg->SetPoint(1,14.9651,11.6283);
cutg->SetPoint(2,12.8739,10.4311);
cutg->SetPoint(3,11.0886,16.3371);
cutg->Draw("");
}[/code]

So the problem you mentioned has already been fixed.

[quote=“couet”][quote]
I see that you are using 6.07/07 ?
[/quote]
So the problem you mentioned has already been fixed.[/quote]

Sorry to be ignorance but how does one get ROOT 6.07/07 while the Pro version is 6.06/02. This sounds like a break-away ?

The master version can be downloaded from here: github.com/root-mirror/root