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