RE: TChain & Symbol chain is not defined in current scope

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Tue, 16 Jan 2007 22:36:19 -0600


Hi,

Essentially, in your example you do not define the variable chain in the global namespace (the one you are trying to access when you type 'chain' on the command prompt).

You need to chain your function in the following fashion:

TChain *myChain(int minrun, int maxrun)
{

  TChain *chain = new TChain("T");
  for (int run=minrun; run<=maxrun; run++)   {
  ....
  }
  return chain;
}

and :

root [26] TChain *chian = myChain(28074, 28080);

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Nevzat Guler
Sent: Tuesday, January 16, 2007 6:08 PM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] TChain & Symbol chain is not defined in current scope

	Hello,
	I wrote the short program below to chain many root files together.
In the root session I link the program:
root [25] .L myChain.C

Then I run the program as:
root [26] myChain(28074, 28080);

it does not complain about anything. So i assume it chained all the root files in the list.
Then I try to draw saomething from the chain by saying: root [27] chain.Draw("IPLOTS.ECT_el:IPLOTS.ECin_el >> h2","","colz");

it says:
Error: Symbol chain is not defined in current scope (tmpfile):1: Error: Failed to evaluate chain.Draw("IPLOTS.ECT_el:IPLOTS.ECin_el >> h2","","colz")Possible candidates are... filename line:size busy function type and name *** Interpreter error recovered ***

Program myChain.C is printed below:

P.S. In this program I also tried to pass root file name quoted as "28074.root" by creating the file name accordingly. But it also did not work. I concluded it is not issue with " sign. In the version below I dont have " sign attached to the ends of root file name..

Thank you very much with your inputs..

                            Nevzat Guler

#include <stdlib.h>
#include <vector>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "TCanvas.h"
#include "TVirtualPad.h"
#include "TPostScript.h"

#include "TLegend.h"
#include "TChain.h"
using namespace std;
#include "/u/home/nguler/inc/utils.h"

void myChain(int minrun, int maxrun)
{

  TChain chain("T");
  for (int run=minrun; run<=maxrun; run++)   {

    string filepathName = "/p/clas-disk1/nevzat/trees/group/";     string runstring;
    runstring = IntToString( run );
    string file(runstring);
    file.append(".root");

    filepathName.append(file);
    int fileExist = 0;
    fileExist = pathExists( filepathName.c_str() );

    if ( fileExist == 1 )
    {

      cout << "Adding " << file << endl;
      chain.Add( file.c_str() );

    }

  }

} Received on Wed Jan 17 2007 - 05:37:37 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 17 2007 - 11:50:00 CET