7 |
|
#include <TObjArray.h> |
8 |
|
#include <TDirectory.h> |
9 |
|
#include <TEnv.h> |
10 |
+ |
#include <TClass.h> |
11 |
|
|
12 |
|
#if !defined(__CINT__) && !defined(__MAKECINT__) |
13 |
|
#include "UserCode/GPetrucc/interface/fwliteHelpers.h" |
52 |
|
rowline += 3+6+3+3-1; // -1 as first char remain blank |
53 |
|
} |
54 |
|
for (int i = 0; i < exprArray->GetEntries(); ++i) { |
55 |
< |
const char *ex = ((TObjString *)(*exprArray)[i])->GetString(); |
56 |
< |
scanner.addExpression(ex); |
57 |
< |
printf(" : %8s", (strlen(ex)>8 ? ex+strlen(ex)-8 : ex)); // the rightmost part is usually the more interesting one |
55 |
> |
TString str = ((TObjString *)(*exprArray)[i])->GetString(); |
56 |
> |
std::string lb = str.Data(); |
57 |
> |
std::string ex = str.Data(); |
58 |
> |
if ((ex[0] == '@') && (ex.find('=') != std::string::npos)) { |
59 |
> |
lb = lb.substr(1,ex.find('=')-1); |
60 |
> |
ex = ex.substr(ex.find('=')+1); |
61 |
> |
} |
62 |
> |
scanner.addExpression(ex.c_str()); |
63 |
> |
printf(" : %8s", (lb.size()>8 ? lb.substr(lb.size()-8) : lb).c_str()); // the rightmost part is usually the more interesting one |
64 |
|
rowline += 3+8; |
65 |
|
} |
66 |
|
std::cout << " :" << std::endl; |
76 |
|
for (event_->toBegin(); (iev != nmax) && !event_->atEnd(); ++iev, ++(*event_)) { |
77 |
|
if (!selectEvent(*event_)) continue; |
78 |
|
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
79 |
+ |
if (handle_.failedToGet()) { |
80 |
+ |
if (ignoreExceptions_) continue; |
81 |
+ |
} |
82 |
|
const std::vector<T> & vals = *handle_; |
83 |
|
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
84 |
|
if (!scanner.test(&vals[j])) continue; |
101 |
|
} |
102 |
|
std::cout << std::endl; |
103 |
|
} |
104 |
< |
|
104 |
> |
|
105 |
> |
size_t count(const char *cut) { |
106 |
> |
helper::ScannerBase scanner(objType); |
107 |
> |
scanner.setIgnoreExceptions(ignoreExceptions_); |
108 |
> |
|
109 |
> |
scanner.setCut(cut); |
110 |
> |
|
111 |
> |
size_t npass = 0; |
112 |
> |
for (event_->toBegin(); !event_->atEnd(); ++(*event_)) { |
113 |
> |
if (!selectEvent(*event_)) continue; |
114 |
> |
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
115 |
> |
const std::vector<T> & vals = *handle_; |
116 |
> |
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
117 |
> |
if (scanner.test(&vals[j])) npass++; |
118 |
> |
} |
119 |
> |
} |
120 |
> |
|
121 |
> |
return npass; |
122 |
> |
} |
123 |
> |
|
124 |
|
TH1 * draw(const char *expr, const char *cut = "", TString drawopt = "", TH1 *hist = 0) { |
125 |
|
// prep the machinery |
126 |
|
helper::ScannerBase scanner(objType); |
130 |
|
|
131 |
|
// make histo, if needed |
132 |
|
if (hist == 0) { |
133 |
< |
htempDelete(); |
134 |
< |
hist = new TH1F("htemp", |
135 |
< |
(strlen(cut) ? TString(expr)+"{"+cut+"}" : TString(expr)), |
136 |
< |
gEnv->GetValue("Hist.Binning.1D.x",100), 0, 0); |
137 |
< |
hist->SetBit(TH1::kCanRebin); |
133 |
> |
if (TString(drawopt).Contains("same",TString::kIgnoreCase) && |
134 |
> |
gDirectory && gDirectory->Get("htemp") != 0 && |
135 |
> |
gDirectory->Get("htemp")->IsA()->InheritsFrom(TH1::Class())) { |
136 |
> |
hist = (TH1*) gDirectory->Get("htemp")->Clone(); |
137 |
> |
hist->Reset(); |
138 |
> |
} else { |
139 |
> |
htempDelete(); |
140 |
> |
hist = new TH1F("htemp", |
141 |
> |
(strlen(cut) ? TString(expr)+"{"+cut+"}" : TString(expr)), |
142 |
> |
gEnv->GetValue("Hist.Binning.1D.x",100), 0, 0); |
143 |
> |
hist->SetBit(TH1::kCanRebin); |
144 |
> |
} |
145 |
|
} |
146 |
|
|
147 |
|
// fill histogram |