Blank histogram using PROOF

Hello, could someone please help me with a small issue?

I am running Root 5.34/04 (the most current as far as I know) and I have some code that runs fine in a single core manner, but when I invoke Proof, it no longer writes. By various iterations I can get the code in a state where it at least writes my output file but the test histogram is empty.

I am sure I am doing something wrong, but with no formal training on parallelizing code, I hope someone more knowledgable will point out what I am doing wrong. I just want to get my test histogram working properly.

Attached is everything required to reproduce the issue, in a minimal form. Go to the directory and type “root -l multrun.C”

EDIT: My data .root file isn’t uploading. Does this board have attachment size limits?
EDIT2: I have uploaded the file here: inside.mines.edu/~rbraid/asm20698.root
process.h (12.7 KB)
process.C (1.29 KB)
multirun.C (257 Bytes)
GeCoreGains_ryan.h (3.31 KB)

Hi,

There are two issues that I see with your code.

PROOF workers are separate processes - from the session or application where you start PROOF, with their own working area (sandbox). These processes produce output (i.e. an histogram in your case) corresponding to the fraction of work that they have been assigned. These outputs are then merged by the central process (the master or, in the case of PROOF-Lite, your client session) to look like a single output.
This has two consequences. First you need to declare what is your output; this is done via the output list (see example below). Second, each worker will have its own file located - if you create it as you did - in the worker sandbox.

So, I suggest that you start by getting the merged histogram in memory. Then you can move to save it automatically to a file and/or merging it via file (useful is you have a lot of histograms).

To get the merged histogram try this:

void process::SlaveBegin(TTree * /*tree*/)
{
   TString option = GetOption();
   
   // OutputFile = new TFile("testout.root","recreate");

   DeclareHistos();

   fOutput->Add(CalibratedSpec);
}

void process::SlaveTerminate()
{
   // OutputFile->Write();
   //OutputFile->Close();
}


void process::Terminate()
{
    if (CalibratedSpec) {
	CalibratedSpec->Draw();
    } else {
        Printf("Histogram 'calib' not found!");
    }
}

Remember to initialize the histogram pointer in the constructor

   
   //Declare Histograms
   
   TH1D  *CalibratedSpec;
   // TFile *OutputFile;
   void DeclareHistos();

   process(TTree * /*tree*/ =0) : fChain(0), CalibratedSpec(0) { }

   ...

Once this is working you can try to use the options described at

   [root.cern.ch/drupal/content/handling-outputs](http://root.cern.ch/drupal/content/handling-outputs)

to save objects into files.

Let me know,

G. Ganis

Thank you for your help. Everything is working as expected now with your changes as well as changing my call:

I have a follow up question however. This method works if I only have one output file, but what if I wanted to produce 2 different root files? As a quick example, in another program I make some plots and then do a fit on the data points. I output the coefficents for the fit, but in a different root file I also plot the histograms themselves for debugging purposes.

Rephrased: the method on the site you linked to is quick and easy, but it doesn’t seem very robust or allow much in the way of fine grain control. Is there an alternate way to do this?

Thanks again!
Ryan