Instantiating a MakeSelector class and running in PROOF

Hello Proofers,

I’m trying to do something I was able to do easily with the regular MakeClass environment but I’m a bit in the dark…

I have a class code generated with MakeSelector, let’s call it “physics” (.h/.C).
I now want to run on a large amount of data that can be described by the variables in this class.

However, I have 3 basic and fair constraints:

  1. I do not want to write my analysis code inside the “Process()” method of physics.C.
  2. I want to instantiate the physics class in another class that will contain all the analysis operations, let’s call it the “controller” class (.h/.C).
  3. I want to do all this within ROOT while compiling and linking against few external libs.

In a regular ROOT session I was able to do all this easily in my “controller” class that had a “loop()” method calling the instantiated “physics” class GetEntry() method etc.

//the controller constructor:
controller::controller()
{
  TChain* chain = new TChain("chain");
  chain->Add("file1");
  chain->Add("file2");
  // etc.
  phys  = new physics(chain); // physics* phys; is defined in the header
}
//... do some stuff ...
//in the loop() method:
controller::loop()
{
   phys->GetEntry(i);
   // do some stuff
}

and the compilation was preformed by another simple root macro like this:

void compile()
{
  gROOT->Reset();
  gROOT->ProcessLine(".include ../include/");
  gROOT->ProcessLine(".include ../src/");
  gROOT->ProcessLine(".include ./");
  gSystem->Load( "libCintex.so" );
  Cintex::Cintex::Enable();
  gROOT->ProcessLine(".L Loader.C+");
  gROOT->ProcessLine(".include ../GoodRunsLists-00-00-91/");
  gROOT->ProcessLine(".include ../GoodRunsLists-00-00-91/GoodRunsLists/");
  gROOT->ProcessLine(".L ../GoodRunsLists-00-00-91/StandAlone/libGoodRunsLists.so");
  gROOT->ProcessLine(".L controller.C++");
  gROOT->ProcessLine("controller ctrl");
  gROOT->ProcessLine("ctrl.loop()");
}

Now I want it to run under PROOF but I cannot figure out how to do that.
I’ve digged in the tutorials but found nothing similar.

My question is if, for compiling my code and running it under PROOF, should my “controller” class look like a class that has been generated using “MakeSelector” ?
If so, how should I call it’s “Process()” method ?
Can my input chain be forwarded to “physics” by it’s “Init()” method ?

I have a lot of other questions but this is a very loaded post anyway…
A reference to a code that does similar task would be great !

Cheers,
Noam

Dear Noam,

Your code is intrinsically sequential and cannot be run in parallel like that. That’s why you did not find anything similar in the tutorials.
The way parallelism is implemented in PROOF requires you to define:

1) the set of data on which to run
2) the initialization procedure (where you read databases or whatever your analysis needs and you define your output objects, e.g. histograms)
3) what to do on each event
4) what to do at the end

Once you have this, PROOF takes care of opening the files and handling the different procedures, including the event loop.
Step 1) above is the definition of TChain or TFileCollection.
Steps 2) to 4) are the various methods of a TSelector, the class you get from MakeSelector. And, yes, it is mandatory to use something generated by MakeSelector. The code generated by MakeClass can be run in PROOF but it will be run in sequential way, with no advantage at all.

Now, your constraints 1 and 2 may be fair and basic but they are incompatible with PROOF:

Fine. But, why? It is a way to make your code more modular and cleaner.

Fine, but why do you need the Physics class at all in such a case?

If you want to use PROOF you have to change the structure of your program. Note that a program structured fro PROOF can be run also in the normal ROOT session, so you do not need to maintain two codes if you do that.
If you are not willing to change your code then OK, nothing wrong, but PROOF is not for you.

If you are still interested, you can have a look at the ProofEventProc.C/.h selectors under $ROOTSYS/tutorials/proof and the way they are called inside $ROOTSYS/tutorials/proof/runProof.C (scope “eventproc”).

Gerri Ganis