// Author: David Lawrence June 25, 2004 // // // MyProcessor.cc // #include using namespace std; #include #include #include "MyProcessor.h" int PAUSE_BETWEEN_EVENTS = 1; int SKIP_BORING_EVENTS = 0; int PRINT_ALL=0; bool LIST_ASSOCIATED_OBJECTS = false; vector toprint; #define ansi_escape ((char)0x1b) #define ansi_bold ansi_escape<<"[1m" #define ansi_black ansi_escape<<"[30m" #define ansi_red ansi_escape<<"[31m" #define ansi_green ansi_escape<<"[32m" #define ansi_blue ansi_escape<<"[34m" #define ansi_normal ansi_escape<<"[0m" #define ansi_up(A) ansi_escape<<"["<<(A)<<"A" #define ansi_down(A) ansi_escape<<"["<<(A)<<"B" #define ansi_forward(A) ansi_escape<<"["<<(A)<<"C" #define ansi_back(A) ansi_escape<<"["<<(A)<<"D" //------------------------------------------------------------------ // brun //------------------------------------------------------------------ jerror_t MyProcessor::brun(JEventLoop *eventLoop, int runnumber) { vector factory_names; eventLoop->GetFactoryNames(factory_names); usleep(100000); //this just gives the Main thread a chance to finish printing the "Launching threads" message cout< really_toprint; for(unsigned int i=0; iGetFactory(f.dataClassName, f.tag.c_str()); fac_info.push_back(f); } cout<GetFactory(name,tag.c_str()); if(!factory)factory = eventLoop->GetFactory("D" + name,tag.c_str()); if(factory){ try{ if(factory->GetNrows()>0){ event_is_boring=0; break; } }catch(...){ // someone threw an exception } } } if(event_is_boring)return NOERROR; }else{ event_is_boring = 0; } // Print event separator cout<<"================================================================"< myfacs = eventLoop->GetFactories(); for(unsigned int i=0; iGetNrows(); eventLoop->PrintFactories(1); // Print data for all specified factories for(unsigned int i=0;iPrint(name,tag.c_str()); if(LIST_ASSOCIATED_OBJECTS)PrintAssociatedObjects(eventLoop, &fac_info[i]); }catch(...){ // exception thrown } } // Wait for user input if pausing if(PAUSE_BETWEEN_EVENTS && !event_is_boring){ cerr.flush(); cout<"; cout.flush(); char c = getchar(); // see note in hd_dump.cc:main() if(c=='\n')cout<Quit(); break; case 'P': //eventLoop->GotoEvent(eventnumber-1); break; case 'N': break; } cout<(fac_info->fac); if(!fac)return; // Get list of all objects from this factory vector vobjs = fac->Get(); vector objs; for(unsigned int i=0; i aobjs; objs[i]->GetT(aobjs); // If no associated objects, just go on to the next object if(aobjs.size()==0)continue; // Print separator cout<<" [== Associated objects for row "< > aofacs; for(unsigned int j=0; jFindOwner(aobjs[j]); map >::iterator iter = aofacs.find(aofac); if(iter==aofacs.end()){ vector tmp; aofacs[aofac] = tmp; } // Record this object as belonging to this factory aofacs[aofac].push_back(aobjs[j]); } // Figure out number of spaces to indent objects based on factory name length map >::iterator iter; unsigned int indent=4; // some minimal string length for(iter=aofacs.begin(); iter!=aofacs.end(); iter++){ JFactory_base *fac = iter->first; string name = fac->GetDataClassName(); if(strlen(fac->Tag())!=0)name += string(":") + fac->Tag(); if(name.length()>indent)indent=name.length(); } indent += 4; // indent the factory name itself // Loop over factories that produced associated objects for this object and // list the objects it created for(iter=aofacs.begin(); iter!=aofacs.end(); iter++){ JFactory_base *fac = iter->first; vector &ptrs = iter->second; // Print out factory name string name = fac->GetDataClassName(); if(strlen(fac->Tag())!=0)name += string(":") + fac->Tag(); cout<