Skim an tuple with proof

I’m trying to skim an ntuple with proof using this example (without proof):

root.cern.ch/root/html/tutorials … ee3.C.html

so I’ve my TSelector with TTree *output_tree as field. The SlaveBegin Crash with SegmentatioFault:

void Skimmer::SlaveBegin(TTree * /*tree*/)
{
   TString option = GetOption();
//   output_tree = fChain->CloneTree(0);
   fChain->CopyAddresses(output_tree);
   fOutput->Add(output_tree);
}

why? what’s the problem? Wha’t the easyiest way to skim a tuple like TTree::CopyTree with proof?

I understood the problem, fChain is 0 in SlaveBegin(), so I’ve added to Process:

void Skimmer::SlaveBegin(TTree * /*tree*/)
{
   TString option = GetOption();
   output_tree = new TTree("output_tree", "skimmed tree");
   fOutput->Add(output_tree);
}

Bool_t Skimmer::Process(Long64_t entry)
{
    if (first)
    {
	fChain->CopyAddresses(output_tree);
// or:
// output_tree = fChain->CloneTree(0);
	first = false;
    }
   
  GetEntry(entry);
  output_tree->Fill();

  return kTRUE;
}

at the end output_tree->GetEntries() is correct, but ther’s no branches in it! I get this warnings in the logs:

17:29:51 16997 Wrk-0.0 | Warning in <TTree::CopyAddresses>: Could not find branch named 'Run' in tree named 'output_tree'
17:29:51 16997 Wrk-0.0 | Warning in <TTree::CopyAddresses>: Could not find branch named 'Event' in tree named 'output_tree'
17:29:51 16997 Wrk-0.0 | Warning in <TTree::CopyAddresses>: Could not find branch named 'LumiBlock' in tree named 'output_tree'

Finally I solved (it a monologue)

Bool_t Skimmer::Process(Long64_t entry)
{
    if (first)
    {
	output_tree = fChain->CloneTree(0);
	fChain->GetTree()->CopyAddresses(output_tree);
	output_tree->SetName(output_tree_name);
	fOutput->Add(output_tree);
	first = false;
    }
    
    GetEntry(entry);
    if (true) output_tree->Fill();
}

Please tell me if is there a better solution

Hi,

You can also put the code in the Init function. See root.cern.ch/drupal/content/deve … ector#Init for details.

Cheers,
Philippe.

[quote=“pcanal”]Hi,

You can also put the code in the Init function. See root.cern.ch/drupal/content/deve … ector#Init for details.

Cheers,
Philippe.[/quote]

I don’t know because my code inside if(first) must be executer only one time. In your link I read: “Init() will be called many times when running with PROOF.”

It will be called once per file being processed by this Selector. (So less often that Process :slight_smile: ).

Cheers,
Philippe.