GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TYYYAnalysis.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 "TYYYAnalysis.h"
15
16#include "TCanvas.h"
17#include "TH1.h"
18
19#include "TGo4AnalysisStep.h"
20#include "TGo4Version.h"
21
22#include "TYYYUnpackEvent.h"
23#include "TYYYParameter.h"
24#include "TYYYRawEvent.h"
25#include "TGo4StepFactory.h"
26
27//***********************************************************
30{
31 TGo4Log::Error("Wrong constructor TYYYAnalysis()!");
32}
33
34//***********************************************************
35// this constructor is used
36TYYYAnalysis::TYYYAnalysis(int argc, char **argv) :
37 TGo4Analysis(argc, argv)
38{
40 TGo4Log::Error("Go4 version mismatch");
41 exit(-1);
42 }
43
44 TGo4Log::Info("Create TYYYAnalysis %s", GetName());
45
46 // the step definitions can be changed in the GUI
47 // first step definitions:
48 // the name of the step can be used later to get event objects
49 TGo4StepFactory* factory1 = new TGo4StepFactory("Unpack-factory");
50
51 factory1->DefUserEventSource("TYYYEventSource"); // class name of user event source
52 factory1->DefInputEvent("RawEvent","TYYYRawEvent"); // object name, class name
53 factory1->DefEventProcessor("UnpackProc", "TYYYUnpackProc");// object name, class name
54 factory1->DefOutputEvent("UnpackEvent", "TYYYUnpackEvent"); // object name, class name
55
56 TGo4UserSourceParameter* source1 = new TGo4UserSourceParameter("befoil50.scf");
57 TString parname = TString::Format("%sOutput", argv[0]);
58 TGo4FileStoreParameter* store1 = new TGo4FileStoreParameter(parname.Data());
59 store1->SetOverwriteMode(kTRUE);
60 TGo4AnalysisStep * step1 = new TGo4AnalysisStep("Unpack", factory1, source1, store1, nullptr);
61
62 step1->SetSourceEnabled(kTRUE);
63 step1->SetStoreEnabled(kFALSE); // disable output
64 step1->SetProcessEnabled(kTRUE);
65 step1->SetErrorStopEnabled(kTRUE);
66 AddAnalysisStep(step1);
67
68 // uncomment following line to define custom passwords for analysis server
69 // DefineServerPasswords("YYYadmin", "YYYctrl", "YYYview");
70
72 // At this point, autosave file has not yet been read!
73 // Therefore parameter values set here will be overwritten
74 // if an autosave file is there.
75 fPar = new TYYYParameter("YYYPar1");
76 fPar->frP1 = 100;
77 fPar->frP2 = 200;
79
80 if (!GetCanvas("TestCanvas")) {
81 TCanvas *mycan = new TCanvas("TestCanvas","Does this work?");
82 mycan->Divide(2,2);
83 AddCanvas(mycan);
84 }
85}
86
87//***********************************************************
89{
90 TGo4Log::Info("TYYYAnalysis: Delete");
91}
92
93//-----------------------------------------------------------
95{
96 TGo4Log::Info("TYYYAnalysis: PreLoop");
97 // we update the pointers to the current event structures here:
98 fRawEvent = dynamic_cast<TYYYRawEvent*> (GetInputEvent("Unpack")); // of step "Unpack"
99 fUnpackEvent = dynamic_cast<TYYYUnpackEvent*> (GetOutputEvent("Unpack"));
100 fEvents = 0;
101
102 // create histogram for UserEventFunc
103 // At this point, the histogram has been restored from autosave file if any.
104 fSize = (TH1D*)GetHistogram("Eventsize");
105 if(!fSize) {
106 // no autosave read, create new and register
107 fSize = new TH1D ("Eventsize", "Read columns",160,1,160);
109 }
110 ClearObjects("Histograms"); // reset all histograms to 0 before run
111 // name specifies folder to clear
112 return 0;
113}
114
115//-----------------------------------------------------------
117{
118 TGo4Log::Info("TYYYAnalysis: PostLoop");
119 TGo4Log::Info("Total events: %d", fEvents);
120 TCanvas *can = GetCanvas("TestCanvas");
121 if(can) {
122 TH1 *hx = GetHistogram("Xfinal");
123 TH1 *hy = GetHistogram("Yfinal");
124 TH1 *hvx = GetHistogram("Vxfinal");
125 TH1 *hvy = GetHistogram("Vyfinal");
126 can->cd(1);
127 if(hx) hx->Draw();
128 can->cd(2);
129 if(hy) hy->Draw();
130 can->cd(3);
131 if(hvx) hvx->Draw();
132 can->cd(4);
133 if(hvy) hvy->Draw();
134 }
135
136 fUnpackEvent = nullptr; // reset to avoid invalid pointer if analysis is changed in between
137 fRawEvent = nullptr;
138 fEvents = 0;
139 return 0;
140}
141
142//-----------------------------------------------------------
144{
146 Int_t value = 0;
147 if(fRawEvent) value = fRawEvent->GetColumns();
148 fSize->Fill(value); // fill histogram
149 fEvents++;
150 return 0;
151}
#define __GO4BUILDVERSION__
Definition TGo4Version.h:24
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.
TGo4EventElement * GetInputEvent(const char *stepname) const
Returns the input event structure of analysis step.
TGo4Analysis(const char *name=nullptr)
Protected constructor for singleton instance.
TCanvas * GetCanvas(const char *name)
Retrieves a TCanvas by name from the Canvases folder.
Bool_t ClearObjects(const char *name)
Clear (reset) the specified objects.
TGo4EventElement * GetOutputEvent() const
Returns the output event (detector) structure of analysis step.
friend class TGo4AnalysisStep
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=nullptr)
Puts a new parameter object in corresponding folder.
TH1 * GetHistogram(const char *name)
Search histogram in histogram list (directory).
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
Method for user analysis constructor to setup the list of analysis steps.
Bool_t AddHistogram(TH1 *his, const char *subfolder=nullptr, Bool_t replace=kTRUE)
Add external histogram to go4 histogram directory.
const char * GetName() const override
Return analysis name.
Bool_t AddCanvas(TCanvas *can, const char *subfolder=nullptr)
Puts a new TCanvas in corresponding folder.
void SetOverwriteMode(Bool_t over=kTRUE)
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 DefUserEventSource(const char *Sclass)
Configure class name for event source.
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.
TYYYParameter * fPar
Int_t UserPreLoop() override
User defined function called once before processing the main event loop.
Int_t UserPostLoop() override
User defined function called once after processing the main event loop.
TYYYUnpackEvent * fUnpackEvent
Int_t UserEventFunc() override
User defined function which processes the actual analysis.
virtual ~TYYYAnalysis()
TYYYRawEvent * fRawEvent
Example for user defined raw event class.