# Minor modification to TCutG.cxx for ROOT 6

**URL:** <https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [April 3, 2016, 1:22pm UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907 "2016-04-03T13:22:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![useROOT](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/f9ae1b/32.png) [@useROOT](https://root-forum.cern.ch/u/useROOT)\
**Post date:** [April 3, 2016, 1:22pm UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/1 "2016-04-03T13:22:34Z")

</div>

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

```auto
// ______________________________________________________________________________
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;
}
```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 4, 2016, 8:49am UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/2 "2016-04-04T08:49:08Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![useROOT](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/f9ae1b/32.png) [@useROOT](https://root-forum.cern.ch/u/useROOT)\
**Post date:** [April 5, 2016, 10:00pm UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/3 "2016-04-05T22:00:07Z")

</div>

[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]

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 6, 2016, 7:48am UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/4 "2016-04-06T07:48:29Z")

</div>

> [@](#):
>
> I see that you are using 6.07/07 ?

So the problem you mentioned has already been fixed.

---

<div class="post-metadata">

**Author:** ![useROOT](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/f9ae1b/32.png) [@useROOT](https://root-forum.cern.ch/u/useROOT)\
**Post date:** [April 6, 2016, 10:17am UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/5 "2016-04-06T10:17:11Z")

</div>

[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 ?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 6, 2016, 10:36am UTC](https://root-forum.cern.ch/t/minor-modification-to-tcutg-cxx-for-root-6/20907/6 "2016-04-06T10:36:53Z")

</div>

The master version can be downloaded from here: [github.com/root-mirror/root](https://github.com/root-mirror/root)
