GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TYYYAnalysis.cxx
Go to the documentation of this file.
1 // $Id: TYYYAnalysis.cxx 2768 2020-04-16 14:49:34Z 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 "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 //***********************************************************
29  TGo4Analysis(),
30  fRawEvent(0),
31  fUnpackEvent(0),
32  fSize(0),
33  fPar(0),
34  fEvents(0)
35 {
36  TGo4Log::Error("Wrong constructor TYYYAnalysis()!");
37 }
38 //***********************************************************
39 // this constructor is used
40 TYYYAnalysis::TYYYAnalysis(int argc, char** argv) :
41  TGo4Analysis(argc, argv),
42  fRawEvent(0),
43  fUnpackEvent(0),
44  fSize(0),
45  fPar(0),
46  fEvents(0)
47 {
49  TGo4Log::Error("Go4 version mismatch");
50  exit(-1);
51  }
52 
53  TGo4Log::Info("Create TYYYAnalysis %s", GetName());
54 
55  // the step definitions can be changed in the GUI
56  // first step definitions:
57  // the name of the step can be used later to get event objects
58  TGo4StepFactory* factory1 = new TGo4StepFactory("Unpack-factory");
59 
60  factory1->DefUserEventSource("TYYYEventSource"); // class name of user event source
61  factory1->DefInputEvent("RawEvent","TYYYRawEvent"); // object name, class name
62  factory1->DefEventProcessor("UnpackProc", "TYYYUnpackProc");// object name, class name
63  factory1->DefOutputEvent("UnpackEvent", "TYYYUnpackEvent"); // object name, class name
64 
65  TGo4UserSourceParameter* source1 = new TGo4UserSourceParameter("befoil50.scf");
66  TGo4FileStoreParameter* store1 = new TGo4FileStoreParameter(Form("%sOutput", argv[0]));
67  store1->SetOverwriteMode(kTRUE);
68  TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
69 
70  step1->SetSourceEnabled(kTRUE);
71  step1->SetStoreEnabled(kFALSE); // disable output
72  step1->SetProcessEnabled(kTRUE);
73  step1->SetErrorStopEnabled(kTRUE);
74  AddAnalysisStep(step1);
75 
76  // uncomment following line to define custom passwords for analysis server
77  // DefineServerPasswords("YYYadmin", "YYYctrl", "YYYview");
78 
80  // At this point, autosave file has not yet been read!
81  // Therefore parameter values set here will be overwritten
82  // if an autosave file is there.
83  fPar = new TYYYParameter("YYYPar1");
84  fPar->frP1 = 100;
85  fPar->frP2 = 200;
87 
88  if (GetCanvas("TestCanvas")==0) {
89  TCanvas* mycan = new TCanvas("TestCanvas","Does this work?");
90  mycan->Divide(2,2);
91  AddCanvas(mycan);
92  }
93 }
94 
95 //***********************************************************
97 {
98  TGo4Log::Info("TYYYAnalysis: Delete");
99 }
100 //***********************************************************
101 
102 //-----------------------------------------------------------
104 {
105  TGo4Log::Info("TYYYAnalysis: PreLoop");
106  // we update the pointers to the current event structures here:
107  fRawEvent = dynamic_cast<TYYYRawEvent*> (GetInputEvent("Unpack")); // of step "Unpack"
108  fUnpackEvent = dynamic_cast<TYYYUnpackEvent*> (GetOutputEvent("Unpack"));
109  fEvents=0;
110 
111  // create histogram for UserEventFunc
112  // At this point, the histogram has been restored from autosave file if any.
113  fSize=(TH1D*)GetHistogram("Eventsize");
114  if(fSize==0) {
115  // no autosave read, create new and register
116  fSize = new TH1D ("Eventsize", "Read columns",160,1,160);
118  }
119  ClearObjects("Histograms"); // reset all histograms to 0 before run
120  // name specifies folder to clear
121  return 0;
122 }
123 //-----------------------------------------------------------
125 {
126  TGo4Log::Info("TYYYAnalysis: PostLoop");
127  TGo4Log::Info("Total events: %d", fEvents);
128  TCanvas* can = GetCanvas("TestCanvas");
129  if(can) {
130  TH1* hx = GetHistogram("Xfinal");
131  TH1* hy = GetHistogram("Yfinal");
132  TH1* hvx = GetHistogram("Vxfinal");
133  TH1* hvy = GetHistogram("Vyfinal");
134  can->cd(1);
135  if(hx) hx->Draw();
136  can->cd(2);
137  if(hy) hy->Draw();
138  can->cd(3);
139  if(hvx) hvx->Draw();
140  can->cd(4);
141  if(hvy) hvy->Draw();
142  }
143 
144  fUnpackEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
145  fRawEvent = 0;
146  fEvents=0;
147  return 0;
148 }
149 
150 //-----------------------------------------------------------
152 {
154  Int_t value=0;
155  if(fRawEvent) value = fRawEvent->GetColumns();
156  fSize->Fill(value); // fill histogram
157  fEvents++;
158  return 0;
159 }
Bool_t AddCanvas(TCanvas *can, const char *subfolder=0)
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
Int_t GetColumns() const
Definition: TYYYRawEvent.h:44
static Bool_t CheckVersion(Int_t version)
Definition: TGo4Version.cxx:42
void DefUserEventSource(const char *Sclass)
void DefEventProcessor(const char *Pname, const char *Pclass)
virtual Int_t UserPostLoop()
friend class TGo4AnalysisStep
TYYYRawEvent * fRawEvent
Definition: TYYYAnalysis.h:33
TGo4EventElement * GetOutputEvent()
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
void SetSourceEnabled(Bool_t on=kTRUE)
virtual ~TYYYAnalysis()
void SetOverwriteMode(Bool_t over=kTRUE)
TH1 * GetHistogram(const char *name)
TGo4EventElement * GetInputEvent(const char *stepname)
TCanvas * GetCanvas(const char *name)
TH1D * fSize
Definition: TYYYAnalysis.h:35
virtual Int_t UserPreLoop()
void DefOutputEvent(const char *Oname, const char *Oclass)
Bool_t ClearObjects(const char *name)
#define __GO4BUILDVERSION__
Definition: TGo4Version.h:24
virtual const char * GetName() const
void SetStoreEnabled(Bool_t on=kTRUE)
virtual Int_t UserEventFunc()
void SetProcessEnabled(Bool_t on=kTRUE)
Bool_t AddAnalysisStep(TGo4AnalysisStep *next)
void SetErrorStopEnabled(Bool_t on)
TYYYUnpackEvent * fUnpackEvent
Definition: TYYYAnalysis.h:34
void DefInputEvent(const char *Iname, const char *Iclass)
static void Error(const char *text,...)
Definition: TGo4Log.cxx:323
static void Info(const char *text,...)
Definition: TGo4Log.cxx:297
TYYYParameter * fPar
Definition: TYYYAnalysis.h:36