Commit bb82dd46 authored by Administrator's avatar Administrator Committed by Florian Uhlig
Browse files

much: Add gFile + gDirectory protection

parent 5b616216
......@@ -135,12 +135,19 @@ void CbmMuchGeoScheme::Init(TObjArray* stations, Int_t flag) {
// -------------------------------------------------------------------------
void CbmMuchGeoScheme::Init(TString digiFileName, Int_t flag) {
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(digiFileName);
TObjArray* stations = (TObjArray*) file->Get("stations");
file->Close();
file->Delete();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
Init(stations, flag);
}
// -------------------------------------------------------------------------
......
......@@ -230,13 +230,18 @@ void CbmMuchSegmentAuto::FinishTask() {
printf("Station%i segmented\n", i + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
DrawSegmentation();
......
......@@ -261,13 +261,18 @@ void CbmMuchSegmentManual::SegmentMuch() {
printf("Station %i segmented\n", iStation + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
// Draw colored stations
DrawSegmentation();
......
......@@ -144,13 +144,18 @@ void CbmMuchSegmentSector::SegmentMuch() {
printf("Station %i segmented\n", iStation + 1);
}
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
// Save parameters
TFile* oldfile = gFile;
TFile* f = new TFile(fDigiFileName, "RECREATE");
fStations->Write("stations", 1);
f->Close();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
DrawSegmentation();
}
......
/*
* CbmMuchFindHitsGem.cxx
*
*
* Modified on 08/08/2019 : Hit reconstruction in Event (in time slice) and Time slice mode
* Default is time slice (kCbmTimeSlice) and it will run in event mode (kCbmEvent) if find event branch in the tree
* @authors Vikas Singhal and Ajit Kumar
......@@ -78,13 +78,13 @@ InitStatus CbmMuchFindHitsGem::Init() {
// fDigis will not be used now. Just for checking. Need to remove
/*fDigis = (TClonesArray*) ioman->GetObject("MuchDigi");
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("MuchBeamTimeDigi");
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("CbmMuchBeamTimeDigi");
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("CbmMuchDigi");
if (! fDigis)
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("MuchBeamTimeDigi");
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("CbmMuchBeamTimeDigi");
if (! fDigis)
fDigis = (TClonesArray*) ioman->GetObject("CbmMuchDigi");
if (! fDigis)
LOG(info) << "MuchFindHitsGem: No MuchDigi or MuchBeamTimeDigi or CbmMuchDigi or CbmMuchBeamTimeDigi exist";
*/
......@@ -117,12 +117,18 @@ InitStatus CbmMuchFindHitsGem::Init() {
IsOutputBranchPersistent("MuchPixelHit"));
// Initialize GeoScheme
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(fDigiFile);
TObjArray* stations = (TObjArray*) file->Get("stations");
file->Close();
file->Delete();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
fGeoScheme->Init(stations, fFlag);
return kSUCCESS;
}
......
......@@ -45,12 +45,18 @@ InitStatus CbmMuchHitProducerIdeal::Init() {
// Initialize GeoScheme
fGeoScheme = CbmMuchGeoScheme::Instance();
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(fDigiFile);
TObjArray* stations = (TObjArray*) file->Get("stations");
file->Close();
file->Delete();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
fGeoScheme->Init(stations, fId);
return kSUCCESS;
}
......
......@@ -138,7 +138,16 @@ InitStatus CbmMuchHitFinderQa::Init() {
// Reading Much Digis from CbmMuchDigiManager which are stored as vector
fDigiManager = CbmDigiManager::Instance();
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* f = new TFile(fGeoFileName, "R");
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
TObjArray* stations = (TObjArray*) f->Get("stations");
fGeoScheme->Init(stations, fFlag);
......
......@@ -2,8 +2,8 @@
*@author Vikas Singhal <vikas@vecc.gov.in>
*@since 15.01.2020
*@version 4.0
*@description: Using std::vector for digi and match containers.
*@author Ekata Nandy (ekata@vecc.gov.in)
*@description: Using std::vector for digi and match containers.
*@author Ekata Nandy (ekata@vecc.gov.in)
*@since 21.06.19 : RPC digitization parameters(for 3rd and 4th MUCH station) now have been implemented along with GEM param// eters (1st and 2nd station) @author Ekata Nandy (ekata@vecc.gov.in)
*@description: ADC channels number is 32.GEM & RPC has different charge threshold value and dynamic range, so SetAdc has been changed acc// ordingly. ADC value starts from 1 to 32. ADC 0 has been excluded as it gives wrong x, y, t. @author Ekata Nandy
*@author Vikas Singhal <vikas@vecc.gov.in>
......@@ -378,7 +378,9 @@ InitStatus CbmMuchDigitizeGem::Init() {
// Initialize GeoScheme
TFile* oldfile = gFile;
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile* file = new TFile(fDigiFile);
if (!file->IsOpen())
LOG(fatal) << fName << ": parameter file " << fDigiFile
......@@ -386,7 +388,9 @@ InitStatus CbmMuchDigitizeGem::Init() {
TObjArray* stations = (TObjArray*) file->Get("stations");
file->Close();
file->Delete();
gFile = oldfile;
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
fGeoScheme->Init(stations, fFlag);
......@@ -808,11 +812,18 @@ void CbmMuchDigitizeGem::Finish() {
LOG(info) << "=====================================";
/*
/// Save old global file and folder pointer to avoid messing with FairRoot
TFile* oldFile = gFile;
TDirectory* oldDir = gDirectory;
TFile *f1 =new TFile ("pri_el_info.root","RECREATE");
hPriElAfterDriftpathgem->Write();
hPriElAfterDriftpathrpc->Write();
hadcGEM->Write();
hadcRPC->Write();
f1->Close();
/// Restore old global file and folder pointer to avoid messing with FairRoot
gFile = oldFile;
gDirectory = oldDir;
*/
//if (fDaq) ReadAndRegister(-1.);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment