Skip to content

Commit

Permalink
Merge pull request #5834 from deguio/deleteMEafterWriting_v3_73x
Browse files Browse the repository at this point in the history
DQMServices -- Delete ME after writing v3 73x
  • Loading branch information
nclopezo committed Oct 17, 2014
2 parents 0cd3486 + 092854b commit bf6cc88
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
3 changes: 3 additions & 0 deletions DQMServices/Components/src/DQMFileSaver.cc
Expand Up @@ -695,6 +695,9 @@ DQMFileSaver::globalEndLuminosityBlock(const edm::LuminosityBlock & iLS, const e
<< "Internal error, can save files"
<< " only in ROOT format.";
}

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

Expand Down
1 change: 1 addition & 0 deletions DQMServices/Core/interface/DQMNet.h
Expand Up @@ -61,6 +61,7 @@ class DQMNet
static const uint32_t DQM_PROP_DEAD = 0x00080000;
static const uint32_t DQM_PROP_STALE = 0x00100000;
static const uint32_t DQM_PROP_EFFICIENCY_PLOT = 0x00200000;
static const uint32_t DQM_PROP_MARKTODELETE = 0x01000000;

static const uint32_t DQM_MSG_HELLO = 0;
static const uint32_t DQM_MSG_UPDATE_ME = 1;
Expand Down
4 changes: 3 additions & 1 deletion DQMServices/Core/interface/DQMStore.h
Expand Up @@ -632,7 +632,9 @@ class DQMStore
void initializeFrom(const edm::ParameterSet&);
void reset(void);
void forceReset(void);

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
9 changes: 9 additions & 0 deletions DQMServices/Core/interface/MonitorElement.h
Expand Up @@ -286,6 +286,15 @@ class MonitorElement
bool isAccumulateEnabled(void) const
{ return data_.flags & DQMNet::DQM_PROP_ACCUMULATE; }

/// true if ME is marked for deletion
bool markedToDelete(void) const
{ return data_.flags & DQMNet::DQM_PROP_MARKTODELETE; }

/// Mark the object for deletion.
/// NB: make sure that the following method is not called simultaneously for the same ME
void markToDelete(void)
{ data_.flags |= DQMNet::DQM_PROP_MARKTODELETE; }

private:
/// reset "was updated" flag
void resetUpdate(void)
Expand Down
56 changes: 53 additions & 3 deletions DQMServices/Core/src/DQMStore.cc
Expand Up @@ -438,9 +438,21 @@ void DQMStore::mergeAndResetMEsLuminositySummaryCache(uint32_t run,
gme = data_.insert(global_me);
assert(gme.second);
}
// make the ME reusable for the next LS
const_cast<MonitorElement*>(&*i)->Reset();
// TODO(rovere): eventually reset the local object and mark it as reusable??
++i;

// check and remove the global lumi based histo belonging to the previous LSs
// if properly flagged as DQMNet::DQM_PROP_MARKTODELETE
global_me.setLumi(1);
std::set<MonitorElement>::const_iterator i_lumi = data_.lower_bound(global_me);
while (i_lumi->data_.lumi != lumi) {
auto temp = i_lumi++;
if (i_lumi->getFullname() == i->getFullname() && i_lumi->markedToDelete())
{
data_.erase(temp);
}
}
}
}

Expand Down Expand Up @@ -2037,6 +2049,44 @@ DQMStore::forceReset(void)
reset_ = true;
}

//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
/** Mark a set of histograms for deletion based on run, lumi and path*/
void
DQMStore::markForDeletion(uint32_t run,
uint32_t lumi)
{

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

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 Expand Up @@ -2474,7 +2524,7 @@ void DQMStore::savePB(const std::string &filename,

//reset the ME just written to make it available for the next LS (online)
if (resetMEsAfterWriting)
const_cast<MonitorElement*>(&*mi)->Reset();
const_cast<MonitorElement*>(&*mi)->Reset();
}
}

Expand Down Expand Up @@ -2687,7 +2737,7 @@ DQMStore::save(const std::string &filename,
TObjString(mi->tagLabelString().c_str()).Write();

//reset the ME just written to make it available for the next LS (online)
if(resetMEsAfterWriting)
if (resetMEsAfterWriting)
const_cast<MonitorElement*>(&*mi)->Reset();
}
}
Expand Down

0 comments on commit bf6cc88

Please sign in to comment.