10 |
|
#if !defined(__CINT__) && !defined(__MAKECINT__) |
11 |
|
#include "UserCode/GPetrucc/interface/fwliteHelpers.h" |
12 |
|
#else |
13 |
+ |
#ifndef UserCode_GPetrucc_CINT_load_library |
14 |
+ |
#define UserCode_GPetrucc_CINT_load_library |
15 |
|
// load the library that contains the dictionaries |
16 |
|
int _load_UserCodeGPetrucc = gSystem->Load("libUserCodeGPetrucc.so"); |
17 |
|
#endif |
18 |
+ |
#endif |
19 |
+ |
|
20 |
+ |
#include "UserCode/GPetrucc/interface/fwlite/EventSelectors.h" |
21 |
|
|
22 |
|
namespace fwlite { |
23 |
|
template<typename T> |
25 |
|
public: |
26 |
|
typedef fwlite::Handle<std::vector<T> > HandleT; |
27 |
|
Scanner(fwlite::EventBase *ev, const char *label, const char *instance = "", const char *process="") : |
23 |
– |
//helper::ScannerBase(Reflex::Type::ByTypeInfo(typeid(T))), |
28 |
|
event_(ev), label_(label), instance_(instance), |
29 |
|
printFullEventId_(ev->isRealData()), |
30 |
+ |
ignoreExceptions_(false), |
31 |
|
exprSep_(":") |
32 |
|
{ |
33 |
< |
Reflex::Type wrapperType = Reflex::Type::ByTypeInfo(HandleT::TempWrapT::typeInfo()); |
34 |
< |
objType = helpme.elementType(Reflex::Type::ByTypeInfo(HandleT::TempWrapT::typeInfo())); |
33 |
> |
objType = helper::Parser::elementType(Reflex::Type::ByTypeInfo(HandleT::TempWrapT::typeInfo())); |
34 |
> |
eventSelectors_.SetOwner(); |
35 |
|
} |
36 |
|
|
37 |
|
|
38 |
|
void scan(const char *exprs, const char *cut="", int nmax=20) { |
39 |
|
helper::ScannerBase scanner(objType); |
40 |
+ |
scanner.setIgnoreExceptions(ignoreExceptions_); |
41 |
|
|
42 |
|
TObjArray *exprArray = TString(exprs).Tokenize(exprSep_); |
43 |
|
int rowline = 0; |
64 |
|
if (strlen(cut)) scanner.setCut(cut); |
65 |
|
|
66 |
|
int iev = 0; |
67 |
< |
for (event_->toBegin(); (iev < nmax) && !event_->atEnd(); ++iev, ++(*event_)) { |
67 |
> |
for (event_->toBegin(); (iev != nmax) && !event_->atEnd(); ++iev, ++(*event_)) { |
68 |
> |
if (!selectEvent(*event_)) continue; |
69 |
|
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
70 |
|
const std::vector<T> & vals = *handle_; |
71 |
|
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
87 |
|
TH1 * draw(const char *expr, const char *cut = "", TString drawopt = "", TH1 *hist = 0) { |
88 |
|
// prep the machinery |
89 |
|
helper::ScannerBase scanner(objType); |
90 |
+ |
scanner.setIgnoreExceptions(ignoreExceptions_); |
91 |
|
scanner.addExpression(expr); |
92 |
|
if (strlen(cut)) scanner.setCut(cut); |
93 |
|
|
101 |
|
|
102 |
|
// fill histogram |
103 |
|
for (event_->toBegin(); !event_->atEnd(); ++(*event_)) { |
104 |
+ |
if (!selectEvent(*event_)) continue; |
105 |
|
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
106 |
|
const std::vector<T> & vals = *handle_; |
107 |
|
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
120 |
|
TProfile * drawProf(TString xexpr, TString yexpr, const char *cut = "", TString drawopt = "", TProfile *hist = 0) { |
121 |
|
// prep the machinery |
122 |
|
helper::ScannerBase scanner(objType); |
123 |
+ |
scanner.setIgnoreExceptions(ignoreExceptions_); |
124 |
|
scanner.addExpression(xexpr); |
125 |
|
scanner.addExpression(yexpr); |
126 |
|
if (strlen(cut)) scanner.setCut(cut); |
135 |
|
|
136 |
|
// fill histogram |
137 |
|
for (event_->toBegin(); !event_->atEnd(); ++(*event_)) { |
138 |
+ |
if (!selectEvent(*event_)) continue; |
139 |
|
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
140 |
|
const std::vector<T> & vals = *handle_; |
141 |
|
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
154 |
|
TH2 * draw2D(TString xexpr, TString yexpr, const char *cut = "", TString drawopt = "", TH2 *hist = 0) { |
155 |
|
// prep the machinery |
156 |
|
helper::ScannerBase scanner(objType); |
157 |
+ |
scanner.setIgnoreExceptions(ignoreExceptions_); |
158 |
|
scanner.addExpression(xexpr); |
159 |
|
scanner.addExpression(yexpr); |
160 |
|
if (strlen(cut)) scanner.setCut(cut); |
170 |
|
|
171 |
|
// fill histogram |
172 |
|
for (event_->toBegin(); !event_->atEnd(); ++(*event_)) { |
173 |
+ |
if (!selectEvent(*event_)) continue; |
174 |
|
handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str()); |
175 |
|
const std::vector<T> & vals = *handle_; |
176 |
|
for (size_t j = 0, n = vals.size(); j < n; ++j) { |
193 |
|
|
194 |
|
void setPrintFullEventId(bool printIt=true) { printFullEventId_ = printIt; } |
195 |
|
void setExpressionSeparator(TString separator) { exprSep_ = separator; } |
196 |
+ |
void setIgnoreExceptions(bool ignoreThem) { ignoreExceptions_ = ignoreThem; } |
197 |
+ |
|
198 |
+ |
void addEventSelector(fwlite::EventSelector *selector) { eventSelectors_.Add(selector); } |
199 |
+ |
void clearEventSelector() { eventSelectors_.Clear(); } |
200 |
+ |
TObjArray & eventSelectors() { return eventSelectors_; } |
201 |
+ |
bool selectEvent(const fwlite::EventBase &ev) const { |
202 |
+ |
for (int i = 0, n = eventSelectors_.GetEntries(); i < n; ++i) { |
203 |
+ |
if (!((fwlite::EventSelector *)(eventSelectors_[i]))->accept(ev)) return false; |
204 |
+ |
} |
205 |
+ |
return true; |
206 |
+ |
} |
207 |
|
private: |
208 |
|
fwlite::EventBase *event_; |
209 |
|
std::string label_, instance_, process_; |
210 |
|
bool printFullEventId_; |
211 |
+ |
bool ignoreExceptions_; |
212 |
|
TString exprSep_; |
213 |
|
HandleT handle_; |
189 |
– |
helper::Parser helpme; |
214 |
|
Reflex::Type objType; |
215 |
|
|
216 |
+ |
TObjArray eventSelectors_; |
217 |
+ |
|
218 |
|
}; |
219 |
|
} |