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

/Go4Example1Step/TXXXAnalysis.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 "TXXXAnalysis.h"
00017 
00018 #include <iostream.h>
00019 #include <time.h>
00020 
00021 #include "MbsAPI/s_filhe_swap.h"
00022 #include "MbsAPI/s_bufhe_swap.h"
00023 
00024 //***********************************************************
00025 TXXXAnalysis::TXXXAnalysis() : fUserFile(0),fMbsEvent(0){}
00026 //***********************************************************
00027 // this constructor is used in Main program
00028 TXXXAnalysis::TXXXAnalysis(Text_t * input, Int_t type, Int_t port, Text_t * output, Bool_t enable)
00029   : fUserFile(0),
00030     fMbsEvent(0),
00031     fEvents(0),
00032     fLastEvent(0)
00033 {
00034 // input: input  file name (*.lmd)  is overwritten in analysis configuration menu
00035 // type:  type of input
00036 // output:   output file name (*.root) is overwritten in analysis configuration menu
00037 // enable:output
00038 
00039 // all these parameter objects will be used for the different MBS inputs
00040   TGo4MbsFileParameter*        mbsfile;
00041   TGo4MbsTransportParameter*   mbstrans;
00042   TGo4MbsStreamParameter*      mbsstream;
00043   TGo4RevServParameter*        mbsrev;
00044   TGo4MbsEventServerParameter* mbsevent;
00045   TGo4FileStoreParameter*      store;
00046   TGo4EventProcessorParameter* proc;
00047 // We will use only one analysis step (factory)
00048   TGo4StepFactory*             factory;
00049   TGo4AnalysisStep*            step;
00050 
00051   factory = new TGo4StepFactory("Factory");
00052   store   = new TGo4FileStoreParameter(output);
00053   proc    = new TGo4EventProcessorParameter("ProcType",4); // arbitrary number
00054   switch (type){
00055     case GO4EV_MBS_FILE:
00056        mbsfile   = new TGo4MbsFileParameter(input);
00057        step      = new TGo4AnalysisStep("Analysis",factory,mbsfile,store,proc);
00058        cout << "**** Analysis: Create file input " << input << endl;
00059        break;
00060     case GO4EV_MBS_STREAM:
00061        mbsstream = new TGo4MbsStreamParameter(input);
00062        step      = new TGo4AnalysisStep("Analysis",factory,mbsstream,store,proc);
00063        cout << "**** Analysis: Create stream input "  << input << endl;
00064        break;
00065     case GO4EV_MBS_TRANSPORT:
00066        mbstrans  = new TGo4MbsTransportParameter(input);
00067        step      = new TGo4AnalysisStep("Analysis",factory,mbstrans,store,proc);
00068        cout << "**** Analysis: Create transport input " << input  << endl;
00069        break;
00070     case GO4EV_MBS_REVSERV:
00071        mbsrev    = new TGo4RevServParameter(input);
00072        mbsrev->SetPort(port);
00073        step      = new TGo4AnalysisStep("Analysis",factory,mbsrev,store,proc);
00074        cout << "**** Analysis: Create remote event server input " << input << " port " << port <<endl;
00075        break;
00076     case GO4EV_MBS_EVENTSERVER:
00077        mbsevent  = new TGo4MbsEventServerParameter(input);
00078        step      = new TGo4AnalysisStep("Analysis",factory,mbsevent,store,proc);
00079        cout << "**** Analysis: Create mbs event server input "  << input << endl;
00080        break;
00081     default:
00082        step      = 0;
00083        break;
00084   }
00085   // tell the factory the names of processor and output event
00086   // both will be created by the framework later
00087   // Input event is by default an MBS event
00088   factory->DefEventProcessor("XXXProc","TXXXProc");// object name, class name
00089   factory->DefOutputEvent("XXXEvent","TXXXEvent"); // object name, class name
00090 
00091   store->SetOverwriteMode(kTRUE); // overwrite file
00092 
00093   step->SetSourceEnabled(kTRUE);
00094   step->SetStoreEnabled(enable);  // en-disable output
00095   step->SetProcessEnabled(kTRUE);
00096   step->SetErrorStopEnabled(kTRUE);
00097 
00098   AddAnalysisStep(step);
00099 
00100   // Now the first analysis step is set up.
00101   // Other steps could be created here
00102 
00104   // At this point, autosave file has not yet been read!
00105   // Therefore parameter values set here will be overwritten
00106   // if an autosave file is there.
00107       fPar = new TXXXParam("Par1");
00108       AddParameter(fPar);
00109       fCtl = new TXXXControl("Control");
00110       AddParameter(fCtl);
00111 }
00112 //***********************************************************
00113 TXXXAnalysis::~TXXXAnalysis()
00114 {
00115   cout << "**** TXXXAnalysis: Delete instance" << endl;
00116 }
00117 
00118 //-----------------------------------------------------------
00119 Int_t TXXXAnalysis::UserPreLoop()
00120 {
00121   // all this is optional:
00122   cout << "**** TXXXAnalysis: PreLoop" << endl;
00123   // get pointer to input event (used in postloop and event function):
00124   fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Analysis"));   // of step "Analysis"
00125   if(fMbsEvent)
00126     {
00127       // fileheader structure (lmd file only):
00128       s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
00129       if(fileheader)
00130          {
00131            cout <<"\nInput file: "<<fileheader->filhe_file << endl;
00132            cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
00133            cout <<"UserName:\t" << fileheader->filhe_user<<endl;
00134            cout <<"RunID:\t" << fileheader->filhe_run<<endl;
00135            cout <<"Explanation: "<<fileheader->filhe_exp <<endl;
00136            cout <<"Comments: "<<endl;
00137            Int_t numlines=fileheader->filhe_lines;
00138            for(Int_t i=0; i<numlines;++i)
00139             {
00140                cout<<"\t"<<fileheader->s_strings[i].string << endl;
00141             }
00142          }
00143     }
00144    fEvents=0; // event counter
00145    fLastEvent=0; // number of last event processed
00146    return 0;
00147 }
00148 //-----------------------------------------------------------
00149 Int_t TXXXAnalysis::UserPostLoop()
00150 {
00151   // all this is optional:
00152    cout << "**** TXXXAnalysis: PostLoop" << endl;
00153    cout << "Last event  #: " << fLastEvent << " Total events: " << fEvents << endl;
00154    fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
00155    fEvents=0;
00156    return 0;
00157 }
00158 
00159 //-----------------------------------------------------------
00160 Int_t TXXXAnalysis::UserEventFunc()
00161 {
00162   // all this is optional:
00163   // This function is called once for each event after all steps.
00164   if(fMbsEvent)
00165     {
00166      fEvents++;
00167      fLastEvent=fMbsEvent->GetCount();
00168     }
00169   if(fEvents == 1 || IsNewInputFile())
00170     {
00171       cout << "First event #: " << fLastEvent  << endl;
00172       SetNewInputFile(kFALSE); // we have to reset the newfile flag
00173     }
00174    return 0;
00175 }
00176 //-----------------------------------------------------------
00177 
00178 ClassImp(TXXXAnalysis)
00179 
00180 
00181 
00182 
00183 //----------------------------END OF GO4 SOURCE FILE ---------------------

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