TChain problem

View As Web Page

Hello,

Im doing local analysis on 34 AliESDs.root (+ friends) files, each of which are localized in a designated directory. Each of these are working individually but when i put them into a TChain i get a variety of different errors. I create my TChain in the following way:

#include "TChain.h"
TChain * CreateChainA00A01()
{
TChain * chain = new TChain(“esdTree”);
chain->Add(“SectorA00A01/1/AliESDs.root”);
chain->Add(“SectorA00A01/2/AliESDs.root”);
.
.
.
chain->(“SectorA00A01/34/AliESDs.root”);
return chain;
}

I enable all brances and are able to retrieve the number of entries. But when I use the ->GetEntry(int) method I get a bad allocation. The error is the follwing:

Processing event number: 0
terminate called after throwing an instance of 'std::bad_alloc’
what(): std::bad_alloc
Aborted

If I instead use the TChain method ->GetChainEntryNumber(int) i am able to loop over the events, but get 0 tracks in all events.

It should be noted, that when I run these scripts in the local directory of one single AliESDs.root file, it works.

I sincerely hope someone can help me.

Rasmus

Could you post teh shortest possible running code reproducing your problem? and indicate which version of ROOT ?

Rene

I created a function like this:

#include "TChain.h"
TChain * CreateChainA00A01()
{
TChain * chain = new TChain(“esdTree”);
chain->AddFile(“SectorA00A01/1/AliESDs.root”);
chain->AddFile(“SectorA00A01/2/AliESDs.root”);
.
.
.
return chain;
}

And the script reproducing the problem is:
#ifndef CINT
#include “TObject.h”
#include “TFile.h”
#include “TTree.h”
#include “TChain.h”
#include “TBranch.h”
#include “TEventList.h”
#include “TCut.h”
#include “TFitter.h”
#include “TMatrixD.h”
#include “TLinearFitter.h”
#include “TMath.h”
#include “TLine.h”
#include “TPaveText.h”
#include “TLatex.h”
#include “TPad.h”

#include “AliLog.h”
#include “AliMagF.h”

#include “AliESD.h”
#include “AliESDfriend.h”
#include “AliESDtrack.h”
#include “AliTracker.h”
#include “AliTPCseed.h”
#include “AliTPCclusterMI.h”
#include “AliTPCclusterInfo.h”
#include “TTreeStream.h”
#include “TF1.h”
#include “TH3F.h”
#include “TGraph.h”
#include “AliSignalProcesor.h”
#include “TCanvas.h”
#include “TGraphErrors.h”
#include “AliTPCclusterInfo.h”
#endif

#include “AliTPCLaserFit.h”
#include “LaserHists1D.h”
#include “LoadPositionArray.h”

#include “CreateChainA00A01.h”

void LoopTest(){
// Intializing the chain and andresses as well as home made fitters and datafiles
TChain * Tree = CreateChainA00A01();
AliESD * esd =0; // Change to AliESD in normal mode!
AliESDfriend evf=0;
Tree->SetBranchStatus("
",1);
Tree->SetBranchStatus(“ESDfriend.”, 1);
Tree->SetBranchAddress(“ESD”,&esd);
Tree->SetBranchAddress(“ESDfriend.”,&evf);

Int_t ntracks = 0;
Int_t nevents = Tree->GetEntries();
cout << "Number of events in the chain: " << nevents << endl;

for (Int_t i = 0; i < nevents;i++){
cout << "Processing event number: " << i << endl;
Tree->GetEntry(i);
ntracks = esd->GetNumberOfTracks();
cout << "Number of tracks in current event: " << ntracks << endl;
esd->SetESDfriend(evf);
if (0 == ntracks) continue;

for (Int_t k = 0; k < ntracks; k++){
  AliESDtrack * track = esd->GetTrack(k);
  AliESDfriendTrack * ftrack = (AliESDfriendTrack *)esd->GetTrack(k)
  ->GetFriendTrack();  
  AliTPCseed * trackseed = (AliTPCseed*) ftrack->GetCalibObject(0);
  cout << k << "\t";
  cout << endl;
  cout << endl;
}

}
}

I get the following:
root [1] LoopTest()
Warning in TStreamerInfo::BuildOld: Cannot convert AliESDCaloCluster::fDigitAmplitude from type:UShort_t* to type:TArrayS, skip element
Warning in TStreamerInfo::BuildOld: Cannot convert AliESDCaloCluster::fDigitTime from type:UShort_t* to type:TArrayS, skip element
Warning in TStreamerInfo::BuildOld: Cannot convert AliESDCaloCluster::fDigitIndex from type:UShort_t* to type:TArrayS, skip element
Warning in TStreamerInfo::Compile: Counter fNumberOfDigits should not be skipped from class AliESDCaloCluster
Number of events in the chain: 884
Processing event number: 0
terminate called after throwing an instance of 'std::bad_alloc’
what(): std::bad_alloc
Aborted

My version of root is | Version 5.17/05 16 October 2007 |

Best Regards

Rasmus

see with the Alice folks.
As the error messages indicate, the auto schema evolution system cannot convert from arrays of Ushort_t to a TArrayS (or like). We can only convert automatically from an array
of ushort to vector<UShort_t>.
You have to implement a custom Streamer for the faulty class.
It is likely that (because of these errors) you keep storing in memory the original UShort_t arrays, but never delete them (hence a memory overflow problem)

Rene

Hello,

I am not using those branches, so I have disabled them instead. I still get the error though, running the same code, but with the following alteration in the branch handling:

Tree->SetBranchAddress(“ESD”,&esd);
Tree->SetBranchAddress(“ESDfriend.”,&evf);

Tree->SetBranchStatus("*",0);
Tree->SetBranchStatus(“TObject”, 1);
Tree->SetBranchStatus(“fRunNumber”, 1);
Tree->SetBranchStatus(“fEventNumberInFile”, 1);
Tree->SetBranchStatus(“ESDfriend.fTracks.fCalibContainer”, 1);
Tree->SetBranchStatus(“ESDfriend.”, 1);
Tree->SetBranchStatus(“ESDfriend.fTracks”, 1);
Tree->SetBranchStatus(“fTracks”,1);
Tree->SetBranchStatus(“fTimeStamp”,1);

Its seems to be the fCalibContainer leaf that causes the problem. I get the following (the same, just without warnings):

root [1] LoopTest()
Number of events in the chain: 884
Processing event number: 0
terminate called after throwing an instance of 'std::bad_alloc’
what(): std::bad_alloc
Aborted

Best regards,

Could you post teh shortest possible test script (say < 100 lines) and the minimum set of files to reproduce the problem?

Rene

Here is the code that gives me the error.

#ifndef CINT
#include “TObject.h”
#include “TFile.h”
#include “TTree.h”
#include “TChain.h”
#include “TBranch.h”
#include “TEventList.h”
#include “AliMagF.h”
#include “AliESD.h”
#include “AliESDfriend.h”
#include “AliESDtrack.h”
#include “AliTPCseed.h”
#include “AliTPCclusterMI.h”
#include “AliTPCclusterInfo.h”
#include “TTreeStream.h”
#include “TF1.h”
#include “AliSignalProcesor.h”
#include “TCanvas.h”
#include “TGraphErrors.h”
#include “AliTPCclusterInfo.h”
#endif

void LoopTest1(){
// Intializing the chain and andresses as well as home made fitters and datafiles
TChain * Tree = new TChain(“esdTree”);
Tree->AddFile(“SectorA00A01/1/AliESDs.root”);
AliESD * esd =0; // Change to AliESD in normal mode!
AliESDfriend *evf=0;
Tree->SetBranchAddress(“ESD”,&esd);
Tree->SetBranchAddress(“ESDfriend.”,&evf);

Tree->SetBranchStatus("*",0);
Tree->SetBranchStatus(“TObject”, 1);
Tree->SetBranchStatus(“fRunNumber”, 1);
Tree->SetBranchStatus(“fEventNumberInFile”, 1);
Tree->SetBranchStatus(“fEventType”, 1);
Tree->SetBranchStatus(“fRecoVersion”, 1);
Tree->SetBranchStatus(“ESDfriend.fTracks.fCalibContainer”, 1);
Tree->SetBranchStatus(“ESDfriend.”, 1);
Tree->SetBranchStatus(“ESDfriend.fTracks”, 1);
Tree->SetBranchStatus(“fTracks”,1);
Tree->SetBranchStatus(“fTimeStamp”,1);

Int_t ntracks = 0;
Int_t nevents = Tree->GetEntries();
cout << "Number of events in the chain: " << nevents << endl;

for (Int_t i = 0; i < nevents;i++){
cout << "Processing event number: " << i << endl;
Tree->GetEntry(i);
ntracks = esd->GetNumberOfTracks();
cout << "Number of tracks in current event: " << ntracks << endl;
esd->SetESDfriend(evf);
if (0 == ntracks) continue;

for (Int_t k = 0; k < ntracks; k++){
  AliESDtrack * track = esd->GetTrack(k);
  AliESDfriendTrack * ftrack = (AliESDfriendTrack *)esd->GetTrack(k)
  ->GetFriendTrack();  
  AliTPCseed * trackseed = (AliTPCseed*) ftrack->GetCalibObject(0);
  // the trackseed is what i need to analyze. 
  // cout << trackseed; 
}

}
}
I use the two files AliESDs.root and AliESDfriends.root.

The files are too large (1 + 27 MB) to be sent. They can be found on Alien at

/alice/cern.ch/user/h/haavard/rec0307_alien/2571

Any one of these file pairs will do (AliESDs.root + AliESDfriends.root)

Best regards

I was hoping to see a short script. Your program requires the full Alice setup.
Please see with the Alice framework guys to help solving your problem.

Rene