// $Id$ //----------------------------------------------------------------------- // The GSI Online Offline Object Oriented (Go4) Project // Experiment Data Processing at EE department, GSI //----------------------------------------------------------------------- // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH // Planckstr. 1, 64291 Darmstadt, Germany // Contact: http://go4.gsi.de //----------------------------------------------------------------------- // This software can be used under the license agreements as stated // in Go4License.txt file which is part of the distribution. //----------------------------------------------------------------------- #include "TYYYAnalysis.h" #include "TCanvas.h" #include "TH1.h" #include "TGo4AnalysisStep.h" #include "TGo4Version.h" #include "TYYYUnpackEvent.h" #include "TYYYParameter.h" #include "TYYYRawEvent.h" #include "TGo4StepFactory.h" //*********************************************************** TYYYAnalysis::TYYYAnalysis() : TGo4Analysis() { TGo4Log::Error("Wrong constructor TYYYAnalysis()!"); } //*********************************************************** // this constructor is used TYYYAnalysis::TYYYAnalysis(int argc, char **argv) : TGo4Analysis(argc, argv) { if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) { TGo4Log::Error("Go4 version mismatch"); exit(-1); } TGo4Log::Info("Create TYYYAnalysis %s", GetName()); // the step definitions can be changed in the GUI // first step definitions: // the name of the step can be used later to get event objects TGo4StepFactory* factory1 = new TGo4StepFactory("Unpack-factory"); factory1->DefUserEventSource("TYYYEventSource"); // class name of user event source factory1->DefInputEvent("RawEvent","TYYYRawEvent"); // object name, class name factory1->DefEventProcessor("UnpackProc", "TYYYUnpackProc");// object name, class name factory1->DefOutputEvent("UnpackEvent", "TYYYUnpackEvent"); // object name, class name TGo4UserSourceParameter* source1 = new TGo4UserSourceParameter("befoil50.scf"); TString parname = TString::Format("%sOutput", argv[0]); TGo4FileStoreParameter* store1 = new TGo4FileStoreParameter(parname.Data()); store1->SetOverwriteMode(kTRUE); TGo4AnalysisStep * step1 = new TGo4AnalysisStep("Unpack", factory1, source1, store1, nullptr); step1->SetSourceEnabled(kTRUE); step1->SetStoreEnabled(kFALSE); // disable output step1->SetProcessEnabled(kTRUE); step1->SetErrorStopEnabled(kTRUE); AddAnalysisStep(step1); // uncomment following line to define custom passwords for analysis server // DefineServerPasswords("YYYadmin", "YYYctrl", "YYYview"); //////////////// Parameter ////////////////////////// // At this point, autosave file has not yet been read! // Therefore parameter values set here will be overwritten // if an autosave file is there. fPar = new TYYYParameter("YYYPar1"); fPar->frP1 = 100; fPar->frP2 = 200; AddParameter(fPar); if (!GetCanvas("TestCanvas")) { TCanvas *mycan = new TCanvas("TestCanvas","Does this work?"); mycan->Divide(2,2); AddCanvas(mycan); } } //*********************************************************** TYYYAnalysis::~TYYYAnalysis() { TGo4Log::Info("TYYYAnalysis: Delete"); } //----------------------------------------------------------- Int_t TYYYAnalysis::UserPreLoop() { TGo4Log::Info("TYYYAnalysis: PreLoop"); // we update the pointers to the current event structures here: fRawEvent = dynamic_cast (GetInputEvent("Unpack")); // of step "Unpack" fUnpackEvent = dynamic_cast (GetOutputEvent("Unpack")); fEvents = 0; // create histogram for UserEventFunc // At this point, the histogram has been restored from autosave file if any. fSize = (TH1D*)GetHistogram("Eventsize"); if(!fSize) { // no autosave read, create new and register fSize = new TH1D ("Eventsize", "Read columns",160,1,160); AddHistogram(fSize); } ClearObjects("Histograms"); // reset all histograms to 0 before run // name specifies folder to clear return 0; } //----------------------------------------------------------- Int_t TYYYAnalysis::UserPostLoop() { TGo4Log::Info("TYYYAnalysis: PostLoop"); TGo4Log::Info("Total events: %d", fEvents); TCanvas *can = GetCanvas("TestCanvas"); if(can) { TH1 *hx = GetHistogram("Xfinal"); TH1 *hy = GetHistogram("Yfinal"); TH1 *hvx = GetHistogram("Vxfinal"); TH1 *hvy = GetHistogram("Vyfinal"); can->cd(1); if(hx) hx->Draw(); can->cd(2); if(hy) hy->Draw(); can->cd(3); if(hvx) hvx->Draw(); can->cd(4); if(hvy) hvy->Draw(); } fUnpackEvent = nullptr; // reset to avoid invalid pointer if analysis is changed in between fRawEvent = nullptr; fEvents = 0; return 0; } //----------------------------------------------------------- Int_t TYYYAnalysis::UserEventFunc() { //// This function is called once for each event. Int_t value = 0; if(fRawEvent) value = fRawEvent->GetColumns(); fSize->Fill(value); // fill histogram fEvents++; return 0; }