Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:53:44

0001 #ifndef IOPool_Input_RunHelper_h
0002 #define IOPool_Input_RunHelper_h
0003 
0004 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/InputSource.h"
0007 
0008 #include <memory>
0009 #include <vector>
0010 
0011 namespace edm {
0012   class IndexIntoFile;
0013   class ParameterSetDescription;
0014 
0015   class RunHelperBase {
0016   public:
0017     explicit RunHelperBase() = default;
0018     virtual ~RunHelperBase();
0019 
0020     virtual InputSource::ItemType nextItemType(InputSource::ItemType const& previousItemType,
0021                                                InputSource::ItemType const& newItemType,
0022                                                RunNumber_t,
0023                                                LuminosityBlockNumber_t,
0024                                                EventNumber_t) {
0025       return newItemType;
0026     }
0027     virtual RunNumber_t runNumberToUseForThisLumi() const { return 0; }
0028     virtual bool fakeNewRun() const { return false; }
0029     virtual void setForcedRunOffset(RunNumber_t firstRun) {}
0030     virtual void checkForNewRun(RunNumber_t run, LuminosityBlockNumber_t nextLumi) {}
0031 
0032     virtual void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const;
0033     virtual void checkLumiConsistency(LuminosityBlockNumber_t lumi, LuminosityBlockNumber_t origninalLumi) const;
0034     virtual void overrideRunNumber(EventID& event, bool isRealData) {}
0035     virtual void overrideRunNumber(RunID& run) {}
0036     virtual void overrideRunNumber(LuminosityBlockID& lumi) {}
0037 
0038     static void fillDescription(ParameterSetDescription& desc);
0039   };
0040 
0041   class DefaultRunHelper : public RunHelperBase {
0042   public:
0043     explicit DefaultRunHelper() = default;
0044     ~DefaultRunHelper() override;
0045   };
0046 
0047   class SetRunHelper : public RunHelperBase {
0048   public:
0049     explicit SetRunHelper(ParameterSet const& pset);
0050     ~SetRunHelper() override;
0051 
0052     void setForcedRunOffset(RunNumber_t firstRun) override;
0053 
0054     void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override;
0055     void overrideRunNumber(EventID& event, bool isRealData) override;
0056     void overrideRunNumber(RunID& run) override;
0057     void overrideRunNumber(LuminosityBlockID& lumi) override;
0058 
0059   private:
0060     RunNumber_t setRun_;
0061     int forcedRunOffset_;
0062     bool firstTime_;
0063   };
0064 
0065   class SetRunForEachLumiHelper : public RunHelperBase {
0066   public:
0067     explicit SetRunForEachLumiHelper(ParameterSet const& pset);
0068     ~SetRunForEachLumiHelper() override;
0069 
0070     InputSource::ItemType nextItemType(InputSource::ItemType const& previousItemType,
0071                                        InputSource::ItemType const& newIemType,
0072                                        RunNumber_t,
0073                                        LuminosityBlockNumber_t,
0074                                        EventNumber_t) override;
0075     RunNumber_t runNumberToUseForThisLumi() const override;
0076     bool fakeNewRun() const override { return fakeNewRun_; }
0077     void checkForNewRun(RunNumber_t run, LuminosityBlockNumber_t nextLumi) override;
0078 
0079     void checkRunConsistency(RunNumber_t run, RunNumber_t origninalRun) const override;
0080     void overrideRunNumber(EventID& event, bool isRealData) override;
0081     void overrideRunNumber(RunID& run) override;
0082     void overrideRunNumber(LuminosityBlockID& lumi) override;
0083 
0084   private:
0085     std::vector<RunNumber_t> setRunNumberForEachLumi_;
0086     size_t indexOfNextRunNumber_;
0087     RunNumber_t realRunNumber_;
0088     bool fakeNewRun_;
0089     bool firstTime_;
0090   };
0091 
0092   class FirstLuminosityBlockForEachRunHelper : public RunHelperBase {
0093   public:
0094     explicit FirstLuminosityBlockForEachRunHelper(ParameterSet const& pset);
0095 
0096     InputSource::ItemType nextItemType(InputSource::ItemType const& previousItemType,
0097                                        InputSource::ItemType const& newIemType,
0098                                        RunNumber_t,
0099                                        LuminosityBlockNumber_t,
0100                                        EventNumber_t) override;
0101     RunNumber_t runNumberToUseForThisLumi() const override;
0102     bool fakeNewRun() const override { return fakeNewRun_; }
0103     void checkForNewRun(RunNumber_t run, LuminosityBlockNumber_t nextLumi) override;
0104 
0105     void checkRunConsistency(RunNumber_t run, RunNumber_t originalRun) const override;
0106     void overrideRunNumber(EventID& event, bool isRealData) override;
0107     void overrideRunNumber(RunID& run) override;
0108     void overrideRunNumber(LuminosityBlockID& lumi) override;
0109 
0110   private:
0111     RunNumber_t findRunFromLumi(LuminosityBlockNumber_t) const;
0112     std::vector<edm::LuminosityBlockID> const lumiToRun_;
0113     RunNumber_t realRunNumber_;
0114     RunNumber_t lastUsedRunNumber_;
0115     bool fakeNewRun_;
0116   };
0117   std::unique_ptr<RunHelperBase> makeRunHelper(ParameterSet const& pset);
0118 }  // namespace edm
0119 
0120 #endif