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

/Go4ExampleMesh/TMeshAnalysis.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 "TMeshAnalysis.h"
00017 
00018 #include <iostream.h>
00019 
00020 #include "Go4EventServer/Go4EventServer.h"
00021 #include "Go4EventServer/TGo4StepFactory.h"
00022 
00023 //***********************************************************
00024 TMeshAnalysis::TMeshAnalysis()
00025 : fMbsEvent(0)
00026 {
00027   cout << "Wrong constructor TMeshAnalysis()!" << endl;
00028 }
00029 //***********************************************************
00030 // this constructor is used
00031 TMeshAnalysis::TMeshAnalysis(Text_t * input, Int_t type, Int_t port, Text_t * out1, Text_t * out2, Bool_t enable1, Bool_t enable2)
00032   : fMbsEvent(0),
00033     fSize(0),
00034     fEvents(0),
00035     fLastEvent(0)
00036 {
00037 // input: input file name (*.lmd)
00038 // out1:  output file name of first analysis step  (*.root)
00039 // out2:  output file name of second analysis step (*.root)
00040   cout << "**** TMeshAnalysis: Create" << endl;
00041 
00042    SetStepChecking(kFALSE); // necessary for non-subsequent mesh analysis
00043 
00044 // first step definitions:
00045   TGo4EventSourceParameter*    source1=0;
00046   TGo4RevServParameter* mbsrev=0;
00047   switch (type){
00048   case GO4EV_MBS_FILE:
00049        source1   = new TGo4MbsFileParameter(input);
00050        cout << "**** Unpack: Create file input " << input << endl;
00051        break;
00052   case GO4EV_MBS_STREAM:
00053        source1 = new TGo4MbsStreamParameter(input);
00054        cout << "**** Unpack: Create stream input "  << input << endl;
00055        break;
00056   case GO4EV_MBS_TRANSPORT:
00057        source1  = new TGo4MbsTransportParameter(input);
00058        cout << "**** Unpack: Create transport input " << input  << endl;
00059        break;
00060   case GO4EV_MBS_REVSERV:
00061        mbsrev    = new TGo4RevServParameter(input);
00062        mbsrev->SetPort(port);
00063        source1=mbsrev;
00064        cout << "**** Unpack: Create remote event server input " << input << " port " << port <<endl;
00065        break;
00066   case GO4EV_MBS_EVENTSERVER:
00067        source1  = new TGo4MbsEventServerParameter(input);
00068        cout << "**** Unpack: Create mbs event server input "  << input << endl;
00069        break;
00070   default:break;
00071   }
00072   TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
00073   factory1->DefOutputEvent("RawEvent", "TMeshRawEvent");   
00074   factory1->DefEventProcessor("Unpacker","TMeshUnpackProc");
00075   TGo4EventStoreParameter* store1   = new TGo4FileStoreParameter("MeshRawEvent"); 
00076   TGo4AnalysisStep* step1     = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
00077   AddAnalysisStep(step1);
00078   step1->SetSourceEnabled(kTRUE);
00079   step1->SetStoreEnabled(enable1);
00080   step1->SetProcessEnabled(kTRUE);
00081 
00082 
00083 
00084 
00086   TGo4StepFactory* factory2 = new TGo4StepFactory("RawProvider1Factory");
00087 //  factory2->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
00088 //  factory2->DefEventProcessor("RawEvent_1","TMeshProviderProc"); // processorname must match name of input event + "_"
00089   factory2->DefInputEvent("RawEvent.fxSub1", "TMeshRawEvent"); // try partial io: eventname must match branch name!
00090   factory2->DefEventProcessor("RawEvent.fxSub1_1","TMeshProviderProc"); // processorname must match name of input event +"_"
00091   factory2->DefOutputEvent("Dummy", "TMeshDummyEvent");   
00092   TGo4AnalysisStep* step2     = new TGo4AnalysisStep("Input1Provider",factory2,0,0,0);
00093   AddAnalysisStep(step2);
00094   step2->SetSourceEnabled(kFALSE);
00095   step2->SetStoreEnabled(kFALSE);
00096   step2->SetProcessEnabled(kTRUE);
00097 
00099    TGo4StepFactory* factory3 = new TGo4StepFactory("RawProvider2Factory");
00100 //  factory3->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
00101 //  factory3->DefEventProcessor("RawEvent_2","TMeshProviderProc"); // name must match name of input event!
00102   factory3->DefInputEvent("RawEvent.fxSub2", "TMeshRawEvent"); // build full raw event, but fill only subbranch as defined in name
00103   factory3->DefEventProcessor("RawEvent.fxSub2_1","TMeshProviderProc");
00104   factory3->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00105   TGo4AnalysisStep* step3     = new TGo4AnalysisStep("Input2Provider",factory3,0,0,0);
00106   AddAnalysisStep(step3);
00107   step3->SetSourceEnabled(kFALSE);
00108   step3->SetStoreEnabled(kFALSE);
00109   step3->SetProcessEnabled(kTRUE);
00110 
00112   TGo4StepFactory* factory4 = new TGo4StepFactory("RawProvider3Factory");
00113 //  factory4->DefInputEvent("RawEvent", "TMeshRawEvent"); // read full raw event without partial io
00114 //  factory4->DefEventProcessor("RawEvent_3","TMeshProviderProc"); // name must match name of input event!
00115  factory4->DefInputEvent("RawEvent.fxSub3", "TMeshRawEvent"); // build full raw event, but fill only subbranch as defined in name
00116  factory4->DefEventProcessor("RawEvent.fxSub3_1","TMeshProviderProc");  
00117   factory4->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00118    // provider factories without definition of output event and proc
00119   TGo4AnalysisStep* step4     = new TGo4AnalysisStep("Input3Provider",factory4,0,0,0);
00120   AddAnalysisStep(step4);
00121   step4->SetSourceEnabled(kFALSE);
00122   step4->SetStoreEnabled(kFALSE);
00123   step4->SetProcessEnabled(kTRUE);
00124 
00126   TGo4StepFactory* factory5 = new TGo4StepFactory("Branch1Factory");
00127   factory5->DefOutputEvent("EventB1", "TMeshB1OutputEvent");   
00128   factory5->DefEventProcessor("Branch1","TMeshB1AnlProc");
00129   TGo4EventStoreParameter* store5   = new TGo4FileStoreParameter("MeshB1");  
00130   TGo4AnalysisStep* step5     = new TGo4AnalysisStep("Exec1",factory5,0,store5,0);
00131   // no own event source for execution step
00132   AddAnalysisStep(step5);
00133   step5->SetSourceEnabled(kFALSE);
00134   step5->SetStoreEnabled(kTRUE);
00135   step5->SetProcessEnabled(kTRUE);
00136 
00138   TGo4StepFactory* factory6 = new TGo4StepFactory("Branch2Factory");
00139   factory6->DefOutputEvent("EventB2", "TMeshB2OutputEvent");   
00140   factory6->DefEventProcessor("Branch2","TMeshB2AnlProc");
00141   TGo4EventStoreParameter* store6   = new TGo4FileStoreParameter("MeshB2");  
00142   TGo4AnalysisStep* step6     = new TGo4AnalysisStep("Exec2",factory6,0,store6,0);
00143   // no own event source for execution step
00144   AddAnalysisStep(step6);
00145   step6->SetSourceEnabled(kFALSE);
00146   step6->SetStoreEnabled(kTRUE);
00147   step6->SetProcessEnabled(kTRUE);
00148 
00150   TGo4StepFactory* factory7 = new TGo4StepFactory("Branch3Factory");
00151   factory7->DefOutputEvent("EventB3", "TMeshB3OutputEvent");   
00152   factory7->DefEventProcessor("Branch3","TMeshB3AnlProc");
00153   TGo4EventStoreParameter* store7   = new TGo4FileStoreParameter("MeshB3");  
00154   TGo4AnalysisStep* step7     = new TGo4AnalysisStep("Exec3",factory7,0,store7,0);
00155   // no own event source for execution step
00156   AddAnalysisStep(step7);
00157   step7->SetSourceEnabled(kFALSE);
00158   step7->SetStoreEnabled(kTRUE);
00159   step7->SetProcessEnabled(kTRUE);
00160 
00161 
00163   TGo4StepFactory* factory8 = new TGo4StepFactory("OutProvider1Factory");
00164   factory8->DefInputEvent("EventB1", "TMeshB1OutputEvent"); 
00165   factory8->DefEventProcessor("EventB1_1","TMeshProviderProc"); // name must match name of input event!
00166   factory8->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00167   TGo4AnalysisStep* step8     = new TGo4AnalysisStep("Output1Provider",factory8,0,0,0);
00168   AddAnalysisStep(step8);
00169   step8->SetSourceEnabled(kFALSE);
00170   step8->SetStoreEnabled(kFALSE);
00171   step8->SetProcessEnabled(kTRUE);
00172 
00174   TGo4StepFactory* factory9 = new TGo4StepFactory("OutProvider2Factory");
00175   factory9->DefInputEvent("EventB2", "TMeshB2OutputEvent"); 
00176   factory9->DefEventProcessor("EventB2_1","TMeshProviderProc"); // name must match name of input event!
00177   factory9->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00178   TGo4AnalysisStep* step9     = new TGo4AnalysisStep("Output2Provider",factory9,0,0,0);
00179   AddAnalysisStep(step9);
00180   step9->SetSourceEnabled(kFALSE);
00181   step9->SetStoreEnabled(kFALSE);
00182   step9->SetProcessEnabled(kTRUE);
00183 
00185   TGo4StepFactory* factory10 = new TGo4StepFactory("OutProvider3Factory");
00186   factory10->DefInputEvent("EventB3", "TMeshB3OutputEvent"); 
00187   factory10->DefEventProcessor("EventB3_1","TMeshProviderProc"); // name must match name of input event!
00188   factory10->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00189   TGo4AnalysisStep* step10     = new TGo4AnalysisStep("Output3Provider",factory10,0,0,0);
00190   AddAnalysisStep(step10);
00191   step10->SetSourceEnabled(kFALSE);
00192   step10->SetStoreEnabled(kFALSE);
00193   step10->SetProcessEnabled(kTRUE);
00194 
00196   TGo4StepFactory* factory11 = new TGo4StepFactory("Branch12Factory");
00197   factory11->DefOutputEvent("EventB12", "TMeshB12OutputEvent");   
00198   factory11->DefEventProcessor("Branch12","TMeshB12AnlProc");
00199   TGo4EventStoreParameter* store11   = new TGo4FileStoreParameter("MeshB12");  
00200   TGo4AnalysisStep* step11     = new TGo4AnalysisStep("Exec12",factory11,0,store11,0);
00201   // no own event source for execution step
00202   AddAnalysisStep(step11);
00203   step11->SetSourceEnabled(kFALSE);
00204   step11->SetStoreEnabled(kTRUE);
00205   step11->SetProcessEnabled(kTRUE);
00206 
00208   TGo4StepFactory* factory12 = new TGo4StepFactory("OutProvider12Factory");
00209   factory12->DefInputEvent("EventB12", "TMeshB12OutputEvent"); 
00210   factory12->DefEventProcessor("EventB12_1","TMeshProviderProc"); // name must match name of input event!
00211   factory12->DefOutputEvent("Dummy", "TMeshDummyEvent");  
00212   TGo4AnalysisStep* step12     = new TGo4AnalysisStep("Output12Provider",factory12,0,0,0);
00213   AddAnalysisStep(step12);
00214   step12->SetSourceEnabled(kFALSE);
00215   step12->SetStoreEnabled(kFALSE);
00216   step12->SetProcessEnabled(kTRUE);
00217 
00219   TGo4StepFactory* factory13 = new TGo4StepFactory("Branch13Factory");
00220   factory13->DefOutputEvent("FinalEvent", "TMeshFinalEvent");   
00221   factory13->DefEventProcessor("Collector","TMeshFinalProc");
00222   TGo4EventStoreParameter* store13   = new TGo4FileStoreParameter("MeshFinal");  
00223   TGo4AnalysisStep* step13     = new TGo4AnalysisStep("Final",factory13,0,store13,0);
00224   // no own event source for execution step
00225   AddAnalysisStep(step13);
00226   step13->SetSourceEnabled(kFALSE);
00227   step13->SetStoreEnabled(kTRUE);
00228   step13->SetProcessEnabled(kTRUE);
00229 
00230 
00231 
00233   // At this point, autosave file has not yet been read!
00234   // Therefore parameter values set here will be overwritten
00235   // if an autosave file is there.
00236       fPar = new TMeshParameter("MeshSetup");
00237       AddParameter(fPar);
00238 
00239 
00240 }
00241 
00242 //***********************************************************
00243 TMeshAnalysis::~TMeshAnalysis()
00244 {
00245   cout << "**** TMeshAnalysis: Delete" << endl;
00246 }
00247 //***********************************************************
00248 
00249 //-----------------------------------------------------------
00250 Int_t TMeshAnalysis::UserPreLoop()
00251 {
00252   cout << "**** TMeshAnalysis: PreLoop" << endl;
00253    // we update the pointers to the current event structures here:
00254    fMbsEvent = dynamic_cast<TGo4MbsEvent*>    (GetInputEvent("Unpack"));   // of step "Unpack"
00255    fEvents=0;
00256    fLastEvent=0;
00257 
00258 
00259 
00260    // create histogram for UserEventFunc
00261    // At this point, the histogram has been restored from autosave file if any.
00262   fSize=(TH1D*)GetHistogram("Eventsize");
00263   if(fSize==0)
00264     { // no autosave read, create new and register
00265       fSize = new TH1D ("Eventsize", "Event size [b]",160,1,160);
00266       AddHistogram(fSize);
00267     }
00268   // we use a fitter envelope parameters to exchange fit results:
00269  
00270 
00271    return 0;
00272 }
00273 //-----------------------------------------------------------
00274 Int_t TMeshAnalysis::UserPostLoop()
00275 {
00276   cout << "**** TMeshAnalysis: PostLoop" << endl;
00277   cout << "Last event: " << fLastEvent << " Total events: " << fEvents << endl;
00278   if(fMbsEvent)
00279     {
00280       // we can check some properties of last event here:
00281       //fMbsEvent->PrintEvent(); // header and data content
00282 
00283       // fileheader structure:
00284       s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
00285       if(fileheader)
00286          {
00287            cout <<"\nInput file was: "<<fileheader->filhe_file << endl;
00288            cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
00289            cout <<"UserName:\t" << fileheader->filhe_user<<endl;
00290            cout <<"RunID:\t" << fileheader->filhe_run<<endl;
00291            cout <<"\tExplanation: "<<fileheader->filhe_exp <<endl;
00292            cout <<"\tComments: "<<endl;
00293            Int_t numlines=fileheader->filhe_lines;
00294            for(Int_t i=0; i<numlines;++i)
00295             {
00296                cout<<"\t\t"<<fileheader->s_strings[i].string << endl;
00297             }
00298          }
00299 
00300       // mbs buffer header structure:
00301       s_bufhe* bufheader=fMbsEvent->GetMbsBufferHeader();
00302       if(bufheader)
00303          {
00304             cout <<"Last Buffer:"<<endl;
00305             cout <<"\tNumber: "<<bufheader->l_buf << endl;
00306             cout <<"\tTime: "<<ctime((const time_t*) &(bufheader->l_time[0]));
00307             cout << "\t\t\t + "<<bufheader->l_time[1] << " µs"<<endl;
00308          }
00309 
00310 
00311     }
00312 
00314 
00315    fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between
00316    fEvents=0;
00317    return 0;
00318 }
00319 
00320 //-----------------------------------------------------------
00321 Int_t TMeshAnalysis::UserEventFunc()
00322 {
00324    Int_t value = 0;
00325    Int_t count = 0;
00326    if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2; // total longwords
00327    fSize->Fill(value); // fill histogram
00328    fEvents++;
00329    if(fEvents == 1 || IsNewInputFile()) {
00330       if(fMbsEvent) {
00331          count=fMbsEvent->GetCount();
00332          cout << "\nFirst event #: " << count  << endl;
00333          s_bufhe* bufheader=fMbsEvent->GetMbsBufferHeader();
00334          if(bufheader) {
00335             cout <<"First Buffer:"<<endl;
00336             cout <<"\tNumber: "<<bufheader->l_buf << endl;
00337             cout <<"\tTime: "<<ctime((const time_t*) &(bufheader->l_time[0]));
00338             cout << "\t\t\t + "<<bufheader->l_time[1] << " µs"<<endl;
00339          }
00340       }
00341       SetNewInputFile(kFALSE); // we have to reset the newfile flag
00342    }
00343    fLastEvent = count;
00344    return 0;
00345 }
00346 //-----------------------------------------------------------
00347 
00348 ClassImp(TMeshAnalysis)
00349 
00350 
00351 
00352 
00353 //----------------------------END OF GO4 SOURCE FILE ---------------------

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