RE: about selecting bins in THnSparse

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 30 Mar 2011 08:46:02 +0000


Hi,

Even with 10 ranges I don't find it that problematic. You could do:

// The lower, upper bound of the ranges
int rangeBegin[10] = {...};
int rangeEnd[10] = {...};

TH1::AddDirectory(false); // we handle histogram lifetime TH1* hProjection = 0; // Contains the projection of all the ranges

// Iterate over ranges
for (int i = 0; i < 10; ++i) {
  thnsparse->GetAxis(0)->SetRange(rangeBegin[i], rangeEnd[i]);   TH1* hThisProj = (TH1*)thnsparse->Projection(axisY);   if (hProjection) {

     hProjection->Add(hThisProj);
     delete hThisProj;
  } else {
     hProjection = hThisProj;

  }
}

Cheers, Axel.



From: owner-roottalk_at_root.cern.ch [owner-roottalk_at_root.cern.ch] on behalf of Xianguo Lu [lu.xianguo_at_gmail.com] Sent: 30 March 2011 10:38
To: Axel Naumann
Cc: roottalk_at_root.cern.ch
Subject: Re: [ROOT] about selecting bins in THnSparse

Hi Axel,

2011/3/30 Axel Naumann <Axel.Naumann_at_cern.ch<mailto:Axel.Naumann_at_cern.ch>> Hi,

Apologies for the slow reply - I was away from work and internet for a while.

You could select the first range, do the projection, then select the second range, do the projection to a different histogram, and then add the two projection histograms. Would that do what you are looking for?

Thanks for the answer! But it does not fit inot my situation because what I actually have is something like 10 patches of discrete ranges, each with considerable staticstics. So projection-merge for every range is not that economical...

Is there a functionality like disabling some status bits of the axis bins so that the disabled bins won't participate in the projection?

Cheers,
Xianguo

Cheers, Axel.



From: owner-roottalk_at_root.cern.ch<mailto:owner-roottalk_at_root.cern.ch> [owner-roottalk_at_root.cern.ch<mailto:owner-roottalk_at_root.cern.ch>] on behalf of Xianguo Lu [lu.xianguo_at_gmail.com<mailto:lu.xianguo_at_gmail.com>] Sent: 26 March 2011 15:12
To: roottalk_at_root.cern.ch<mailto:roottalk_at_root.cern.ch> Subject: [ROOT] about selecting bins in THnSparse

Hi Rooters,

I have a question about selecting bins in THnSparse. It is the following.

If I want to select only a certain range of a axis and do the projection of the THnSparse, then I do
thnsparse->GetAxis(axisX)->SetRange(bin0, bin1); hh=(TH1D*)thnsparse->Projection(axisY);

But what if I want to selection discontinuous patches of bins, like e.g.  [bin0-bin1]+[bin4, bin5],
then is there a simple way to do the projection?

Many thanks!

best regards,
Xianguo

--

Xianguo Lu

Physikalisches Institut
Raum 204 OG2
Philosophenweg 12
D-69120 Heidelberg

Tel: +49-6221-549499

--

Xianguo Lu

Physikalisches Institut
Raum 204 OG2
Philosophenweg 12
D-69120 Heidelberg

Tel: +49-6221-549499 Received on Wed Mar 30 2011 - 10:46:07 CEST

This archive was generated by hypermail 2.2.0 : Wed Mar 30 2011 - 11:50:01 CEST