CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
evf::DirManager Class Reference

#include <DirManager.h>

Public Member Functions

bool checkDirEmpty (std::string &)
 
 DirManager (std::string &d)
 
unsigned int findHighestRun ()
 
std::string findHighestRunDir ()
 
std::string findRunDir (unsigned int)
 
virtual ~DirManager ()
 

Private Attributes

std::string dir_
 

Detailed Description

Definition at line 13 of file DirManager.h.

Constructor & Destructor Documentation

◆ DirManager()

evf::DirManager::DirManager ( std::string &  d)
inline

Definition at line 15 of file DirManager.h.

15 : dir_(d) {}

◆ ~DirManager()

virtual evf::DirManager::~DirManager ( )
inlinevirtual

Definition at line 16 of file DirManager.h.

16 {}

Member Function Documentation

◆ checkDirEmpty()

bool evf::DirManager::checkDirEmpty ( std::string &  d)

Definition at line 62 of file DirManager.cc.

62  {
63  int filecount = 0;
64  DIR *dir = opendir(d.c_str());
65  struct dirent *buf;
66  while ((buf = readdir(dir))) {
67  filecount++;
68  }
69  return (filecount == 0);
70  }

References visDQMUpload::buf, ztail::d, dqmPostProcessing_online::DIR, and DeadROC_duringRun::dir.

◆ findHighestRun()

unsigned int evf::DirManager::findHighestRun ( )

Definition at line 7 of file DirManager.cc.

7  {
8  DIR *dir = opendir(dir_.c_str());
9  struct dirent *buf;
10  int maxrun = 0;
11  while ((buf = readdir(dir))) {
12  std::string dirnameNum = buf->d_name;
13  if (dirnameNum.find("run") != std::string::npos)
14  dirnameNum = dirnameNum.substr(3, std::string::npos);
15  if (atoi(dirnameNum.c_str()) > maxrun) {
16  maxrun = atoi(dirnameNum.c_str());
17  }
18  }
19  closedir(dir);
20  return maxrun;
21  }

References visDQMUpload::buf, dqmPostProcessing_online::DIR, DeadROC_duringRun::dir, dir_, maxrun, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ findHighestRunDir()

std::string evf::DirManager::findHighestRunDir ( )

Definition at line 22 of file DirManager.cc.

22  {
23  std::string retval = dir_ + "/";
24  std::string tmpdir;
25  DIR *dir = opendir(dir_.c_str());
26  struct dirent *buf;
27  int maxrun = 0;
28  while ((buf = readdir(dir))) {
29  std::string dirnameNum = buf->d_name;
30  if (dirnameNum.find("run") != std::string::npos)
31  dirnameNum = dirnameNum.substr(3, std::string::npos);
32  if (atoi(dirnameNum.c_str()) > maxrun) {
33  tmpdir = buf->d_name;
34  maxrun = atoi(dirnameNum.c_str());
35  }
36  }
37  closedir(dir);
38  retval += tmpdir;
39  return retval;
40  }

References visDQMUpload::buf, dqmPostProcessing_online::DIR, DeadROC_duringRun::dir, dir_, maxrun, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by evf::EvFDaqDirector::preBeginRun().

◆ findRunDir()

std::string evf::DirManager::findRunDir ( unsigned int  run)

Definition at line 42 of file DirManager.cc.

42  {
43  std::string retval = dir_ + "/";
44  std::string tmpdir = "";
45  DIR *dir = opendir(dir_.c_str());
46  struct dirent *buf;
47  while ((buf = readdir(dir))) {
48  std::string dirnameNum = buf->d_name;
49  if (dirnameNum.find("run") != std::string::npos)
50  dirnameNum = dirnameNum.substr(3, std::string::npos);
51  if ((unsigned int)atoi(dirnameNum.c_str()) == run) {
52  tmpdir = buf->d_name;
53  break;
54  }
55  }
56  closedir(dir);
57  if (tmpdir.empty())
58  throw cms::Exception("LogicError") << "Run Directory for Run " << run << " Not Found";
59  retval += tmpdir;
60  return retval;
61  }

References visDQMUpload::buf, dqmPostProcessing_online::DIR, DeadROC_duringRun::dir, dir_, writedatasetfile::run, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by evf::EvFDaqDirector::findCurrentRunDir().

Member Data Documentation

◆ dir_

std::string evf::DirManager::dir_
private

Definition at line 23 of file DirManager.h.

Referenced by findHighestRun(), findHighestRunDir(), and findRunDir().

dqmPostProcessing_online.DIR
DIR
Definition: dqmPostProcessing_online.py:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
maxrun
Int_t maxrun
Definition: trackSplitPlot.h:41
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
evf::DirManager::dir_
std::string dir_
Definition: DirManager.h:23
writedatasetfile.run
run
Definition: writedatasetfile.py:27
ztail.d
d
Definition: ztail.py:151
cms::Exception
Definition: Exception.h:70
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23