Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ExampleUserSource/TYYYAnalysis.cxx

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

Generated on Tue Nov 8 10:55:55 2005 for Go4-v2.10-5 by doxygen1.2.15