00001
00002 #include "cafe/Select.hpp"
00003 #include "cafe/Config.hpp"
00004 #include "cafe/Event.hpp"
00005 #include "cafe/SelectBranches.hpp"
00006
00007 #include "TTreeFormula.h"
00008
00009 namespace cafe {
00010
00011 Select::Select(const char *name)
00012 : Processor(name),
00013 Formula(this)
00014 {
00015
00016 Config config(name);
00017 std::string expr = config.get("Select","1");
00018
00019 _tag = config.get("Tag","");
00020 _branches = config.getVString("Variables", " ,");
00021
00022 setFormula(expr);
00023 out() << "Select[" << name << "]: " << expr << std::endl;
00024 if(_tag != "") {
00025 out() << "Select[" << name << "]: Tag = " << _tag << std::endl;
00026 }
00027 }
00028
00029 void Select::inputFileOpened(TFile *file)
00030 {
00031 Formula::inputFileOpened(file);
00032 getFormula()->SetQuickLoad(kTRUE);
00033 }
00034
00035 bool Select::processEvent(Event& event)
00036 {
00037 SelectBranches enable(event, _branches);
00038
00039
00040 TTreeFormula *formula = getFormula();
00041 int ndata = formula->GetNdata();
00042 for(int i = 0; i < ndata; i++) {
00043 if(formula->EvalInstance(i) > 0.0) {
00044 if(_tag != "") {
00045 event.tag(_tag);
00046 }
00047 return true;
00048 }
00049 }
00050 return _tag != "" ? true : false;
00051 }
00052
00053 }
00054
00055 ClassImp(cafe::Select)