Skip to content

Commit

Permalink
plotstyle updates
Browse files Browse the repository at this point in the history
  • Loading branch information
yiiyama committed Feb 21, 2019
1 parent 09672c9 commit 5645246
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 39 deletions.
29 changes: 24 additions & 5 deletions common/MultiDraw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "TError.h"
#include "TLeafF.h"
#include "TLeafD.h"
#include "TEntryList.h"

#include <stdexcept>
#include <cstring>
Expand Down Expand Up @@ -599,7 +600,7 @@ MultiDraw::deleteFormula_(TTreeFormulaCached* _formula)
}

void
MultiDraw::fillPlots(long _nEntries/* = -1*/, long _firstEntry/* = 0*/)
MultiDraw::fillPlots(long _nEntries/* = -1*/, long _firstEntry/* = 0*/, char const* _filter/* = nullptr*/)
{
float* weightF(nullptr);
double weight(1.);
Expand Down Expand Up @@ -639,13 +640,25 @@ MultiDraw::fillPlots(long _nEntries/* = -1*/, long _firstEntry/* = 0*/)
else if (printLevel_ >= 4)
printEvery = 1;

long iEntry(_firstEntry);
long iEntryMax(_firstEntry + _nEntries);
long iLocalEntry(0);
if (_filter != nullptr && std::strlen(_filter) != 0) {
tree_.Draw(">>elist", _filter, "entrylist");
auto* elist(static_cast<TEntryList*>(gDirectory->Get("elist")));
tree_.SetEntryList(elist);
}

long long iEntry(_firstEntry);
long long iEntryMax(_firstEntry + _nEntries);
int treeNumber(-1);
unsigned passBase(0);
unsigned passFull(0);
while (iEntry != iEntryMax && (iLocalEntry = tree_.LoadTree(iEntry++)) >= 0) {
while (iEntry != iEntryMax) {
long long iEntryFiltered(tree_.GetEntryNumber(iEntry++));
if (iEntryFiltered < 0)
break;
long long iLocalEntry(tree_.LoadTree(iEntryFiltered));
if (iLocalEntry < 0)
break;

if (printLevel_ >= 0 && iEntry % printEvery == 1) {
std::cout << "\r " << iEntry << " events";
if (printLevel_ > 2)
Expand Down Expand Up @@ -839,6 +852,12 @@ MultiDraw::fillPlots(long _nEntries/* = -1*/, long _firstEntry/* = 0*/)
}
}

if (tree_.GetEntryList() != nullptr) {
auto* elist(tree_.GetEntryList());
tree_.SetEntryList(nullptr);
delete elist;
}

delete baseResults;
delete fullResults;
delete weightF;
Expand Down
2 changes: 1 addition & 1 deletion common/MultiDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class MultiDraw {
void addTreeBranch(TTree* tree, char const* bname, char const* expr);

//! Run and fill the plots and trees.
void fillPlots(long nEntries = -1, long firstEntry = 0);
void fillPlots(long nEntries = -1, long firstEntry = 0, char const* filter = nullptr);

void setPrintLevel(int l) { printLevel_ = l; }
long getTotalEvents() { return totalEvents_; }
Expand Down
Loading

0 comments on commit 5645246

Please sign in to comment.