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