CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes

CmsShowNavigator Class Reference

#include <CmsShowNavigator.h>

Inheritance diagram for CmsShowNavigator:
FWNavigatorBase FWConfigurable

List of all members.

Classes

struct  FileQueue_t

Public Types

enum  EFilterMode { kOr = 1, kAnd = 2 }
enum  EFilterState { kOff, kOn, kWithdrawn }

Public Member Functions

void activateNewFileOnNextEvent ()
virtual void addTo (FWConfiguration &) const
bool appendFile (const std::string &fileName, bool checkFileQueueSize, bool live)
void applyFiltersFromGUI ()
bool canEditFiltersExternally ()
 CmsShowNavigator (const CmsShowMain &)
void editFiltersExternally ()
void eventFilterEnableCallback (Bool_t)
bool filesNeedUpdate () const
void filterEvents ()
void filterEventsAndReset ()
const char * filterStatusMessage ()
virtual void firstEvent ()
const char * frameTitle ()
virtual const edm::EventBasegetCurrentEvent () const
int getFilterState ()
int getNSelectedEvents ()
int getNTotalEvents ()
std::vector< std::string > & getProcessList () const
void goTo (FileQueue_i fi, int event)
virtual void goToRunEvent (edm::RunNumber_t, edm::LuminosityBlockNumber_t, edm::EventNumber_t)
virtual bool isFirstEvent ()
virtual bool isLastEvent ()
virtual void lastEvent ()
virtual void nextEvent ()
virtual bool nextSelectedEvent ()
bool openFile (const std::string &fileName)
virtual void previousEvent ()
virtual bool previousSelectedEvent ()
Int_t realEntry (Int_t rawEntry)
void resetNewFileOnNextEvent ()
void resumeFilter ()
virtual void setFrom (const FWConfiguration &)
void setMaxNumberOfFilesToChain (unsigned int i)
void showEventFilterGUI (const TGWindow *p)
void toggleFilterEnable ()
void withdrawFilter ()
virtual ~CmsShowNavigator ()

Public Attributes

sigc::signal< void, bool > editFiltersExternally_
sigc::signal< void, const TFile * > fileChanged_
sigc::signal< void, int > filterStateChanged_
sigc::signal< void > postFiltering_
sigc::signal< void > preFiltering_

Private Types

typedef FileQueue_t::iterator FileQueue_i
typedef FQBase_t::iterator FQBase_i
typedef std::list< FWFileEntry * > FQBase_t

Private Member Functions

void addFilter (FWEventSelector *)
void changeFilter (FWEventSelector *, bool filterNeedUpdate)
 CmsShowNavigator (const CmsShowNavigator &)
void newFile (FileQueue_i)
const CmsShowNavigatoroperator= (const CmsShowNavigator &)
void removeFilter (std::list< FWEventSelector * >::iterator)
void setCurrentFile (FileQueue_i)
void updateFileFilters ()
void updateSelectorsInfo ()

Private Attributes

int m_currentEvent
FileQueue_i m_currentFile
FileQueue_t m_files
bool m_filesNeedUpdate
int m_filterMode
EFilterState m_filterState
FWGUIEventFilterm_guiFilter
const CmsShowMainm_main
unsigned int m_maxNumberOfFilesToChain
bool m_newFileOnNextEvent
std::list< FWEventSelector * > m_selectors

Detailed Description

Definition at line 37 of file CmsShowNavigator.h.


Member Typedef Documentation

Definition at line 78 of file CmsShowNavigator.h.

typedef FQBase_t::iterator CmsShowNavigator::FQBase_i [private]

Definition at line 45 of file CmsShowNavigator.h.

typedef std::list<FWFileEntry*> CmsShowNavigator::FQBase_t [private]

Definition at line 44 of file CmsShowNavigator.h.


Member Enumeration Documentation

Enumerator:
kOr 
kAnd 

Reimplemented from FWNavigatorBase.

Definition at line 41 of file CmsShowNavigator.h.

{ kOr = 1, kAnd = 2 };
Enumerator:
kOff 
kOn 
kWithdrawn 

Reimplemented from FWNavigatorBase.

Definition at line 40 of file CmsShowNavigator.h.


Constructor & Destructor Documentation

CmsShowNavigator::CmsShowNavigator ( const CmsShowMain main)
CmsShowNavigator::~CmsShowNavigator ( ) [virtual]

Definition at line 63 of file CmsShowNavigator.cc.

References m_guiFilter.

{
   delete m_guiFilter;
}
CmsShowNavigator::CmsShowNavigator ( const CmsShowNavigator ) [private]

Member Function Documentation

void CmsShowNavigator::activateNewFileOnNextEvent ( ) [inline]

Definition at line 130 of file CmsShowNavigator.h.

References m_newFileOnNextEvent.

void CmsShowNavigator::addFilter ( FWEventSelector ref) [private]

Definition at line 527 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, fwLog, fwlog::kDebug, FWEventSelector::m_expression, m_files, m_filesNeedUpdate, and m_selectors.

Referenced by applyFiltersFromGUI().

{
   fwLog(fwlog::kDebug) << "CmsShowNavigator::addFilter " << ref->m_expression << std::endl;

   FWEventSelector* selector = new FWEventSelector(ref);
   m_selectors.push_back(selector);

   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      (*file)->filters ().push_back(new FWFileEntry::Filter(selector));
   }
   m_filesNeedUpdate = true;
}
void CmsShowNavigator::addTo ( FWConfiguration iTo) const [virtual]

Implements FWNavigatorBase.

Definition at line 915 of file CmsShowNavigator.cc.

References FWConfiguration::addKeyValue(), align_tpl::filter, kOn, m_filterMode, m_filterState, m_selectors, alignCSCRings::s, EgammaValidation_Wenu_cff::sel, and tmp.

{
   // selectors
   FWConfiguration tmp;
   int cnt = 0;
   for (std::list<FWEventSelector*>::const_iterator sel = m_selectors.begin(); sel != m_selectors.end(); ++sel) 
   {
      FWConfiguration filter;

      filter.addKeyValue("expression",FWConfiguration((*sel)->m_expression));
      filter.addKeyValue("enabled", FWConfiguration((*sel)->m_enabled ? "1" : "0"));
      filter.addKeyValue("comment", FWConfiguration((*sel)->m_description));
  
      if (!(*sel)->m_triggerProcess.empty())
         filter.addKeyValue("triggerProcess",FWConfiguration((*sel)->m_triggerProcess));

      tmp.addKeyValue(Form("------Filter[%d]------", cnt), filter,true);
      ++cnt;
   }

   iTo.addKeyValue("EventFilters", tmp,true);

   // mode
   {
      std::stringstream s;
      s<< m_filterMode;
      iTo.addKeyValue("EventFilter_mode", s.str());
   }

   // enabled
   iTo.addKeyValue("EventFilter_enabled",FWConfiguration( m_filterState == kOn ? "1" : "0"));
}
bool CmsShowNavigator::appendFile ( const std::string &  fileName,
bool  checkFileQueueSize,
bool  live 
)

Definition at line 120 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), dtNoiseDBValidation_cfg::cerr, FWFileEntry::closeFile(), exception, mergeVDriftHistosByStation::file, FWFileEntry::filters(), fwLog, CmsShowMain::getVersionCheck(), i, CmsShowNavigator::FileQueue_t::iterator::isSet(), fwlog::kDebug, fwlog::kError, kOff, fwlog::kWarning, m_currentFile, m_files, m_filterState, m_main, m_maxNumberOfFilesToChain, m_selectors, newFile(), setCurrentFile(), and updateFileFilters().

{
   fwLog(fwlog::kDebug) << "CmsShowNavigator::appendFile [" << fileName << "]" << std::endl;
   FWFileEntry* newFile  = 0;
   try
   {
      newFile = new FWFileEntry(fileName, m_main.getVersionCheck());
   }
   catch(std::exception& iException)
   {
      fwLog(fwlog::kError) <<"Navigator::appendFile caught exception FWFileEntry constructor "<<iException.what()<<std::endl;
      delete newFile;
      return false;
   }

   try
   {  
      if (checkFileQueueSize)
      {
         int toErase = m_files.size() - (m_maxNumberOfFilesToChain + 1);
         while (toErase > 0)
         {
            FileQueue_i si = m_files.begin();
            if (m_currentFile == si)
               si++;
            FWFileEntry* file = *si;
            file->closeFile();
            delete file;
            
            m_files.erase(si);
            --toErase;
         }

         if (m_files.size() > m_maxNumberOfFilesToChain)
            fwLog(fwlog::kWarning) << "  " <<  m_files.size() << " chained files more than maxNumberOfFilesToChain \n" <<  m_maxNumberOfFilesToChain << std::endl;
      }

      m_files.push_back(newFile);

      // Needed for proper handling of first registered file when -port option is in effect.
      if (!m_currentFile.isSet())
         setCurrentFile(m_files.begin());

      // set filters
      for (std::list<FWEventSelector*>::iterator i = m_selectors.begin(); i != m_selectors.end(); ++i)
         newFile->filters().push_back(new FWFileEntry::Filter(*i));

      if (m_filterState != kOff)     
         updateFileFilters();

   }   
   catch(std::exception& iException)
   {
      std::cerr <<"Navigator::openFile caught exception "<<iException.what()<<std::endl;
      return false;
   }

   return true;
}
void CmsShowNavigator::applyFiltersFromGUI ( )

Definition at line 563 of file CmsShowNavigator.cc.

References addFilter(), changeFilter(), filterStateChanged_, g, FWGUIEventFilter::getFilterMode(), FWGUIEventFilter::guiSelectors(), kOff, kOn, FWEventSelector::m_description, FWEventSelector::m_enabled, FWEventSelector::m_expression, m_filesNeedUpdate, m_filterMode, m_filterState, m_guiFilter, m_selectors, python::connectstrParser::o, removeFilter(), FWGUIEventFilter::setupDisableFilteringButton(), and updateFileFilters().

Referenced by FWGUIEventFilter::apply().

{
   m_filesNeedUpdate = false;

   // check if filters are set ON
   if (m_filterState == kOff)
   {
      m_filesNeedUpdate = true;
      m_filterState = kOn;
      m_guiFilter->setupDisableFilteringButton(true);
   }

   // compare changes and then call updateFileFilters
   std::list<FWEventSelector*>::iterator    si = m_selectors.begin();
   std::list<FWGUIEventSelector*>::iterator gi = m_guiFilter->guiSelectors().begin();

   if (m_filterMode != m_guiFilter->getFilterMode()) {
      m_filterMode = m_guiFilter->getFilterMode();
      m_filesNeedUpdate = true;
   }

   while (si != m_selectors.end() || gi != m_guiFilter->guiSelectors().end())
   {
      if (gi == m_guiFilter->guiSelectors().end() && si != m_selectors.end())
      {
         removeFilter(si++);
      }
      else if (si == m_selectors.end() && gi != m_guiFilter->guiSelectors().end() )
      {
         addFilter((*gi)->guiSelector());
         (*gi)->setOrigSelector(m_selectors.back());
         ++gi;
      }
      else
      {
         if (*si == (*gi)->origSelector())
         {
            FWEventSelector* g  = (*gi)->guiSelector();
            FWEventSelector* o = *si;
            bool filterNeedUpdate = o->m_expression != g->m_expression;
            if (filterNeedUpdate || o->m_enabled != g->m_enabled) {
               *o = *g;
               changeFilter(*si, filterNeedUpdate);
            }
            else
            {
               o->m_description = g->m_description;
            }
            ++si; ++gi;
         }
         else if ((*gi)->origSelector() == 0)
         {
            addFilter((*gi)->guiSelector());
            (*gi)->setOrigSelector(m_selectors.back());
            ++gi;
         }
         else
         {
            removeFilter(si++);
         }
      }
   }

   if ( m_filesNeedUpdate )
      updateFileFilters();

   filterStateChanged_.emit(m_filterState);

}
bool CmsShowNavigator::canEditFiltersExternally ( )

Definition at line 766 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, FWGUIEventFilter::isOpen(), m_files, and m_guiFilter.

Referenced by editFiltersExternally(), and showEventFilterGUI().

{
   bool haveActiveFilters = false;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      if ((*file)->hasActiveFilters())
      {
         haveActiveFilters = true;
         break;
      }
   }

   bool btnEnabled = haveActiveFilters;

   if (m_guiFilter && m_guiFilter->isOpen())
      btnEnabled = false;

   return btnEnabled;
}
void CmsShowNavigator::changeFilter ( FWEventSelector selector,
bool  filterNeedUpdate 
) [private]

Definition at line 542 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, fwLog, fwlog::kDebug, FWEventSelector::m_expression, m_files, and m_filesNeedUpdate.

Referenced by applyFiltersFromGUI().

{
   fwLog(fwlog::kDebug) << "CmsShowNavigator::changeFilter " << selector->m_expression << std::endl;

   std::list<FWFileEntry::Filter*>::iterator it;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      for (it = (*file)->filters().begin(); it != (*file)->filters().end(); ++it)
      {
         if ((*it)->m_selector == selector)
         {
            if (updateFilter)  (*it)->m_needsUpdate = true;
            (*it)->m_selector->m_expression  = selector->m_expression;
            break;
         }
      }
   }
   m_filesNeedUpdate = true;
}
void CmsShowNavigator::editFiltersExternally ( )
void CmsShowNavigator::eventFilterEnableCallback ( Bool_t  )
bool CmsShowNavigator::filesNeedUpdate ( ) const [inline]

Definition at line 125 of file CmsShowNavigator.h.

References m_filesNeedUpdate.

{ return m_filesNeedUpdate; }
void CmsShowNavigator::filterEvents ( )
void CmsShowNavigator::filterEventsAndReset ( )
const char * CmsShowNavigator::filterStatusMessage ( )

Definition at line 755 of file CmsShowNavigator.cc.

References getNSelectedEvents(), getNTotalEvents(), kOff, kOn, and m_filterState.

{
   if (m_filterState == kOn)
      return Form("%d events are selected from %d.", getNSelectedEvents(), getNTotalEvents());
   else if (m_filterState == kOff)
      return "Filtering is OFF.";
   else
      return "Filtering is disabled.";
}
void CmsShowNavigator::firstEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 254 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), goTo(), kOn, m_files, m_filterState, and x.

{
   FileQueue_i x = m_files.begin();
   if (m_filterState == kOn)
   {
      while (x != m_files.end())
      {
         if ((*x)->hasSelectedEvents())
         {
            goTo(x, (*x)->firstSelectedEvent());
            return;
         }
         ++x;
      }
   }
   else
   {
      goTo(x, 0);
   }
}
const char * CmsShowNavigator::frameTitle ( )

Definition at line 961 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), i, prof2calltree::l, m_currentEvent, m_currentFile, m_files, and mergeVDriftHistosByStation::name.

{
   if (m_files.empty()) return "";

   int nf = 0;
   for (FileQueue_t::const_iterator i = m_files.begin(); i!= m_files.end(); i++)
   {

      if ( i == m_currentFile) break;
      nf++;
   }

   TString name = (*m_currentFile)->file()->GetName();
   int l = name.Last('/');
   if (l != kNPOS)
      name.Remove(0, l+1);

   return Form("%s [%d/%d], event [%d/%d]", name.Data(),
               nf+1,  (int) m_files.size(),
               m_currentEvent+1, (*m_currentFile)->lastEvent()+1);
}
const edm::EventBase * CmsShowNavigator::getCurrentEvent ( ) const [virtual]

Implements FWNavigatorBase.

Definition at line 955 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::iterator::isSet(), and m_currentFile.

{
   return m_currentFile.isSet() ? (*m_currentFile)->event() : 0; 
}
int CmsShowNavigator::getFilterState ( ) [inline]

Definition at line 126 of file CmsShowNavigator.h.

References m_filterState.

{ return m_filterState; }
int CmsShowNavigator::getNSelectedEvents ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 731 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, and m_files.

Referenced by filterStatusMessage(), updateFileFilters(), and FWGUIEventFilter::updateFilterStateLabel().

{
   int sum = 0;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      if ((*file)->globalSelection())
         sum += (*file)->globalSelection()->GetN();
   }
   return sum;
}
int CmsShowNavigator::getNTotalEvents ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 743 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, and m_files.

Referenced by filterStatusMessage(), updateFileFilters(), and FWGUIEventFilter::updateFilterStateLabel().

{
   int sum = 0;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      sum += (*file)->tree()->GetEntries();
   }

   return sum;
}
std::vector< std::string > & CmsShowNavigator::getProcessList ( ) const
void CmsShowNavigator::goTo ( FileQueue_i  fi,
int  event 
)

Definition at line 201 of file CmsShowNavigator.cc.

References event(), fwLog, fwlog::kDebug, m_currentEvent, m_currentFile, FWNavigatorBase::newEvent_, fwlog::presentLogLevel(), setCurrentFile(), cond::rpcobgas::time, and pileupDistInMC::total.

Referenced by firstEvent(), goToRunEvent(), lastEvent(), nextEvent(), nextSelectedEvent(), previousEvent(), and previousSelectedEvent().

{
   if (fi != m_currentFile)
      setCurrentFile(fi);

   if (fwlog::presentLogLevel() == fwlog::kDebug)
   {
      int total = (*fi)->tree()->GetEntries();
      fwLog(fwlog::kDebug) << "CmsShowNavigator::goTo  current file event [" << event  << "/" << total -1<< "]"  << std::endl;

      CpuInfo_t  cpuInfo;
      MemInfo_t  memInfo;
      ProcInfo_t procInfo;
      gSystem->GetCpuInfo(&cpuInfo, 0);
      gSystem->GetMemInfo(&memInfo);
      gSystem->GetProcInfo(&procInfo);

      time_t curtime;
      time(&curtime);
      
      fwLog(fwlog::kDebug) << "Current Time: "  << ctime(&curtime);
      fwLog(fwlog::kDebug) << "memInfo.fMemUsed \t"  << memInfo.fMemUsed << std::endl;
      fwLog(fwlog::kDebug) << "memInfo.fSwapUsed\t" << memInfo.fSwapUsed << std::endl; 
      fwLog(fwlog::kDebug) << "procInfo.fMemResident\t" << procInfo.fMemResident << std::endl;
      fwLog(fwlog::kDebug) << "procInfo.fMemVirtual\t" << procInfo.fMemVirtual << std::endl;
      fwLog(fwlog::kDebug) << "cpuInfo.fLoad1m \t" << cpuInfo.fLoad1m << std::endl;
      fwLog(fwlog::kDebug) << "cpuInfo.fLoad5m \t" << cpuInfo.fLoad5m << std::endl;
   }
   
   (*m_currentFile)->event()->to(event);
   (*m_currentFile)->tree()->LoadTree(event);
   m_currentEvent = event;

   newEvent_.emit();
}
void CmsShowNavigator::goToRunEvent ( edm::RunNumber_t  run,
edm::LuminosityBlockNumber_t  lumi,
edm::EventNumber_t  event 
) [virtual]

Implements FWNavigatorBase.

Definition at line 238 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, goTo(), getHLTprescales::index, and m_files.

{
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      Long64_t index = (*file)->event()->indexFromEventId(run, lumi, event);
      if (index >= 0)
      {
         goTo(file, index);
         break;
      }
   }
}
bool CmsShowNavigator::isFirstEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 636 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, kOn, m_currentEvent, m_currentFile, m_files, and m_filterState.

{
   if (m_filterState == kOn)
   {
      FileQueue_i firstSelectedFile;
      for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
      {
         if ((*file)->hasSelectedEvents())
         {
            firstSelectedFile = file;
            break;
         }
      }

      if (firstSelectedFile == m_currentFile)
         return (*m_currentFile)->firstSelectedEvent() == m_currentEvent;
   }
   else
   {
      if (m_currentFile == m_files.begin())
      {
         return m_currentEvent == 0;
      }
   }
   return false;
}
bool CmsShowNavigator::isLastEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 664 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, kOn, m_currentEvent, m_currentFile, m_files, and m_filterState.

{
   if (m_filterState == kOn)
   {
      FileQueue_i lastSelectedFile;
      for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
      {
         if ((*file)->hasSelectedEvents())
            lastSelectedFile = file;
      }
      if (lastSelectedFile == m_currentFile)
         return (*m_currentFile)->lastSelectedEvent() == m_currentEvent;
   }
   else
   {
      FileQueue_i lastFile = m_files.end();
      --lastFile;
      if (m_currentFile == lastFile)
      {
         return (*m_currentFile)->lastEvent() == m_currentEvent;
      }
   }
   return false;
}
void CmsShowNavigator::lastEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 276 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), goTo(), kOn, m_files, m_filterState, and x.

{
   FileQueue_i x = m_files.end();
   if (m_filterState == kOn)
   {
      while (x != m_files.begin())
      {
         --x;
         if ((*x)->hasSelectedEvents())
         {
            goTo(x, (*x)->lastSelectedEvent());
            return;
         }
      }
   }
   else
   {
      --x;
      goTo(x, (*x)->lastEvent());
   }
}
void CmsShowNavigator::newFile ( FileQueue_i  ) [private]

Referenced by appendFile(), and openFile().

void CmsShowNavigator::nextEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 329 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::end(), goTo(), kOn, prof2calltree::last, m_currentEvent, m_currentFile, m_files, m_filterState, m_newFileOnNextEvent, nextSelectedEvent(), and x.

{
   if (m_newFileOnNextEvent)
   {
      FileQueue_i last = m_files.end(); --last;
      if (m_filterState == kOn)
         goTo(last, (*last)->firstSelectedEvent());
      else
         goTo(last, 0);

      m_newFileOnNextEvent = false;
      return;
   }
   
   if (m_filterState == kOn)
   {
      nextSelectedEvent();
      return;
   }
   else
   {
      if (m_currentEvent < (*m_currentFile)->lastEvent())
      {
         goTo(m_currentFile, m_currentEvent + 1);
      }
      else
      {
         FileQueue_i x = m_currentFile ; ++x;
         if (x != m_files.end())
         {
            goTo(x, 0);
         }
      }
   }
}
bool CmsShowNavigator::nextSelectedEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 301 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::end(), goTo(), i, m_currentEvent, m_currentFile, and m_files.

Referenced by nextEvent(), and updateFileFilters().

{
   int nextEv = (*m_currentFile)->nextSelectedEvent(m_currentEvent);
   if (nextEv > -1)
   {
      goTo(m_currentFile, nextEv);
      return true;
   }
   else
   {
      FileQueue_i i = m_currentFile; ++i;
      while (i != m_files.end())
      {
         if ((*i)->hasSelectedEvents())
         {
            goTo(i, (*i)->firstSelectedEvent());
            return true;
         }
         ++i;
      }
   }

   return false;
}
bool CmsShowNavigator::openFile ( const std::string &  fileName)

Definition at line 73 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), FWFileEntry::closeFile(), exception, mergeVDriftHistosByStation::file, FWFileEntry::filters(), fwLog, CmsShowMain::getVersionCheck(), i, fwlog::kDebug, fwlog::kError, kOff, m_files, m_filterState, m_main, m_selectors, newFile(), setCurrentFile(), and updateFileFilters().

{
   fwLog(fwlog::kDebug) << "CmsShowNavigator::openFile [" << fileName << "]" << std::endl;
   FWFileEntry* newFile = 0;
   try
   {
      newFile = new FWFileEntry(fileName, m_main.getVersionCheck());
   }
   catch (std::exception& iException)
   {
      fwLog(fwlog::kError) <<"Navigator::openFile ecaught exception FWFileEntry constructor " << iException.what()<<std::endl;

      delete newFile;
      return false;
   }

   try 
   {
      // delete all previous files
      while ( !m_files.empty() )
      {
         FWFileEntry* file = m_files.front();
         m_files.pop_front();
         file->closeFile();
         delete file;
      }

      m_files.push_back(newFile);
      setCurrentFile(m_files.begin());

      // set filters
      for (std::list<FWEventSelector*>::iterator i = m_selectors.begin(); i != m_selectors.end(); ++i)
         newFile->filters().push_back(new FWFileEntry::Filter(*i));

      if (m_filterState != kOff)
         updateFileFilters();

      return true;
   }
   catch (std::exception& iException) 
   {
      fwLog(fwlog::kError) <<"Navigator::openFile caught exception "<<iException.what()<<std::endl;
      return false;
   }
}
const CmsShowNavigator& CmsShowNavigator::operator= ( const CmsShowNavigator ) [private]
void CmsShowNavigator::previousEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 395 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), goTo(), kOn, m_currentEvent, m_currentFile, m_files, m_filterState, previousSelectedEvent(), and x.

{
   if (m_filterState == kOn)
   {
      previousSelectedEvent();
   }
   else
   {
      if (m_currentEvent > 0)
      {
         goTo(m_currentFile, m_currentEvent - 1);
      }
      else
      {
         // last event in previous file
         FileQueue_i x = m_currentFile;
         if (x != m_files.begin())
         {
            --x;
            goTo(x, (*x)->lastEvent());
         }
      }
   }
}
bool CmsShowNavigator::previousSelectedEvent ( ) [virtual]

Implements FWNavigatorBase.

Definition at line 368 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::end(), goTo(), i, m_currentEvent, m_currentFile, m_files, and CmsShowNavigator::FileQueue_t::iterator::previous().

Referenced by previousEvent(), and updateFileFilters().

{
   int prevEv = (*m_currentFile)->previousSelectedEvent(m_currentEvent);
   if (prevEv > -1)
   {
      goTo(m_currentFile, prevEv);
      return true;
   }
   else
   {
      FileQueue_i i(m_currentFile); i.previous(m_files);
      while (i != m_files.end())
      {
         if ((*i)->hasSelectedEvents())
         {
            goTo(i, (*i)->lastSelectedEvent());
            return true;
         }
         i.previous(m_files);
      }
   }
   return false;
}
Int_t CmsShowNavigator::realEntry ( Int_t  rawEntry)
void CmsShowNavigator::removeFilter ( std::list< FWEventSelector * >::iterator  si) [private]

Definition at line 502 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), f, mergeVDriftHistosByStation::file, fwLog, fwlog::kDebug, m_files, m_filesNeedUpdate, and m_selectors.

Referenced by applyFiltersFromGUI().

{
   fwLog(fwlog::kDebug) << "CmsShowNavigator::removeFilter " << (*si)->m_expression << std::endl;

   std::list<FWFileEntry::Filter*>::iterator it;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      for (it = (*file)->filters().begin(); it != (*file)->filters().end(); ++it)
      {
         if ((*it)->m_selector == *si)
         {
            FWFileEntry::Filter* f = *it;
            delete f;
            (*file)->filters().erase(it);
            break;
         }
      }
   }

   delete *si;
   m_selectors.erase(si);
   m_filesNeedUpdate = true;
}
void CmsShowNavigator::resetNewFileOnNextEvent ( ) [inline]

Definition at line 131 of file CmsShowNavigator.h.

References m_newFileOnNextEvent.

{ m_newFileOnNextEvent = false; }
void CmsShowNavigator::resumeFilter ( )

Definition at line 454 of file CmsShowNavigator.cc.

References filterStateChanged_, fwLog, fwlog::kInfo, kOn, and m_filterState.

Referenced by updateFileFilters().

{
   fwLog(fwlog::kInfo) << "CmsShowNavigator::resumeFilter" << std::endl;
   m_filterState = kOn;
   filterStateChanged_.emit(m_filterState);
}
void CmsShowNavigator::setCurrentFile ( FileQueue_i  fi) [private]

Definition at line 182 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), fileChanged_, fwLog, i, fwlog::kDebug, m_currentFile, m_files, and fwlog::presentLogLevel().

Referenced by appendFile(), goTo(), and openFile().

{
   if (fwlog::presentLogLevel() == fwlog::kDebug)
   {
      int cnt = 0;
      for (FileQueue_i i = m_files.begin(); i!= m_files.end(); i++)
      {
         if ( i == fi) break;
         cnt++;
      }
      
      fwLog(fwlog::kDebug) << "CmsShowNavigator::setCurrentFile [" << (*fi)->file()->GetName() << "] file idx in chain [" << cnt << "/" << m_files.size() -1 << "]" << std::endl;
   }
   
   m_currentFile = fi;
   fileChanged_.emit((*m_currentFile)->file());
}
void CmsShowNavigator::setFrom ( const FWConfiguration iFrom) [virtual]

Implements FWNavigatorBase.

Definition at line 809 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), dbtoconf::conf, CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, filterStateChanged_, i, FWConfiguration::keyValues(), kOff, kOn, FWEventSelector::m_description, FWEventSelector::m_enabled, FWEventSelector::m_expression, m_files, m_filesNeedUpdate, m_filterMode, m_filterState, m_guiFilter, m_selectors, FWEventSelector::m_triggerProcess, postFiltering_, FWGUIEventFilter::reset(), alignCSCRings::s, FWGUIEventFilter::show(), updateFileFilters(), FWConfiguration::value(), relativeConstraints::value, FWConfiguration::valueForKey(), and x.

{
   m_filesNeedUpdate = true;

   EFilterState oldFilterState =  m_filterState;

  
   m_selectors.clear();

   // selectors   
   const FWConfiguration* sConf = iFrom.valueForKey("EventFilters");

   if (sConf)
   {
      const FWConfiguration::KeyValues* keyVals = sConf->keyValues();
      if (keyVals) {
         for(FWConfiguration::KeyValuesIt it = keyVals->begin(); it!= keyVals->end(); ++it)
         {
            const FWConfiguration& conf = (*it).second;
            FWEventSelector* selector = new FWEventSelector();
            selector->m_expression   = conf.valueForKey("expression")->value();
            selector->m_description  = conf.valueForKey("comment")->value();
            selector->m_enabled      = atoi(conf.valueForKey("enabled")->value().c_str());
            if (conf.valueForKey("triggerProcess"))
               selector->m_triggerProcess = conf.valueForKey("triggerProcess")->value();
            m_selectors.push_back(selector);
         }
      }
   }
   else
   {
      int numberOfFilters = 0;
      const FWConfiguration* nfvalue = iFrom.valueForKey( "EventFilter_total" );
      if(nfvalue)
         numberOfFilters = atoi(nfvalue->value().c_str());

      for(int i=0; i<numberOfFilters; ++i)
      {
         FWEventSelector* selector = new FWEventSelector();
         {
            const FWConfiguration* value = iFrom.valueForKey( Form("EventFilter%d_enabled",i));
            assert(value);
            std::istringstream s(value->value());
            s>>selector->m_enabled;
         }
         selector->m_expression  = iFrom.valueForKey( Form("EventFilter%d_selection",i))->value();
         selector->m_description = iFrom.valueForKey( Form("EventFilter%d_comment",i) )->value();

         
         if (strstr(selector->m_expression.c_str(), "HLT"))
            selector->m_triggerProcess = "HLT";
         
         m_selectors.push_back(selector);
      }
   }

   // filter mode
   {
      const FWConfiguration* value = iFrom.valueForKey( "EventFilter_mode" );
      if (value)
      {
         std::istringstream s(value->value());
         s>> m_filterMode;
      }
   }
   
   // filter on
   {
      const FWConfiguration* value = iFrom.valueForKey( "EventFilter_enabled" );
      std::istringstream s(value->value());
      int x;
      s>> x;
      m_filterState = x ? kOn : kOff;
   }
   

   // redesplay new filters in event filter dialog if already mapped
   if (m_guiFilter)
   {
      m_guiFilter->reset();
      if (m_guiFilter->IsMapped()) m_guiFilter->show(&m_selectors, m_filterMode, m_filterState);
   }
   
   if (!m_files.empty())
   {
      // change filters in existing files 
      for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
      { 
         (*file)->filters().clear();
         for (std::list<FWEventSelector*>::iterator i = m_selectors.begin(); i != m_selectors.end(); ++i)
            (*file)->filters().push_back(new FWFileEntry::Filter(*i));
      }
      
      
      // run new filters if enabled, else just reset 
      if  (m_filterState == kOn)
         updateFileFilters();
      else
         postFiltering_.emit();
   }
   // update CmsShowMainFrame checkBoxIcon and button text
   if (oldFilterState != m_filterState)
      filterStateChanged_.emit(m_filterState);
}
void CmsShowNavigator::setMaxNumberOfFilesToChain ( unsigned int  i) [inline]

Definition at line 105 of file CmsShowNavigator.h.

References i, and m_maxNumberOfFilesToChain.

Referenced by CmsShowMain::CmsShowMain().

void CmsShowNavigator::showEventFilterGUI ( const TGWindow *  p)
void CmsShowNavigator::toggleFilterEnable ( )
void CmsShowNavigator::updateFileFilters ( ) [private]

Definition at line 462 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowMain::context(), CmsShowNavigator::FileQueue_t::end(), fireworks::Context::eventItemsManager(), mergeVDriftHistosByStation::file, fwLog, getNSelectedEvents(), getNTotalEvents(), fwlog::kDebug, kOr, kWithdrawn, m_currentEvent, m_files, m_filesNeedUpdate, m_filterMode, m_filterState, m_main, nextSelectedEvent(), postFiltering_, fwlog::presentLogLevel(), previousSelectedEvent(), resumeFilter(), updateSelectorsInfo(), and withdrawFilter().

Referenced by appendFile(), applyFiltersFromGUI(), openFile(), setFrom(), and toggleFilterEnable().

{
   // run filters on files
   std::list<FWFileEntry::Filter>::iterator it;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      if ( m_filesNeedUpdate) (*file)->needUpdate();
      (*file)->updateFilters(m_main.context()->eventItemsManager(), m_filterMode == kOr);
   }
   updateSelectorsInfo();
   m_filesNeedUpdate = false;
 
   int nSelected = getNSelectedEvents();
   if (nSelected)
   {
      // go to the nearest selected event/file
      if (!(*m_currentFile)->isEventSelected(m_currentEvent))
      {
         if (!nextSelectedEvent())
            previousSelectedEvent();
      }

      if (m_filterState == kWithdrawn)
         resumeFilter();

      postFiltering_.emit();
   }
   else
   {
      withdrawFilter();
   }

   if (fwlog::presentLogLevel() == fwlog::kDebug)
   {
      fwLog(fwlog::kDebug) << "CmsShowNavigator::updateFileFilters selected events over files [" << getNSelectedEvents() << "/" << getNTotalEvents() << "]" << std::endl;
   }
}
void CmsShowNavigator::updateSelectorsInfo ( ) [private]

Definition at line 691 of file CmsShowNavigator.cc.

References CmsShowNavigator::FileQueue_t::begin(), CmsShowNavigator::FileQueue_t::end(), mergeVDriftHistosByStation::file, filters, FWGUIEventFilter::guiSelectors(), i, m_files, m_guiFilter, m_selectors, and EgammaValidation_Wenu_cff::sel.

Referenced by updateFileFilters().

{
 
   // reset
   std::list<FWEventSelector*>::const_iterator sel = m_selectors.begin();
   while ( sel != m_selectors.end())
   {
      (*sel)->m_selected = 0;
      (*sel)->m_updated  = true;
      ++sel;
   }

   // loop file filters
   std::list<FWFileEntry::Filter*>::iterator i;
   for (FileQueue_i file = m_files.begin(); file != m_files.end(); ++file)
   {
      std::list<FWFileEntry::Filter*>& filters = (*file)->filters();
      for (i = filters.begin(); i != filters.end(); ++i)
      {
         if ((*i)->m_eventList)
         {
            (*i)->m_selector->m_selected += (*i)->m_eventList->GetN();
         }

         if ((*i)->m_needsUpdate) 
            (*i)->m_selector->m_updated = false;
      }
   }
   if (m_guiFilter) 
   {
      std::list<FWGUIEventSelector*>::const_iterator gs = m_guiFilter->guiSelectors().begin();
      while ( gs !=  m_guiFilter->guiSelectors().end())
      {
         (*gs)->updateNEvents();
         ++gs;
      }
   }
}
void CmsShowNavigator::withdrawFilter ( )

Definition at line 446 of file CmsShowNavigator.cc.

References filterStateChanged_, fwLog, fwlog::kInfo, kWithdrawn, and m_filterState.

Referenced by updateFileFilters().

{
   fwLog(fwlog::kInfo) << "CmsShowNavigator::witdrawFilter" << std::endl;
   m_filterState = kWithdrawn;
   filterStateChanged_.emit(m_filterState);
}

Member Data Documentation

sigc::signal<void, bool> CmsShowNavigator::editFiltersExternally_

Definition at line 138 of file CmsShowNavigator.h.

Referenced by editFiltersExternally(), and showEventFilterGUI().

sigc::signal<void, const TFile*> CmsShowNavigator::fileChanged_

Definition at line 135 of file CmsShowNavigator.h.

Referenced by setCurrentFile().

sigc::signal<void, int> CmsShowNavigator::filterStateChanged_

Reimplemented from FWNavigatorBase.

Definition at line 171 of file CmsShowNavigator.h.

Referenced by appendFile(), getProcessList(), openFile(), and updateFileFilters().

Definition at line 167 of file CmsShowNavigator.h.

Referenced by appendFile(), and setMaxNumberOfFilesToChain().

Definition at line 137 of file CmsShowNavigator.h.

Referenced by setFrom(), and updateFileFilters().

sigc::signal<void> CmsShowNavigator::preFiltering_

Definition at line 136 of file CmsShowNavigator.h.