void AnalyzeResponseUniformity::storeFits( string strOutputROOTFileName, std::string strOption ){ //Variable Declaration TFile * ptr_fileOutput = new TFile(strOutputROOTFileName.c_str(), strOption.c_str(),"",1); //Check if File Failed to Open Correctly if ( !ptr_fileOutput->IsOpen() || ptr_fileOutput->IsZombie() ) { printClassMethodMsg("AnalyzeResponseUniformity","storeFits","Error: File I/O"); printROOTFileStatus(ptr_fileOutput); printClassMethodMsg("AnalyzeResponseUniformity","storeFits", "\tPlease cross check input file name, option, and the execution directory\n" ); printClassMethodMsg("AnalyzeResponseUniformity","storeFits", "\tExiting; No Fits have been stored!\n" ); return; } //End Check if File Failed to Open Correctly //Loop Over Stored iEta Sectors for (auto iterEta = detMPGD.map_sectorsEta.begin(); iterEta != detMPGD.map_sectorsEta.end(); ++iterEta) { //Loop Over iEta Sectors //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_SectorEta = ptr_fileOutput->GetDirectory( ( "SectorEta" + getString( (*iterEta).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_SectorEta == nullptr) { //Case: Directory did not exist in file, CREATE dir_SectorEta = ptr_fileOutput->mkdir( ( "SectorEta" + getString( (*iterEta).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Debugging //cout<<"dir_SectorEta->GetName() = " << dir_SectorEta->GetName()<<endl; //Store Fits - SectorEta Level //------------------------------------- dir_SectorEta->cd(); (*iterEta).second.gEta_ClustADC_Fit_NormChi2->Write(); (*iterEta).second.gEta_ClustADC_Fit_PkPos->Write(); (*iterEta).second.gEta_ClustADC_Fit_Failures->Write(); (*iterEta).second.gEta_ClustADC_Spec_NumPks->Write(); (*iterEta).second.gEta_ClustADC_Spec_PkPos->Write(); //Loop Over Stored iPhi Sectors within this iEta Sector for (auto iterPhi = (*iterEta).second.map_sectorsPhi.begin(); iterPhi != (*iterEta).second.map_sectorsPhi.end(); ++iterPhi) { //Loop Over Stored iPhi Sectors //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_SectorPhi = dir_SectorEta->GetDirectory( ( "SectorPhi" + getString( (*iterPhi).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_SectorPhi == nullptr) { //Case: Directory did not exist in file, CREATE dir_SectorPhi = dir_SectorEta->mkdir( ( "SectorPhi" + getString( (*iterPhi).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Debugging //cout<<"dir_SectorPhi->GetName() = " << dir_SectorPhi->GetName()<<endl; //Store Fits - SectorPhi Level //------------------------------------- dir_SectorPhi->cd(); //No Fits defined at this level - yet //Slices //Now that all clusters have been analyzed we extract the slices for (auto iterSlice = (*iterPhi).second.map_slices.begin(); iterSlice != (*iterPhi).second.map_slices.end(); ++iterSlice ) { //Loop Over Slices //int iSliceCount = std::distance( (*iterPhi).second.map_slices.begin(), iterSlice ); //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_Slice = dir_SectorPhi->GetDirectory( ( "Slice" + getString( (*iterSlice).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_Slice == nullptr) { //Case: Directory did not exist in file, CREATE dir_Slice = dir_SectorPhi->mkdir( ( "Slice" + getString( (*iterSlice).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Store Fits - Slice Level //------------------------------------- dir_Slice->cd(); //(*iterSlice).second.pmrkSlice_ClustADC->Write( getNameByIndex( (*iterEta).first, (*iterPhi).first, (*iterSlice).first, "PeakMrk", "clustADC" ).c_str() ); (*iterSlice).second.fitSlice_ClustADC->Write(); } //End Loop Over Slices } //End Loop Over Stored iPhi Sectors } //End Loop Over Stored iEta Sectors //Close the ROOT file ptr_fileOutput->Close(); return; } //End storeHistos()
//Stores booked histograms (for those histograms that are non-null) void AnalyzeResponseUniformity::storeHistos( string strOutputROOTFileName, std::string strOption ){ //Variable Declaration //std::shared_ptr<TFile> ptr_fileOutput; TFile * ptr_fileOutput = new TFile(strOutputROOTFileName.c_str(), strOption.c_str(),"",1); //Assign the TFile to the ptr_fileOutput //ptr_fileOutput = make_shared<TFile>(TFile(strOutputROOTFileName.c_str(), strOption.c_str(),"",1) ); //Check if File Failed to Open Correctly if ( !ptr_fileOutput->IsOpen() || ptr_fileOutput->IsZombie() ) { printClassMethodMsg("AnalyzeResponseUniformity","storeHistos","Error: File I/O"); printROOTFileStatus(ptr_fileOutput); printClassMethodMsg("AnalyzeResponseUniformity","storeHistos", "\tPlease cross check input file name, option, and the execution directory\n" ); printClassMethodMsg("AnalyzeResponseUniformity","storeHistos", "\tExiting; No Histograms have been stored!\n" ); return; } //End Check if File Failed to Open Correctly //Loop over ieta's //Create/Load file structure //Store ieta level histograms //Loop over iphi's within ieta's //Create/Load file structure //Store iphi level histograms //Loop over slices //Create/Load file structure //store slice level histograms //Close File //Loop Over Stored iEta Sectors for (auto iterEta = detMPGD.map_sectorsEta.begin(); iterEta != detMPGD.map_sectorsEta.end(); ++iterEta) { //Loop Over iEta Sectors //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_SectorEta = ptr_fileOutput->GetDirectory( ( "SectorEta" + getString( (*iterEta).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_SectorEta == nullptr) { //Case: Directory did not exist in file, CREATE dir_SectorEta = ptr_fileOutput->mkdir( ( "SectorEta" + getString( (*iterEta).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Debugging cout<<"dir_SectorEta->GetName() = " << dir_SectorEta->GetName()<<endl; //Store Histograms - SectorEta Level //------------------------------------- dir_SectorEta->cd(); (*iterEta).second.hEta_ClustADC->Write(); (*iterEta).second.hEta_ClustPos->Write(); (*iterEta).second.hEta_ClustSize->Write(); (*iterEta).second.hEta_ClustTime->Write(); (*iterEta).second.hEta_ClustADC_v_ClustPos->Write(); //Loop Over Stored iPhi Sectors within this iEta Sector for (auto iterPhi = (*iterEta).second.map_sectorsPhi.begin(); iterPhi != (*iterEta).second.map_sectorsPhi.end(); ++iterPhi) { //Loop Over Stored iPhi Sectors //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_SectorPhi = dir_SectorEta->GetDirectory( ( "SectorPhi" + getString( (*iterPhi).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_SectorPhi == nullptr) { //Case: Directory did not exist in file, CREATE dir_SectorPhi = dir_SectorEta->mkdir( ( "SectorPhi" + getString( (*iterPhi).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Debugging cout<<"dir_SectorPhi->GetName() = " << dir_SectorPhi->GetName()<<endl; //Store Histograms - SectorPhi Level //------------------------------------- dir_SectorPhi->cd(); (*iterPhi).second.hPhi_ClustADC->Write(); (*iterPhi).second.hPhi_ClustSize->Write(); (*iterPhi).second.hPhi_ClustTime->Write(); (*iterPhi).second.hPhi_ClustADC_v_ClustPos->Write(); //Loop through Slices //To be implemented //Slices //Now that all clusters have been analyzed we extract the slices for (auto iterSlice = (*iterPhi).second.map_slices.begin(); iterSlice != (*iterPhi).second.map_slices.end(); ++iterSlice ) { //Loop Over Slices //int iSliceCount = std::distance( (*iterPhi).second.map_slices.begin(), iterSlice ) + 1; //Get Directory //------------------------------------- //Check to see if the directory exists already TDirectory *dir_Slice = dir_SectorPhi->GetDirectory( ( "Slice" + getString( (*iterSlice).first ) ).c_str(), false, "GetDirectory" ); //If the above pointer is null the directory does NOT exist, create it if (dir_Slice == nullptr) { //Case: Directory did not exist in file, CREATE dir_Slice = dir_SectorPhi->mkdir( ( "Slice" + getString( (*iterSlice).first ) ).c_str() ); } //End Case: Directory did not exist in file, CREATE //Store Histograms - Slice Level //------------------------------------- dir_Slice->cd(); (*iterSlice).second.hSlice_ClustADC->Write(); } //End Loop Over Slices } //End Loop Over Stored iPhi Sectors } //End Loop Over Stored iEta Sectors //Close the ROOT file ptr_fileOutput->Close(); return; } //End storeHistos()