IfPr.cpp

Go to the documentation of this file.
00001 #include "cafe/IfPr.hpp"
00002 #include "cafe/ParseRun.hpp"
00003 #include "cafe/Config.hpp"
00004 #include "cafe/Event.hpp"
00005 
00006 #include "TFile.h"
00007 #include "TTreeFormula.h"
00008 
00009 #include <iostream>
00010 #include <vector>
00011 
00012 namespace cafe {
00013 
00014     IfPr::IfPr(const char *name) 
00015       : Controller(name, std::list<Processor*>())
00016     {
00017         using namespace std;
00018 
00019         Config config(name);
00020 
00021         // Get select/then/else branches
00022         ParseRun parser;
00023         string pelse =  config.get("Else", "") ;
00024         add(new Controller((string(name) + "_Select").c_str(), parser.parse(config.get("Select", ""))));
00025         add(new Controller((string(name) + "_Then").c_str(), parser.parse(config.get("Then", ""))));
00026         if (!pelse.empty()) 
00027           add(new Controller((string(name) + "_Else").c_str(), parser.parse(pelse))); 
00028 
00029         // Be nice and tell user if he specified the .Run: entry
00030         if(config.get("Run","") != "") {
00031             err() << "IfPr[" << name << "]: .Run not used in IfPr[]. .Use 'Then:' and '.Else:' instead" << endl;
00032         }
00033 
00034         _untag = config.getVString("Untag", " ,");
00035         _tag = config.getVString("Tag", " ,");
00036     }
00037 
00038     IfPr::~IfPr() {}
00039 
00040 
00041     // Processor interface
00042     bool IfPr::processEvent(Event& event)
00043     {
00044         event.untag(_untag.begin(), _untag.end());
00045         event.tag(_tag.begin(), _tag.end());
00046 
00047         if(_processors.size() == 0) return true ;
00048         std::list<Processor*>::iterator it = _processors.begin();
00049         // call first subprocessor
00050         
00051         (*it)->incEventCount();
00052         if ((*it)->processEvent(event)) {           
00053           // call second subprocessor(than)
00054           ++it;
00055           (*it)->incEventCount();
00056           return (*it)->processEvent(event) ;
00057         }                 
00058           // call any other subprocessor, abort if
00059           // any of them returns false.
00060           ++it;
00061           ++it;
00062           while(it != _processors.end()) {
00063             (*it)->incEventCount();
00064             if(!(*it)->processEvent(event)) return false;
00065             ++it;
00066           }
00067         
00068         return true;
00069     }
00070 }
00071 
00072 ClassImp(cafe::IfPr);
00073 

Generated on Thu Apr 3 04:14:23 2008 for CAF by doxygen 1.3.4