Hi rooters.
I try to read back a raw data file (“PH207_31_0.root”) and to apply an energy calibration from the “chikkyTest.root” file. I obtain a segfault depending on the order of root files declaration.
The following piece of code is working:
[code]void test()
{
TFile *inFile = new TFile("~/scratch/ph207/RAW/ROOT/PH207_37_0.root");
TTree tree = (TTree) inFile->Get(“T”);
TRawData *rawData = new TRawData();
tree->SetBranchAddress(“rawData”, &rawData);
TFile *inFileCalib = new TFile("$PH207/root/chikkyTest.root");
Int_t nentries = (Int_t)tree->GetEntries();
for (Int_t i = 0; i < nentries; i++) {
tree->GetEntry(i);
}
}
[/code]
but, this one is not working, why? (the errors reported by cint are attached)
void test()
{
TFile *inFileCalib = new TFile("$PH207/root/chikkyTest.root");
TFile *inFile = new TFile("~/scratch/ph207/RAW/ROOT/PH207_37_0.root");
TTree *tree = (TTree*) inFile->Get("T");
TRawData *rawData = new TRawData();
tree->SetBranchAddress("rawData", &rawData);
Int_t nentries = (Int_t)tree->GetEntries();
for (Int_t i = 0; i < nentries; i++) {
tree->GetEntry(i);
}
}
Another problem is that if I run twice the first code with “.x test.C” I obtain the same segfault.
I think it must be something stupid related to scope problem but I couldn’t solve it. Tell me if you need the root files or the description of the TRawData class.
Any help will be appreciated, thanks
Nicolas
RH7.3, ROOT 4.01/03
log.txt (4.54 KB)