CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 "boost/shared_ptr.hpp"
00022 
00023 #include <vector>
00024 #include <set>
00025 #include <string>
00026 
00027 
00028 namespace edm {
00029 
00030   class ParameterSet;
00031   class ParameterSetDescription;
00032 
00033   class DuplicateChecker {
00034   public:
00035 
00036     DuplicateChecker(ParameterSet const& pset);
00037 
00038     void disable();
00039 
00040     void inputFileOpened(
00041       bool realData,
00042       IndexIntoFile const& indexIntoFile,
00043       std::vector<boost::shared_ptr<IndexIntoFile> > const& indexesIntoFiles,
00044       std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile);
00045 
00046     void inputFileClosed();
00047 
00048     bool noDuplicatesInFile() const { return itIsKnownTheFileHasNoDuplicates_; }
00049 
00050     bool checkDisabled() const {
00051       return duplicateCheckMode_ == noDuplicateCheck ||
00052         (duplicateCheckMode_ == checkEachRealDataFile && dataType_ == isSimulation) ||
00053         disabled_;
00054     }
00055 
00056     bool isDuplicateAndCheckActive(int index,
00057                                    RunNumber_t run,
00058                                    LuminosityBlockNumber_t lumi,
00059                                    EventNumber_t event,
00060                                    std::string const& fileName);
00061 
00062     bool checkingAllFiles() const {return checkAllFilesOpened == duplicateCheckMode_;} 
00063 
00064     static void fillDescription(ParameterSetDescription & desc);
00065 
00066   private:
00067 
00068     enum DuplicateCheckMode { noDuplicateCheck, checkEachFile, checkEachRealDataFile, checkAllFilesOpened };
00069 
00070     DuplicateCheckMode duplicateCheckMode_;
00071 
00072     enum DataType { isRealData, isSimulation, unknown };
00073 
00074     DataType dataType_;
00075 
00076     // If checking the entire input for duplicates, then this holds
00077     // events from previous files that duplicate events in the
00078     // the current file.  Plus it holds events that have been already
00079     // processed in the current file.  It is not used if there are
00080     // no duplicates or duplicate checking has been disabled.
00081     std::set<IndexIntoFile::IndexRunLumiEventKey> relevantPreviousEvents_;
00082 
00083     bool itIsKnownTheFileHasNoDuplicates_;
00084 
00085     bool disabled_;
00086   };
00087 }
00088 #endif