Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:05

0001 #ifndef DataFormats_Provenance_DuplicateChecker_h
0002 #define DataFormats_Provenance_DuplicateChecker_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 IOPool/Input/src/DuplicateChecker.h
0007 
0008 Used by PoolSource to detect events with
0009 the same process history, run, lumi, and event number.
0010 It is configurable whether it checks for duplicates
0011 within the scope of each single input file or all input
0012 files or does not check for duplicates at all.
0013 
0014 ----------------------------------------------------------------------*/
0015 
0016 #include "DataFormats/Provenance/interface/EventID.h"
0017 #include "DataFormats/Provenance/interface/RunID.h"
0018 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
0019 
0020 #include <memory>
0021 #include <set>
0022 #include <string>
0023 #include <vector>
0024 
0025 namespace edm {
0026 
0027   class ParameterSet;
0028   class ParameterSetDescription;
0029 
0030   class DuplicateChecker {
0031   public:
0032     DuplicateChecker(ParameterSet const& pset);
0033 
0034     void disable();
0035 
0036     void inputFileOpened(bool realData,
0037                          IndexIntoFile const& indexIntoFile,
0038                          std::vector<std::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
0039                          std::vector<std::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile);
0040 
0041     void inputFileClosed();
0042 
0043     bool noDuplicatesInFile() const { return itIsKnownTheFileHasNoDuplicates_; }
0044 
0045     bool checkDisabled() const {
0046       return duplicateCheckMode_ == noDuplicateCheck ||
0047              (duplicateCheckMode_ == checkEachRealDataFile && dataType_ == isSimulation) || disabled_;
0048     }
0049 
0050     // Note that all references to the ProcessHistoryID in this class are to
0051     // the "reduced" process history, including the index argument to this function.
0052     bool isDuplicateAndCheckActive(
0053         int index, RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, std::string const& fileName);
0054 
0055     bool checkingAllFiles() const { return checkAllFilesOpened == duplicateCheckMode_; }
0056 
0057     static void fillDescription(ParameterSetDescription& desc);
0058 
0059   private:
0060     enum DuplicateCheckMode { noDuplicateCheck, checkEachFile, checkEachRealDataFile, checkAllFilesOpened };
0061 
0062     DuplicateCheckMode duplicateCheckMode_;
0063 
0064     enum DataType { isRealData, isSimulation, unknown };
0065 
0066     DataType dataType_;
0067 
0068     // If checking the entire input for duplicates, then this holds
0069     // events from previous files that duplicate events in the
0070     // the current file.  Plus it holds events that have been already
0071     // processed in the current file.  It is not used if there are
0072     // no duplicates or duplicate checking has been disabled.
0073     std::set<IndexIntoFile::IndexRunLumiEventKey> relevantPreviousEvents_;
0074 
0075     bool itIsKnownTheFileHasNoDuplicates_;
0076 
0077     bool disabled_;
0078   };
0079 }  // namespace edm
0080 #endif