ATLAS Offline Software
Classes | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | List of all members
VP1AvailEvents Class Referenceabstract

#include <VP1AvailEvents.h>

Inheritance diagram for VP1AvailEvents:
Collaboration diagram for VP1AvailEvents:

Classes

class  Imp
 

Signals

void allLocalEventsChanged ()
 
void freshEventsChanged ()
 
void message (const QString &) const
 

Public Member Functions

 VP1AvailEvents (int timeCutForNew, QString tmpdir, int maxLocalFilesToKeep=-1, QObject *parent=0)
 
virtual void init ()=0
 
virtual ~VP1AvailEvents ()
 
QList< VP1EventFileallLocalEvents () const
 
QList< VP1EventFilefreshEvents () const
 
VP1EventFile newestEvent () const
 
void setCurrentEvent (int run, int event)
 
int maxLocalFilesToKeep () const
 

Protected Member Functions

void cleanupAndCheckForEventListChanges ()
 
void invalidateDirCache (const QString &dir)
 
bool inHistory (int run, int event) const
 
QList< VP1EventFileallEventFilesInDir (const QString &dir) const
 
QList< VP1EventFilefreshEvents (VP1EventFile newestEvt, const QList< VP1EventFile > &) const
 
QString tmpDir () const
 
QString tmpLocalFileDir () const
 
QString tmpActiveRetrievalDir ()
 
int timeCutForNew () const
 
bool requireNewestRunNumber () const
 
bool isConsideredFresh (const VP1EventFile &evt, const VP1EventFile &newestEvt) const
 
void messageDebug (const QString &) const
 

Private Slots

void actualCleanup ()
 
void actualCheckForEventListChanges ()
 

Private Attributes

Impm_d
 

Detailed Description

Definition at line 25 of file VP1AvailEvents.h.

Constructor & Destructor Documentation

◆ VP1AvailEvents()

VP1AvailEvents::VP1AvailEvents ( int  timeCutForNew,
QString  tmpdir,
int  maxLocalFilesToKeep = -1,
QObject *  parent = 0 
)

Definition at line 71 of file VP1AvailEvents.cxx.

72  : QObject(parent), m_d(new Imp)
73 {
74  m_d->theclass = this;
76  m_d->tmpDir = QString(td + (td.endsWith("/")?"":"/")).replace("//","/");
78 }

◆ ~VP1AvailEvents()

VP1AvailEvents::~VP1AvailEvents ( )
virtual

Definition at line 81 of file VP1AvailEvents.cxx.

82 {
83  //Fixme: These two remove commands only has an effect when dir is empty!!
84  if (!m_d->tmpActiveRetrievalDir.isEmpty()&&m_d->tmpActiveRetrievalDir!="bad")
86  if (!m_d->tmpLocalFileDir.isEmpty()&&m_d->tmpLocalFileDir!="bad")
88  delete m_d;
89 }

Member Function Documentation

◆ actualCheckForEventListChanges

void VP1AvailEvents::actualCheckForEventListChanges ( )
privateslot

Definition at line 161 of file VP1AvailEvents.cxx.

162 {
163  QList<VP1EventFile> allLocal = allLocalEvents();
164  QList<VP1EventFile> fresh = freshEvents();
165  if (m_d->lastAllLocal != allLocal) {
166  m_d->lastAllLocal = allLocal;
168  }
169  if (m_d->lastFresh != fresh) {
170  m_d->lastFresh = fresh;
172  }
173 }

◆ actualCleanup

void VP1AvailEvents::actualCleanup ( )
privateslot

Definition at line 151 of file VP1AvailEvents.cxx.

152 {
153  //First we cleanup:
155 
156  //Then we schedule a check for event list changes:
157  QTimer::singleShot(10, this, SLOT(actualCheckForEventListChanges()));
158 }

◆ allEventFilesInDir()

QList< VP1EventFile > VP1AvailEvents::allEventFilesInDir ( const QString &  dir) const
protected

Definition at line 202 of file VP1AvailEvents.cxx.

203 {
204  if (dir.isEmpty())
205  return QList<VP1EventFile>();
206 
207  QFileInfo fi_dir(dir);
208  if (!fi_dir.exists()||!fi_dir.isDir())
209  return QList<VP1EventFile>();
210 
211  QDateTime modtime = fi_dir.lastModified();
212  if (abs(modtime.time().msecsTo(QTime::currentTime()))>50) {
213  std::map<QString,std::pair<QDateTime,QList<VP1EventFile> > >::iterator it = m_d->dircache.find(dir);
214  if (it!=m_d->dircache.end()&&it->second.first==modtime)
215  return it->second.second;
216  }
217 
218  QStringList filters;
219  filters << "*_*.pool.root";
220  //fixme
221  QDirIterator itDir(dir,filters,QDir::Files | QDir::NoDotAndDotDot | QDir::Readable | QDir::CaseSensitive);
222 
223  QList<VP1EventFile> l;
224  while (itDir.hasNext()) {
225  QString fn = itDir.next();
226  fn.replace("//","/");
228  if (evt.isValid())
229  l << evt;
230  else
231  message("Could not decode event file name: "+fn);
232  }
233 
234  std::sort(l.begin(), l.end());
235 
236  m_d->dircache[dir]=std::make_pair(modtime,l);
237  return l;
238 }

◆ allLocalEvents()

QList< VP1EventFile > VP1AvailEvents::allLocalEvents ( ) const

Definition at line 241 of file VP1AvailEvents.cxx.

242 {
244 }

◆ allLocalEventsChanged

void VP1AvailEvents::allLocalEventsChanged ( )
signal

◆ cleanupAndCheckForEventListChanges()

void VP1AvailEvents::cleanupAndCheckForEventListChanges ( )
protected

Definition at line 176 of file VP1AvailEvents.cxx.

177 {
178  //We schedule the cleanup to take place shortly. The check for event
179  //list changes will be scheduled after the cleanup:
180 
181  //Then we schedule a check for event list changes:
182  QTimer::singleShot(10, this, SLOT(actualCleanup()));
183 
184 }

◆ freshEvents() [1/2]

QList< VP1EventFile > VP1AvailEvents::freshEvents ( ) const

Definition at line 129 of file VP1AvailEvents.cxx.

130 {
132 }

◆ freshEvents() [2/2]

QList< VP1EventFile > VP1AvailEvents::freshEvents ( VP1EventFile  newestEvt,
const QList< VP1EventFile > &  inputEventList 
) const
protected

Definition at line 110 of file VP1AvailEvents.cxx.

111 {
112  QList<VP1EventFile> l;
113  if (!newestEvt.isValid())
114  return l;
115  std::set<Imp::EventID>::const_iterator histIt, histItE(m_d->historySorted.end());
116  if (m_d->timeCutForNew==0) {
117  if (m_d->historySorted.find(Imp::evtToID(newestEvt))==histItE)
118  l << newestEvt;
119  return l;
120  }
121  for(VP1EventFile evt : inputEventList)
122  if (m_d->historySorted.find(Imp::evtToID(evt))==histItE && isConsideredFresh(evt,newestEvt))
123  l << evt;
124  return l;
125 }

◆ freshEventsChanged

void VP1AvailEvents::freshEventsChanged ( )
signal

◆ inHistory()

bool VP1AvailEvents::inHistory ( int  run,
int  event 
) const
protected

Definition at line 187 of file VP1AvailEvents.cxx.

188 {
189  return m_d->historySorted.find(Imp::EventID(run,event))!=m_d->historySorted.end();
190 }

◆ init()

virtual void VP1AvailEvents::init ( )
pure virtual

◆ invalidateDirCache()

void VP1AvailEvents::invalidateDirCache ( const QString &  dir)
protected

Definition at line 194 of file VP1AvailEvents.cxx.

195 {
196  std::map<QString,std::pair<QDateTime,QList<VP1EventFile> > >::iterator it = m_d->dircache.find(dir);
197  if (it!=m_d->dircache.end())
198  m_d->dircache.erase(it);
199 }

◆ isConsideredFresh()

bool VP1AvailEvents::isConsideredFresh ( const VP1EventFile evt,
const VP1EventFile newestEvt 
) const
protected

Definition at line 336 of file VP1AvailEvents.cxx.

337 {
338  //Notice: Logic here must be similar to logic in VP1EvtsOnServerInfo::events
339 
340  if (m_d->timeCutForNew==0) {
341  //Special case where only the newest event is fresh
342  return evt.rawTime()==newestEvt.rawTime() && evt.runNumber()==newestEvt.runNumber();
343  }
344  if (requireNewestRunNumber()&&evt.runNumber()!=newestEvt.runNumber())
345  return false;
346  const unsigned oldest_time = (m_d->timeCutForNew<0||unsigned(m_d->timeCutForNew)>newestEvt.rawTime()) ? 0 : newestEvt.rawTime() - m_d->timeCutForNew;
347  return evt.rawTime() >= oldest_time;
348 }

◆ maxLocalFilesToKeep()

int VP1AvailEvents::maxLocalFilesToKeep ( ) const

Definition at line 98 of file VP1AvailEvents.cxx.

99 {
100  return m_d->maxLocalFilesToKeep;
101 }

◆ message

void VP1AvailEvents::message ( const QString &  ) const
signal

◆ messageDebug()

void VP1AvailEvents::messageDebug ( const QString &  s) const
protected

Definition at line 351 of file VP1AvailEvents.cxx.

352 {
353  std::cout<<VP1Msg::prefix_verbose()<<": "<<s.toStdString()<<std::endl;
354 }

◆ newestEvent()

VP1EventFile VP1AvailEvents::newestEvent ( ) const

Definition at line 135 of file VP1AvailEvents.cxx.

136 {
137  QList<VP1EventFile> evts(allLocalEvents());
138  if (evts.isEmpty())
139  return VP1EventFile();//invalid
140  return evts.front();
141 }

◆ requireNewestRunNumber()

bool VP1AvailEvents::requireNewestRunNumber ( ) const
inlineprotected

Definition at line 62 of file VP1AvailEvents.h.

62 { return false; /*fixme*/ }

◆ setCurrentEvent()

void VP1AvailEvents::setCurrentEvent ( int  run,
int  event 
)

Definition at line 144 of file VP1AvailEvents.cxx.

145 {
146  m_d->historyOrdered << Imp::EventID(run,event);
147  m_d->historySorted.insert(Imp::EventID(run,event));
148 }

◆ timeCutForNew()

int VP1AvailEvents::timeCutForNew ( ) const
protected

Definition at line 92 of file VP1AvailEvents.cxx.

93 {
94  return m_d->timeCutForNew;
95 }

◆ tmpActiveRetrievalDir()

QString VP1AvailEvents::tmpActiveRetrievalDir ( )
protected

Definition at line 277 of file VP1AvailEvents.cxx.

278 {
279  return m_d->attemptGenerationOfTmpSubdir("activeretrievals",m_d->tmpActiveRetrievalDir);
280 }

◆ tmpDir()

QString VP1AvailEvents::tmpDir ( ) const
protected

Definition at line 104 of file VP1AvailEvents.cxx.

105 {
106  return m_d->tmpDir;
107 }

◆ tmpLocalFileDir()

QString VP1AvailEvents::tmpLocalFileDir ( ) const
protected

Definition at line 283 of file VP1AvailEvents.cxx.

284 {
285  return m_d->attemptGenerationOfTmpSubdir("eventfiles",m_d->tmpLocalFileDir);
286 }

Member Data Documentation

◆ m_d

Imp* VP1AvailEvents::m_d
private

Definition at line 79 of file VP1AvailEvents.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1AvailEvents::tmpLocalFileDir
QString tmpLocalFileDir() const
Definition: VP1AvailEvents.cxx:283
VP1AvailEvents::actualCheckForEventListChanges
void actualCheckForEventListChanges()
Definition: VP1AvailEvents.cxx:161
VP1AvailEvents::allLocalEvents
QList< VP1EventFile > allLocalEvents() const
Definition: VP1AvailEvents.cxx:241
VP1AvailEvents::allLocalEventsChanged
void allLocalEventsChanged()
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1AvailEvents::actualCleanup
void actualCleanup()
Definition: VP1AvailEvents.cxx:151
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
VP1AvailEvents::Imp::tmpDir
QString tmpDir
Definition: VP1AvailEvents.cxx:31
AthenaPoolTestRead.Files
Files
Definition: AthenaPoolTestRead.py:10
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
VP1AvailEvents::freshEventsChanged
void freshEventsChanged()
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
VP1AvailEvents::message
void message(const QString &) const
VP1AvailEvents::freshEvents
QList< VP1EventFile > freshEvents() const
Definition: VP1AvailEvents.cxx:129
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
VP1AvailEvents::newestEvent
VP1EventFile newestEvent() const
Definition: VP1AvailEvents.cxx:135
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
VP1AvailEvents::Imp::timeCutForNew
int timeCutForNew
Definition: VP1AvailEvents.cxx:30
VP1AvailEvents::Imp::cleanupTmpLocalFiles
void cleanupTmpLocalFiles()
Definition: VP1AvailEvents.cxx:289
VP1AvailEvents::Imp::maxLocalFilesToKeep
int maxLocalFilesToKeep
Definition: VP1AvailEvents.cxx:32
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1AvailEvents::timeCutForNew
int timeCutForNew() const
Definition: VP1AvailEvents.cxx:92
run
Definition: run.py:1
VP1EventFile::isValid
bool isValid() const
Definition: VP1EventFile.cxx:158
VP1AvailEvents::requireNewestRunNumber
bool requireNewestRunNumber() const
Definition: VP1AvailEvents.h:62
VP1EventFile::runNumber
int runNumber() const
Definition: VP1EventFile.cxx:176
beamspotman.dir
string dir
Definition: beamspotman.py:623
VP1AvailEvents::m_d
Imp * m_d
Definition: VP1AvailEvents.h:78
VP1AvailEvents::Imp::historyOrdered
QList< EventID > historyOrdered
Definition: VP1AvailEvents.cxx:59
VP1EventFile::rawTime
unsigned rawTime() const
Definition: VP1EventFile.cxx:188
VP1AvailEvents::Imp::tmpActiveRetrievalDir
QString tmpActiveRetrievalDir
Definition: VP1AvailEvents.cxx:35
VP1AvailEvents::Imp::historySorted
std::set< EventID > historySorted
Definition: VP1AvailEvents.cxx:60
VP1AvailEvents::maxLocalFilesToKeep
int maxLocalFilesToKeep() const
Definition: VP1AvailEvents.cxx:98
VP1Msg::prefix_verbose
static const char * prefix_verbose()
Definition: VP1Msg.h:59
VP1AvailEvents::Imp::tmpLocalFileDir
QString tmpLocalFileDir
Definition: VP1AvailEvents.cxx:34
VP1EventFile
Definition: VP1EventFile.h:23
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
VP1AvailEvents::Imp::lastFresh
QList< VP1EventFile > lastFresh
Definition: VP1AvailEvents.cxx:62
VP1AvailEvents::Imp::theclass
VP1AvailEvents * theclass
Definition: VP1AvailEvents.cxx:29
VP1AvailEvents::allEventFilesInDir
QList< VP1EventFile > allEventFilesInDir(const QString &dir) const
Definition: VP1AvailEvents.cxx:202
VP1AvailEvents::Imp::lastAllLocal
QList< VP1EventFile > lastAllLocal
Definition: VP1AvailEvents.cxx:61
VP1AvailEvents::Imp::evtToID
static EventID evtToID(const VP1EventFile &evt)
Definition: VP1AvailEvents.cxx:55
VP1AvailEvents::isConsideredFresh
bool isConsideredFresh(const VP1EventFile &evt, const VP1EventFile &newestEvt) const
Definition: VP1AvailEvents.cxx:336
VP1AvailEvents::Imp::attemptGenerationOfTmpSubdir
QString attemptGenerationOfTmpSubdir(const QString &preferredname, QString &cachevar)
Definition: VP1AvailEvents.cxx:248
VP1AvailEvents::Imp::dircache
std::map< QString, std::pair< QDateTime, QList< VP1EventFile > > > dircache
Definition: VP1AvailEvents.cxx:64