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/detail/rootOutputConfigurationTools.h" 00010 #include "canvas/Utilities/Exception.h" 00011 #include "messagefacility/MessageLogger/MessageLogger.h" 00012 00013 using namespace art; 00014 00015 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 result = false; 00041 mf::LogWarning("FastCloning") << "Fast cloning deactivated due to presence of\n" 00042 << "event selection configuration."; 00043 } 00044 if (fastCloning && maxCriterionSpecified(cc) && cc.granularity() < BOUNDARY_GRANULARITY) { 00045 result = false; 00046 mf::LogWarning("FastCloning") << "Fast cloning deactivated due to request to allow\n" 00047 << "output file switching at an Event, SubRun, or Run boundary."; 00048 } 00049 return result; 00050 } 00051 00052 bool 00053 art::detail::shouldDropEvents(bool const dropAllEventsSet, 00054 bool const dropAllEvents, 00055 bool const dropAllSubRuns) 00056 { 00057 if (!dropAllSubRuns) 00058 return dropAllEvents; 00059 00060 if (dropAllEventsSet && !dropAllEvents) { 00061 throw art::Exception(errors::Configuration) 00062 << "\nThe following FHiCL specification is illegal\n\n" 00063 << " dropAllEvents : false \n" 00064 << " dropAllSubRuns : true \n\n" 00065 << "[1] Both can be 'true', " 00066 << "[2] both can be 'false', or " 00067 << "[3] 'dropAllEvents : true' and 'dropAllSubRuns : false' " 00068 << "is allowed.\n\n"; 00069 } 00070 return true; 00071 } 00072 00073 void 00074 art::detail::validateFileNamePattern(bool const do_check, std::string const& pattern) 00075 { 00076 if (!do_check) return; 00077 00078 if (pattern.find("%#") == std::string::npos) 00079 throw Exception(errors::Configuration) 00080 << "If you have specified the 'fileProperties' table in a RootOutput module configuration,\n" 00081 << "then the file pattern '%#' MUST be present in the file name. For example:\n" 00082 << " " << pattern.substr(0,pattern.find(".root")) << "_%#.root\n" 00083 << "is a supported file name. Please change your file name to include the '%#' pattern."; 00084 }