GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ComGetCurrentEvent.cxx
Go to the documentation of this file.
1 // $Id: TGo4ComGetCurrentEvent.cxx 1001 2013-07-25 15:10:31Z 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 für 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 <stdio.h>
17 
18 #include "TTree.h"
19 
20 #include "TGo4Log.h"
21 #include "TGo4AnalysisClientImp.h"
22 #include "TGo4AnalysisImp.h"
23 #include "TGo4EventElement.h"
24 #include "TGo4RemoteCommand.h"
25 
27  TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis",obname),
28  fbOutputEvent(kTRUE),
29  fbPrintoutOnly(kFALSE),
30  fbTreeMode(kTRUE)
31 {
32  GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent(const char*) ctor",__LINE__, __FILE__));
33  SetReceiverName("AnalysisClient"); // this command needs client as receiver
34  // override default receiver
35 }
36 
38  TGo4AnalysisObjectCommand("ANGetEvent","Get current event from analysis","his"),
39  fbOutputEvent(kTRUE),
40  fbPrintoutOnly(kFALSE),
41  fbTreeMode(kTRUE)
42  {
43  GO4TRACE((12,"TGo4ComGetCurrentEvent::TGo4ComGetCurrentEvent() ctor",__LINE__, __FILE__));
44  SetReceiverName("AnalysisClient"); // this command needs client as receiver
45  // override default receiver
46 }
47 
49 {
50  GO4TRACE((12,"TGo4ComGetCurrentEvent::~TGo4ComGetCurrentEvent() dtor",__LINE__, __FILE__));
51 }
52 
53 
55 {
56  GO4TRACE((12,"TGo4ComGetCurrentEvent::ExeCom()",__LINE__, __FILE__));
57 
58  TGo4Log::Debug(" Executing %s : Event %s requested, isoutput=%d, printoutonly=%d ",
59  GetName(), GetObjectName(), IsOutputEvent(), IsPrintoutOnly() );
60 
62 
63  if (cli==0) {
64  GO4TRACE((11,"TGo4ComGetCurrentEvent::ExeCom() - no receiver specified ERROR!",__LINE__, __FILE__));
65  TGo4Log::Debug(" !!! %s : NO or WRONG RECEIVER ERROR!!!",GetName());
66  return 1;
67  }
68 
70  if (ana==0) {
71  // never come here
72  cli->SendStatusMessage(3, kTRUE,TString::Format(" %s ERROR no analysis ",GetName()));
73  return -2;
74  }
75 
76  if(IsTreeMode()) {
77  // tree mode:
78  if(IsPrintoutOnly()) {
79  // only display event content on terminal
81  } else {
82  TTree* sampletree = ana->CreateSingleEventTree(GetObjectName(), IsOutputEvent());
83  if(sampletree) {
84  cli->SendObject(sampletree, GetTaskName());
85  delete sampletree;
86  } else {
87  cli->SendStatusMessage(3, kTRUE,TString::Format(
88  "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
89  }
90  }// if(IsPrintoutOnly())
91  }// if(IsTreeMode())
92  else
93  {
94  // event mode:
95  TGo4EventElement* event=0;
96  if(IsOutputEvent())
97  event=ana->GetOutputEvent(GetObjectName());
98  else
99  event=ana->GetInputEvent(GetObjectName());
100  if(event==0)
101  // event step of name does not exists, we search event in folder:
102  event = ana->GetEventStructure(GetObjectName());
103  if(event) {
104  if (IsPrintoutOnly())
105  event->PrintEvent();
106  else
107  cli->SendObject(event, GetTaskName());
108  }
109  else
110  {
111  cli->SendStatusMessage(3, kTRUE,TString::Format(
112  "GetCurrentEvent %s - ERROR: no such event ", GetObjectName()));
113  } // if(event)
114  } // if(IsTreeMode())
115 
116  if (IsPrintoutOnly()) {
117  fflush(stderr);
118  fflush(stdout);
119  }
120 
121  return -1;
122 }
123 
125 {
126  if(remcom==0) return;
128  fbOutputEvent = remcom->GetValue(0);
129  fbPrintoutOnly = remcom->GetValue(1);
130  fbTreeMode = remcom->GetValue(2);
131 }
void SetReceiverName(const char *)
Definition: TGo4Command.cxx:92
virtual void SendStatusMessage(Int_t level, Bool_t printout, const TString &text)
TGo4CommandReceiver * fxReceiverBase
Definition: TGo4Command.h:117
TGo4EventElement * GetOutputEvent(const char *stepname)
virtual void Set(TGo4RemoteCommand *remcon)
const char * GetTaskName() const
Definition: TGo4Command.cxx:98
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:120
#define GO4TRACE(X)
Definition: TGo4Log.h:26
static TGo4Analysis * Instance()
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:270