I have code that works like this:
Float_t emenergy;
Float_t nuenergy;
Int_t train_nentries = (Int_t)trainTree->GetEntries();
for (Int_t i = 0; i < train_nentries; i++){
if(i%1000==0) cout<<"i = "<<i<<endl;
trainTree->GetEntry(i,1);
emenergy = trainRecord->shi.emenergy;
nuenergy = trainRecord->mctrue.nuEnergy;
}
i would prefer to have something more like this:
Float_t *vals[2];
char *vars[2] = {“shi.emenergy”,“mctrue.nuEnergy”};
Int_t train_nentries = (Int_t)trainTree->GetEntries();
for (Int_t i = 0; i < train_nentries; i++){
if(i%1000==0) cout<<"i = "<<i<<endl;
trainTree->GetEntry(i,1);
for(int j=0;j<2j++){
vals[j] = GetValue(Form("trainRecord->%s",vars[j]));
}
Where “GetValue()” is some function that takes a string and returns the value for the leaf it of the given entry. Having this ability would greatly simplify my code, and make it much easier to new variables to process. Is something like this possible
Thanks
Dan