I have fixed a typo in my call of GetEntry() and the scope error has disappeared. Now I have an issue with the script not reading any data from the tree, though similar code worked fine for a TTree (rather than a TChain).
The script as it is is now:
[code]int GG () {
TChain tebchain(“teb”);
tebchain.Add("/mnt/bigraid/gretina-runs/atlas1593/staged/merged/Run0667/Run0667.root");
tebchain.Add("/mnt/bigraid/gretina-runs/atlas1593/staged/merged/Run0667/Run0667_1.root");
tebchain.Add("/mnt/bigraid/gretina-runs/atlas1593/staged/merged/Run0667/Run0667_2.root");
tebchain.Add("/mnt/bigraid/gretina-runs/atlas1593/staged/merged/Run0667/Run0667_3.root");
tebchain.Add("/mnt/bigraid/gretina-runs/atlas1593/staged/merged/Run0667/Run0667_4.root");
Double_t chainEntries = tebchain.GetEntries();
/* declare histogram we’ll use as destination */
TH2F *GG_cc0_D = new TH2F(“GG_cc0_D”, “GG, cc0, Doppler corrected”, 4096,0,4096,4096,0,4096);
cout << chainEntries << " entries." << endl;
Int_t ent;
cout << "Pick an entry to show: ";
cin >> ent;
/* tebchain.Show(ent); */
Float_t cc0[28] = {0}; Float_t doppler[28] = {0};
tebchain.SetBranchStatus("*",0);
tebchain.SetBranchStatus(“xtals.cc”,1);
tebchain.SetBranchStatus(“xtals.doppler”,1);
tebchain.SetBranchAddress(“xtals.cc”,&cc0);
tebchain.SetBranchAddress(“xtals.doppler”,&doppler);
for (int e=0; e<chainEntries; e++) {
for (int thisreset=0; thisreset<28; thisreset++) {
cc0[thisreset] = 0; doppler[thisreset] = 0;
} /* resets done */
int gammaMult = 0;
/* Int_t entryBytes = */ tebchain.GetEntry(e,0);
if (e == ent) {tebchain.Show(e);}
for (int m=0; m<28; m++) {
if (cc0[m] != 0) {gammaMult++;}
}
if (gammaMult > 0) {
cout << "Mult: " << gammaMult << endl;
}
for (int j=0; j<gammaMult; j++) {
for (int jj=j+1; jj<gammaMult; jj++) {
float ex = cc0[j];
float ey = cc0[jj];
GG_cc0_D->Fill(ex,ey);
GG_cc0_D->Fill(ey,ex);
}
}
}
new TCanvas;
GG_cc0_D->Draw();
}[/code]
And this is the output; Notice that the ‘Mult:’ display never shows, so not a single event read in properly. Yet the event randomly chosen to display on the screen does show the desired data:
Warning in <TClass::TClass>: no dictionary for class phosWallCalc is available
Warning in <TClass::TClass>: no dictionary for class calEvent is available
Warning in <TClass::TClass>: no dictionary for class phosWallRaw is available
Warning in <TClass::TClass>: no dictionary for class hitEvent is available
Warning in <TClass::TClass>: no dictionary for class phosWallAux is available
Warning in <TClass::TClass>: no dictionary for class auxHit is available
Warning in <TClass::TClass>: no dictionary for class g1OUT is available
Warning in <TClass::TClass>: no dictionary for class g1GammaEvent is available
Warning in <TClass::TClass>: no dictionary for class g2OUT is available
Warning in <TClass::TClass>: no dictionary for class g2CrystalEvent is available
Warning in <TClass::TClass>: no dictionary for class g3OUT is available
Warning in <TClass::TClass>: no dictionary for class g3CrystalEvent is available
Warning in <TClass::TClass>: no dictionary for class g4SimOUT is available
Warning in <TClass::TClass>: no dictionary for class g4Sim_abcd1234 is available
Warning in <TClass::TClass>: no dictionary for class g4Sim_emittedGamma is available
Warning in <TClass::TClass>: no dictionary for class Bank29 is available
Warning in <TClass::TClass>: no dictionary for class cloverEvent is available
Warning in <TClass::TClass>: no dictionary for class cloverPacket is available
Warning in <TClass::TClass>: no dictionary for class g2IntPt is available
6.97731e+06 entries.
Pick an entry to show: 43746
======> EVENT:43746
g2 = (g2OUT*)0x1470150
xtals = (vector<g2CrystalEvent>*)0x1470190
xtals.cc = 1003.247864
xtals.doppler = 1.034173
Is there a difference in how SetBranchAddress and SetBranchStatus work in TChain vs. TTree? Because the multiplicity never goes above 0, the matrix never fills.