GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4SimpleEventProcessor.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
15 
16 #include "TGo4Log.h"
17 #include "TGo4SimpleEvent.h"
18 #include "TGo4SimpleSubEvent.h"
19 #include "Go4EventServer.h"
20 
22 :TGo4EventProcessor("Go4 Standard SimpleEvent Processor")
23 {
24  GO4TRACE((14,"TGo4SimpleEventProcessor::TGo4SimpleEventProcessor(Int_t)",__LINE__, __FILE__));
25 }
26 
28 {
29  GO4TRACE((14,"TGo4SimpleEventProcessor::TGo4SimpleEventProcessor(Int_t)",__LINE__, __FILE__));
30 }
31 
33 {
34  GO4TRACE((11,"TGo4SimpleEventProcessor::TGo4SimpleEventProcessor(Int_t)",__LINE__, __FILE__));
36 
37  if (!input) {
38  TGo4Log::Error("Simple Event Processor: no input event !");
39  return kFALSE;
40  }
41 
42 
43  Short_t procid;
44  input->ResetIterator();
45  while (auto insub = input->NextSubEvent()) {
46  // find out procid
47  procid = insub->GetProcid();
48  auto outsubix = target->GetSubEvent(procid);
49  TGo4SimpleSubEvent *outsub = nullptr;
50  if (outsubix) {
51  outsub = outsubix;
52  } else {
53  // no such procid in array, add new one
54  outsub = target->AddSubEvent(procid);
55  if (!outsub) {
56  TGo4Log::Error("simple event processor: error adding subevent");
57  return kFALSE;
58  }
59 
60  } // if (outsubix)
61 
62  // copy subevent data of that procid into target struct
63  outsub->Clear();
64  Int_t fieldsize = (insub->GetDlen() - 2) * sizeof(Short_t) / sizeof(Int_t);
65  outsub->fiFieldLen = fieldsize;
66  void *sourcefield = (void *)(insub->GetDataField());
67  void *destfield = (void *)&(outsub->fiD0);
68  memcpy(destfield, sourcefield, fieldsize * sizeof(Int_t));
69 
70  } // while
71  target->fiCount = input->GetCount();
72  return kTRUE;
73 }
TGo4SimpleSubEvent * AddSubEvent(Short_t procid)
TGo4MbsSubEvent * NextSubEvent(Bool_t all=kFALSE)
TGo4SimpleSubEvent * GetSubEvent(Short_t procid)
Bool_t BuildSimpleEvent(TGo4SimpleEvent *target)
Int_t GetCount() const
Definition: TGo4MbsEvent.h:151
static void Error(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:320
TGo4EventElement * GetInputEvent()
#define GO4TRACE(X)
Definition: TGo4Log.h:25
void Clear(Option_t *opt="") override
void ResetIterator()
Definition: TGo4MbsEvent.h:100