# Draw the 2-D histograms which in the subFolder

**URL:** <https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902>\
**Category:** ROOT\
**Created:** [February 19, 2011, 6:33am UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902 "2011-02-19T06:33:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ertaoLee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/47e85d/32.png) [@ertaoLee](https://root-forum.cern.ch/u/ertaoLee)\
**Post date:** [February 19, 2011, 6:33am UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902/1 "2011-02-19T06:33:43Z")

</div>

I have a file which have a Folder and a subFolder, in the subFolder there are some 2-D histograms. My question is: how to Draw the 2-D histograms using command method?

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [February 28, 2011, 6:00pm UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902/2 "2011-02-28T18:00:12Z")

</div>

Hi,

Humm do you mean:

```auto
TFile *f = TFile::Open("myfile.root");
f->cd("mydirectory");
myhist->Draw();

```

Philippe.

---

<div class="post-metadata">

**Author:** ![ertaoLee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/47e85d/32.png) [@ertaoLee](https://root-forum.cern.ch/u/ertaoLee)\
**Post date:** [March 8, 2011, 12:33pm UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902/3 "2011-03-08T12:33:15Z")

</div>

I am sorry! This is my .root file:[run.root](https://root-forum.cern.ch/uploads/default/original/2X/3/3b2306cf06f973f238a4bfd4c2b0a4b5304f8a09.root) (228 KB) It contains shDsssdE histogram, how can I draw it use command method?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [March 8, 2011, 2:21pm UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902/4 "2011-03-08T14:21:03Z")

</div>

Try (the strange thing is that you have a “TFolder” in a file - as far as I am aware, the “TFolder” is memory specific, there is the “TDirectory” which is for disk resident structures as well as memory):

```auto
// http://root.cern.ch/root/html/TFile.html

TFile *file = new TFile("run.root", "READ");

file->ls();

// http://root.cern.ch/root/html/TFolder.html

TFolder *histos = (TFolder*)(file->FindObjectAny("histos"));

histos->ls();
histos->FindObjectAny("shDsssdE")->Draw();
histos->FindObjectAny("chDsssdE")->Draw();
histos->GetListOfFolders()->Print();
histos->FindObject("singles")->ls();
histos->FindObject("singles (cut)")->ls();
((TFolder*)(histos->GetListOfFolders()->FindObject("singles")))->FindObjectAny("shDsssdE")->Draw();
histos->GetListOfFolders()->FindObject("singles")->FindObject("shDsssdE")->Draw();
std::cout << histos->FindFullPathName("shDsssdE") << std::endl;
histos->FindObject("coincidences")->ls();
((TFolder*)(histos->GetListOfFolders()->FindObject("coincidences")))->FindObjectAny("chDsssdE")->Draw();
histos->GetListOfFolders()->FindObject("coincidences")->FindObject("chDsssdE")->Draw();
std::cout << histos->FindFullPathName("chDsssdE") << std::endl;
histos->FindObject("coincidences (cut)")->ls();

// http://root.cern.ch/root/html/TH1.html

TH1F *shDsssdERf = (TH1F*)(histos->FindObjectAny("shDsssdERf"));
TH1F *chDsssdERf = (TH1F*)(histos->FindObjectAny("chDsssdERf"));

shDsssdERf->Draw();
std::cout << shDsssdERf->GetNbinsX() << std::endl;
std::cout << shDsssdERf->GetEntries() << std::endl;
std::cout << shDsssdERf->GetBinContent(shDsssdERf->FindBin(500.0)) << std::endl;

chDsssdERf->Draw();
std::cout << chDsssdERf->GetNbinsX() << std::endl;
std::cout << chDsssdERf->GetEntries() << std::endl;
std::cout << chDsssdERf->GetBinContent(chDsssdERf->FindBin(500.0)) << std::endl;

// http://root.cern.ch/root/html/TH2.html

TH2F *shDsssdE = (TH2F*)(histos->FindObjectAny("shDsssdE"));
TH2F *chDsssdE = (TH2F*)(histos->FindObjectAny("chDsssdE"));

shDsssdE->Draw();
shDsssdE->ProfileX()->Draw();
shDsssdE->ProfileY()->Draw();
shDsssdE->ProjectionX()->Draw();
shDsssdE->ProjectionY()->Draw();
std::cout << shDsssdE->GetNbinsX() << std::endl;
std::cout << shDsssdE->GetNbinsY() << std::endl;
std::cout << shDsssdE->GetEntries() << std::endl;
std::cout << shDsssdE->GetBinContent(shDsssdE->FindBin(2200.0, 8.0)) << std::endl;

chDsssdE->Draw();
chDsssdE->ProfileX()->Draw();
chDsssdE->ProfileY()->Draw();
chDsssdE->ProjectionX()->Draw();
chDsssdE->ProjectionY()->Draw();
std::cout << chDsssdE->GetNbinsX() << std::endl;
std::cout << chDsssdE->GetNbinsY() << std::endl;
std::cout << chDsssdE->GetEntries() << std::endl;
std::cout << chDsssdE->GetBinContent(chDsssdE->FindBin(2200.0, 8.0)) << std::endl;

// http://root.cern.ch/root/html/tutorials/hist/index.html
// http://root.cern.ch/download/doc/3Histograms.pdf

// http://root.cern.ch/drupal/content/tutorials-and-courses
// http://root.cern.ch/root/html/tutorials/
// http://root.cern.ch/drupal/content/howtos
// http://root.cern.ch/drupal/content/users-guide
// http://root.cern.ch/drupal/content/reference-guide
```

---

<div class="post-metadata">

**Author:** ![ertaoLee](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/47e85d/32.png) [@ertaoLee](https://root-forum.cern.ch/u/ertaoLee)\
**Post date:** [March 20, 2011, 12:15pm UTC](https://root-forum.cern.ch/t/draw-the-2-d-histograms-which-in-the-subfolder/11902/5 "2011-03-20T12:15:51Z")

</div>

Thanks a lot!
