ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
VP1AvailEvents::Imp Class Reference
Collaboration diagram for VP1AvailEvents::Imp:

Classes

class  EventID
 

Public Member Functions

QString attemptGenerationOfTmpSubdir (const QString &preferredname, QString &cachevar)
 
void cleanupTmpLocalFiles ()
 

Static Public Member Functions

static EventID evtToID (const VP1EventFile &evt)
 

Public Attributes

VP1AvailEventstheclass
 
int timeCutForNew
 
QString tmpDir
 
int maxLocalFilesToKeep
 
QString tmpLocalFileDir
 
QString tmpActiveRetrievalDir
 
QList< EventIDhistoryOrdered
 
std::set< EventIDhistorySorted
 
QList< VP1EventFilelastAllLocal
 
QList< VP1EventFilelastFresh
 
std::map< QString, std::pair< QDateTime, QList< VP1EventFile > > > dircache
 

Detailed Description

Definition at line 27 of file VP1AvailEvents.cxx.

Member Function Documentation

◆ attemptGenerationOfTmpSubdir()

QString VP1AvailEvents::Imp::attemptGenerationOfTmpSubdir ( const QString &  preferredname,
QString &  cachevar 
)

Definition at line 248 of file VP1AvailEvents.cxx.

249 {
250  if (!cachevar.isEmpty())
251  return cachevar=="bad"?"":cachevar;
252 
253  QFileInfo fi(tmpDir);
254  if (!( fi.exists()&&fi.isDir())) {
255  theclass->message("Could not create subdir in "+tmpDir+", since it does not exists or is not a directory" );
256  cachevar="bad";
257  return "";
258  }
259  int i(0);
260  while (true) {
261  ++i;
262  QString dir = tmpDir+(tmpDir.endsWith("/")?"":"/")+preferredname+(i==1?QString(""):QString::number(i))+"/";
263  if (!QFile::exists(dir)) {
264  bool ok = QDir().mkdir(dir);
265  if (!ok) {
266  theclass->message("Could not create directory:: "+dir );
267  cachevar="bad";
268  return "";
269  }
270  cachevar = dir;
271  return dir;
272  }
273  }
274 }

◆ cleanupTmpLocalFiles()

void VP1AvailEvents::Imp::cleanupTmpLocalFiles ( )

Definition at line 289 of file VP1AvailEvents.cxx.

290 {
291  if (maxLocalFilesToKeep<=2)
292  return;
293  if (tmpLocalFileDir.isEmpty())
294  return;
295  QString dir = theclass->tmpLocalFileDir();
296  if (dir.isEmpty())
297  return;
298 
299  QList<VP1EventFile> events = theclass->allLocalEvents();
300  int ntoremove = events.count()-maxLocalFilesToKeep;
301  if (ntoremove<=3)//3 instead of 0 to keep down the times we call the machinery below.
302  return;
303 
304  //Rules of engagement:
305  //We never delete the current event. We never delete the previous
306  //event. We never delete the maxLocalFilesToKeep newest of the fresh
307  //events.
308 
309  QList<Imp::EventID> protectedEvents;
310  if (!historyOrdered.isEmpty()) {
311  protectedEvents << historyOrdered.back();
312  if (historyOrdered.count()>1)
313  protectedEvents << historyOrdered.at(historyOrdered.count()-2);
314  }
315  QList<VP1EventFile> freshEvts = theclass->freshEvents();
316  int ifreshkept(0);
317  for (VP1EventFile evt : theclass->freshEvents()) {
318  protectedEvents << Imp::evtToID(evt);
319  if (++ifreshkept==maxLocalFilesToKeep)
320  break;
321  }
322 
323  //Remove:
324  for (int i = events.count()-1; i>=0; --i ) {
325  if (protectedEvents.contains(Imp::evtToID(events.at(i)))) {
326  continue;
327  }
328  QFile::remove(events.at(i).fileName());
329  if (--ntoremove<=0)
330  break;
331  }
333 }

◆ evtToID()

static EventID VP1AvailEvents::Imp::evtToID ( const VP1EventFile evt)
inlinestatic

Definition at line 55 of file VP1AvailEvents.cxx.

55  {
56  return EventID(evt.runNumber(),evt.eventNumber());
57  }

Member Data Documentation

◆ dircache

std::map<QString,std::pair<QDateTime,QList<VP1EventFile> > > VP1AvailEvents::Imp::dircache

Definition at line 64 of file VP1AvailEvents.cxx.

◆ historyOrdered

QList<EventID> VP1AvailEvents::Imp::historyOrdered

Definition at line 59 of file VP1AvailEvents.cxx.

◆ historySorted

std::set<EventID> VP1AvailEvents::Imp::historySorted

Definition at line 60 of file VP1AvailEvents.cxx.

◆ lastAllLocal

QList<VP1EventFile> VP1AvailEvents::Imp::lastAllLocal

Definition at line 61 of file VP1AvailEvents.cxx.

◆ lastFresh

QList<VP1EventFile> VP1AvailEvents::Imp::lastFresh

Definition at line 62 of file VP1AvailEvents.cxx.

◆ maxLocalFilesToKeep

int VP1AvailEvents::Imp::maxLocalFilesToKeep

Definition at line 32 of file VP1AvailEvents.cxx.

◆ theclass

VP1AvailEvents* VP1AvailEvents::Imp::theclass

Definition at line 29 of file VP1AvailEvents.cxx.

◆ timeCutForNew

int VP1AvailEvents::Imp::timeCutForNew

Definition at line 30 of file VP1AvailEvents.cxx.

◆ tmpActiveRetrievalDir

QString VP1AvailEvents::Imp::tmpActiveRetrievalDir

Definition at line 35 of file VP1AvailEvents.cxx.

◆ tmpDir

QString VP1AvailEvents::Imp::tmpDir

Definition at line 31 of file VP1AvailEvents.cxx.

◆ tmpLocalFileDir

QString VP1AvailEvents::Imp::tmpLocalFileDir

Definition at line 34 of file VP1AvailEvents.cxx.


The documentation for this class was generated from the following file:
VP1AvailEvents::tmpLocalFileDir
QString tmpLocalFileDir() const
Definition: VP1AvailEvents.cxx:283
VP1AvailEvents::allLocalEvents
QList< VP1EventFile > allLocalEvents() const
Definition: VP1AvailEvents.cxx:241
VP1AvailEvents::Imp::tmpDir
QString tmpDir
Definition: VP1AvailEvents.cxx:31
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1AvailEvents::Imp::maxLocalFilesToKeep
int maxLocalFilesToKeep
Definition: VP1AvailEvents.cxx:32
beamspotman.dir
string dir
Definition: beamspotman.py:623
VP1AvailEvents::Imp::historyOrdered
QList< EventID > historyOrdered
Definition: VP1AvailEvents.cxx:59
python.selection.number
number
Definition: selection.py:20
VP1AvailEvents::Imp::tmpLocalFileDir
QString tmpLocalFileDir
Definition: VP1AvailEvents.cxx:34
VP1EventFile
Definition: VP1EventFile.h:23
EventID
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventID.h:35
checkFileSG.fi
fi
Definition: checkFileSG.py:65
VP1AvailEvents::Imp::theclass
VP1AvailEvents * theclass
Definition: VP1AvailEvents.cxx:29
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
VP1AvailEvents::Imp::evtToID
static EventID evtToID(const VP1EventFile &evt)
Definition: VP1AvailEvents.cxx:55
VP1AvailEvents::invalidateDirCache
void invalidateDirCache(const QString &dir)
Definition: VP1AvailEvents.cxx:194