GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ComGetCurrentEvent.cxx
Go to the documentation of this file.
1 // $Id: TGo4ComGetCurrentEvent.cxx 2745 2020-04-16 08:55:15Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ComGetCurrentEvent.h"
15 
16 #include "TTree.h"
17 
18 #include "TGo4Log.h"
19 #include "TGo4AnalysisClientImp.h"
20 #include "TGo4AnalysisImp.h"
21 #include "TGo4EventElement.h"
22 #include "TGo4RemoteCommand.h"
23 
25  TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis",obname),
26  fbOutputEvent(kTRUE),
27  fbPrintoutOnly(kFALSE),
28  fbTreeMode(kTRUE)
29 {
30  GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent(const char*) ctor",__LINE__, __FILE__));
31  SetReceiverName("AnalysisClient"); // this command needs client as receiver
32  // override default receiver
33 }
34 
36  TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis","his"),
37  fbOutputEvent(kTRUE),
38  fbPrintoutOnly(kFALSE),
39  fbTreeMode(kTRUE)
40  {
41  GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent() ctor",__LINE__, __FILE__));
42  SetReceiverName("AnalysisClient"); // this command needs client as receiver
43  // override default receiver
44 }
45 
47 {
48  GO4TRACE((12,"TGo4ComGetCurrentEvent::~TGo4ComGetCurrentEvent() dtor",__LINE__, __FILE__));
49 }
50 
51 
53 {
54  GO4TRACE((12,"TGo4ComGetCurrentEvent::ExeCom()",__LINE__, __FILE__));
55 
56  TGo4Log::Debug(" Executing %s : Event %s requested, isoutput=%d, printoutonly=%d ",
57  GetName(), GetObjectName(), IsOutputEvent(), IsPrintoutOnly() );
58 
60 
61  if (cli==0) {
62  GO4TRACE((11,"TGo4ComGetCurrentEvent::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
63  TGo4Log::Debug(" !!! %s : NO or WRONG RECEIVER ERROR!!!",GetName());
64  return 1;
65  }
66 
68  if (ana==0) {
69  // never come here
70  cli->SendStatusMessage(3, kTRUE,TString::Format(" %s ERROR no analysis ",GetName()));
71  return -2;
72  }
73 
74  if(IsTreeMode()) {
75  // tree mode:
76  if(IsPrintoutOnly()) {
77  // only display event content on terminal
79  } else {
80  TTree* sampletree = ana->CreateSingleEventTree(GetObjectName(), IsOutputEvent());
81  if(sampletree) {
82  cli->SendObject(sampletree, GetTaskName());
83  delete sampletree;
84  } else {
85  cli->SendStatusMessage(3, kTRUE,TString::Format(
86  "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
87  }
88  }// if(IsPrintoutOnly())
89  }// if(IsTreeMode())
90  else
91  {
92  // event mode:
93  TGo4EventElement* event=0;
94  if(IsOutputEvent())
95  event=ana->GetOutputEvent(GetObjectName());
96  else
97  event=ana->GetInputEvent(GetObjectName());
98  if(event==0)
99  // event step of name does not exists, we search event in folder:
100  event = ana->GetEventStructure(GetObjectName());
101  if(event) {
102  if (IsPrintoutOnly())
103  event->PrintEvent();
104  else
105  cli->SendObject(event, GetTaskName());
106  }
107  else
108  {
109  cli->SendStatusMessage(3, kTRUE,TString::Format(
110  "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
111  } // if(event)
112  } // if(IsTreeMode())
113 
114  if (IsPrintoutOnly()) {
115  fflush(stderr);
116  fflush(stdout);
117  }
118 
119  return -1;
120 }
121 
123 {
124  if(remcom==0) return;
126  fbOutputEvent = remcom->GetValue(0);
127  fbPrintoutOnly = remcom->GetValue(1);
128  fbTreeMode = remcom->GetValue(2);
129 }
void SetReceiverName(const char *)
Definition: TGo4Command.cxx:93
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
TGo4CommandReceiver * fxReceiverBase
Definition: TGo4Command.h:116
TGo4EventElement * GetOutputEvent(const char *stepname)
virtual void Set(TGo4RemoteCommand *remcon)
const char * GetTaskName() const
Definition: TGo4Command.cxx:99
void ShowEvent(const char *stepname, Bool_t isoutput=kTRUE)
Int_t GetValue(Int_t i) const
virtual void PrintEvent()
TTree * CreateSingleEventTree(const char *name, Bool_t isoutput=kTRUE)
virtual void Set(TGo4RemoteCommand *remcon)
TGo4EventElement * GetEventStructure(const char *name)
const char * GetObjectName() const
TGo4EventElement * GetInputEvent(const char *stepname)
void SendObject(TObject *obj, const char *receiver=0)
Definition: TGo4Slave.cxx:119
#define GO4TRACE(X)
Definition: TGo4Log.h:26
static TGo4Analysis * Instance()
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:284