00001 #include "art/Framework/Core/OutputFileGranularity.h" 00002 #define BOUNDARY_GRANULARITY Granularity::InputFile 00003 #include "art/Framework/IO/Root/RootOutputClosingCriteria.h" 00004 #include "artdaq/ArtModules/RootDAQOutput/detail/rootOutputConfigurationTools.h" 00005 #include "canvas/Utilities/Exception.h" 00006 #include "messagefacility/MessageLogger/MessageLogger.h" 00007 00008 using namespace art; 00009 00010 namespace { 00016 bool maxCriterionSpecified(ClosingCriteria const& cc) 00017 { 00018 auto fp = std::mem_fn(&ClosingCriteria::fileProperties); 00019 return 00020 fp(cc).nEvents() != Defaults::unsigned_max() || 00021 fp(cc).nSubRuns() != Defaults::unsigned_max() || 00022 fp(cc).nRuns() != Defaults::unsigned_max() || 00023 fp(cc).size() != Defaults::size_max() || 00024 fp(cc).age().count() != Defaults::seconds_max(); 00025 } 00026 } 00027 00028 bool 00029 art::detail::shouldFastClone(bool const fastCloningSet, 00030 bool const fastCloning, 00031 bool const wantAllEvents, 00032 ClosingCriteria const& cc) 00033 { 00034 bool result{ fastCloning }; 00035 mf::LogInfo("FastCloning") << "Initial fast cloning configuration " 00036 << (fastCloningSet ? "(user-set): " : "(from default): ") 00037 << std::boolalpha << fastCloning; 00038 00039 if (fastCloning && !wantAllEvents) 00040 { 00041 result = false; 00042 mf::LogWarning("FastCloning") << "Fast cloning deactivated due to presence of\n" 00043 << "event selection configuration."; 00044 } 00045 if (fastCloning && maxCriterionSpecified(cc) && cc.granularity() < BOUNDARY_GRANULARITY) 00046 { 00047 result = false; 00048 mf::LogWarning("FastCloning") << "Fast cloning deactivated due to request to allow\n" 00049 << "output file switching at an Event, SubRun, or Run boundary."; 00050 } 00051 return result; 00052 } 00053 00054 bool 00055 art::detail::shouldDropEvents(bool const dropAllEventsSet, 00056 bool const dropAllEvents, 00057 bool const dropAllSubRuns) 00058 { 00059 if (!dropAllSubRuns) 00060 return dropAllEvents; 00061 00062 if (dropAllEventsSet && !dropAllEvents) 00063 { 00064 throw art::Exception(errors::Configuration) 00065 << "\nThe following FHiCL specification is illegal\n\n" 00066 << " dropAllEvents : false \n" 00067 << " dropAllSubRuns : true \n\n" 00068 << "[1] Both can be 'true', " 00069 << "[2] both can be 'false', or " 00070 << "[3] 'dropAllEvents : true' and 'dropAllSubRuns : false' " 00071 << "is allowed.\n\n"; 00072 } 00073 return true; 00074 } 00075 00076 void 00077 art::detail::validateFileNamePattern(bool const do_check, std::string const& pattern) 00078 { 00079 if (!do_check) return; 00080 00081 if (pattern.find("%#") == std::string::npos) 00082 throw Exception(errors::Configuration) 00083 << "If you have specified the 'fileProperties' table in a RootOutput module configuration,\n" 00084 << "then the file pattern '%#' MUST be present in the file name. For example:\n" 00085 << " " << pattern.substr(0, pattern.find(".root")) << "_%#.root\n" 00086 << "is a supported file name. Please change your file name to include the '%#' pattern."; 00087 }