SetBranchAddress data not loaded

I have been trying to read and analyze the data from a tree by writing a class. I initialized the variables and array in the constructor and set the branch address in a function of the class. There is no error message compling the files and running the analysis but the data does not pass to these array and variables (in fact when I print them out they show 0). Here is the short version of my script.

Reader::Reader(const char* dirName, const char* fileName, int maxFiles):mMaxFiles(maxFiles), mDebug(0), mCurrentFile(0),mTTree(0)


int Reader::Read()
  Chain = new Chain("E12345","Event");
  int nFiles=0;

  //call a function that fills the chain with root files listed in a text file
  if (file!="") { // if a filename was given
    if( strstr(file.c_str(),".lis") || strstr(file.c_str(),".list") ) { // if a file list is specified
      try {
	nFiles = fillChain(mTChain, (dir+file).c_str(), mMaxFiles);
      catch(StException e) {
	throw e;
    else { // a single file was specified


  return nFiles;

However, the branch address are set if I simply use a macro like

double  KinEnergy[20];
double Phi[20];

I dont understand what the problem is as the logic seems ok. So I am hoping someone can tell me the correct approach to set branch address in a class. Thank you very much.

What is the “type” of the branch? (i.e. check Chain->Print()) Are the variable type the same in both your example?

Yes. I have checked the type of the data which are Int_t and Double_t for multi and KinEnergy respectively. I have defined Int_t multi and Double_t KinEnergy…etc in the header file. Just curious, does it allow me to define int even though the data type of the branch is Int_t?

I found that the data type of some of the branches are Double_t[7] but I have Double_t[20]…I changed them and also setmakeclass(1) as the branches are subbranches… And now the data is loaded. Thanks!