Problem running a macro with versions 6

Please provide the following information:


ROOT Version (e.g. 6.12/02): 6.06/02 vs 5.24/00
Platform, compiler (e.g. CentOS 7.3, gcc6.2): OSX 10.10.5


Hi,
I used to run a file ElectronAnalyser.S containing the following instructions:

  void ElectronAnalyser() {
  TFile *f = new TFile("DYJetsToLL_M50.root");
  gROOT->LoadMacro("ElectronAnalyser.C");
  TTree *tree = (TTree*)f->Get("treeProducerWMassEle");
  ElectronAnalyser *a = new ElectronAnalyser(tree);
  a->Loop();
  b=new TBrowser();
}

with versions 5 and that does not work with versions 6. What should I do to have it running on versions 6?
Thanks.

Try

#include "ElectronAnalyser.C”);
void ElectronAnalyser() {
   TFile *f = new TFile(“DYJetsToLL_M50.root”); 
   TTree tree = (TTree)f->Get(“treeProducerWMassEle”);
   ElectronAnalyser *a = new ElectronAnalyser(tree);
   a->Loop();
   b=new TBrowser();
}

Hi.

Thank you for your suggestion. I tried it without the parenthesis on first line and also added the .h file. Unfortunately I run into a problem of undeclared identifiers, which are nevertheless declared in the .C file:

/mymount/ElectronAnalyser.C:129:10: error: array initializer must be an initializer list

char *mZ_BB_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:131:10: error: array initializer must be an initializer list

char *mZ_BB_DYcor_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:133:10: error: array initializer must be an initializer list

char *mZ_BB_Wcor_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:135:10: error: array initializer must be an initializer list

char *mZ_EE_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:137:10: error: array initializer must be an initializer list

char *mZ_EE_DYcor_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:139:10: error: array initializer must be an initializer list

char *mZ_EE_Wcor_pt[50] = new char[50];

^

/mymount/ElectronAnalyser.C:142:10: error: array initializer must be an initializer list

char *mZ_eta[50] = new char[50];

^

/mymount/ElectronAnalyser.C:144:10: error: array initializer must be an initializer list

char *mZ_DYcor_eta[50] = new char[50];

^

/mymount/ElectronAnalyser.C:146:10: error: array initializer must be an initializer list

char *mZ_Wcor_eta[50] = new char[50];

^

/mymount/ElectronAnalyser.C:269:24: error: use of undeclared identifier 'nptstep'

for (int ipt=0; ipt<nptstep; ipt++) { // Define 5 pt bins

I attach the 3 files involved.

Thanks for your help.

ElectronAnalyser.C (46.3 KB)

ElectronAnalyser.h (6.35 KB)

Your code was full of basic C/C++ mistakes. I fixed them in the attached file. Now your code compiles. It does not mean it produces the desired results. ElectronAnalyser.C (47.1 KB)

Dear Olivier,

Thank you for correcting the mistakes. I was not aware of these mistakes as everything was properly working with versions 5.

As you say it does not produce the expected results as the command “.x ElectronAnalyser.S” still does not work. There are probably mistakes in .h or/and .S which revealed themselves when going from versions 5 to versions 6.

Yes the way this macro was written was not C++. ROOT 5 did not complain. Using ROOT 6 will make your code much more reliable.

It works now. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.