ATLAS Offline Software
Classes | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Attributes | Friends | List of all members
VP1AvailEvtsLocalDir Class Reference

#include <VP1AvailEvtsLocalDir.h>

Inheritance diagram for VP1AvailEvtsLocalDir:
Collaboration diagram for VP1AvailEvtsLocalDir:

Classes

class  Imp
 

Signals

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

Public Member Functions

 VP1AvailEvtsLocalDir (int timeCutForNew, const QString &sourcedir, const QString &tmpcopydir, int maxLocalFilesToKeep=-1, QObject *parent=0)
 
void setSourceDir (const QString &)
 
const QString & currentSourceDir () const
 
void setAvailableSourceDirectories (const QStringList &)
 
const QStringList & availableSourceDirectories () const
 
virtual ~VP1AvailEvtsLocalDir ()
 
virtual void init ()
 
QList< VP1EventFileallLocalEvents () const
 
QList< VP1EventFilefreshEvents () const
 
VP1EventFile newestEvent () const
 
void setCurrentEvent (int run, int event)
 
int maxLocalFilesToKeep () const
 

Protected Member Functions

QList< VP1EventFilefreshEvents (VP1EventFile newestEvt, const QList< VP1EventFile > &) const
 
void cleanupAndCheckForEventListChanges ()
 
void invalidateDirCache (const QString &dir)
 
bool inHistory (int run, int event) const
 
QList< VP1EventFileallEventFilesInDir (const QString &dir) const
 
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
 

Friends

class VP1LocalEvtRetriever
 

Detailed Description

Definition at line 24 of file VP1AvailEvtsLocalDir.h.

Constructor & Destructor Documentation

◆ VP1AvailEvtsLocalDir()

VP1AvailEvtsLocalDir::VP1AvailEvtsLocalDir ( int  timeCutForNew,
const QString &  sourcedir,
const QString &  tmpcopydir,
int  maxLocalFilesToKeep = -1,
QObject *  parent = 0 
)

Definition at line 33 of file VP1AvailEvtsLocalDir.cxx.

39  m_d(new Imp(sourcedir+(sourcedir.endsWith("/")?"":"/")))
40 {
41 }

◆ ~VP1AvailEvtsLocalDir()

VP1AvailEvtsLocalDir::~VP1AvailEvtsLocalDir ( )
virtual

Definition at line 52 of file VP1AvailEvtsLocalDir.cxx.

53 {
54  delete m_d;
55 }

Member Function Documentation

◆ actualCheckForEventListChanges

void VP1AvailEvents::actualCheckForEventListChanges ( )
privateslotinherited

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 ( )
privateslotinherited

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
protectedinherited

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
inherited

Definition at line 241 of file VP1AvailEvents.cxx.

242 {
244 }

◆ allLocalEventsChanged

void VP1AvailEvents::allLocalEventsChanged ( )
signalinherited

◆ availableSourceDirectories()

const QStringList & VP1AvailEvtsLocalDir::availableSourceDirectories ( ) const

Definition at line 78 of file VP1AvailEvtsLocalDir.cxx.

79 {
80  return m_d->availablesourcedirs;
81 }

◆ cleanupAndCheckForEventListChanges()

void VP1AvailEvents::cleanupAndCheckForEventListChanges ( )
protectedinherited

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 }

◆ currentSourceDir()

const QString & VP1AvailEvtsLocalDir::currentSourceDir ( ) const

Definition at line 58 of file VP1AvailEvtsLocalDir.cxx.

59 {
60  return m_d->sourcedir;
61 }

◆ freshEvents() [1/2]

QList< VP1EventFile > VP1AvailEvents::freshEvents ( ) const
inherited

Definition at line 129 of file VP1AvailEvents.cxx.

130 {
132 }

◆ freshEvents() [2/2]

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

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 ( )
signalinherited

◆ inHistory()

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

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()

void VP1AvailEvtsLocalDir::init ( )
virtual

Implements VP1AvailEvents.

Definition at line 45 of file VP1AvailEvtsLocalDir.cxx.

46 {
47  m_d->retriever = new VP1LocalEvtRetriever(this,m_d->sourcedir); // Memleak
48  m_d->retriever->start();
49 }

◆ invalidateDirCache()

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

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
protectedinherited

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
inherited

Definition at line 98 of file VP1AvailEvents.cxx.

99 {
100  return m_d->maxLocalFilesToKeep;
101 }

◆ message

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

◆ messageDebug()

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

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
inherited

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
inlineprotectedinherited

Definition at line 62 of file VP1AvailEvents.h.

62 { return false; /*fixme*/ }

◆ setAvailableSourceDirectories()

void VP1AvailEvtsLocalDir::setAvailableSourceDirectories ( const QStringList &  l)

Definition at line 71 of file VP1AvailEvtsLocalDir.cxx.

72 {
74 }

◆ setCurrentEvent()

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

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 }

◆ setSourceDir()

void VP1AvailEvtsLocalDir::setSourceDir ( const QString &  dir)

Definition at line 64 of file VP1AvailEvtsLocalDir.cxx.

65 {
67  m_d->sourcedir = dir;
68 }

◆ timeCutForNew()

int VP1AvailEvents::timeCutForNew ( ) const
protectedinherited

Definition at line 92 of file VP1AvailEvents.cxx.

93 {
94  return m_d->timeCutForNew;
95 }

◆ tmpActiveRetrievalDir()

QString VP1AvailEvents::tmpActiveRetrievalDir ( )
protectedinherited

Definition at line 277 of file VP1AvailEvents.cxx.

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

◆ tmpDir()

const QString & VP1AvailEvents::tmpDir ( ) const
protectedinherited

Definition at line 104 of file VP1AvailEvents.cxx.

105 {
106  return m_d->tmpDir;
107 }

◆ tmpLocalFileDir()

QString VP1AvailEvents::tmpLocalFileDir ( ) const
protectedinherited

Definition at line 283 of file VP1AvailEvents.cxx.

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

Friends And Related Function Documentation

◆ VP1LocalEvtRetriever

friend class VP1LocalEvtRetriever
friend

Definition at line 30 of file VP1AvailEvtsLocalDir.h.

Member Data Documentation

◆ m_d

Imp* VP1AvailEvtsLocalDir::m_d
private

Definition at line 50 of file VP1AvailEvtsLocalDir.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
VP1AvailEvtsLocalDir::Imp::availablesourcedirs
QStringList availablesourcedirs
Definition: VP1AvailEvtsLocalDir.cxx:26
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
python.getCurrentFolderTag.fn
fn
Definition: getCurrentFolderTag.py:65
VP1AvailEvents::VP1AvailEvents
VP1AvailEvents(int timeCutForNew, const QString &tmpdir, int maxLocalFilesToKeep=-1, QObject *parent=0)
Definition: VP1AvailEvents.cxx:71
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
VP1AvailEvtsLocalDir::Imp::sourcedir
QString sourcedir
Definition: VP1AvailEvtsLocalDir.cxx:24
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1AvailEvents::timeCutForNew
int timeCutForNew() const
Definition: VP1AvailEvents.cxx:92
VP1AvailEvtsLocalDir::m_d
Imp * m_d
Definition: VP1AvailEvtsLocalDir.h:49
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
VP1LocalEvtRetriever::setSourceDir
void setSourceDir(QString)
Definition: VP1LocalEvtRetriever.cxx:109
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
VP1AvailEvtsLocalDir::Imp::retriever
VP1LocalEvtRetriever * retriever
Definition: VP1AvailEvtsLocalDir.cxx:27
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::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
VP1AvailEvtsLocalDir::VP1LocalEvtRetriever
friend class VP1LocalEvtRetriever
Definition: VP1AvailEvtsLocalDir.h:30