Re: [ROOT] problem with MakeClass()

From: Perfetto Francesco (Francesco.Perfetto@na.infn.it)
Date: Sat Sep 21 2002 - 09:41:35 MEST


On Fri, 20 Sep 2002, Rene Brun wrote:
Hi Rene',

Thanks for your reply, you are always very kind;
I send you a copy of my code how you request me (naturally this is only a
skeleton of my code)


Double_t lambda(Double_t x,Double_t y,Double_t z)
{...}

Double_t xlow(Double_t y)
{...}

Double_t xup(Double_t y)
{...}

#define ana_dali_mc_cxx
#include "ana_dali_mc.h"

Double_t delta_egamma()
{

  Double_t psigma,sigmap,E1,E2,costheta,prod_scal,pxtot,pytot,pztot,pluto;
  const Double_t Mpich = 139.56995;
...
   for(Int_t i=0;i<ntv;i++) // ntv is a variable of chain that I have do
                            // with MakeClass().
     {...
      }
   return  sigmap - (1019.4-E1-E2);

}

void ana_dali_mc::Loop(Int_t howMany)
{

  if (!TClassTable::GetDict("Physics")) {
    gSystem.Load("$ROOTSYS/lib/libPhysics.so");
  }

  if (fChain == 0) return;

  Int_t nentries;
  if (howMany == 0)
    nentries = Int_t(fChain->GetEntries());
  else {
    Int_t n0 =  fChain->GetEntries() ;
    nentries = howMany < n0 ? howMany : n0 ;
       }

  Int_t nbytes = 0, nb = 0;
  Int_t initDone = 0;
  TH1D* tmp = ( TH1D *) gROOT->FindObject("histo1");
  if (tmp != 0)
    {
      cout << "Found and Destroyed" << endl;
      delete tmp;
    }

  TFile *f1 = gROOT->FindObject("analisi_mc_prova.root"); if (f1)
f1->Close();
  f1 = new TFile("analisi_mc_prova.root","RECREATE"," ROOT file with
tree");

  Bool_t   isrec;
  Double_t Tp_mc,Tm_mc,T0_mc,Q_mc;
  Double_t Tprec,Tmrec,T0rec,Qrec,E0,T0chrec,Qchrec,daliy_ch_rec;
  Double_t
dalix_mc,daliy_mc,dalix_mc_rec,daliy_mc_rec,dalix_rec,daliy_rec;
  Double_t dalixmin,dalixmax,pluto;
  const Double_t Mpich = 139.56995;
  const Double_t Mpi0  = 134.9764;
  TLorentzVector p4rad_mc,p4eta_mc,p4pip_mc,p4pim_mc,p4piz_mc,
                 p4pipetasys_mc,p4pimetasys_mc,p4pizetasys_mc;
  TLorentzVector p4datrad,p4dateta;
  TLorentzVector p4datetasys_pim,p4datetasys_pip,p4datetasys_piz;

  TTree *tmc = new TTree("tmc","Tree for montecarlo");

  tmc->Branch("dalix_mc"    ,&dalix_mc    ,"dalix_mc/D"    );
  tmc->Branch("dalix_mc_rec",&dalix_mc_rec,"dalix_mc_rec/D");
  tmc->Branch("dalix_rec"   ,&dalix_rec   ,"dalix_rec/D"   );
  tmc->Branch("daliy_mc"    ,&daliy_mc    ,"daliy_mc/D"    );
  tmc->Branch("daliy_ch_rec",&daliy_ch_rec,"daliy_ch_rec/D");
  tmc->Branch("daliy_mc_rec",&daliy_mc_rec,"daliy_mc_rec/D");
  tmc->Branch("daliy_rec"   ,&daliy_rec   ,"daliy_rec/D"   );
  tmc->Branch("isrec"       ,&isrec       ,"isrec/B"       );
  tmc->Branch("dalixmin"    ,&dalixmin    ,"dalixmin/D"    );
  tmc->Branch("dalixmax"    ,&dalixmax    ,"dalixmax/D"    );
  tmc->Branch("pluto"    ,&pluto    ,"pluto/D"    );

  for (Int_t jentry=0; jentry<nentries;jentry++)
    {
      Int_t ientry = LoadTree(jentry); //in case of a TChain, ientry is
the entry number in the current file
      nb = fChain->GetEntry(jentry);   nbytes += nb;

      for(Int_t j=0; j<ntmc; j++)
	{
	  if(kine[j]==4)
	    {...}
	}

      TVector3 beta_eta;
	  beta_eta = p4eta_mc.BoostVector();
	...
       dalixmin = xlow(daliy_rec);
       dalixmax = xup(daliy_rec);

       pluto = delta_egamma();

       tmc ->Fill();
    }
  tmc->Write();
  f1->Write();
  f1->Close();
}

					Regards,
					Francesco.




> Hi Francesco,
>
> It is difficult to come with a diagnostic without a full copy of your
> code. One thing wrong for sure, You should remove the line#
>   gROOT->Reset();
>
> This statement should be used only in unnamed macros executing in the
> global scope. In your case, this has the effect to remove all the
> definitions in #include "ana_dali_mc.h"
>
> Rene Brun
>
> On Fri, 20 Sep 2002, Perfetto Francesco wrote:
>
> > Hi Rooters,
> > I have a problem with a MakeClass().
> > I have do a chain of root files and to this chain I have applicate
> > MakeClass() method that crete me the two files analisi.C and analisi.h.
> > In the file analisi.C I have put my analisys program; this program recall
> > a function (that I have put out the function analisi::Loop() and is
> > important that it stay out) that use variables included in the chain,
> > the problem is that after load the program (.L analisi.C, analisi
> > mio),when use the loop function (mio.Loop() ) it say me :
> > root [0] .L ana_dali_mc.C
> > root [1] ana_dali_mc mio
> > root [2] mio.Loop(110)
> > Error: < Error: Symbol ntv is not defined in current scope
> > FILE:ana_dali_mc.C LINE:13
> > Error: Binary operator oprand missing FILE:ana_dali_mc.C LINE:13
> > *** Interpreter error recovered ***
> > root [3]
> >
> > Someone can tell me where i mistake ?
> >
> > Double_t delta_egamma()
> > {
> >   const Double_t Mpich = 139.56995;
> > ..
> >
> >    for(Int_t i=0;i<ntv;i++) // ntv = numero tracce da un vertice.
> >      {
> >        num_v = iv[i];       // iv[ntv] = indice di vertice.
> >  ...
> > }
> >
> > #define ana_dali_mc_cxx
> > #include "ana_dali_mc.h"
> >
> > gROOT->Reset();
> >
> > void ana_dali_mc::Loop(Int_t howMany)
> > {
> > ...
> >        taglio = delta_egamma();
> >         tmc ->Fill();
> >     ...
> >   tmc->Write();
> >   f1->Write();
> >   f1->Close();
> > }
> >
> > 					Regards,
> > 					Francesco.
> >
>
>



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET