Hi all,
I’ve been banging my head over a small bug in this piece of code:
[code]// Set Branch
Short_t sum[16];
t->SetBranchAddress(“sum”, &sum);
// Cycle events
const Int_t nevts = (Int_t)t->GetEntries();
for(Int_t j = 0; j < nevts; j++) {
cout << j << endl; // 1
if(j % 50000 == 0)
cout << "Processing evt " << j << " of " << nevts << endl;
cout << j << endl; // 2
t->GetEntry(j);
cout << j << endl; // 3
for(Int_t k = 0; k < npairs; k++) {
if(sum[k] > 0)
h[k]->Fill(sum[k]);
}
cout << j << endl; // 4
}
[/code]
On the output of this I get:
0
Processing evt 0 of 500
0
8519794
8519794
I really don’t have any clue of what might be wrong in this code…
I hope someone could help on this one…
Thanks in advance ,
Rui
pcanal
February 8, 2006, 7:02pm
2
Hi,
I think you meant to use:
Short_t sum[16];
t->SetBranchAddress("sum", &(sum[0]), "sum[16]/S");
Cheers,
Philippe.
Nope, that gives an error that the function SetBranchAddress(bla bla bla) doesn’t exist, possible candidates are…
Meanwhile I tried reading all branches by order:
Short_t adc[32] = {0}
t->SetBranchAddress(“adc”, &adc);
Short_t sum[16] = {0}
t->SetBranchAddress(“sum”, &sum);
Double_t a[16] = {0}
t->SetBranchAddress(“a”, &a);
and, with no further modifications, it started working…
Strange world we live in…
But thanks for your prompt reply!
Rui
pcanal
February 8, 2006, 9:36pm
4
Oups … I mis-read (SetBranchAddress vs just Branch)
In your original code what is ‘npairs’?
Philippe.
Is defined in a header file like this:
static const Int_t npairs = 15;
Rui
pcanal
February 14, 2006, 3:14am
6
[quote]and, with no further modifications, it started working…
[/quote]After re-reading your messages, I am unsure what constitute working or not.
Anyway I assume that the problem is now gone.
Philippe.