# G++ standalone: TProof using TChain

**URL:** <https://root-forum.cern.ch/t/g-standalone-tproof-using-tchain/17733>\
**Category:** ROOT\
**Created:** [June 5, 2014, 3:56pm UTC](https://root-forum.cern.ch/t/g-standalone-tproof-using-tchain/17733 "2014-06-05T15:56:07Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![jolange](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/34f0e0/32.png) [@jolange](https://root-forum.cern.ch/u/jolange)\
**Post date:** [June 5, 2014, 3:56pm UTC](https://root-forum.cern.ch/t/g-standalone-tproof-using-tchain/17733/1 "2014-06-05T15:56:07Z")

</div>

Hi everybody,

I am trying to compile and link (g++) a code using Proof (Lite, 4 workers) with a TChain.

As a demonstration example I am using the TSelector(-derivative) from the Hands-on-Tutorial ([http://root.cern.ch/drupal/content/processing-proof](http://root.cern.ch/drupal/content/processing-proof), ProofFirst.C and ProofFirst.h) and add a check whether the histogram is created (or available) or not:

`void ProofFirst::Terminate()
{
   TCanvas *c1 = new TCanvas("c1", "Proof ProofFirst canvas",200,10,400,400);
   fH1F = dynamic_cast<TH1F *>(fOutput->FindObject("FirstH1F"));
   if (fH1F) fH1F->Draw();
   c1->Update();
   // EDIT:
   if(fH1F)
      Info("Terminate","ok");
   else
      Info("Terminate","not ok");
}`

Now I’ve got 3 scenarios, each using a TChain and loading a TTree from a \*.root-File:  
[ol]  
[li]

`// startProof.C:
{
   TChain* chain = new TChain("photonTree");
   chain->Add("/path-to/myfile.root");
   chain->SetProof();
   TProof *p = TProof::Open("lite://");
   chain->Process("ProofFirst.C+");
   p->Close();
}`  
I run this via “root -l startProof.C+” and get “Info in ProofFirst::Terminate: ok”.  
[/li]  
[li] Now compiling with g++

[code][//startProof.cpp](https://startProof.cpp):  
#include “TChain.h”  
#include “TProof.h”  
#include “ProofFirst.h”

int main() {  
TChain\* chain = new TChain(“photonTree”);  
chain-\>Add("/path-to/myfile.root");  
chain-\>SetProof();  
TProof \*p = TProof::Open(“lite://”);  
chain-\>Process(“ProofFirst.C+”);  
gSystem-\>Exit(0);  
return 0;  
}[/code]  
I compile/link and run this via

`$ rootcint -f ProofFirst_dict.C -c ProofFirst.h
$ g++ $(root-config --libs --cflags) -lProof -lProofPlayer startProof.cpp ProofFirst.C ProofFirst_dict.C -o startProof
$ ./startProof`  
This works as well.  
[/li]  
[li] This is the case I am actually interested in. The difference to B) is that I run TChain::Process(void\* selector) instead of passing the filename:

[code][//startProof.cpp](https://startProof.cpp):  
#include “TChain.h”  
#include “TProof.h”  
#include “ProofFirst.h”

int main() {  
TChain\* chain = new TChain(“photonTree”);  
chain-\>Add("/path-to/myfile.root");  
chain-\>SetProof();  
TProof _p = TProof::Open(“lite://”);  
ProofFirst_ pf = new ProofFirst();  
chain-\>Process(pf);  
gSystem-\>Exit(0);  
return 0;  
}[/code]  
Running this as in B) results in

[code] +++ Starting PROOF-Lite with 4 workers +++  
Opening connections to workers: OK (4 workers)  
Setting up worker servers: OK (4 workers)  
PROOF set to parallel mode (4 workers)

Info in TProofLite::SetQueryRunning: starting query: 1  
Info in TProofQueryResult::SetRunning: nwrks: 4  
Looking up for exact location of files: OK (1 files)  
Looking up for exact location of files: OK (1 files)  
Info in TPacketizerAdaptive::TPacketizerAdaptive: Setting max number of workers per node to 4  
Validating files: OK (1 files)  
Info in TPacketizerAdaptive::InitStats: fraction of remote files 0.000000  
Info in ProofFirst::Terminate: not ok |\>…| 0.00 %  
Lite-0: all output objects have been merged[/code]  
So “Info in ProofFirst::Terminate: not ok” says the histogram isn’t there.[/li][/ol]

I tried to figure out for some time now, why this does not work. I think SlaveBegin() is not entered.  
Can you help me here? Is proof designed to be able doing this at all?

Thanks in advance,  
Johannes

---

_[View the full topic](https://root-forum.cern.ch/t/g-standalone-tproof-using-tchain/17733)._
