Finding the Tree name in a .root file

I have recreated a .root file using TSelector and I want to use this file for further analysis e.g I subtracted some channel numbers in a histogram and made a new .root file where histograms are lying at shifted positions. Now while using this file into another root program (where I am generating more new histograms using the shifted one) it is giving me an error:

Error in <TChain::LoadTree>: Cannot find tree with name RoseNIAS in file RFshifted.root

I made this RFshifted.root file which has Tree Name RoseNIAS.

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Can you post here the output of:

$ root RFshifted.root
...
root [1] _file0->ls()

or the output of:

$ rootls -l RFshifted.root

Dropping down to last entry:-

So this file does not contain the TTree RoseNIAS … Indeed, it does not contain any TTree. It has only TH1D. So it is normal you get this message from TChain.

This is understandable. Tree is not forming but what is the way out in that case if I want to use this file further for analysis. Means after applying shifting to some of the histograms I saved it into a .root file. The header file is generated as:
** This class has been automatically generated by ROOT version 5.34/09 from TTree RoseNIAS/ROSE **

Now I want to use this file into another program where I am changing time-of-flight to energy (obviously with the corrected centroids) but while clubbing/chaining it is giving the error.

Your file does not contain a tree. It contains only histograms. You should create a tree (somehow) if you want to use a chain. That’s your data you should know what your tree should contain. Creating a tree from histograms is not the normal way. Usually you do the opposite.

Ok I have created a .root file having Tree with leaves and branches. But this I have created using

         TFile *f = new TFile("232Th_280MeV_2.001", "READ");
        TTree *RoseNIAS = (TTree* )f->Get("RoseNIAS");        
        Double_t ADC01_ADC[32];
        Double_t ADC02_ADC[32];
        Double_t TDC01_TDC[32];    //RoseNIAS is the name of tree
          
         RoseNIAS->SetBranchAddress("ADC01.ADC",ADC01_ADC);	
         RoseNIAS->SetBranchAddress("ADC02.ADC",ADC02_ADC);
         RoseNIAS->SetBranchAddress("TDC01.TDC",TDC01_TDC);

TFile *ff = new TFile("232Th_280MeV_2.root","RECREATE");
	TTree *FissionTree = new TTree("FissionTree", "having all the leaves");        

      UShort_t P8009,P8027,P8045,P8063,P8081,P8099,P8117,P8135,P8207,P8225;
      UShort_t E8009,E8027,E8045,E8063,E8081,E8099,E8117,E8135,E8207,E8225;
      UShort_t T8009,T8027,T8045,T8063,T8081,T8099,T8117,T8135,T8207,T8225;
      Long64_t i,j,entries;

	FissionTree->Branch("P8009",&P8009,"P8009/s");
	FissionTree->Branch("P8027",&P8027,"P8027/s");
	FissionTree->Branch("P8045",&P8045,"P8045/s");
	FissionTree->Branch("P8063",&P8063,"P8063/s");
        FissionTree->Branch("P8081",&P8081,"P8081/s");

so on… and then

for(i=0;i<entries;i++)
	{
	  RoseNIAS->GetEntry(i);
          if (!(i%50000)) printf("Percentage done=%.1f\n",100.0*i/entries);
     P8009=ADC01_ADC[0];  E8009=ADC01_ADC[1];    T8009=TDC01_TDC[0]; 
.
.
.
In the last
FissionTree->Fill();
	}

	ff->Write();
	ff->Close();

filling the tree and the writing.
I want to know is there any way in which I can use this tree to generate histograms further into a root file.
Also suppose I want to add some channels in timing “T8009”. How can I do that???

When you have a tree the Draw() method (for instance) creates histogram for you from the tree variables.
But may be you do not need tree at all ? I understood you already had the histograms.
What I was saying is that the method TChain::LoadTree needs a tree and you can not use it if you do not have a tree. Why do you need to use TChain ?

I need to use TChain in order to utilise the regenerated “.root” files (having histograms and some shifted peak histograms too) into a program where I need to obtain Energy expression from Time of flight and to apply some graphical cuts. Obviously I will club/add all the data files because all belong to same set of conditions. It is tedious to do things one by one with each file where I need to get the same kind of output everytime.

So:

auto h = new TH1D('h","h".....);
tree->Draw("v1>>h");
auto h = new TH1D('h","h".....);
tree->Draw("v1+v2>>h");
  • v1 and v2 are variables in your tree