Dear All,
I am facing this apparently very simple problem.
I have even googled on the Root Forum but to no avail…
The incriminated piece of code is the following:
// TFile* fileSyst = new TFile("pngResults/Systematics.root", "recreate");
// TH1F* Systematics = new TH1F("Systematics", "Systematics", 1000, -0.5, 999.5);
// TH1F* Errors = new TH1F("Errors", "Errors", 1000, -0.5, 999.5);
// Systematics->Fill(0);
// Errors->Fill(0);
// Systematics->Write(Systematics->GetName(), TObject::kOverwrite);
// Errors->Write(Errors->GetName(), TObject::kOverwrite);
// fileSyst->Close();
TFile* fileSyst = new TFile("pngResults/Systematics.root");
Systematics = (TH1F*) fileSyst->Get("Systematics");
Errors = (TH1F*) fileSyst->Get("Errors");
fileSyst->cd();
fileSyst->Close();
TFile* fileSyst2 = new TFile("pngResults/Systematics2.root", "recreate");
fileSyst2->cd();
Systematics->Fill( selectionFlag+selectionFlag2, numberOfTotalJPsi );
Errors ->Fill( selectionFlag+selectionFlag2, numberOfTotalJPsiErr );
Systematics->Write(Systematics->GetName(), TObject::kOverwrite);
Errors ->Write(Errors ->GetName(), TObject::kOverwrite);
// Systematics->Write();
// Errors ->Write();
fileSyst2 ->Close();
Basically, what I am doing is:
- open a file;
- take two histograms out of it;
- filling them;
- then overwriting them for bookkeeping;
Please, note that the commented code at the beginning is just a snippet to recreate the source tfiles…
The best thing would be to write on the same tfile, but this is not possible (not writable?), so I had to go on this roundabout way… But it doesn’t work the same and gives segmentation fault.
Any help is highly appreciated!!
Thanks,
Simone