No matching constructor for initialization of 'TTreeReaderValue<Int_t>'

Hello folks, I’m working for the first time with ntuples and during the common steps taken in order to analyze the file, namely:

root [0] TFile *f = TFile::Open("myNTuple.root")
(TFile *) 0x561e2edc0260
root [1] TTree *t = (TTree*)f->Get("tree")
(TTree *) 0x561e2f67fcb0
root [2] t->MakeSelector("MySelector")
(int) 0
root [3] .!ls MySelector*
MySelector.C  MySelector.h
root [7] gROOT->Time()
Real time 0:06:13.538685, CP time 0.860
root [8] t->Process("MySelector.C")
(long long) 0
Real time 0:00:00.317506, CP time 0.310

The next final step would be .L MySelector.C, but issuing that command gave me a strange error:

root [10] .L MySelector.C
In file included from input_line_165:1:
In file included from /home/ets9/Desktop/TESI/myselector/MySelector.C:28:
/home/ets9/Desktop/TESI/myselector/MySelector.h:30:42: error: no matching constructor for initialization of 'TTreeReaderValue<Int_t>' (aka
      'TTreeReaderValue<int>')
   TTreeReaderValue<Int_t> EventNumber = {fReader, "EventNumber"};
                                         ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^

And it repeats the same error for every TTreeReaderValue entry which appears in MySelector.h.
Because the MySelector.C and MySelector.h are automatically generated by the function MakeSelector, where should I look for trying to fix the problem?

MySelector.C = http ://txt.do/16by1
MySelector.h = http ://txt.do/16byr

I’ll appreciate every suggestions!
Regards,
S

ROOT Version: 6.20/00
Platform: Ubuntu 18.04 LTS
Compiler: gcc 7.4.0
(79.1 KB) TSelectorREADME-1.txt (1.8 KB)

Hi Stefano,
welcome to the ROOT forum!

Please check out this post about posting code on the forum – and feel free to edit your message so it’s better readable :slight_smile:

There should be one of the “candidate constructor not viable” error lines that mentions the constructor you want (it’s missing from your copy-paste): it’s the constructor with two arguments. The error message should then tell you why the compiler can’t use that constructor in that place.

Meanwhile let me see if I can reproduce on my machine with the files you shared… (EDIT: note that you can upload .C and .h files to the forum directly with the upload button in the edit bar)

Hello thanks for pointing me out some format suggestions. Sharing my ntuple.root file will be useful too?

Sharing my ntuple.root file will be useful too?

Yes that might help.

I seem to be able to run these just fine on the code you shared:

root [0] .L MySelector.C
root [1] .L MySelector.C++

This is quite weird. Are you confident that your ROOT installation is ok? Can you run this from the ROOT prompt (haven’t tested, might have mistyped something, but you get the idea)?

root [0] TFile f("your_ntuple_file.root");
root [0] TTreeReader r("your_tree_name", &f);
root [1] TTreeReaderValue<Int_t> EventNumber = {fReader, "EventNumber"};

?

Actually the command:

.L MySelector.C++

With my big surprise it run without problems! I can’t tell actually why.
So you suggest to remove and build again root from scratch?

Anyway the other instructions did not quite work well:

root [12] TFile::TFile* f = TFile::Open("myNtuple.root")
root [13] TTreeReader::TTreeReader r("tree", &f)
ROOT_prompt_13:1:14: error: qualified reference to 'TTreeReader' is a constructor name rather than a type in
      this context
TTreeReader::TTreeReader r("tree", &f)
             ^
ROOT_prompt_13:1:26: error: no matching constructor for initialization of 'TTreeReader::TTreeReader'
TTreeReader::TTreeReader r("tree", &f)
                         ^ ~~~~~~~~~~
/home/ets9/root/include/TTreeReader.h:157:4: note: candidate constructor not viable: no known conversion from 'TFile **' to
      'TDirectory *' for 2nd argument; remove &
   TTreeReader(const char* keyname, TDirectory* dir, TEntryList* entryLi...
   ^
/home/ets9/root/include/TTreeReader.h:158:4: note: candidate constructor not viable: no known conversion from 'TFile **' to
      'TEntryList *' for 2nd argument
   TTreeReader(const char* keyname, TEntryList* entryList = nullptr):
   ^
/home/ets9/root/include/TTreeReader.h:156:4: note: candidate constructor not viable: no known conversion from 'const char [5]' to
      'TTree *' for 1st argument
   TTreeReader(TTree* tree, TEntryList* entryList = nullptr);
   ^
/home/ets9/root/include/TTreeReader.h:43:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class TTreeReader: public TObject {
      ^
/home/ets9/root/include/TTreeReader.h:154:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReader();
   ^

and the other instruction:

root [14] TTreeReaderValue::TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"}
ROOT_prompt_14:1:1: error: 'TTreeReaderValue' is not a class, namespace, or enumeration
TTreeReaderValue::TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"}
^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: 'TTreeReaderValue' declared here
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
ROOT_prompt_14:1:36: error: use of undeclared identifier 'int_t'
TTreeReaderValue::TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"}
                                   ^
ROOT_prompt_14:1:43: error: C++ requires a type specifier for all declarations
TTreeReaderValue::TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"}
                                          ^
ROOT_prompt_14:1:58: error: use of undeclared identifier 'fReader'
TTreeReaderValue::TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"}
                                                         ^
root [15] TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"};
ROOT_prompt_15:1:18: error: template argument for template type parameter must be a type
TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"};
                 ^~~~~
/home/ets9/root/include/TTreeReaderValue.h:139:20: note: template parameter is declared here
template <typename T>
                   ^
ROOT_prompt_15:1:40: error: use of undeclared identifier 'fReader'
TTreeReaderValue<int_t> EventNumber = {fReader, "EventNumber"};
                                       ^

My Ntuple.root file is too big to be uploaded here…

Hi, do not use

TFile::TFile* f = TFile::Open("myNtuple.root")

but

TFile f("your_ntuple_file.root");

like in my snippet :slight_smile:

EDIT:

and not TTreeReader::TTreeReader or TFile::TFile but TTreeReader and TFile.

Here we go:

root [0] TFile f("user.mfujimot.18125658._000001.myNTuple.root")
(TFile &) Name: user.mfujimot.18125658._000001.myNTuple.root Title: 
root [1] TTreeReader r("tree", &f)
(TTreeReader &) Name: TTreeReader Title: A simple interface to read treesroot
root [3] TTreeReaderValue<Int_t> EventNumber = {fReader, "EventNumber"}
input_line_110:2:31: error: use of undeclared identifier 'fReader'
 new TTreeReaderValue<Int_t>({fReader, "EventNumber"})
                              ^
(TTreeReaderValue<Int_t> &) @0x7ffee32045e0
root [4] 

Yes, this one is my fault: it should of course be r, not fReader

And it should be TTreeReaderValue<Int_t> rv = {r, "asfsd"}, with an equal, not parentheses, to keep it as similar as possible to your code that does not compile.

It works fine now:

root [6] TTreeReaderValue<Int_t> EventNumber = {r, "EventNumber"}
(TTreeReaderValue<Int_t> &) @0x7f29fff5e4d0

So what is the purpose of these steps you issued me to do?

This is equivalent code to the one you have inside MySelector.h, which ROOT’s interpreter complains about. It’s good that it compiles at the prompt, as it should. The code also compiles when I run it as .L MySelector.C or .L MySelector.C++ from my ROOT prompt.

So the code seems, fine, your ROOT installation is fine, there is just something weird going on when you invoke .L MySelector.C from your ROOT prompt. Can you try again from a fresh ROOT prompt and upload the exact files you used and the whole error message please?

As for the data, you can share them via afs, eos, cernbox or any other such service.

Cheers,
Enrico

Wow, it actually gave different results this time. I made the following tests, in a new folder in which I put only my ntuple files:

root [0] TFile f("user.mfujimot.18125658._000001.myNTuple.root")
(TFile &) Name: user.mfujimot.18125658._000001.myNTuple.root Title: 
root [1] TTreeReader r("tree", &f)
(TTreeReader &) Name: TTreeReader Title: A simple interface to read trees
root [2] TTreeReaderValue<Int_t> EventNumber = {r, "EventNumber"}
(TTreeReaderValue<Int_t> &) @0x7f39da5db540
root [3] TTree* t = (TTree*)f.Get("tree")
(TTree *) 0x5615a386fb50
root [4] t->MakeSelector("MySelector")
(int) 0
root [5] .L MySelector.C
root [6] t->Process("MySelector.C")
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:38:40: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> HitsOnDisks = {fReader, "HitsOnDisks"};
                                       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:39:38: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> sideDiskA = {fReader, "sideDiskA"};
                                     ^~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:40:38: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> sideDiskC = {fReader, "sideDiskC"};
                                     ^~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:41:44: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> BCMprescale = {fReader, "BCMprescale"};
                                           ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:45:44: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> HLTprescale = {fReader, "HLTprescale"};
                                           ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:48:46: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> ZAsymmetryTRT = {fReader, "ZAsymmetryTRT"};
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_141:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:55:48: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> ZAsymmetryPixel = {fReader, "ZAsymmetryPixel"};
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
Error in <TSelector::GetSelector>: The file MySelector.C does not define a class named MySelector.
(long long) -1
root [14] 

As you can see, the command .L MySelector.C worked just fine while the command t->Process("MySelector.C") gave me the same old errors as before. This time the first error given it is not referring to EventNumber line but to HitsOnDisks line.

EDIT: After that sequence of command, I tried using .L MySelector.C again but this time the error appeared:

 
root [14] .L MySelector.C
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:38:40: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> HitsOnDisks = {fReader, "HitsOnDisks"};
                                       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:39:38: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> sideDiskA = {fReader, "sideDiskA"};
                                     ^~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:40:38: error: no matching constructor for initialization of 'TTreeReaderArray<int>'
   TTreeReaderArray<int> sideDiskC = {fReader, "sideDiskC"};
                                     ^~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderArray final : public ROOT::Inter...
                             ^
/home/ets9/root/include/TTreeReaderArray.h:75:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:41:44: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> BCMprescale = {fReader, "BCMprescale"};
                                           ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:45:44: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> HLTprescale = {fReader, "HLTprescale"};
                                           ^~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:48:46: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> ZAsymmetryTRT = {fReader, "ZAsymmetryTRT"};
                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^
In file included from input_line_142:1:
In file included from /home/ets9/Desktop/TESI/my/MySelector.C:28:
/home/ets9/Desktop/TESI/my/MySelector.h:55:48: error: no matching constructor for initialization of 'TTreeReaderValue<Float_t>' (aka
      'TTreeReaderValue<float>')
   TTreeReaderValue<Float_t> ZAsymmetryPixel = {fReader, "ZAsymmetryPixel"};
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit copy constructor) not viable: requires 1
      argument, but 2 were provided
class R__CLING_PTRCHECK(off) TTreeReaderValue final: public ROOT::Intern...
                             ^
/home/ets9/root/include/TTreeReaderValue.h:140:30: note: candidate constructor (the implicit move constructor) not viable: requires 1
      argument, but 2 were provided
/home/ets9/root/include/TTreeReaderValue.h:145:4: note: candidate constructor not viable: requires 0 arguments, but 2 were provided
   TTreeReaderValue() = delete;
   ^

What ROOT version are you on?

ROOT Version: 6.20/00
Platform: Ubuntu 18.04 LTS
Compiler: gcc 7.4.0

Cool (I see now you had already shared the information in your first post).

Your ROOT version is nice and recent, your installation look fine, and the prompt can correctly parse the code that fails when you use TTree::Process. I will have to be able to reproduce the problem locally in order to debug.

As a first test, I created a small file (f.root (5.3 KB) ) that only contains one float branch called "BCMprescale". Then I took your MySelector class and commented out all the TTreeReaderValue definitions except for the one for "BCMprescale" in MySelector.h. In MySelector.cxx inside the MySelector::Process function, I inserted these two lines:

   fReader.SetLocalEntry(entry);
++ std::cout << entry << std::endl;
++ std::cout << *BCMprescale << std::endl;

   return kTRUE;

This is the result:

eguiraud@cern762:~/Scratchpad/ROOT/forum_nomatchingctor$ root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.21/01                        https://root.cern |
  | (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Mar 09 2020, 17:55:55                 |
  | From heads/master@v6-19-01-3287-g7a6ae88a68                      |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] TFile f("f.root")
(TFile &) Name: f.root Title: 
root [1] TTree *t = f.Get<TTree>("t")
(TTree *) 0x55706432e8c0
root [2] .L MySelector.cxx
root [3] t->Process("MySelector")
0
10
1
10
2
10
3
10
4
10
5
10
6
10
7
10
8
10
9
10
(long long) 0

This is the expected output, i.e. I am not able to reproduce your problem.
Can you give me a recipe to reproduce the issue? Can you reproduce it on another computer? For example, can you try to reproduce the problem on lxplus, so we can run the exact same ROOT version in the exact same environment?

Cheers,
Enrico

Can you also t->Process("MySelector.C") without problems?

1 Like

Oooooof that’s it! You can either do

root [2] .L MySelector.cxx
root [3] t->Process("MySelector")

or

root [2] t->Process("MySelector.C")

The reason is that t->Process("MySelector.C") tells ROOT to parse the file (while t->Process("MySelector") tells ROOT to use a selctor class that was previously defined. And ROOT is not able to load a macro twice, as you can see by running .L MySelector.C twice in a row.

Thanks for your support, Enrico.
I’ll show up again after having tested your suggestions.