Share constant between master and slaves

Dear expert, I want, for example, share how many bins use for a particular histogram between master and slaves. For example:

MySelector::Begin()
{
  cout << "the number of bins is: " << nbins;
}

where nbins is a const data member of MySelector. This constant is used also by

MySelector::SlaveBegin()
{
  h = new TH1F("h", "h", nbins, 0, 10);
}

when I can initialize nbins? In the MySelector constructor?
}

Hi,

You need to pass the number of bins to the slave (unless it is hard coded in your source) via the fInputList.

Cheers,
Philippe.

[quote=“pcanal”]Hi,

You need to pass the number of bins to the slave (unless it is hard coded in your source) via the fInputList.

Cheers,
Philippe.[/quote]

I don’t like this solution. Why I can’t do:

MySelector::MySelector()
{
 nbins = 10;
}

? The constructor is executed on the master and on the slave, is it? Another possibility is to declare the variable globally, but I prefer to declare the variable as a class member.

[quote]I don’t like this solution. Why I can’t do: [/quote]You of course can, this is what I was referring to in ‘unless it is hard coded in your source’.

Cheers,
Philippe.

Dear wiso,

Just to clarify,

No, the selector is not created on the master, only on the client and workers.

However, I am not sure to understand what is the problem you are trying to raise in this thread.
You can hard code the number of bins (either in the selector constructor or where you create the histogram) and that will work w/o problems (basically all examples under tutorials/proof do this).
Or you can control it via the input list as Philippe suggested.

Can you try to detail a bit more what functionality you miss, if any?

G. Ganis

[quote=“ganis”]Dear wiso,

Just to clarify,

No, the selector is not created on the master, only on the client and workers.

However, I am not sure to understand what is the problem you are trying to raise in this thread.
You can hard code the number of bins (either in the selector constructor or where you create the histogram) and that will work w/o problems (basically all examples under tutorials/proof do this).
Or you can control it via the input list as Philippe suggested.

Can you try to detail a bit more what functionality you miss, if any?

G. Ganis[/quote]

the point is: how to share a constat between master and slaves? For example I want to share. If a well understood I can:

  1. define a global constant
  2. define a constant in the constructor of the TSelector derived class
  3. use the input list

Hi Wiso,

Do you mean to share between the proof master and slaves or between the root session on your desktop and the slaves?

Philippe.

[quote=“pcanal”]Hi Wiso,

Do you mean to share between the proof master and slaves or between the root session on your desktop and the slaves?

Philippe.[/quote]

between proof master and the slaves

Hi Wiso,

In which context to you need to use the contant on the master?

Philippe.

[quote=“pcanal”]Hi Wiso,

In which context to you need to use the contant on the master?

Philippe.[/quote]

I use it to instanciate the histograms in the Begin method, but I use also in the SlaveBegin method

Hi,

You might be confused about what the proof master is ; see some documentation at root.cern.ch/drupal/content/mult … chitecture. Neither the Begin nor the SlaveBegin is run on the master. I think you do really mean ’ between the root session on your desktop and the slaves’ in which case the constructor is indeed just fine.

Philippe.

[quote=“pcanal”]Hi,

You might be confused about what the proof master is ; see some documentation at root.cern.ch/drupal/content/mult … chitecture. Neither the Begin nor the SlaveBegin is run on the master. I think you do really mean ’ between the root session on your desktop and the slaves’ in which case the constructor is indeed just fine.

Philippe.[/quote]

sorry, the problem is that in our infractuture the master and the client are the same machine.

Hi,

Fair enough ; I assume that your problem is now resolved?

Philippe.

[quote=“pcanal”]Hi,

Fair enough ; I assume that your problem is now resolved?

Philippe.[/quote]

yes, it is, thank you