# Saved cut file, hoho.c and "cutg\_hello.root"

**URL:** <https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435>\
**Category:** Newbie\
**Created:** [October 21, 2019, 9:37am UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435 "2019-10-21T09:37:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![teffo1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teffo1/32/24826_2.png) [@teffo1](https://root-forum.cern.ch/u/teffo1)\
**Post date:** [October 21, 2019, 9:37am UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435/1 "2019-10-21T09:37:49Z")

</div>

Hi guys I am trying to save the cut and read it and again create a root file using:

```auto
if( DoesFileExist("cutg_hello.root") ) { f_cut = new TFile("cutg_hello.root","RECREATE"); Skip = true; cout << "getting the cut"<< endl;cutg = (TCutG*)f_cut->Get("CUTG"); cout << "got the cut"<< endl; cutg->SaveAs("hoho.c");

```

and after running my code I cannot find the data inside cutg\_hello.root file and a saved hoho.c file thanks in advance.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 21, 2019, 10:10am UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435/2 "2019-10-21T10:10:31Z")

</div>

You “[RECREATE](https://root.cern.ch/doc/master/classTFile.html#ab845cc9ba0d8f84b0da918f7708f5398)” the file, which means that it becomes empty.

---

<div class="post-metadata">

**Author:** ![teffo1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teffo1/32/24826_2.png) [@teffo1](https://root-forum.cern.ch/u/teffo1)\
**Post date:** [October 21, 2019, 10:30am UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435/3 "2019-10-21T10:30:16Z")

</div>

Thank you Wile for your reply, I think I posted an old part of the code, this is the right part were I do’nt recreate 🙂

if (!Skip) {  
f\_cut = new TFile(“cutg\_hello.root”);  
cutg = (TCutG\*) gPad-\>WaitPrimitive(“CUTG”, “CUTG”); // making cut, store to CUTG  
cout \<\< “\n … finished graphical cut … rereading the ntuple using that g-cut \n”;  
f\_cut-\>cd();  
cutg-\>Write();  
cutg-\>SaveAs(“hoho.c”); // just testing  
f\_cut-\>Close();  
cout \<\< "Area is … " \<\< cutg-\>Area() \<\< endl;

And I only get the saved hoho.c file saved when I open the “cutg\_hello.root” I get thie following error: Error in TFile::ReadBuffer: error reading all requested bytes from file cutg\_hello.root, got 226 of 300

Error in TFile::Init: cutg\_hello.root failed to read the file type data.

(TFile \*) nullptr

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [October 21, 2019, 11:16am UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435/4 "2019-10-21T11:16:09Z")

</div>

If you open your (existing) file for “[READ](https://root.cern.ch/doc/master/classTFile.html#ab845cc9ba0d8f84b0da918f7708f5398)” then you cannot write to it.

---

<div class="post-metadata">

**Author:** ![teffo1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/teffo1/32/24826_2.png) [@teffo1](https://root-forum.cern.ch/u/teffo1)\
**Post date:** [October 21, 2019, 12:40pm UTC](https://root-forum.cern.ch/t/saved-cut-file-hoho-c-and-cutg-hello-root/36435/5 "2019-10-21T12:40:23Z")

</div>

> [@teffo1](#):
>
> f\_cut = new TFile(“cutg\_hello.root”);  
> cutg = (TCutG\*) gPad-\>WaitPrimitive(“CUTG”, “CUTG”); // making cut, store to CUTG

Noted! thanks Wile .
