Skip to content
Snippets Groups Projects
Commit cc311aad authored by Administrator's avatar Administrator Committed by Florian Uhlig
Browse files

pwgcha: Add gFile + gDirectory protection

parent e28bbc47
No related branches found
No related tags found
1 merge request!280Analysis fix tfile glob point
Pipeline #9048 passed
......@@ -58,8 +58,17 @@ void CbmAnaJpsiSuperEvent::Run() {
Draw();
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(fOutputFile.c_str(), "RECREATE");
fHM->WriteToFile();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
file->Close();
cout << "-I- Output file:" << fOutputFile << endl;
......@@ -234,6 +243,11 @@ void CbmAnaJpsiSuperEvent::ReadCandidates() {
fPlusCandidates.clear();
cout << "-I- ReadCandidates" << endl;
cout << "-I- fFileNames.size:" << fFileNames.size() << endl;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
for (UInt_t iFile = 0; iFile < fFileNames.size(); iFile++) {
cout << "-I- Reading file No " << iFile << " path:" << fFileNames[iFile]
<< endl;
......@@ -278,6 +292,10 @@ void CbmAnaJpsiSuperEvent::ReadCandidates() {
f->Close();
delete f;
}
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
cout << "-I- fMinusCandidates.size:" << fMinusCandidates.size() << endl;
cout << "-I- fPlusCandidates.size:" << fPlusCandidates.size() << endl;
cout << "-I- number of events:" << fHM->H1("fh_se_event_number")->GetEntries()
......
......@@ -38,6 +38,10 @@ CbmAnaJpsiSuperEventReport::~CbmAnaJpsiSuperEventReport() {}
void CbmAnaJpsiSuperEventReport::Create(const string& fileEventByEvent,
const string& fileSuperEvent,
const string& outputDir) {
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
fHMSuperEvent = new CbmHistManager();
TFile* fileSE = new TFile(fileSuperEvent.c_str());
fHMSuperEvent->ReadFromFile(fileSE);
......@@ -48,6 +52,10 @@ void CbmAnaJpsiSuperEventReport::Create(const string& fileEventByEvent,
SetOutputDir(outputDir);
CreateReports();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
}
void CbmAnaJpsiSuperEventReport::Create() {
//Out().precision(3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment