Skip to content

Commit

Permalink
shrink down the markForDeletion function
Browse files Browse the repository at this point in the history
  • Loading branch information
deguio committed Oct 3, 2014
1 parent 65e7497 commit db44fc8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 55 deletions.
2 changes: 1 addition & 1 deletion DQMServices/Components/src/DQMFileSaver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ DQMFileSaver::globalEndLuminosityBlock(const edm::LuminosityBlock & iLS, const e
}

// after saving per LS, delete the old LS global histograms.
dbe_->markForDeletion("", enableMultiThread_ ? irun : 0, ilumi);
dbe_->markForDeletion(enableMultiThread_ ? irun : 0, ilumi);
}
}

Expand Down
5 changes: 2 additions & 3 deletions DQMServices/Core/interface/DQMStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,8 @@ class DQMStore
void initializeFrom(const edm::ParameterSet&);
void reset(void);
void forceReset(void);
void markForDeletion(const std::string &path = "",
const uint32_t run = 0,
const uint32_t lumi = 0);
void markForDeletion(uint32_t run,
uint32_t lumi);

bool extract(TObject *obj, const std::string &dir, bool overwrite, bool collateHistograms);
TObject * extractNextObject(TBufferFile&) const;
Expand Down
80 changes: 29 additions & 51 deletions DQMServices/Core/src/DQMStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2037,61 +2037,39 @@ DQMStore::forceReset(void)
//////////////////////////////////////////////////////////////////////
/** Mark a set of histograms for deletion based on run, lumi and path*/
void
DQMStore::markForDeletion(const std::string &path /*= ""*/,
const uint32_t run /*= 0*/,
const uint32_t lumi /*= 0*/)
DQMStore::markForDeletion(uint32_t run,
uint32_t lumi)
{
std::set<std::string>::iterator di, de;
MEMap::iterator mi, me = data_.end();
int nme = 0;

std::string null_str("");
MonitorElement proto(&null_str, null_str, run, 0, 0);
if (enableMultiThread_)
proto.setLumi(lumi);

std::set<MonitorElement>::const_iterator e = data_.end();
std::set<MonitorElement>::const_iterator i = data_.lower_bound(proto);

// Loop over the directory structure.
for (di = dirs_.begin(), de = dirs_.end(); di != de; ++di)
{
// Check if we should process this directory. We process the
// requested part of the object tree, including references.
if (! path.empty() &&
! isSubdirectory(path, *di))
continue;

// Loop over monitor elements in this directory.
MonitorElement proto(&*di, std::string(), run, 0, 0);
if (enableMultiThread_)
proto.setLumi(lumi);

mi = data_.lower_bound(proto);
for ( ; mi != me && isSubdirectory(*di, *mi->data_.dirname); ++mi)
{
// Upper bound in the loop over the MEs
if (enableMultiThread_ && ((*mi).lumi() != lumi))
break;

// Skip if it isn't a direct child.
if (*di != *mi->data_.dirname)
continue;

// Keep backward compatibility with the old way of
// booking/handlind MonitorElements into the DQMStore. If run is
// 0 it means that a booking happened w/ the old non-threadsafe
// style, and we have to ignore the streamId and moduleId as a
// consequence.

if (run != 0 && (mi->data_.streamId !=0 || mi->data_.moduleId !=0))
continue;

const_cast<MonitorElement*>(&*mi)->markToDelete();

if (verbose_ > 1)
std::cout << "DQMStore::markForDeletion: marked monitor element '"
<< *mi->data_.dirname << "/" << mi->data_.objname << "'"
<< "flags " << mi->data_.flags << "\n";


nme++;
}
}
while (i != e) {
if (i->data_.streamId != 0 ||
i->data_.moduleId != 0)
break;
if ((i->data_.lumi != lumi) && enableMultiThread_)
break;
if (i->data_.run != run)
break;

const_cast<MonitorElement*>(&*i)->markToDelete();

if (verbose_ > 1)
std::cout << "DQMStore::markForDeletion: marked monitor element '"
<< *i->data_.dirname << "/" << i->data_.objname << "'"
<< "flags " << i->data_.flags << "\n";

++i;
}
}


//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit db44fc8

Please sign in to comment.