LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
DuplicateChecker.cc
Go to the documentation of this file.
3 #include "cetlib_except/exception.h"
5 
6 #include <cassert>
7 
8 using mf::LogWarning;
9 
10 namespace art {
11 
14  :
15 
16  duplicateCheckMode_(checkEachRealDataFile)
17  , dataType_(unknown)
18  , eventIDs_()
19  , itIsKnownTheFileHasNoDuplicates_(false)
20  {
21  std::string const& duplicateCheckMode = config().duplicateCheckMode();
22 
23  if (duplicateCheckMode == std::string("noDuplicateCheck"))
25  else if (duplicateCheckMode == std::string("checkEachFile"))
27  else if (duplicateCheckMode == std::string("checkEachRealDataFile"))
29  else if (duplicateCheckMode == std::string("checkAllFilesOpened"))
31  else {
32  throw cet::exception("Configuration")
33  << "Illegal configuration parameter value passed to RootInput for\n"
34  << "the \"duplicateCheckMode\" parameter, legal values are:\n"
35  << "\"noDuplicateCheck\", \"checkEachFile\", "
36  "\"checkEachRealDataFile\", \"checkAllFilesOpened\"\n";
37  }
38  }
39 
40  void
41  DuplicateChecker::init(bool realData, FileIndex const& fileIndex)
42  {
44  return;
46  return;
47 
48  assert(dataType_ == unknown);
49  dataType_ = realData ? isRealData : isSimulation;
50 
53  dataType_ == isRealData)) {
55  }
56  }
57 
58  void
60  {
62  return;
64  return;
65 
67  eventIDs_.clear();
69  }
70 
71  void
73  {
74  eventIDs_.clear();
75  }
76 
77  bool
79  std::string const& fileName)
80  {
82  return false;
85  return false;
86 
89  assert(dataType_ != unknown);
91  return false;
92  }
93 
94  bool duplicate = !eventIDs_.insert(eventID).second;
95 
96  if (duplicate) {
98  LogWarning("DuplicateEvent")
99  << "Duplicate Events found in entire set of input files.\n"
100  << "Both events were from " << eventID << ".\n"
101  << "The duplicate was from file " << fileName << ".\n"
102  << "The duplicate will be skipped.\n";
103  } else {
104  LogWarning("DuplicateEvent")
105  << "Duplicate Events found in file " << fileName << ".\n"
106  << "Both events were " << eventID << ".\n"
107  << "The duplicate will be skipped.\n";
108  }
109  return true;
110  }
111  return false;
112  }
113 
114 } // art
void init(bool realData, FileIndex const &fileIndex)
DuplicateCheckMode duplicateCheckMode_
bool isDuplicateAndCheckActive(EventID const &eventID, std::string const &fileName)
ProductStatus unknown()
Definition: ProductStatus.h:31
DuplicateChecker(fhicl::TableFragment< Config > const &config)
bool eventsUniqueAndOrdered() const
Definition: FileIndex.cc:81
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
HLT enums.
std::set< EventID > eventIDs_
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33