GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TMeshUnpackProc.cxx
Go to the documentation of this file.
1 // $Id: TMeshUnpackProc.cxx 2627 2019-10-01 08:02:45Z linev $
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 
14 #include "TMeshUnpackProc.h"
15 
16 #include "TGo4MbsEvent.h"
17 #include "TGo4Log.h"
18 
19 #include "TMeshRawEvent.h"
20 #include "TMeshB1InputEvent.h"
21 #include "TMeshB2InputEvent.h"
22 
23 //***********************************************************
25  TGo4EventProcessor("Unpacker")
26 {
27 }
28 //***********************************************************
29 // this one is used in TXXXUnpackFact.cxx
31  TGo4EventProcessor(name)
32 {
33  TGo4Log::Info("TMeshUnpackProc: Create %s", name);
34 }
35 
36 //***********************************************************
38 {
39 }
40 //***********************************************************
41 
42 //-----------------------------------------------------------
44 {
45  if(poutevt==0) return;
46  // process subcomponents independently
47  // note: this will run subevent loop each time, which is not performance optimized in this example
48  // however, for the general case this unpacker decoupling is more suitable
49  UnpackBranch1(&(poutevt->fxSub1));
50  UnpackBranch2(&(poutevt->fxSub2));
51  UnpackBranch3(&(poutevt->fxSub3));
52  poutevt->SetValid(kTRUE); // to store
53 }
54 
55 
57 {
58  fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
59  if(fInput==0) {
60  TGo4Log::Error("UnpackBranch1: no input event !");
61  return;
62  }
63 
64  Int_t index(0), value(0), lwords(0);
65  Int_t *pdata(0);
66  TGo4MbsSubEvent* psubevt(0);
68  while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
69  {
70  if( psubevt->GetSubcrate() == 1)
71  {
72  pdata=psubevt->GetDataField();
73  lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
74  if(lwords >= 8) lwords=8; // take only first 8 lwords
75  for(Int_t i = 0; i<lwords; ++i)
76  {
77  index = *pdata&0xfff; // in case low word is index
78  value = *pdata; // save for 2d histogram
79  //value = (*pdata>>16)&0xfff; // in case high word is data
80  if((value != 0) && (index>=0)) {
81  poutevt->fiCrate1[i] = value; // fill output event
82  }
83  pdata++;
84  } // for SEW LW
85  } // if (subcrate)
86 
87  } // while
88  poutevt->SetValid(kTRUE); // to store
89 }
90 
92 {
93  fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
94  if(fInput==0) {
95  TGo4Log::Error("UnpackBranch2: no input event !");
96  return;
97  }
98 
99  Int_t index(0), value(0), lwords(0);
100  Int_t *pdata(0);
101  TGo4MbsSubEvent* psubevt(0);
103  while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
104  {
105  if( psubevt->GetSubcrate() == 2)
106  {
107  pdata=psubevt->GetDataField();
108  lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
109  if(lwords >= 8) lwords=8;
110  for(Int_t i = 0; i<lwords; ++i)
111  {
112  index = *pdata&0xfff;
113  //value=(*pdata>>16)&0xfff;
114  value = *pdata;
115  if((value != 0) && (index>=0)) {
116  poutevt->fiCrate2[i] = value;
117  }
118  pdata++;
119  } // for SEW LW
120  } // if (subcrate)
121  } // while
122  poutevt->SetValid(kTRUE); // to store
123 }
124 
126 {
127  fInput = dynamic_cast<TGo4MbsEvent*> (GetInputEvent()); // from this
128  if(fInput==0) {
129  TGo4Log::Error("UnpackBranch3: no input event !");
130  return;
131  }
132 
133  Int_t index(0), value(0), lwords(0);
134  Int_t *pdata(0);
135  TGo4MbsSubEvent* psubevt(0);
137  while ((psubevt = fInput->NextSubEvent()) != 0) // subevent loop
138  {
139  if( psubevt->GetSubcrate() == 3)
140  {
141  pdata=psubevt->GetDataField();
142  lwords= (psubevt->GetDlen() -2) * sizeof(Short_t)/sizeof(Int_t);
143  if(lwords >= 8) lwords=8; // take only first 8 lwords
144  for(Int_t i = 0; i<lwords; ++i)
145  {
146  index = *pdata&0xfff; // in case low word is index
147  //value = (*pdata>>16)&0xfff; // in case high word is data
148  value = *pdata;
149  if((value != 0) && (index>=0)) {
150  poutevt->fiCrate3[i] = value; // fill output event
151  }
152  pdata++;
153  } // for SEW LW
154  } // if (subcrate)
155  } // while
156  poutevt->SetValid(kTRUE); // to store
157 }
void UnpackBranch1(TMeshB1InputEvent *target)
TGo4MbsEvent * fInput
void UnpackBranch3(TMeshB3InputEvent *target)
void SetValid(Bool_t on)
Int_t GetDlen() const
TMeshB1InputEvent fxSub1
Definition: TMeshRawEvent.h:47
TGo4MbsSubEvent * NextSubEvent(Bool_t all=kFALSE)
void Unpack(TMeshRawEvent *target)
TMeshB2InputEvent fxSub2
Definition: TMeshRawEvent.h:48
Int_t * GetDataField()
TMeshB3InputEvent fxSub3
Definition: TMeshRawEvent.h:49
TGo4EventElement * GetInputEvent()
Char_t GetSubcrate() const
void UnpackBranch2(TMeshB2InputEvent *target)
virtual ~TMeshUnpackProc()
void ResetIterator()
Definition: TGo4MbsEvent.h:101
static void Error(const char *text,...)
Definition: TGo4Log.cxx:313
static void Info(const char *text,...)
Definition: TGo4Log.cxx:287