Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

FindDuplicateEvents.cpp

Go to the documentation of this file.
00001 #include "caf_util/FindDuplicateEvents.hpp"
00002 #include "cafe/Config.hpp"
00003 
00004 using namespace std ;
00005 using namespace cafe ;
00006  
00007 namespace caf_util {
00008 
00009   FindDuplicateEvents::FindDuplicateEvents(const char *name) 
00010     : cafe::Processor(name), _vars("_runno", "_evtno")
00011  {
00012     // get parameters from the configuration file
00013     cafe::Config config(name);
00014 
00015     _nscreams   = config.get("Nscreams", 1);
00016     _ignoreMC   = config.get("IgnoreMC", true);
00017     _ndups = 0;
00018   };
00019   
00020   bool FindDuplicateEvents::processEvent(cafe::Event &event)
00021   {
00022     const TMBGlobal* global = event.getGlobal (_vars) ;
00023     assert (global);
00024     const int run = global->runno();
00025     const int evtno = global->evtno();
00026     
00027     // in lieu of an official way to check for MC, count MC chunks:
00028     const TMBMCevtInfo* pMC = event.getMCEventInfo ();
00029     int   nchunks = pMC? pMC->nchunks(): -1;
00030     if (debug() > 9) out()<<"run: "<<run<<" evt: "<<evtno<<" pMC: "<<(int)pMC<<" nc: "<<nchunks<<endl;
00031     if (_ignoreMC && nchunks > 0) return true;
00032 
00033     Key key (run, evtno);
00034 
00035     // look for it
00036     KeyIter pos = _keys.find (key);
00037     if (debug() > 1) {
00038       out()<<"FindDuplicatedEvents processor: size: "
00039            <<_keys.size()<<" ndups: "<<_ndups<<". run: "<<run<<" evt: "
00040            << evtno ;
00041       if (pos == _keys.end())
00042         out() << " New event." ;
00043       else 
00044         out() << " Duplicated event." ;
00045       out() << endl ;
00046     }
00047     // didn't find it in the set --> first appearance --> pass it through
00048     if (pos == _keys.end()) {
00049       _keys.insert (key);
00050       return true;
00051     }
00052 
00053     if (++_ndups <= _nscreams) {
00054       err()<<endl<<_line<<endl;
00055       err()<<"!  Warning: caf_util::FindDuplicateEvents["<<name()
00056            <<"] removed a duplicate event, run# "<<run<<", event# "<<evtno<<endl;
00057       err()<<_line<<endl<<endl;
00058     }
00059     return false;
00060   };
00061 
00062   void FindDuplicateEvents::finish() {
00063     if (_ndups > 0) {
00064       if (_nscreams > 0) out()<<endl<<_line<<endl;
00065       out()<<"WARNING: caf_util::FindDuplicateEvents["<<name()
00066            <<"] removed "<<_ndups<<" duplicate events."<<endl;
00067       if (_nscreams > 0) out()<<_line<<endl<<endl;
00068     }
00069   }
00070 
00071   const TString FindDuplicateEvents::_line
00072                 ("!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
00073 }
00074 ClassImp(caf_util::FindDuplicateEvents);
00075   

Generated on Tue Mar 28 10:13:04 2006 for CAF by doxygen 1.3.4