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