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

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

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