# Calling a private constructor of class 'TFile'

**URL:** <https://root-forum.cern.ch/t/calling-a-private-constructor-of-class-tfile/31508>\
**Category:** Newbie\
**Created:** [November 8, 2018, 11:54pm UTC](https://root-forum.cern.ch/t/calling-a-private-constructor-of-class-tfile/31508 "2018-11-08T23:54:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oocampo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oocampo](https://root-forum.cern.ch/u/oocampo)\
**Post date:** [November 8, 2018, 11:54pm UTC](https://root-forum.cern.ch/t/calling-a-private-constructor-of-class-tfile/31508/1 "2018-11-08T23:54:58Z")

</div>

Hello,

I am trying to use root to display a series of Histograms on a cent OS virtual machine.  
I am supposed to call “root analysis.C” and this analysis.C file calls an output.root file that I think it may contain the data for the histograms.

After calling “root analysis.C” this appears:

```auto
 ------------------------------------------------------------
  | Welcome to ROOT 6.14/04 http://root.cern.ch |
  | (c) 1995-2018, The ROOT Team |
  | Built for linuxx8664gcc |
  | From tags/v6-14-04@v6-14-04, Aug 23 2018, 17:00:44 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------

root [0] 
Processing analysis.C...
/home/oocampo/Documentos/G4_examples_test/extended/medical/dna/pdb4dna/./analysis.C:30:13: error: calling a private constructor of class 'TFile'
  TFile f = TFile("pdb4dna_output.root");
            ^
/home/oocampo/Documentos/programas/root_builddir/include/TFile.h:156:4: note: declared private here
   TFile(const TFile &); //Files cannot be copied
   ^
/home/oocampo/Documentos/G4_examples_test/extended/medical/dna/pdb4dna/./analysis.C:54:8: error: member reference type 'TH1D *' is a pointer; did you mean to use '->'?
  hist1.GetStats(pdbStats);
  ~~~~~ ^
       ->
/home/oocampo/Documentos/G4_examples_test/extended/medical/dna/pdb4dna/./analysis.C:57:8: error: member reference type 'TH1D *' is a pointer; did you mean to use '->'?
  hist2.GetStats(pdbStats);
  ~~~~~ ^
       ->
/home/oocampo/Documentos/G4_examples_test/extended/medical/dna/pdb4dna/./analysis.C:60:8: error: member reference type 'TH1D *' is a pointer; did you mean to use '->'?
  hist3.GetStats(pdbStats);
  ~~~~~ ^
       ->

```

I am trying to display the histograms for a Geant4 example called pdb4dna.

Thanks a lot for your help.

---

<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:** [November 9, 2018, 7:00am UTC](https://root-forum.cern.ch/t/calling-a-private-constructor-of-class-tfile/31508/2 "2018-11-09T07:00:53Z")

</div>

```auto
TFile f("pdb4dna_output.root");
// ... or ...
TFile *f = TFile::Open("pdb4dna_output.root");
// ... and for each histogram pointer ...
hist123->GetStats(pdbStats);

```

BTW. When you post “source code” or “output” here, do remember to enclose them into two lines which contain just three characters ``` (see how your post has been edited above).

---

<div class="post-metadata">

**Author:** ![oocampo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oocampo](https://root-forum.cern.ch/u/oocampo)\
**Post date:** [November 14, 2018, 6:33pm UTC](https://root-forum.cern.ch/t/calling-a-private-constructor-of-class-tfile/31508/3 "2018-11-14T18:33:22Z")

</div>

Thank you so much, it solved the problem.

Also thanks a lot for the info on using this ```.

Cheers!
