[Frost] arrays of histograms in root
Brian Morrison
btmorr at jlab.org
Wed Feb 10 10:45:40 EST 2010
Hey all,
I'm trying to save myself several thousand lines of code by using an array
of characters as a means to call my histogram names within a loop. For
example:
char hist_a[28];
hist_a[0] = final_1575_h1_low;
hist_a[1] = final_1575_h2_low;
hist_a[2] = final_1625_h1_low;
.
.
.
for(int i=0;i<=700;i++){
if(i<50){ // separate into 50 MeV wide W bins
num1 = 0;
num2 = 1;
}
else if (i>=50 && i<100){
num1 = 2;
num2 = 3;
}
else if (i>=100 && i<150){
num1 = 4;
num2 = 5;
}
.
.
.
for(int j=0;j<=100;j++){ // Mass
for(int q=0;q<=10;q++){ // Cosine Theta
// First Helicity
data = hist_a[num1]->GetBinContent(j,q);
err = hist_a[num1]->GetBinError(j,q);
*manipulate data and error*
.
.
.
hist_a[num1]->SetBinContent(j,q,data);
hist_a[num1]->SetBinError(j,q,err);
.
.
.
}
}
}
and if I can't get this to work I end up having to do the above action
about 28 times for each run period and again for the higher energy runs
making for a lot of tedious code that can easily have errors crop up in
it. However, root complains that I have a "non class,struct,union object
hist_a[num1] used with . or ->" on the first attempt to call the histogram
by this means. I've tried casting the called name into a non-array
character variable but that results in the same error. I haven't had any
luck finding any information on this on either the root site or the web so
I was hoping someone in the group may have some experience with using
arrays to call histograms. Thanks in advance.
-Brian
More information about the Frost
mailing list