Hello,
What is wrong here ?
TH2S *hists[2,10] = new TH2S*[2*n];
for (int i=0;i<n;i++) {
char buffer[100];
sprints(buffer,"Energy_v_Pos_Det%d",i);
hists[1,i] = new TH2S(buffer, . . . }
sprints(buffer,"Time_Det%d",i);
hists[2,i] = new TH2S(buffer, . . . }
}
and then
hist[2,i]->Fill(Time[i],);
hist[1,i]->Fill(Energy[i],Position[i]);
or something like this
Hope this helps,
Valeri
----- Original Message -----
From: Karl Hauschild <karlhaus@hep.saclay.cea.fr>
To: <roottalk@pcroot.cern.ch>
Sent: 27 марта 2001 г. 12:08
Subject: [ROOT] Multiple histos/matrices
>
> Hi,
>
> I want to increment histograms and matrices (2D histograms)
> for NDET similar detectors.
>
> A simple, but tedious, solution would be
>
> switch( Id ) {
> case 1 :
> hTime_Det1->Fill(Time[1]);
> hEnergy_v_Pos_Det1->Fill(Energy[1],Position[1]);
> break;
> case 2 :
> hTime_Det2->Fill(Time[2]);
> hEnergy_v_Pos_Det2->Fill(Energy[2],Position[2]);
> break;
> :
> :
> default : break;
> }
>
>
> In other analysis packages I use one can increment 2D histograms
> based on the detector id in the following way
>
> for(i = 1; i <= NDetHit; i++) {
> Id = Det_Id[i];
> inc_Time(Id, Time[Id]);
> inc_Energy_v_Pos(Id, Energy[Id], Position[Id]);
> }
>
> Is something simialr available in ROOT ?
>
> This would also apply to the histogram definitions :
>
> eg definitions like :
>
> HISTO Time 1D NHISTS=NDET XLEN=4096
> HISTO Energy_v_Pos 2D NHISTS=NDET XLEN=XXXX YLEN=YYYY
>
> How does one do this with ROOT ? I would not want to define
> more than a few histograms in the following way :
>
> TH2S *hEnergy_v_Pos_Det1 = new TH2S("Energy_v_Pos_Det1"......)
> TH2S *hEnergy_v_Pos_Det2 = new TH2S("Energy_v_Pos_Det2"......)
>
> Many thanks,
>
> Karl Hauschild
> ==========================================================================
>
> CEA Saclay, DAPNIA/SPhN Phone : (33) 01 69 08 7553
> Bat 703 - l'Orme des Merisiers Fax : (33) 01 69 08 7584
> F-91191 Gif-sur-Yvette E-mail : khauschild@cea.fr
> France karl_hauschild@yahoo.co.uk
> WWW: http://www-dapnia.cea.fr/Sphn
>
>
>
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:40 MET