Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Slots | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
VP1LocalEvtRetriever Class Reference

#include <VP1LocalEvtRetriever.h>

Inheritance diagram for VP1LocalEvtRetriever:
Collaboration diagram for VP1LocalEvtRetriever:

Public Slots

void updateLocalDirFromSource ()
 

Public Member Functions

 VP1LocalEvtRetriever (VP1AvailEvtsLocalDir *, QString, QObject *parent=0)
 
 ~VP1LocalEvtRetriever ()
 
void setSourceDir (QString)
 

Protected Member Functions

void run ()
 

Private Member Functions

void updateLocalDir ()
 

Private Attributes

VP1AvailEvtsLocalDirm_availEvts
 
QString m_sourcedir
 
QTimer * m_timer
 
QMutex m_mutex
 

Detailed Description

Definition at line 15 of file VP1LocalEvtRetriever.h.

Constructor & Destructor Documentation

◆ VP1LocalEvtRetriever()

VP1LocalEvtRetriever::VP1LocalEvtRetriever ( VP1AvailEvtsLocalDir availEvts,
QString  sourcedir,
QObject *  parent = 0 
)

Definition at line 13 of file VP1LocalEvtRetriever.cxx.

16  : QThread(parent)
17  , m_availEvts(availEvts)
18  , m_sourcedir(sourcedir)
19  , m_timer(0)
20 {
21 }

◆ ~VP1LocalEvtRetriever()

VP1LocalEvtRetriever::~VP1LocalEvtRetriever ( )

Definition at line 23 of file VP1LocalEvtRetriever.cxx.

24 {
25  delete m_timer;
26 }

Member Function Documentation

◆ run()

void VP1LocalEvtRetriever::run ( )
protected

Definition at line 28 of file VP1LocalEvtRetriever.cxx.

29 {
30  m_timer = new QTimer(0);
31  connect(m_timer, SIGNAL(timeout()), this, SLOT(updateLocalDirFromSource()),Qt::DirectConnection);
32  m_timer->start(3000);
34  exec();
35 }

◆ setSourceDir()

void VP1LocalEvtRetriever::setSourceDir ( QString  dir)

Definition at line 109 of file VP1LocalEvtRetriever.cxx.

110 {
111  QMutexLocker locker(&m_mutex);
112 
113  if (!dir.endsWith("/"))
114  dir += "/";
115  if (m_sourcedir==dir)
116  return;
117 
118  //Ensure that the next event is from the new directory by removing
119  //all cached fresh events:
120 
121  while (true) {
122  QList<VP1EventFile> freshevts = m_availEvts->freshEvents();
123  if (freshevts.isEmpty())
124  break;
125  for(VP1EventFile evt : freshevts) {
126  QString fn = evt.fileName();
127  if (!QFile::remove(fn))
128  m_availEvts->message("ERROR: Could not remove "+fn);
129  }
130  }
131 
132  //Now change directory
133  m_sourcedir = dir;
134  updateLocalDir();
135 }

◆ updateLocalDir()

void VP1LocalEvtRetriever::updateLocalDir ( )
private

Definition at line 43 of file VP1LocalEvtRetriever.cxx.

44 {
45  QList<VP1EventFile> evts = m_availEvts->allEventFilesInDir(m_sourcedir);
46  if (evts.isEmpty()) {
47  m_availEvts->cleanupAndCheckForEventListChanges();//In case we e.g. changed to an empty input directory
48  return;
49  }
50  //We don't copy more than enough to give us 3 fresh files. But if
51  //there are more available, we will check back in 3 seconds.
52 
53  const int nfreshneeded = 3 - m_availEvts->freshEvents().count();
54  if (evts.count()>m_availEvts->maxLocalFilesToKeep()+3&&nfreshneeded<=0) {
55  //Don't copy anything, but schedule cleanup and check back in 3 seconds:
57 // --- todo? QTimer::singleShot(3000, this, SLOT(updateLocalDirFromSource()));
58  return;
59  }
60 
61  static unsigned ntmpdlcount = 0;
62 
63  QList<VP1EventFile> freshEvtsInSource = m_availEvts->freshEvents(evts.front(), evts);
64 
65  QString ad = m_availEvts->tmpActiveRetrievalDir();
66  QString tmplocal = m_availEvts->tmpLocalFileDir();
67  bool changestmplocal(false), changesad(false);
68  if (!ad.isEmpty()&&!tmplocal.isEmpty()) {
69  int ncopied(0);
70  for (VP1EventFile evt : freshEvtsInSource) {
71  QString fn = evt.fileName();
72  QString basefn = QFileInfo(fn).fileName();
73  QString target = tmplocal + basefn;
74  if (!QFile::exists(target)) {
75  QString tmptarget = ad+basefn+"_"+QString::number(ntmpdlcount++);
76  if (!QFile::copy(fn,tmptarget)) {
77  m_availEvts->message("Problems copying "+fn+" to "+tmptarget);
78  changesad = true;
79  } else {
80  if (!QFile::rename(tmptarget,target)) {
81  m_availEvts->message("Problems moving "+tmptarget+" to "+target+" directory");
82  changesad = true;
83  } else {
84  if (!QFile::exists(target)) {
85  m_availEvts->message("Inconsistent copy of "+basefn+" to local tmp directory");
86  } else {
87  ++ncopied;
88  m_availEvts->messageDebug("Copied "+basefn+" to local tmp directory");//Fixme: verbose!
89  changestmplocal = true;
90  }
91  }
92  }
93  }
94  if (ncopied>=nfreshneeded) {
95 // -- todo? QTimer::singleShot(3000, this, SLOT(updateLocalDirFromSource()));
96  break;
97  }
98  }
99  } else {
100  m_availEvts->message("Problems with temporary local directories.");
101  }
102  if (changestmplocal)
103  m_availEvts->invalidateDirCache(tmplocal);
104  if (changesad)
107 }

◆ updateLocalDirFromSource

void VP1LocalEvtRetriever::updateLocalDirFromSource ( )
slot

Definition at line 37 of file VP1LocalEvtRetriever.cxx.

38 {
39  QMutexLocker locker(&m_mutex);
41 }

Member Data Documentation

◆ m_availEvts

VP1AvailEvtsLocalDir* VP1LocalEvtRetriever::m_availEvts
private

Definition at line 37 of file VP1LocalEvtRetriever.h.

◆ m_mutex

QMutex VP1LocalEvtRetriever::m_mutex
private

Definition at line 40 of file VP1LocalEvtRetriever.h.

◆ m_sourcedir

QString VP1LocalEvtRetriever::m_sourcedir
private

Definition at line 38 of file VP1LocalEvtRetriever.h.

◆ m_timer

QTimer* VP1LocalEvtRetriever::m_timer
private

Definition at line 39 of file VP1LocalEvtRetriever.h.


The documentation for this class was generated from the following files:
VP1LocalEvtRetriever::updateLocalDirFromSource
void updateLocalDirFromSource()
Definition: VP1LocalEvtRetriever.cxx:37
VP1AvailEvents::tmpLocalFileDir
QString tmpLocalFileDir() const
Definition: VP1AvailEvents.cxx:283
VP1LocalEvtRetriever::updateLocalDir
void updateLocalDir()
Definition: VP1LocalEvtRetriever.cxx:43
VP1LocalEvtRetriever::m_availEvts
VP1AvailEvtsLocalDir * m_availEvts
Definition: VP1LocalEvtRetriever.h:37
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1AvailEvents::cleanupAndCheckForEventListChanges
void cleanupAndCheckForEventListChanges()
Definition: VP1AvailEvents.cxx:176
VP1AvailEvents::tmpActiveRetrievalDir
QString tmpActiveRetrievalDir()
Definition: VP1AvailEvents.cxx:277
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
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
VP1LocalEvtRetriever::m_mutex
QMutex m_mutex
Definition: VP1LocalEvtRetriever.h:40
LArG4FSStartPointFilter.exec
exec
Definition: LArG4FSStartPointFilter.py:103
test_pyathena.parent
parent
Definition: test_pyathena.py:15
beamspotman.dir
string dir
Definition: beamspotman.py:623
python.selection.number
number
Definition: selection.py:20
VP1LocalEvtRetriever::m_timer
QTimer * m_timer
Definition: VP1LocalEvtRetriever.h:39
VP1AvailEvents::maxLocalFilesToKeep
int maxLocalFilesToKeep() const
Definition: VP1AvailEvents.cxx:98
VP1EventFile
Definition: VP1EventFile.h:23
copySelective.target
string target
Definition: copySelective.py:37
VP1AvailEvents::allEventFilesInDir
QList< VP1EventFile > allEventFilesInDir(const QString &dir) const
Definition: VP1AvailEvents.cxx:202
calibdata.copy
bool copy
Definition: calibdata.py:27
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
VP1AvailEvents::messageDebug
void messageDebug(const QString &) const
Definition: VP1AvailEvents.cxx:351
python.TrigInDetArtSteps.timeout
timeout
Definition: TrigInDetArtSteps.py:36
VP1AvailEvents::invalidateDirCache
void invalidateDirCache(const QString &dir)
Definition: VP1AvailEvents.cxx:194
VP1LocalEvtRetriever::m_sourcedir
QString m_sourcedir
Definition: VP1LocalEvtRetriever.h:38