Problem with using my class in script

For starting data processing I using the following script:

{
gROOT->ProcessLine(“.L mc_base.C+”);
gROOT->ProcessLine(“.L hmanager.C+”);
gROOT->ProcessLine(“.L inclu_proc.C+”);

TChain chain(“t1”);

chain.Add(“/sweet/home/shtol/snd2k/reldev/work/tup/mc/hadronisr1E4-nochrcut/*.root”);

incluproc* proc = new incluproc(&chain,“inclhists_mc900.root”);

proc->Loop();

}


Running of this script gives the following result:

[shtol@sndbb2 macro]$ root -l test_start.C

Processing test_start.C…
/sweet/home/shtol/root/macro/./test_start.C:11:24: error: unknown type name ‘incluproc’
incluproc* proc = new incluproc(&chain,“inclhists_mc900.root”);
^
/sweet/home/shtol/root/macro/./test_start.C:13:2: error: use of undeclared identifier ‘proc’
proc->Loop();
^
[shtol@sndbb2 macro]

But if I process the same commands in command line, it works:

[shtol@sndbb2 macro]$ root -l
root [0] gROOT->ProcessLine(“.L mc_base.C+”);
root [1] gROOT->ProcessLine(“.L hmanager.C+”);
root [2] gROOT->ProcessLine(“.L inclu_proc.C+”);
root [3] TChain chain(“t1”);
root [4] chain.Add("/sweet/home/shtol/snd2k/reldev/work/tup/mc/hadronisr1E4-nochrcut/.root");
root [5] incluproc
proc = new incluproc(&chain,“inclhists_mc900.root”);
root [6]
tab completion not implemented for this context
root [6] proc->Loop();
… Loop output…

Why it works from command line, but doesn’t works as a script?

Thanks.

ROOT Version: 6.22/0
Platform: CentOS 8
Compiler: Built for linuxx8664gcc


Create a simple “loader.C” script:

{ // loader.C ...
  gROOT->ProcessLine(".L mc_base.C+");
  gROOT->ProcessLine(".L hmanager.C+");
  gROOT->ProcessLine(".L inclu_proc.C+");
} // ... loader.C

and then your “test_start.C” script would look like this:

{
  TChain chain("t1");
  chain.Add(...);
  incluproc* proc = ...;
  ...
}

Runnig everything would look like this:

root -l loader.C test_start.C

or:

root -l -e '.x loader.C' test_start.C

Of course, you could also live without the “loader.C” script:

root -l -e '.L mc_base.C+' -e '.L hmanager.C+' -e '.L inclu_proc.C+' test_start.C

Alternative:

// test_start.C:
#include "mc_base.C"
#include "hmanager.C"
#include "inclu_proc.C"

void test_start() {
   TChain chain(“t1”);
   chain.Add("/sweet/home/shtol/snd2k/reldev/work/tup/mc/hadronisr1E4-nochrcut/*.root");
   incluproc* proc = new incluproc(&chain,“inclhists_mc900.root”);
   proc->Loop();
}

I’ve just tried first variant - it works. Thanks!

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