Re: Variable declaration in a macro

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Feb 10 1998 - 15:15:26 MET


Axel Schwank wrote:
> 
> Dear Rooters,
> I have a problem again and I do absolutely not see what's going wrong.
> In the following macro:
> 
> {
> //////////////////////////////////////////////////////////
> //   This file has been automatically generated
> //     (Fri Feb  6 10:17:16 1998 by ROOT version 1.03/09)
> //   from TTree T/Required banks for cosmic analysis
> //   found on file: /afs/desy.de/user/s/schwank/store/root/Test.root
> //////////////////////////////////////////////////////////
> 
> //Reset ROOT and connect tree file
>    gROOT->Reset();
>    TFile *f = new TFile("/afs/desy.de/user/s/schwank/store/root/Dice3.root");
>    TTree *T = (TTree*)f->Get("T");
> 
> //Declaration of leaves types
>    Int_t           DTRA_;
>    Float_t         DTRA_fPtinv_tr[160];
>    Float_t         DTRA_fPhi_tr[160];
>    Float_t         DTRA_fThet_tr[160];
> // ....
>    Float_t         DTRA_fQ_tr[160];
>    UInt_t          DMIS_fUniqueID[20];
>    UInt_t          DMIS_fBits[20];
> 
> //Set branch addresses
>    T->SetBranchAddress("DTRA_",&DTRA_);
>    T->SetBranchAddress("DTRA.fPtinv_tr",DTRA_fPtinv_tr);
>    T->SetBranchAddress("DTRA.fPhi_tr",DTRA_fPhi_tr);
>    T->SetBranchAddress("DTRA.fThet_tr",DTRA_fThet_tr);
>    T->SetBranchAddress("DTRA.fQ_tr",DTRA_fQ_tr);
> // ....
>    T->SetBranchAddress("DMIS.fUniqueID",DMIS_fUniqueID);
>    T->SetBranchAddress("DMIS.fBits",DMIS_fBits);
> 
> //     This is the loop skeleton
> //       To read only selected branches, Insert statements like:
> // T->SetBranchStatus("*",0);  // disable all branches
> // T->SetBranchStatus("branchname",1);  // activate branchname
> 
>    Int_t nentries = T->GetEntries();
>    histo1=TH1S("DKappa","Delta Kappa",80,0,2);
>    histo2=TH1S("SKappa","Sigma Kappa",80,-2,2);
> 
>    Float_t dkappa = 0;
>    Float_t skappa = 0;
>    Float_t kappa = 0;
>    Int_t nbytes = 0;
>    for (Int_t i=0; i<nentries;i++) {
>       nbytes += T->GetEvent(i);
>       cout << 0.5*(DTNV_fDcurv_tn[DCOS_fDtnv[0]]+DTNV_fDcurv_tn[DCOS_fDtnv2[0]]);
> //      skappa = DTNV_fCurv_tn[DCOS_fDtnv[0]]-DTNV_fCurv_tn[DCOS_fDtnv2[0]];
> //      kappa = 0.5*(DTNV_fCurv_tn[DCOS_fDtnv[0]]+DTNV_fCurv_tn[DCOS_fDtnv2[0]]);
> //      pt = fabsf(2.99795e-4*DMIS_fB_field[0]/kappa);
> //      if (pt>1 && pt<10){
> //        histo1.Fill(dkappa/kappa);
> //        histo2.Fill(skappa/kappa);
> //      }
>    }
> }
> 
> ROOT complains "No symbol i in current scope" in the line containing the
> for-loop !!! If i remove the comments in the following lines, the
> interpreter complains "Undeclared data member skappa", even if declared.
> I'm helpless, who sees the problem ?
> Thanks in advance.
> 
> Axel Schwank

Axel,
When I run your macro, I correctly get the following errors:
Error: No symbol DCOS_fDtnv[0] in current scope 
FILE:/disk2/user/brun/root/./axel.C LINE:5

If I remove the cout statement, your program runs as expected.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:29 MET