CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/IOPool/Input/src/DuplicateChecker.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_DuplicateChecker_h
00002 #define DataFormats_Provenance_DuplicateChecker_h
00003 
00004 
00005 /*----------------------------------------------------------------------
00006 
00007 IOPool/Input/src/DuplicateChecker.h
00008 
00009 Used by PoolSource to detect events with
00010 the same process history, run, lumi, and event number.
00011 It is configurable whether it checks for duplicates
00012 within the scope of each single input file or all input
00013 files or does not check for duplicates at all.
00014 
00015 ----------------------------------------------------------------------*/
00016 
00017 #include "DataFormats/Provenance/interface/EventID.h"
00018 #include "DataFormats/Provenance/interface/RunID.h"
00019 #include "DataFormats/Provenance/interface/IndexIntoFile.h"
00020 
00021 #include <memory>
00022 #include <set>
00023 #include <string>
00024 #include <vector>
00025 
00026 
00027 namespace edm {
00028 
00029   class ParameterSet;
00030   class ParameterSetDescription;
00031 
00032   class DuplicateChecker {
00033   public:
00034 
00035     DuplicateChecker(ParameterSet const& pset);
00036 
00037     void disable();
00038 
00039     void inputFileOpened(
00040       bool realData,
00041       IndexIntoFile const& indexIntoFile,
00042       std::vector<boost::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
00043       std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile);
00044 
00045     void inputFileClosed();
00046 
00047     bool noDuplicatesInFile() const { return itIsKnownTheFileHasNoDuplicates_; }
00048 
00049     bool checkDisabled() const {
00050       return duplicateCheckMode_ == noDuplicateCheck ||
00051         (duplicateCheckMode_ == checkEachRealDataFile && dataType_ == isSimulation) ||
00052         disabled_;
00053     }
00054 
00055     // Note that all references to the ProcessHistoryID in this class are to
00056     // the "reduced" process history, including the index argument to this function.
00057     bool isDuplicateAndCheckActive(int index,
00058                                    RunNumber_t run,
00059                                    LuminosityBlockNumber_t lumi,
00060                                    EventNumber_t event,
00061                                    std::string const& fileName);
00062 
00063     bool checkingAllFiles() const {return checkAllFilesOpened == duplicateCheckMode_;} 
00064 
00065     static void fillDescription(ParameterSetDescription & desc);
00066 
00067   private:
00068 
00069     enum DuplicateCheckMode { noDuplicateCheck, checkEachFile, checkEachRealDataFile, checkAllFilesOpened };
00070 
00071     DuplicateCheckMode duplicateCheckMode_;
00072 
00073     enum DataType { isRealData, isSimulation, unknown };
00074 
00075     DataType dataType_;
00076 
00077     // If checking the entire input for duplicates, then this holds
00078     // events from previous files that duplicate events in the
00079     // the current file.  Plus it holds events that have been already
00080     // processed in the current file.  It is not used if there are
00081     // no duplicates or duplicate checking has been disabled.
00082     std::set<IndexIntoFile::IndexRunLumiEventKey> relevantPreviousEvents_;
00083 
00084     bool itIsKnownTheFileHasNoDuplicates_;
00085 
00086     bool disabled_;
00087   };
00088 }
00089 #endif