Re: [ROOT] TChain Merge

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Jun 04 2003 - 17:53:51 MEST


Hi Martina,

You are writing into the string array s[100], but your file names are 
more than 120 characters, so you overwrite this array.
This is likely the cause of the crash.
You should also remove the statement "gROOT->Reset();"
This statement should be used only at the beginning of unnamed macros.

See my modified file below.
Let me know the result

Rene

void mergephoton(int a, int b){
  //gROOT->Reset();  //<============
  char s[160];  //<============
  Long_t id,size,flags,mt;  //<============
  TChain tree("CBNT/h3333");
  for (int j=a;j<=b;j++){
    if(j<10)
       
sprintf(s,"rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.0000%d.test.photon_20_250.root",j);
    else
       
sprintf(s,"rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.000%d.test.photon_20_250.root",j);
    Int_t i = gSystem->GetPathInfo(s,&id,&size,&flags,&mt);
    cout<<s<<" "<<i<<endl;
    if (i==0) tree.Add(s);
  }
  sprintf(s,"~/cern/w0/photons002028lumi10/files%d-%d.root",a,b);
  cout <<s<<endl;
  tree->Merge(s);
  cout <<"done"<<endl;
}

On 
Wed, 4 Jun 2003, 
Schaefer Martina wrote:

> Hi,
> 
> i send you my macro and the output. Everything is working fine, the output 
> root-file is ok, but there is this 
> *** Break *** segmentation violation
>  Generating stack trace...
> at the end.
> 
> What am I doing wrong?
> 
> 
> 	Thanks a lot,	
> 			Martina
> 
> the macro:
> --------------------------------------
> void mergephoton(int a, int b){
>   gROOT->Reset();
>   char s[100];
>   TChain tree("CBNT/h3333");
>   for (int j=a;j<=b;j++){
>     if(j<10)
> sprintf(s,"rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.0000%d.test.photon_20_250.root",j);
>     else
> sprintf(s,"rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.000%d.test.photon_20_250.root",j);
>     Long_t id,size,flags,mt;
>     Int_t i = gSystem->GetPathInfo(s,&id,&size,&flags,&mt);
>     cout<<s<<" "<<i<<endl; 
>     if (i==0) tree.Add(s);
>   sprintf(s,"~/cern/w0/photons002028lumi10/files%d-%d.root",a,b);
>   cout <<s<<endl;
>   tree->Merge(s);
>   cout <<"done"<<endl;
> 
> }
> 
> 
> 
> --------------
> the output:
> --------------
> root [0] .L merge.C
> root [1] mergephoton(16,20)
> rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.00016.test.photon_20_250.root 
> 0
> rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.00017.test.photon_20_250.root 
> 0
> rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.00018.test.photon_20_250.root 
> 0
> rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.00019.test.photon_20_250.root 
> 0
> rfio:/castor/cern.ch/user/m/mschafer/photons002028lumi10/dc1.002028.lumi10.recon.008.00020.test.photon_20_250.root 
> 0
> ~/cern/w0/photons002028lumi10/files16-20.root
> done
> 
>  *** Break *** segmentation violation
>  Generating stack trace...
> 
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET