00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ComGetCurrentEvent.h"
00015
00016 #include <stdio.h>
00017
00018 #include "TTree.h"
00019
00020 #include "TGo4Log.h"
00021 #include "TGo4AnalysisClientImp.h"
00022 #include "TGo4AnalysisImp.h"
00023 #include "TGo4EventElement.h"
00024 #include "TGo4RemoteCommand.h"
00025
00026 TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent(const char* obname) :
00027 TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis",obname),
00028 fbOutputEvent(kTRUE),
00029 fbPrintoutOnly(kFALSE),
00030 fbTreeMode(kTRUE)
00031 {
00032 GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent(const char*) ctor",__LINE__, __FILE__));
00033 SetReceiverName("AnalysisClient");
00034
00035 }
00036
00037 TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent() :
00038 TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis","his"),
00039 fbOutputEvent(kTRUE),
00040 fbPrintoutOnly(kFALSE),
00041 fbTreeMode(kTRUE)
00042 {
00043 GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent() ctor",__LINE__, __FILE__));
00044 SetReceiverName("AnalysisClient");
00045
00046 }
00047
00048 TGo4ComGetCurrentEvent::~TGo4ComGetCurrentEvent()
00049 {
00050 GO4TRACE((12,"TGo4ComGetCurrentEvent::~TGo4ComGetCurrentEvent() dtor",__LINE__, __FILE__));
00051 }
00052
00053
00054 Int_t TGo4ComGetCurrentEvent::ExeCom()
00055 {
00056 GO4TRACE((12,"TGo4ComGetCurrentEvent::ExeCom()",__LINE__, __FILE__));
00057
00058 TGo4Log::Debug(" Executing %s : Event %s requested, isoutput=%d, printoutonly=%d ",
00059 GetName(), GetObjectName(), IsOutputEvent(), IsPrintoutOnly() );
00060
00061 TGo4AnalysisClient* cli = dynamic_cast<TGo4AnalysisClient*> (fxReceiverBase);
00062
00063 if (cli==0) {
00064 GO4TRACE((11,"TGo4ComGetCurrentEvent::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
00065 TGo4Log::Debug(" !!! %s : NO or WRONG RECEIVER ERROR!!!",GetName());
00066 return 1;
00067 }
00068
00069 TGo4Analysis* ana = TGo4Analysis::Instance();
00070 if (ana==0) {
00071
00072 cli->SendStatusMessage(3, kTRUE,TString::Format(" %s ERROR no analysis ",GetName()));
00073 return -2;
00074 }
00075
00076 if(IsTreeMode()) {
00077
00078 if(IsPrintoutOnly()) {
00079
00080 ana->ShowEvent(GetObjectName(), IsOutputEvent());
00081 } else {
00082 TTree* sampletree = ana->CreateSingleEventTree(GetObjectName(), IsOutputEvent());
00083 if(sampletree) {
00084 cli->SendObject(sampletree, GetTaskName());
00085 delete sampletree;
00086 } else {
00087 cli->SendStatusMessage(3, kTRUE,TString::Format(
00088 "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
00089 }
00090 }
00091 }
00092 else
00093 {
00094
00095 TGo4EventElement* event=0;
00096 if(IsOutputEvent())
00097 event=ana->GetOutputEvent(GetObjectName());
00098 else
00099 event=ana->GetInputEvent(GetObjectName());
00100 if(event==0)
00101
00102 event = ana->GetEventStructure(GetObjectName());
00103 if(event) {
00104 if (IsPrintoutOnly())
00105 event->PrintEvent();
00106 else
00107 cli->SendObject(event, GetTaskName());
00108 }
00109 else
00110 {
00111 cli->SendStatusMessage(3, kTRUE,TString::Format(
00112 "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
00113 }
00114 }
00115
00116 if (IsPrintoutOnly()) {
00117 fflush(stderr);
00118 fflush(stdout);
00119 }
00120
00121 return -1;
00122 }
00123
00124 void TGo4ComGetCurrentEvent::Set(TGo4RemoteCommand* remcom)
00125 {
00126 if(remcom==0) return;
00127 TGo4AnalysisObjectCommand::Set(remcom);
00128 fbOutputEvent = remcom->GetValue(0);
00129 fbPrintoutOnly = remcom->GetValue(1);
00130 fbTreeMode = remcom->GetValue(2);
00131 }