Can't get the tree content from the root file

Hi,
I’m trying to convert ORTEC-MAESTRO files to root files by adding required information on tree branches. When I check the root file via TBrowser, I get/see the stored values but in the batch mode nothing comes back.

_ROOT Version: 5.34/38
_Platform: Win10
_Compiler: Cint


void okuw(){
	char		mSPEC_ID[256], //specinfo
				mDATE_MEA[256]; //datetime
	Int_t		mInitialCh,
				mFinalCh,
				*mData,
				mLiveTime, //MEAS_TIM
				mRealTime, 
				mDataSize;
	Float_t	mEnCal[3], 
				mShpCal[3];

	TH1F	*histo=new TH1F();
		histo->SetName("histo");
	TFile *mActiveFile = new TFile("MCA.root","RECREATE");
	TTree *mMCATree = new TTree("MCATree","Maestro File");
		mMCATree->Branch("mLiveTime",&mLiveTime,"mLiveTime/I");
		mMCATree->Branch("mRealTime",&mRealTime,"mRealTime/I");
		mMCATree->Branch("mDataSize",&mDataSize,"mDataSize/I");
		mMCATree->Branch("mEnCal",mEnCal,"mEnCal[3]/F");
		mMCATree->Branch("mShpCal",mShpCal,"mShpCal[3]/F");
		mMCATree->Branch("histo",histo,128000,0);
		mMCATree->Branch("mSPEC_ID",mSPEC_ID,"mSPEC_ID[256]/C");
		mMCATree->Branch("mDATE_MEA",mDATE_MEA,"mDATE_MEA[256]/C");

	Int_t i;
	char linex[256];
	ifstream	in;	
// https://drive.google.com/file/d/1cseGkus91ahrkL541Ixo8Z9c1vtvbqIf/view?usp=sharing
		in.open("Eu152_Pb_10.Spe"); 
	TString FLine(linex);
	while(1) {
		in.getline(linex,256);
		FLine=linex;

		if (FLine.Contains("$SPEC_ID:"))	{
			in.getline(mSPEC_ID,256);
			mSPEC_ID[strlen(mSPEC_ID)]='\0';
		}
		if (FLine.Contains("$DATE_MEA:")){
			in.getline(mDATE_MEA,256);
			mDATE_MEA[strlen(mDATE_MEA)]='\0';
		}
		if (FLine.Contains("$MEAS_TIM:"))	in >> mLiveTime >> mRealTime;
		if (FLine.Contains("$DATA:")) {
			in >> mInitialCh >> mFinalCh;
			mDataSize = (mFinalCh - mInitialCh) + 1;
			mData = new Int_t[mDataSize];
			for (i=mInitialCh; i<=mFinalCh; i++){ in >> mData[i];}
		}
		if (FLine.Contains("$MCA_CAL:")){	
			in.getline(linex, 256);
			in >> mEnCal[0] >> mEnCal[1] >> mEnCal[2] ;
		}
		if (FLine.Contains("$SHAPE_CAL:")){	
			in.getline(linex, 256);
			in >> mShpCal[0] >> mShpCal[1] >> mShpCal[2] ;
		}
		if (!in.good()) break;
	}
	
	cout << mSPEC_ID   << endl
	     << mDATE_MEA  << endl
		  << mInitialCh << endl
	     << mFinalCh   << endl
	     << mLiveTime  << endl
	     << mRealTime  << endl
	     << mDataSize  << endl
	     << mEnCal[0]  << " " << mEnCal[1]  << " " << mEnCal[2]  << " " << endl
	     << mShpCal[0] << " " << mShpCal[1] << " " << mShpCal[2] << " " << endl;
	in.close();	
	
	histo->SetTitle(mSPEC_ID);
	histo->SetBins(mDataSize-1, (Float_t)mInitialCh+0.5, (Float_t)mFinalCh+0.5);
	histo->GetXaxis()->SetTitle("Channel (Ch)");
	histo->GetYaxis()->SetTitle("dN/dCh");
	for (i=mInitialCh;i<=mFinalCh;i++){
		histo->SetBinContent(i, (Float_t)mData[i]);
	}

	mMCATree->Fill();
	mMCATree->Print();
	cout 	<< "#Branch : " << mMCATree->GetNbranches() << endl 
			<< "#Entries: " << mMCATree->GetEntries() << endl 	
			<< "#Bins   : " << histo->GetEntries() << endl << endl; 
	mMCATree->Write();
	mActiveFile->Close();

}
void okur(){
	char		rSPEC_ID[256], //specinfo
				rDATE_MEA[256]; //datetime
	Int_t		rLiveTime, //MEAS_TIM
				rRealTime, 
				rDataSize;
	Float_t	rEnCal[3], 
				rShpCal[3];

	TH1F	*rhisto;
	TFile *rActiveFile = new TFile("MCA.root","READ");
	TTree *rMCATree = (TTree*)rActiveFile->Get("MCATree");
		rMCATree->SetBranchAddress("mLiveTime",&rLiveTime);
		rMCATree->SetBranchAddress("mRealTime",&rRealTime);
		rMCATree->SetBranchAddress("mDataSize",&rDataSize);
		rMCATree->SetBranchAddress("mEnCal",rEnCal);
		rMCATree->SetBranchAddress("mShpCal",rShpCal);
		rMCATree->SetBranchAddress("histo",&rhisto);
		rMCATree->SetBranchAddress("mSPEC_ID",rSPEC_ID);
		rMCATree->SetBranchAddress("mDATE_MEA",rDATE_MEA);
	rMCATree->GetEntry(1);
	rMCATree->Print();
	rMCATree->Show();

	cout 	<< endl
			<< "#Branch : " << rMCATree->GetNbranches() << endl 
			<< "#Entries: " << rMCATree->GetEntries() << endl 	
			<< "#Bins   : " << rhisto->GetEntries() << endl << endl; 

	cout << rSPEC_ID   << endl
	     << rDATE_MEA  << endl
	     << rLiveTime  << endl
	     << rRealTime  << endl
	     << rDataSize  << endl
	     << rEnCal[0]  << " " << rEnCal[1]  << " " << rEnCal[2]  << " " << endl
	     << rShpCal[0] << " " << rShpCal[1] << " " << rShpCal[2] << " " << endl;
	
	rActiveFile->Close();		
}

At least (in “okur”): TH1F *rhisto = 0;

Thanks for reply. I’ve tried it but still nothing.

I guess, you should have (in “okuw”):

mMCATree->Branch("mSPEC_ID", mSPEC_ID, "mSPEC_ID/C");
mMCATree->Branch("mDATE_MEA", mDATE_MEA, "mDATE_MEA/C");

The output of TTree::Show() for okuw()

======> EVENT:-1
mLiveTime = 1177
mRealTime = 1200
mDataSize = 2048
mEnCal = -16.561,
0.723679, 1.4497e-005
mShpCal = 0,
0, 0
histo = (TH1F*)0x2f6e7e0
mSPEC_ID = Eu152 Pb m=536.6 t=1
mDATE_MEA = 08/09/2019 14:15:12

and for okur()

======> EVENT:-1
mLiveTime = 0
mRealTime = 0
mDataSize = 0
mEnCal = 2.6439e+020,
4.51325e+027, 1.41531e-043
mShpCal = 3.32031e+012,
3285.95, 6.16993e-039
histo = (TH1F*)0x3305738
mSPEC_ID = pä0­┤ m=536.6 t=1
mDATE_MEA = Ém/­┤AL:

Dropping the array didn’t make any change.

Try: rMCATree->GetEntry(0);

Solved, thanks for help.