@@ -121,18 +121,20 @@ void utils::addFECInfo()
121121
122122void utils::saveCanvases (TObjArray& arr, std::string_view outDir, std::string_view types, std::string_view rootFileName)
123123{
124- for (auto c : arr) {
125- utils::saveCanvas (*static_cast <TCanvas*>(c), outDir, types);
124+ if (types.size ()) {
125+ for (auto c : arr) {
126+ utils::saveCanvas (*static_cast <TCanvas*>(c), outDir, types);
127+ }
126128 }
127129
128130 if (rootFileName.size ()) {
129- std::unique_ptr<TFile> outFile (TFile::Open (fmt::format (" {}/NoiseAndPedestalCanvases.root " , outDir).data (), " recreate" ));
131+ std::unique_ptr<TFile> outFile (TFile::Open (fmt::format (" {}/{} " , outDir, rootFileName ).data (), " recreate" ));
130132 arr.Write (arr.GetName (), TObject::kSingleKey );
131133 outFile->Close ();
132134 }
133135}
134136
135- void utils::saveCanvases (std::vector<TCanvas*> canvases, std::string_view outDir, std::string_view types, std::string_view rootFileName)
137+ void utils::saveCanvases (std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types, std::string_view rootFileName)
136138{
137139 TObjArray arr;
138140 for (auto c : canvases) {
@@ -144,6 +146,9 @@ void utils::saveCanvases(std::vector<TCanvas*> canvases, std::string_view outDir
144146
145147void utils::saveCanvas (TCanvas& c, std::string_view outDir, std::string_view types)
146148{
149+ if (!types.size ()) {
150+ return ;
151+ }
147152 const auto typesVec = tokenize (types, " ," );
148153 for (const auto & type : typesVec) {
149154 c.SaveAs (fmt::format (" {}/{}.{}" , outDir, c.GetName (), type).data ());
0 commit comments