Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TYYYAnalysis.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TYYYAnalysis.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TCanvas.h"
00021 #include "TH1.h"
00022 #include "TFile.h"
00023 
00024 #include "Go4EventServer.h"
00025 #include "TGo4AnalysisStep.h"
00026 
00027 #include "TYYYUnpackFact.h"
00028 #include "TYYYUnpackEvent.h"
00029 #include "TYYYParameter.h"
00030 #include "TYYYRawEvent.h"
00031 
00032 //***********************************************************
00033 TYYYAnalysis::TYYYAnalysis()
00034 : fUserFile(0),fRawEvent(0),fUnpackEvent(0)
00035 {
00036   cout << "Wrong constructor TYYYAnalysis()!" << endl;
00037 }
00038 //***********************************************************
00039 // this constructor is used
00040 TYYYAnalysis::TYYYAnalysis(const char* lmd, const char* out1, const char* out2)
00041   : fUserFile(0),
00042     fRawEvent(0),
00043     fUnpackEvent(0),
00044     fSize(0),
00045     fEvents(0),
00046     fLastEvent(0)
00047 {
00048 // lmd: input file name (*.lmd)
00049 // out1: output file name of first analysis step  (*.root)
00050 // out2: output file name of second analysis step (*.root)
00051   cout << "**** TYYYAnalysis: Create" << endl;
00052 
00053 // the step definitions can be changed in the GUI
00054 // first step definitions:
00055 // the name of the step can be used later to get event objects
00056   TYYYUnpackFact*         factory1 = new TYYYUnpackFact("Unpack-factory");
00057   TGo4UserSourceParameter*   source1  = new TGo4UserSourceParameter(lmd);
00058   TGo4FileStoreParameter* store1   = new TGo4FileStoreParameter(out1);
00059   TGo4AnalysisStep*       step1    = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
00060   store1->SetOverwriteMode(kTRUE);
00061   step1->SetSourceEnabled(kTRUE);
00062   step1->SetStoreEnabled(kFALSE);  // dissable output
00063   step1->SetProcessEnabled(kTRUE);
00064   step1->SetErrorStopEnabled(kTRUE);
00065   AddAnalysisStep(step1);
00066 
00067 
00068 
00070   // At this point, autosave file has not yet been read!
00071   // Therefore parameter values set here will be overwritten
00072   // if an autosave file is there.
00073       fPar = new TYYYParameter("YYYPar1");
00074       fPar->frP1 = 100;
00075       fPar->frP2 = 200;
00076       AddParameter(fPar);
00077   TCanvas* mycan=new TCanvas("TestCanvas","Does this work?");
00078   mycan->Divide(2,2);
00079   AddCanvas(mycan);
00080 
00081 
00082 }
00083 
00084 //***********************************************************
00085 TYYYAnalysis::~TYYYAnalysis()
00086 {
00087   cout << "**** TYYYAnalysis: Delete" << endl;
00088 }
00089 //***********************************************************
00090 
00091 //-----------------------------------------------------------
00092 Int_t TYYYAnalysis::UserPreLoop()
00093 {
00094   cout << "**** TYYYAnalysis: PreLoop" << endl;
00095    // we update the pointers to the current event structures here:
00096    fRawEvent = dynamic_cast<TYYYRawEvent*>    (GetInputEvent("Unpack"));   // of step "Unpack"
00097    fUnpackEvent = dynamic_cast<TYYYUnpackEvent*> (GetOutputEvent("Unpack"));
00098    fEvents=0;
00099    fLastEvent=0;
00100 
00101    // create histogram for UserEventFunc
00102    // At this point, the histogram has been restored from autosave file if any.
00103   fSize=(TH1D*)GetHistogram("Eventsize");
00104   if(fSize==0)
00105     { // no autosave read, create new and register
00106       fSize = new TH1D ("Eventsize", "Read columns",160,1,160);
00107       AddHistogram(fSize);
00108     }
00109   ClearObjects("Histograms"); // reset all histograms to 0 before run
00110                               // name specifies folder to clear
00111    return 0;
00112 }
00113 //-----------------------------------------------------------
00114 Int_t TYYYAnalysis::UserPostLoop()
00115 {
00116   cout << "**** TYYYAnalysis: PostLoop" << endl;
00117   cout << " Total events: " << fEvents << endl;
00118   TCanvas* can=GetCanvas("TestCanvas");
00119   TH1* hx=GetHistogram("Xfinal");
00120   TH1* hy=GetHistogram("Yfinal");
00121   TH1* hvx=GetHistogram("Vxfinal");
00122   TH1* hvy=GetHistogram("Vyfinal");
00123   if(can)
00124     {
00125       can->cd(1);
00126       if(hx) hx->Draw();
00127       can->cd(2);
00128       if(hy) hy->Draw();
00129       can->cd(3);
00130       if(hvx) hvx->Draw();
00131       can->cd(4);
00132       if(hvy) hvy->Draw();
00133     }
00134 
00135 
00136    fUnpackEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
00137    fRawEvent = 0;
00138    fEvents=0;
00139    return 0;
00140 }
00141 
00142 //-----------------------------------------------------------
00143 Int_t TYYYAnalysis::UserEventFunc()
00144 {
00146    Int_t value=0;
00147    if(fRawEvent) value = fRawEvent->GetColumns();
00148    fSize->Fill(value); // fill histogram
00149    fEvents++;
00150    return 0;
00151 }
00152 
00153 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:11 2008 for Go4-v3.04-1 by  doxygen 1.4.2