ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/GPetrucc/interface/fwlite/Scanner.h
(Generate patch)

Comparing UserCode/GPetrucc/interface/fwlite/Scanner.h (file contents):
Revision 1.9 by gpetrucc, Thu Feb 11 11:15:18 2010 UTC vs.
Revision 1.11 by gpetrucc, Wed Mar 3 09:29:53 2010 UTC

# Line 31 | Line 31 | namespace fwlite {
31                  printFullEventId_(ev->isRealData()),
32                  ignoreExceptions_(false),
33                  exprSep_(":"),
34 +                maxEntries_(-1),
35                  maxLinesToPrint_(50)
36              {
37                  objType = helper::Parser::elementType(Reflex::Type::ByTypeInfo(HandleT::TempWrapT::typeInfo()));
# Line 109 | Line 110 | namespace fwlite {
110                  scanner.setCut(cut);
111  
112                  size_t npass = 0;
113 <                for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
113 >                int iev = 0;
114 >                for (event_->toBegin(); !event_->atEnd(); ++(*event_), ++iev) {
115 >                    if (maxEntries_ > -1 && iev > maxEntries_) break;
116                      if (!selectEvent(*event_)) continue;
117                      handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
118                      const std::vector<T> & vals = *handle_;
# Line 117 | Line 120 | namespace fwlite {
120                          if (scanner.test(&vals[j])) npass++;
121                      }
122                  }
120
123                  return npass;
124              }
125 <
125 >
126              TH1 * draw(const char *expr, const char *cut = "", TString drawopt = "", TH1 *hist = 0) {
127                  // prep the machinery
128                  helper::ScannerBase scanner(objType);
# Line 135 | Line 137 | namespace fwlite {
137                          gDirectory->Get("htemp")->IsA()->InheritsFrom(TH1::Class())) {
138                          hist = (TH1*) gDirectory->Get("htemp")->Clone();
139                          hist->Reset();
140 +                        hist->SetLineColor(kBlack);
141 +                        hist->SetMarkerColor(kBlack);
142                      } else {
143                          htempDelete();
144                          hist = new TH1F("htemp",
# Line 145 | Line 149 | namespace fwlite {
149                  }
150  
151                  // fill histogram
152 <                for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
152 >                int iev = 0;
153 >                for (event_->toBegin(); !event_->atEnd(); ++(*event_), ++iev) {
154 >                    if (maxEntries_ > -1 && iev > maxEntries_) break;
155                      if (!selectEvent(*event_)) continue;
156                      handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
157                      const std::vector<T> & vals = *handle_;
# Line 154 | Line 160 | namespace fwlite {
160                      }
161                  }
162  
163 +                if (TString(drawopt).Contains("NORM",TString::kIgnoreCase) && (hist->Integral() != 0)) hist->Scale(1.0/hist->Integral());
164 +
165                  if (!TString(drawopt).Contains("goff",TString::kIgnoreCase)) hist->Draw(drawopt);
166                  return hist;
167              }
168              TH1 * draw(const char *expr, int bins, double xlow, double xhigh, const char *cut = "", const char *drawopt = "") {
169 +                if (!TString(drawopt).Contains("same",TString::kIgnoreCase)) return drawProf(expr,cut,drawopt);
170                  htempDelete();
171                  TH1 * htemp = new TH1F("htemp", (strlen(cut) ? TString(expr)+"{"+cut+"}" : TString(expr)), bins, xlow, xhigh);
172                  return draw(expr,cut,drawopt,htemp);
# Line 181 | Line 190 | namespace fwlite {
190                  }
191  
192                  // fill histogram
193 <                for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
193 >                int iev = 0;
194 >                for (event_->toBegin(); !event_->atEnd(); ++(*event_), ++iev) {
195 >                    if (maxEntries_ > -1 && iev > maxEntries_) break;
196                      if (!selectEvent(*event_)) continue;
197                      handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
198                      const std::vector<T> & vals = *handle_;
# Line 207 | Line 218 | namespace fwlite {
218                  if (!scanner.addExpression((const char *)yexpr)) return 0;
219                  if (strlen(cut)) scanner.setCut(cut);
220  
221 +                int iev = 0;
222                  // make histo, if needed
223                  if (hist == 0) {
224                      // ok this is much more a hack than for the 1D case
225                      double xmin = 0, xmax = -1, ymin = 0, ymax = -1;
226 <                    for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
226 >                    for (event_->toBegin(), iev = 0; !event_->atEnd(); ++(*event_), ++iev) {
227 >                        if (maxEntries_ > -1 && iev > maxEntries_) break;
228                          if (!selectEvent(*event_)) continue;
229                          handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
230                          const std::vector<T> & vals = *handle_;
# Line 233 | Line 246 | namespace fwlite {
246                  }
247  
248                  // fill histogram
249 <                for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
249 >                for (event_->toBegin(), iev = 0; !event_->atEnd(); ++(*event_), ++iev) {
250 >                    if (maxEntries_ > -1 && iev > maxEntries_) break;
251                      if (!selectEvent(*event_)) continue;
252                      handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
253                      const std::vector<T> & vals = *handle_;
# Line 273 | Line 287 | namespace fwlite {
287                  }
288  
289                  // fill graph
290 <                for (event_->toBegin(); !event_->atEnd(); ++(*event_)) {
290 >                int iev = 0;
291 >                for (event_->toBegin(); !event_->atEnd(); ++(*event_), ++iev) {
292 >                    if (maxEntries_ > -1 && iev > maxEntries_) break;
293                      if (!selectEvent(*event_)) continue;
294                      handle_.getByLabel(*event_, label_.c_str(), instance_.c_str(), process_.c_str());
295                      const std::vector<T> & vals = *handle_;
# Line 302 | Line 318 | namespace fwlite {
318                  }
319                  return true;
320              }
321 +
322 +            void setMaxEntries(int max) { maxEntries_ = max; }
323          private:
324              fwlite::EventBase *event_;
325              std::string    label_, instance_, process_;
# Line 313 | Line 331 | namespace fwlite {
331  
332              TObjArray eventSelectors_;
333  
334 +            int maxEntries_;
335 +
336              int maxLinesToPrint_;
337              bool wantMore() const {
338                  // ask if user wants more

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines