Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:45:00

0001 // -*- C++ -*-
0002 #ifndef Fireworks_Core_CmsShowNavigator_h
0003 #define Fireworks_Core_CmsShowNavigator_h
0004 //
0005 // Package:     newVersion
0006 // Class  :     CmsShowNavigator
0007 //
0008 
0009 // system include files
0010 #include <string>
0011 #include <sigc++/sigc++.h>
0012 
0013 // user include files
0014 #include "Fireworks/Core/interface/FWNavigatorBase.h"
0015 #include "Fireworks/Core/interface/FWEventSelector.h"
0016 #include "Fireworks/Core/interface/FWConfigurable.h"
0017 #include "Fireworks/Core/interface/FWFileEntry.h"
0018 
0019 #include "DataFormats/FWLite/interface/Event.h"
0020 
0021 #include "TEventList.h"
0022 
0023 // forward declarations
0024 class TEventList;
0025 class CSGAction;
0026 class CmsShowMain;
0027 class TFile;
0028 class TGWindow;
0029 class FWGUIEventFilter;
0030 
0031 namespace edm {
0032   class EventBase;
0033   class EventID;
0034 }  // namespace edm
0035 
0036 class CmsShowNavigator : public FWNavigatorBase {
0037 public:
0038   enum EFilterState { kOff, kOn, kWithdrawn };
0039   enum EFilterMode { kOr = 1, kAnd = 2 };
0040 
0041 private:
0042   typedef std::list<FWFileEntry*> FQBase_t;
0043   typedef FQBase_t::iterator FQBase_i;
0044 
0045   struct FileQueue_t : public FQBase_t {
0046     struct iterator : public FQBase_i {
0047     private:
0048       bool m_isSet;
0049 
0050     public:
0051       iterator() : m_isSet(false) {}
0052       iterator(FQBase_i i) : FQBase_i(i), m_isSet(true) {}
0053 
0054       bool isSet() const { return m_isSet; }
0055 
0056       iterator& previous(FileQueue_t& cont) {
0057         // Go back one element, set to end() when falling off the end.
0058         if (*this == cont.begin())
0059           *this = cont.end();
0060         else
0061           FQBase_i::operator--();
0062         return *this;
0063       }
0064     };
0065 
0066     FileQueue_t() : FQBase_t() {}
0067 
0068     iterator begin() { return iterator(FQBase_t::begin()); }
0069     iterator end() { return iterator(FQBase_t::end()); }
0070   };
0071 
0072   typedef FileQueue_t::iterator FileQueue_i;
0073 
0074 public:
0075   CmsShowNavigator(const CmsShowMain&);
0076   ~CmsShowNavigator() override;
0077 
0078   //configuration management interface
0079   void addTo(FWConfiguration&) const override;
0080   void setFrom(const FWConfiguration&) override;
0081 
0082   Int_t realEntry(Int_t rawEntry);
0083   bool openFile(const std::string& fileName);
0084   bool appendFile(const std::string& fileName, bool checkFileQueueSize, bool live);
0085 
0086   void nextEvent() override;
0087   void previousEvent() override;
0088   bool nextSelectedEvent() override;
0089   bool previousSelectedEvent() override;
0090   void firstEvent() override;
0091   void lastEvent() override;
0092   void goToRunEvent(edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t) override;
0093   void goTo(FileQueue_i fi, int event);
0094 
0095   void eventFilterEnableCallback(Bool_t);
0096   void filterEvents();
0097   void filterEventsAndReset();
0098 
0099   void setMaxNumberOfFilesToChain(unsigned int i) { m_maxNumberOfFilesToChain = i; }
0100 
0101   bool isLastEvent() override;
0102   bool isFirstEvent() override;
0103 
0104   void showEventFilterGUI(const TGWindow* p);
0105   void applyFiltersFromGUI();
0106   void toggleFilterEnable();
0107   void withdrawFilter();
0108   void resumeFilter();
0109 
0110   const edm::EventBase* getCurrentEvent() const override;
0111 
0112   const char* frameTitle();
0113   const char* filterStatusMessage();
0114   std::string getCurrentGlobalTag();
0115 
0116   int getNSelectedEvents() override;
0117   int getNTotalEvents() override;
0118   bool canEditFiltersExternally();
0119   bool filesNeedUpdate() const { return m_filesNeedUpdate; }
0120   int getFilterState() { return m_filterState; }
0121 
0122   void editFiltersExternally();
0123 
0124   void activateNewFileOnNextEvent() { m_newFileOnNextEvent = true; }
0125   void resetNewFileOnNextEvent() { m_newFileOnNextEvent = false; }
0126 
0127   std::vector<std::string>& getProcessList() const;
0128 
0129   sigc::signal<void(const TFile*)> fileChanged_;
0130   sigc::signal<void()> preFiltering_;
0131   sigc::signal<void(bool)> postFiltering_;
0132   sigc::signal<void(bool)> editFiltersExternally_;
0133   sigc::signal<void(int)> filterStateChanged_;
0134 
0135 private:
0136   CmsShowNavigator(const CmsShowNavigator&);                   // stop default
0137   const CmsShowNavigator& operator=(const CmsShowNavigator&);  // stop default
0138 
0139   void setCurrentFile(FileQueue_i);
0140   void updateFileFilters();
0141   void updateSelectorsInfo();
0142 
0143   void removeFilter(std::list<FWEventSelector*>::iterator);
0144   void addFilter(FWEventSelector*);
0145   void changeFilter(FWEventSelector*, bool filterNeedUpdate);
0146 
0147   void newFile(FileQueue_i);
0148 
0149   // ---------- member data --------------------------------
0150 
0151   std::list<FWEventSelector*> m_selectors;
0152   FileQueue_t m_files;
0153   FileQueue_i m_currentFile;
0154   int m_currentEvent;
0155 
0156   EFilterState m_filterState;
0157   int m_filterMode;
0158   bool m_filesNeedUpdate;
0159   bool m_newFileOnNextEvent;
0160 
0161   unsigned int m_maxNumberOfFilesToChain;
0162   // entry is an event index nubmer which runs from 0 to
0163   // #events or #selected_events depending on if we filter
0164   // events or not
0165   const CmsShowMain& m_main;
0166   FWGUIEventFilter* m_guiFilter;
0167 };
0168 
0169 #endif