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