GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
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 "TH1.h"
17
18#include "TGo4Log.h"
19#include "TGo4AnalysisStep.h"
20#include "TGo4StepFactory.h"
21
22#include "TXXXUnpackEvent.h"
23#include "TXXXAnlEvent.h"
24#include "TGo4Version.h"
25
26//***********************************************************
29{
30 TGo4Log::Error("Wrong constructor TXXXAnalysis()!");
31}
32
33//***********************************************************
34// this constructor is called by go4analysis executable
35TXXXAnalysis::TXXXAnalysis(int argc, char **argv) :
36 TGo4Analysis(argc, argv)
37{
39 TGo4Log::Error("Go4 version mismatch");
40 exit(-1);
41 }
42
43 TGo4Log::Info("TXXXAnalysis: Create %s", GetName());
44
45// Create step 1 Unpack.
46 TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
47 factory1->DefEventProcessor("UnpackProc", "TXXXUnpackProc");// object name, class name
48 factory1->DefOutputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
49 TGo4AnalysisStep *step1 = new TGo4AnalysisStep("Unpack", factory1, nullptr, nullptr, nullptr);
50 step1->SetErrorStopEnabled(kTRUE);
51 AddAnalysisStep(step1);
52// These settings will be overwritten by setup.C
53 step1->SetSourceEnabled(kTRUE);
54 step1->SetStoreEnabled(kFALSE);
55 step1->SetProcessEnabled(kTRUE);
56
57// Create step 2 Analysis.
58 TGo4StepFactory* factory2 = new TGo4StepFactory("AnalysisFactory");
59 factory2->DefInputEvent("UnpackEvent", "TXXXUnpackEvent"); // object name, class name
60 factory2->DefEventProcessor("AnlProc", "TXXXAnlProc"); // object name, class name
61 factory2->DefOutputEvent("AnlEvent", "TXXXAnlEvent"); // object name, class name
62 TGo4AnalysisStep *step2 = new TGo4AnalysisStep("Analysis", factory2, nullptr, nullptr, nullptr);
63 step2->SetErrorStopEnabled(kTRUE);
64 AddAnalysisStep(step2);
65// These settings will be overwritten by setup.C
66 step2->SetSourceEnabled(kFALSE);
67 step2->SetStoreEnabled(kFALSE);
68 step2->SetProcessEnabled(kTRUE);
69
70 // This condition is used in both steps.
71 // Therefore we create it here
72 fWinCon1 = MakeWinCond("wincon1", 50, 2000);
73}
74
75//-----------------------------------------------------------
77{
78 TGo4Log::Info("TXXXAnalysis: Delete");
79}
80
81//-----------------------------------------------------------
83{
84 TGo4Log::Info("TXXXAnalysis: PreLoop");
85 Print(); // printout the step settings
86 // we update the pointers to the current event structures here:
87 fMbsEvent = dynamic_cast<TGo4MbsEvent *> (GetInputEvent("Unpack")); // of step "Unpack"
88 fRawEvent = dynamic_cast<TXXXUnpackEvent *> (GetOutputEvent("Unpack"));
89 fCalEvent = dynamic_cast<TXXXAnlEvent *> (GetOutputEvent("Analysis"));
90 fEvents = 0;
91 fLastEvent = 0;
92
93 // create histogram for UserEventFunc
94 // At this point, the histogram has been restored
95 // from auto-save file if any.
96 fSize = MakeTH1('D', "Eventsize", "Event size [b]", 160, 1., 160.);
97 return 0;
98}
99
100//-----------------------------------------------------------
102{
103 TGo4Log::Info("TXXXAnalysis: PostLoop");
104 TGo4Log::Info("Last event: %d, total events: %d", fLastEvent, fEvents);
105 if(fMbsEvent) {
106 // we can check some properties of last event here:
107 fMbsEvent->PrintEvent(); // header and data content
108
109 // fileheader structure:
110 fMbsEvent->PrintMbsFileHeader();
111
112 // mbs buffer header structure:
113 fMbsEvent->PrintMbsBufferHeader();
114 }
115
116 fMbsEvent = nullptr; // reset to avoid invalid pointer if analysis is changed in between
117 fRawEvent = nullptr;
118 fCalEvent = nullptr;
119 fEvents = 0;
120 return 0;
121}
122
123//-----------------------------------------------------------
125{
127 Int_t value = 0;
128 Int_t count = 0;
129 if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
130 fSize->Fill(value); // fill histogram
131 fEvents++;
132 if(fEvents == 1 || IsNewInputFile()) {
133 if(fMbsEvent) {
134 count = fMbsEvent->GetCount();
135 TGo4Log::Info("First event #: %d", count);
136 fMbsEvent->PrintMbsBufferHeader();
137 }
138 }
139 fLastEvent = count;
140 return 0;
141}
#define __GO4BUILDVERSION__
Definition TGo4Version.h:24
Contains a single step of the analysis.
void SetErrorStopEnabled(Bool_t on)
Enables or disables the stop-on-error mode.
void SetProcessEnabled(Bool_t on=kTRUE)
Enables or disables the event processing.
void SetStoreEnabled(Bool_t on=kTRUE)
Enables or disables the event store.
void SetSourceEnabled(Bool_t on=kTRUE)
Enables or disables the event source.
The mother of all go4 analysis.
TGo4EventElement * GetInputEvent(const char *stepname) const
Returns the input event structure of analysis step.
TGo4EventElement * GetOutputEvent() const
Returns the output event (detector) structure of analysis step.
Bool_t IsNewInputFile() const
True if input filelist has changed to a new lmd file.
TH1 * MakeTH1(char type, const char *fullname, const char *title, Int_t nbinsx, Double_t xlow, Double_t xup, const char *xtitle=nullptr, const char *ytitle=nullptr)
Create one dimensional histogram of specified type.
void Print(Option_t *opt="") const override
Printout the analysis (step-) setup.
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
Ready to use step factory.
void DefEventProcessor(const char *Pname, const char *Pclass)
Configure name and class name for event processor.
void DefInputEvent(const char *Iname, const char *Iclass)
Configure name and class name for input event.
void DefOutputEvent(const char *Oname, const char *Oclass)
Configure name and class name for output event.
static Bool_t CheckVersion(Int_t version)
Returns true if Version number matches the argument of the Method.
TXXXAnlEvent * fCalEvent
TGo4MbsEvent * fMbsEvent
Int_t UserPostLoop() override
User defined function called once after processing the main event loop.
TXXXUnpackEvent * fRawEvent
Int_t UserPreLoop() override
User defined function called once before processing the main event loop.
virtual ~TXXXAnalysis()
Int_t UserEventFunc() override
User defined function which processes the actual analysis.