13 #include <JANA/JApplication.h>
14 #include <JANA/JApplication.h>
33 #define ansi_escape ((char)0x1b)
34 #define ansi_bold ansi_escape<<"[1m"
35 #define ansi_black ansi_escape<<"[30m"
36 #define ansi_red ansi_escape<<"[31m"
37 #define ansi_green ansi_escape<<"[32m"
38 #define ansi_blue ansi_escape<<"[34m"
39 #define ansi_normal ansi_escape<<"[0m"
40 #define ansi_up(A) ansi_escape<<"["<<(A)<<"A"
41 #define ansi_down(A) ansi_escape<<"["<<(A)<<"B"
42 #define ansi_forward(A) ansi_escape<<"["<<(A)<<"C"
43 #define ansi_back(A) ansi_escape<<"["<<(A)<<"D"
50 vector<string> factory_names;
51 eventLoop->GetFactoryNames(factory_names);
58 for(
auto fac_name : factory_names)
toprint.insert(fac_name);
61 for(
auto fac_name : factory_names)
tosummarize.insert(fac_name);
67 set<string> core_factories;
81 set<string> really_toprint;
85 for(
unsigned int j=0;j<factory_names.size();j++){
86 if(factory_names[j] == fac_name)found =
true;
87 if(factory_names[j] ==
"D" + fac_name)dfound =
true;
90 really_toprint.insert(fac_name);
92 really_toprint.insert(
"D" + fac_name);
95 <<
" Couldn't find factory for \""
100 toprint = really_toprint;
112 unsigned int pos = fac_name.rfind(
":",fac_name.size()-1);
113 if(pos != (
unsigned int)string::npos){
114 tag = fac_name.substr(pos+1,fac_name.size());
121 fac_info.push_back(f);
138 int event_is_boring = 1;
140 for(
unsigned int i=0;i<
toprint.size();i++){
142 string name =fac_info[i].dataClassName;
143 string tag = fac_info[i].tag;
144 JFactory_base *factory = eventLoop->GetFactory(name,tag.c_str());
145 if(!factory)factory = eventLoop->GetFactory(
"D" + name,tag.c_str());
148 if(factory->GetNrows()>0){
162 cout<<
"================================================================"<<endl;
163 cout<<
"Event: "<<eventnumber<<endl;
170 for(
auto fac : eventLoop->GetFactories() ){
171 string name = fac->GetDataClassName();
172 string tag = fac->Tag()==NULL ?
"":fac->Tag();
173 if(tag.size()>0)name = name +
":" + tag;
182 for(
unsigned int i=0;i<fac_info.size();i++){
184 string name =fac_info[i].dataClassName;
185 string tag = fac_info[i].tag;
186 eventLoop->Print(name,tag.c_str());
195 if(eventLoop->GetJApplication()->GetQuittingStatus())
return NOERROR;
200 cout<<endl<<
"< Hit return for the next event (P=prev. Q=quit) >";
207 eventLoop->QuitProgram();
229 JFactory_base *fac =
const_cast<JFactory_base*
>(fac_info->
fac);
233 vector<void*> vobjs = fac->Get();
234 vector<JObject*> objs;
235 for(
unsigned int i=0; i<vobjs.size(); i++)objs.push_back((JObject*)vobjs[i]);
238 for(
unsigned int i=0; i<objs.size(); i++){
241 vector<const JObject*> aobjs;
242 objs[i]->GetT(aobjs);
244 if(aobjs.size()==0)
continue;
247 cout<<
" [== Associated objects for row "<<i<<
" ==]"<<endl;
250 map<JFactory_base*, vector<const JObject*> > aofacs;
251 for(
unsigned int j=0; j<aobjs.size(); j++){
252 JFactory_base *aofac = loop->FindOwner(aobjs[j]);
254 map<JFactory_base*, vector<const JObject*> >::iterator iter = aofacs.find(aofac);
255 if(iter==aofacs.end()){
256 vector<const JObject*> tmp;
260 aofacs[aofac].push_back(aobjs[j]);
263 map<JFactory_base*, vector<const JObject*> >::iterator iter;
264 unsigned int indent=4;
265 for(iter=aofacs.begin(); iter!=aofacs.end(); iter++){
266 JFactory_base *fac = iter->first;
267 string name = fac->GetDataClassName();
268 if(strlen(fac->Tag())!=0)name +=
string(
":") + fac->Tag();
269 if(name.length()>indent)indent=name.length();
275 for(iter=aofacs.begin(); iter!=aofacs.end(); iter++){
276 JFactory_base *fac = iter->first;
277 vector<const JObject*> &ptrs = iter->second;
280 string name = fac->GetDataClassName();
281 if(strlen(fac->Tag())!=0)name +=
string(
":") + fac->Tag();
282 cout<<
string(indent-name.length()-1,
' ');
286 for(
unsigned int j=0; j<ptrs.size(); j++){
287 if(j!=0)cout<<
string(indent,
' ');
288 cout<<
"0x"<<hex<<(
unsigned long)ptrs[j]<<dec<<endl;
bool LIST_ASSOCIATED_OBJECTS
bool PRINT_SUMMARY_HEADER
jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
Called once at program start.
bool PAUSE_BETWEEN_EVENTS
set< string > tosummarize
bool ACTIVATE_TAGGED_FOR_SUMMARY
void PrintAssociatedObjects(JEventLoop *eventLoop, const factory_info_t *fac_info)
jerror_t evnt(JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
Called after last event of last event source has been processed.