# Using TProof with TSelector Class

**URL:** <https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876>\
**Category:** Newbie\
**Created:** [February 23, 2019, 10:17am UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876 "2019-02-23T10:17:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sakib\_rahman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@sakib\_rahman](https://root-forum.cern.ch/u/sakib_rahman)\
**Post date:** [February 23, 2019, 10:17am UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/1 "2019-02-23T10:17:04Z")

</div>

I am trying to use TProof with TSelector Class. My code works if I use just the selector class with no TProof. But when I turn it on, it gets segmentation violation saying that it doesn’t recognize the data type of the option passed to it even though I use an string. The exact error message:  
“could not convert argument 1” which is where the option is placed.My root version is 6.14.

 ![TProof](https://root-forum.cern.ch/uploads/default/original/3X/5/8/5868a8dfbc28583a597d0886509424c89e5c11f2.png)  
What am I missing here?

---

<div class="post-metadata">

**Author:** ![ganis](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ganis/32/12484_2.png) [@ganis](https://root-forum.cern.ch/u/ganis)\
**Post date:** [February 25, 2019, 9:10am UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/2 "2019-02-25T09:10:13Z")

</div>

Dear Sakib\_Rahman,

1. What do you pass as argv[2] and argv[3]?
2. What is the full error message (please post a larger screen portion)

Note that PROOF is in legacy mode. Consider moving to TProcessExecutor, for example [https://root.cern.ch/doc/master/mp103\_\_processSelector\_8C.html](https://root.cern.ch/doc/master/mp103__processSelector_8C.html) .

G Ganis

---

<div class="post-metadata">

**Author:** ![sakib\_rahman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@sakib\_rahman](https://root-forum.cern.ch/u/sakib_rahman)\
**Post date:** [February 25, 2019, 2:12pm UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/3 "2019-02-25T14:12:38Z")

</div>

I pass two strings that tell the selector what folder to save the output files to and add a unique identifier to each processed file. I will try out TProcessExecutor. Thanks for the suggestion.

---

<div class="post-metadata">

**Author:** ![sakib\_rahman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@sakib\_rahman](https://root-forum.cern.ch/u/sakib_rahman)\
**Post date:** [February 25, 2019, 5:49pm UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/4 "2019-02-25T17:49:32Z")

</div>

```auto
#include "ROOT/RMakeUnique.hxx"
#include "TString.h"
#include "TROOT.h"
#include "TChain.h"
#include "TFileCollection.h"
#include "TH1F.h"
#include "TTreeReader.h"
#include "ROOT/TTreeProcessorMP.hxx"

int wrapper(){

TChain* T=new TChain("T");
T->Add("/global/scratch/rahmans/scratch/beamStudy/beamUpstreamR0.0/beam/beam_1.root");

gROOT->SetBatch(kTRUE);
TString selectorPath="/home/rahmans/analysis/analyse_col/processD.C";
auto sel=TSelector::GetSelector(selectorPath);
sel->SetOption("/home/rahmans/analysis/analyse_col/default.txt,default");

ROOT::TTreeProcessorMP pool(4);

pool.Process(*T,*sel);
sel->GetOutputList()->Delete();

return 0;
}

I used the above code based on the TProcessExecutor example. However, now I am getting this error:

Warning in <TList::Merge>: list is empty - nothing to merge

 ***Break*** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00002b69cc4dc82e in waitpid () from /lib64/libc.so.6
#1 0x00002b69cc46e479 in do_system () from /lib64/libc.so.6
#2 0x00002b69cb6a790c in TUnixSystem::StackTrace() () at /home/software/src/geant4/2018/root-6.14.04/core/unix/src/TUnixSystem.cxx:2119
#3 0x00002b69cb6a9f83 in TUnixSystem::DispatchSignals(ESignals) () at /home/software/src/geant4/2018/root-6.14.04/core/unix/src/TUnixSystem.cxx:3644
#4 <signal handler called>
#5 0x00002b69dc66878a in ?? ()
#6 0x00007fffe90af110 in ?? ()
#7 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x00002b69dc66878a in ?? ()
#6 0x00007fffe90af110 in ?? ()
#7 0x0000000000000000 in ?? ()
===========================================================

```

---

<div class="post-metadata">

**Author:** ![sakib\_rahman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@sakib\_rahman](https://root-forum.cern.ch/u/sakib_rahman)\
**Post date:** [February 25, 2019, 6:30pm UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/5 "2019-02-25T18:30:38Z")

</div>

Attempt with PyROOT:

```auto
import sys
import os
import ROOT as R

R.gROOT.SetBatch(1)
ch=R.TChain("T")
ch.Add(sys.argv[1])

selectorPath = "/home/rahmans/analysis/analyse_col/processD.C+"
sel = R.TSelector.GetSelector(selectorPath);
sel.SetOption(sys.argv[2]+","+sys.argv[3])
print("selector used is: "+ selectorPath+" with option "+sel.GetOption())

pool=R.TTreeProcessorMP(4)

pool.Process(ch, sel);
sel.GetOutputList().Delete();

Error:

TList::Merge:0: RuntimeWarning: list is empty - nothing to merge
TCanvas::Constructor:0: RuntimeWarning: Deleting canvas with same name: c
TCanvas::Constructor:0: RuntimeWarning: Deleting canvas with same name: c1

 ***Break*** segmentation violation

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00002b7b8730d82e in waitpid () from /lib64/libc.so.6
#1 0x00002b7b8729f479 in do_system () from /lib64/libc.so.6
#2 0x00002b7b9187d90c in TUnixSystem::StackTrace() () at /home/software/src/geant4/2018/root-6.14.04/core/unix/src/TUnixSystem.cxx:2119
#3 0x00002b7b9187ff83 in TUnixSystem::DispatchSignals(ESignals) () at /home/software/src/geant4/2018/root-6.14.04/core/unix/src/TUnixSystem.cxx:3644
#4 <signal handler called>
#5 0x00002b7ba011f92f in processD::Terminate() () from /home/rahmans/analysis/analyse_col/processD_C.so
#6 0x00002b7b8ea2b6d8 in ROOT::TTreeProcessorMP::Process(TTree&, TSelector&, TEntryList&, unsigned long long, unsigned long long) () at /home/software/src/geant4/2018/root-6.14.04/tree/treeplayer/src/TTreeProcessorMP.cxx:149
#7 0x00002b7b8ea2cef2 in ROOT::TTreeProcessorMP::Process(TTree&, TSelector&, unsigned long long, unsigned long long) () at /home/software/src/geant4/2018/root-6.14.04/tree/treeplayer/src/TTreeProcessorMP.cxx:319
#8 0x00002b7b980fd074 in ?? ()
#9 0x00000000052c5820 in ?? ()
#10 0x00002b7b980fd000 in ?? ()
#11 0x00007ffc663f4cc0 in ?? ()
#12 0x0000000000000007 in ?? ()
#13 0x0036315f66635f5f in ?? ()
#14 0x00007ffc663f4ad0 in ?? ()
#15 0x0000000005325b10 in ?? ()
#16 0x0000000000000594 in ?? ()
#17 0x0000000000000594 in ?? ()
#18 0x0000000000000000 in ?? ()
===========================================================

The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x00002b7ba011f92f in processD::Terminate() () from /home/rahmans/analysis/analyse_col/processD_C.so
#6 0x00002b7b8ea2b6d8 in ROOT::TTreeProcessorMP::Process(TTree&, TSelector&, TEntryList&, unsigned long long, unsigned long long) () at /home/software/src/geant4/2018/root-6.14.04/tree/treeplayer/src/TTreeProcessorMP.cxx:149
#7 0x00002b7b8ea2cef2 in ROOT::TTreeProcessorMP::Process(TTree&, TSelector&, unsigned long long, unsigned long long) () at /home/software/src/geant4/2018/root-6.14.04/tree/treeplayer/src/TTreeProcessorMP.cxx:319
#8 0x00002b7b980fd074 in ?? ()
#9 0x00000000052c5820 in ?? ()
#10 0x00002b7b980fd000 in ?? ()
#11 0x00007ffc663f4cc0 in ?? ()
#12 0x0000000000000007 in ?? ()
#13 0x0036315f66635f5f in ?? ()
#14 0x00007ffc663f4ad0 in ?? ()
#15 0x0000000005325b10 in ?? ()
#16 0x0000000000000594 in ?? ()
#17 0x0000000000000594 in ?? ()
#18 0x0000000000000000 in ?? ()
===========================================================

Traceback (most recent call last):
  File "processD.py", line 20, in <module>
    pool.Process(ch, sel);
TypeError: none of the 10 overloaded methods succeeded. Full details:
  TList* ROOT::TTreeProcessorMP::Process(const vector<string>& fileNames, TSelector& selector, TEntryList& entries, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    takes at least 3 arguments (2 given)
  TList* ROOT::TTreeProcessorMP::Process(const string& fileName, TSelector& selector, TEntryList& entries, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    takes at least 3 arguments (2 given)
  TList* ROOT::TTreeProcessorMP::Process(TFileCollection& files, TSelector& selector, TEntryList& entries, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    takes at least 3 arguments (2 given)
  TList* ROOT::TTreeProcessorMP::Process(TChain& files, TSelector& selector, TEntryList& entries, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    takes at least 3 arguments (2 given)
  TList* ROOT::TTreeProcessorMP::Process(TTree& tree, TSelector& selector, TEntryList& entries, ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    takes at least 3 arguments (2 given)
  TList* ROOT::TTreeProcessorMP::Process(const vector<string>& fileNames, TSelector& selector, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    could not convert argument 1
  TList* ROOT::TTreeProcessorMP::Process(const string& fileName, TSelector& selector, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    could not convert argument 1
  TList* ROOT::TTreeProcessorMP::Process(TFileCollection& files, TSelector& selector, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    could not convert argument 1
  TList* ROOT::TTreeProcessorMP::Process(TChain& files, TSelector& selector, const string& treeName = "", ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    problem in C++; program state has been reset
  TList* ROOT::TTreeProcessorMP::Process(TTree& tree, TSelector& selector, ULong64_t nToProcess = 0, ULong64_t jFirst = 0) =>
    problem in C++; program state has been reset

```

---

<div class="post-metadata">

**Author:** ![Triple\_S](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/triple_s/32/17129_2.png) [@Triple\_S](https://root-forum.cern.ch/u/Triple_S)\
**Post date:** [February 25, 2019, 8:27pm UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/6 "2019-02-25T20:27:03Z")

</div>

To me it sounds like the output list of your TSelector remains empty and is therefore not being initialized. This would cause the Delete() to cause a null pointer exception. Maybe change to

```auto
if (sel->GetOutputList())
   sel->GetOutputList()->Delete();

```

---

<div class="post-metadata">

**Author:** ![sakib\_rahman](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/9f8e36/32.png) [@sakib\_rahman](https://root-forum.cern.ch/u/sakib_rahman)\
**Post date:** [February 26, 2019, 1:08am UTC](https://root-forum.cern.ch/t/using-tproof-with-tselector-class/32876/7 "2019-02-26T01:08:31Z")

</div>

The output list would be empty if the processor did not execute the selector which is what the problem is. I am passing the chain and the selector to the processor and for some reason it’s not recognising them. I know that the chain and the selector both work because I can call  
chain-\>Process(selector) and run it on a single core. But I want to implement a parallel version because otherwise I will be occupying memory on multiple cores without using the processing power on my server which is outside best practice.
