GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TXXXAnalysis.cxx
Go to the documentation of this file.
1 // $Id: TXXXAnalysis.cxx 1905 2016-04-27 07:54:31Z adamczew $
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 "TXXXAnalysis.h"
15 
16 #include <stdlib.h>
17 
18 #include "TGo4Version.h"
19 #include "TGo4Log.h"
20 #include "Go4EventServer.h"
21 #include "TGo4StepFactory.h"
22 #include "TGo4AnalysisStep.h"
23 
24 #include "TXXXControl.h"
25 
26 //***********************************************************
28  fMbsEvent(0),
29  fCtl(0),
30  fEvents(0),
31  fLastEvent(0)
32 {
33 }
34 //***********************************************************
35 
36 // this constructor is called by go4analysis executable
37 TXXXAnalysis::TXXXAnalysis(int argc, char** argv) :
38  TGo4Analysis(argc, argv),
39  fMbsEvent(0),
40  fCtl(0),
41  fEvents(0),
42  fLastEvent(0)
43 {
45  TGo4Log::Error("Go4 version mismatch");
46  exit(-1);
47  }
48 
49  TGo4Log::Info("Create TXXXAnalysis name: %s", argv[0]);
50 
51  TGo4StepFactory* factory = new TGo4StepFactory("Factory");
52  factory->DefEventProcessor("XXXProc","TXXXProc");// object name, class name
53  factory->DefOutputEvent("XXXEvent","TXXXEvent"); // object name, class name
54 
55 // Text_t lmdfile[512]; // source file
56 // sprintf(lmdfile,"%s/data/test.lmd",getenv("GO4SYS"));
57  // TGo4EventSourceParameter* sourcepar = new TGo4MbsTransportParameter("r3b");
59 
60  TGo4FileStoreParameter* storepar = new TGo4FileStoreParameter(Form("%sOutput", argv[0]));
61  storepar->SetOverwriteMode(kTRUE);
62 
63  TGo4AnalysisStep* step = new TGo4AnalysisStep("Analysis", factory, sourcepar, storepar);
64 
65  step->SetSourceEnabled(kTRUE);
66  step->SetStoreEnabled(kFALSE);
67  step->SetProcessEnabled(kTRUE);
68  step->SetErrorStopEnabled(kTRUE);
69 
70  // Now the first analysis step is set up.
71  // Other steps could be created here
72  AddAnalysisStep(step);
73 
74  // uncomment following line to define custom passwords for analysis server
75  // DefineServerPasswords("XXXadmin", "XXXctrl", "XXXview");
76 
78  // At this point, autosave file has not yet been read!
79  // Therefore parameter values set here will be overwritten
80  // if an autosave file is there.
81  fCtl = new TXXXControl("Control");
83 }
84 
85 //***********************************************************
87 {
88  TGo4Log::Info("TXXXAnalysis: Delete instance");
89 }
90 
91 //-----------------------------------------------------------
93 {
94  // all this is optional:
95  TGo4Log::Info("TXXXAnalysis: PreLoop");
96  // get pointer to input event (used in postloop and event function):
97  fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Analysis")); // of step "Analysis"
99  // fileheader structure (lmd file only):
100 
101  fEvents=0; // event counter
102  fLastEvent=0; // number of last event processed
103  return 0;
104 }
105 //-----------------------------------------------------------
107 {
108  // all this is optional:
109  TGo4Log::Info("TXXXAnalysis: PostLoop");
110  TGo4Log::Info("Last event #: %d Total events: %d", fLastEvent, fEvents);
111  fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
112  fEvents = 0;
113  return 0;
114 }
115 
116 //-----------------------------------------------------------
118 {
119  // all this is optional:
120  // This function is called once for each event after all steps.
121  if(fMbsEvent) {
122  fEvents++;
124  }
125  if((fEvents == 1) || IsNewInputFile()) {
126  TGo4Log::Info("First event #: %d", fLastEvent);
127  }
128  return 0;
129 }
Int_t fLastEvent
Definition: TXXXAnalysis.h:34
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
TGo4MbsEvent * fMbsEvent
Definition: TXXXAnalysis.h:31
virtual Int_t UserPreLoop()
void DefEventProcessor(const char *Pname, const char *Pclass)
friend class TGo4AnalysisStep
TXXXControl * fCtl
Definition: TXXXAnalysis.h:32
virtual Int_t UserEventFunc()
Bool_t IsNewInputFile() const
void SetSourceEnabled(Bool_t on=kTRUE)
void SetOverwriteMode(Bool_t over=kTRUE)
TGo4EventElement * GetInputEvent(const char *stepname)
void DefOutputEvent(const char *Oname, const char *Oclass)
Int_t GetCount() const
Definition: TGo4MbsEvent.h:149
#define __GO4BUILDVERSION__
Definition: TGo4Version.h:24
void SetStoreEnabled(Bool_t on=kTRUE)
void PrintMbsFileHeader()
virtual Int_t UserPostLoop()
void SetProcessEnabled(Bool_t on=kTRUE)
const char * GetDefaultTestFileName() const
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
void SetErrorStopEnabled(Bool_t on)
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283
virtual ~TXXXAnalysis()