Counter and TSelector::Begin()

Hello,

I would need some tips on the following :

Let’s consider a program using proof and a standard selector made from MakeSelector(). As member of the class of the selector, one put a given integer counter . Let’s call it “int counter”.

in the Selector :: Begin() function
i put counter a given value (counter=5)

*in the Process() i print the value of the counter, but it is always 0 : how is that possible ?
Should i need to put counter=5 in the SlaveBegin ? Why ?

*Now, let’s suppose i wish to make the counter to vary (as it should be : to count some events) on paralell processing on the slaves. How will i manage to prevent the counter to give a wrong value ? (counter++).

Should i put all the counter using fOutput->Add(TheCounter) so that Proof deals correctly the stuff ?

==>If so, then, since fOutput is a TList i would not have the right to use a standard counter as a “int” ? (TList accepts only TObject)
So performance of increasing the value of an object would be drastically reduced as compared to a simple integer counter ?

Anyway, let’s consider we choose a TObject for making the counter, it seems that even a TParameter would not success because the merge of this would not be ok. I mean : let’s suppose each slave does the incrementation by doing something like this in the method Process() :
(pseudo-code not checked ) : myparameter->SetVal(myparameter->GetVal()+1).

Then i don’t know how Proof woud success to merge the counter. An histogram would success in the operation, but it seems not the best type of object for a simple counter ?

thank you for your help and tips

Hi,

Yes, Begin is not called on the workers, so you need to put things in SlaveBegin.

I see your points.
We could probably add the ‘Merge’ method and ‘+=’, ‘-=’,… operators to TParameter; we will see. But keeping the statistics of an analysis is typically analysis dependent, and, in general, you will have more than one counter. So the best is that you design your small ‘MyCounters’ class, deriving from TObject, where in the ‘Merge’ method you do what you need. This is what other people do, and it is certainly more compact and probably cleaner. And if you have just a list of integers you can just use a TH1I: it is quite efficient for this kind of things and we are already using for the same purpose in stressProof.

G. Ganis

all right

thank you very much for the tips

everything is clear