StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSvtDaqMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StSvtDaqMaker.cxx,v 1.21 2016/04/21 01:36:24 perev Exp $
4  *
5  * Author: Marcelo Munhoz
6  ***************************************************************************
7  *
8  * Description: SVT Library Maker
9  *
10  ***************************************************************************
11  *
12  * $Log: StSvtDaqMaker.cxx,v $
13  * Revision 1.21 2016/04/21 01:36:24 perev
14  * Remove redundant commentout
15  *
16  * Revision 1.20 2007/05/17 08:56:19 caines
17  * Remove printf
18  *
19  * Revision 1.19 2007/04/28 17:57:08 perev
20  * Redundant StChain.h removed
21  *
22  * Revision 1.18 2005/12/07 20:48:50 perev
23  * EndCrashFix
24  *
25  * Revision 1.17 2005/08/04 04:07:27 perev
26  * Cleanup
27  *
28  * Revision 1.16 2004/03/18 01:51:05 caines
29  * Make sure GetDaqReader returns something as it is declared Int_t
30  *
31  * Revision 1.15 2004/02/04 16:14:23 munhoz
32  * fix few problems with pedestal reading
33  *
34  * Revision 1.14 2004/02/03 21:47:27 perev
35  * Error ==>Warning
36  *
37  * Revision 1.13 2004/01/30 00:14:42 munhoz
38  * few corrections to pedestal reading and adding getDaqReader method
39  *
40  * Revision 1.12 2002/02/27 01:37:20 munhoz
41  * move GetDataSet(StDAQReader) from Init() to Make()
42  *
43  * Revision 1.11 2002/02/15 02:39:28 munhoz
44  * switching from .const to .data
45  *
46  * Revision 1.10 2001/10/24 16:49:42 munhoz
47  * adding capability to retrieve t0 and first SCA
48  *
49  * Revision 1.9 2001/09/16 22:08:44 caines
50  * Add extra checks for when SVT isnt in every event
51  *
52  * Revision 1.8 2001/07/11 23:29:47 munhoz
53  * adding capability for zero suppressed and pedestal reading
54  *
55  * Revision 1.6 2000/08/23 22:29:08 munhoz
56  * add time to StSvtData object
57  *
58  * Revision 1.5 2000/08/04 21:03:51 perev
59  * Leaks + Clear() cleanup
60  *
61  * Revision 1.4 2000/07/04 02:36:53 perev
62  * formal corrections, gStChain removed
63  *
64  * Revision 1.3 2000/07/01 20:14:06 caines
65  * Removed unneccesary delete that was crashing code
66  *
67  * Revision 1.2 2000/06/25 20:40:16 caines
68  * Add debugging statements and protection against SVT not being there
69  *
70  *
71  **************************************************************************/
72 
73 #include "St_DataSetIter.h"
74 #include "TObjectSet.h"
75 #include "StDAQMaker/StSVTReader.h"
76 #include "StSvtDaqData.hh"
77 #include "StSvtDaqPed.hh"
78 #include "StSvtHybridDaqData.hh"
79 #include "StSvtDaqMaker.h"
80 #include "StMessMgr.h"
81 #include "StSvtClassLibrary/StSvtConfig.hh"
82 
83 ClassImp(StSvtDaqMaker)
84 
85 //_____________________________________________________________________________
86  StSvtDaqMaker::StSvtDaqMaker(const char *name, const char* config, const char* data):StMaker(name)
87 {
88  fConfig = config;
89  fDataType = data;
90 
91  fData = NULL;
92  fSvtData = NULL;
93 
94  fSvtSet = NULL;
95  fHybridSet = NULL;
96 
97  fPedSet = NULL;
98  fSvtPed = NULL;
99  fRMSPedSet = NULL;
100  fSvtRMSPed = NULL;
101 
102  daqReader = NULL;
103  svtReader = NULL;
104 }
105 
106 //_____________________________________________________________________________
107 StSvtDaqMaker::~StSvtDaqMaker()
108 {
109  delete fData; fData = 0;
110  fSvtData = 0;
111 }
112 
113 //_____________________________________________________________________________
114 Int_t StSvtDaqMaker::Init()
115 {
116  if (Debug()) gMessMgr->Debug() << "StSvtDaqMaker::Init" << endm;
117 
118  daqReader = NULL;
119 
120  /*
121  St_DataSet *dataSet;
122  dataSet = GetDataSet("StDAQReader");
123  assert(dataSet);
124  daqReader = (StDAQReader*)(dataSet->GetObject());
125  assert(daqReader);
126  */
127 
128  SetSvtData();
129 
130  return StMaker::Init();
131 }
132 
133 /*
134 //_____________________________________________________________________________
135 Int_t StSvtDaqMaker::InitRun(int runnumber)
136 {
137  if (Debug()) gMessMgr->Debug() << "StSvtDaqMaker::InitRun" << endm;
138 
139  SetSvtData();
140 
141  return 0;
142 }
143 */
144 
145 //_____________________________________________________________________________
146 Int_t StSvtDaqMaker::SetSvtData()
147 {
148  fSvtSet = new TObjectSet("StSvtRawData");
149  AddData(fSvtSet);
150 
151  St_DataSet *dataSet = NULL;
152  dataSet = GetDataSet("StSvtConfig");
153 
154 
155  if (dataSet)
156  fSvtData = new StSvtDaqData((StSvtConfig*)(dataSet->GetObject()));
157  else
158  fSvtData = new StSvtDaqData(fConfig);
159 
160  fSvtSet->SetObject(fSvtData);
161 
162  return kStOK;
163 }
164 
165 //_____________________________________________________________________________
166 Int_t StSvtDaqMaker::SetSvtPed()
167 {
168  St_DataSet *dataSet;
169  dataSet = (TObjectSet*)GetDataSet("StSvtPedestal");
170 
171  if (!dataSet) {
172  fPedSet = new TObjectSet("StSvtPedestal");
173  AddConst(fPedSet);
174 
175  St_DataSet *dataSet2;
176  dataSet2 = GetDataSet("StSvtConfig");
177 
178  if (!fSvtPed) {
179  if (dataSet2)
180  fSvtPed = new StSvtDaqPed((StSvtConfig*)(dataSet2->GetObject()));
181  else
182  fSvtPed = new StSvtDaqPed(fConfig);
183  fPedSet->SetObject((TObject*)fSvtPed);
184  //assert(fSvtPed);
185  }
186  }
187  else {
188  fSvtPed = (StSvtDaqPed*)(dataSet->GetObject());
189  assert(fSvtPed);
190  }
191 
192  return kStOK;
193 }
194 
195 //_____________________________________________________________________________
196 Int_t StSvtDaqMaker::SetSvtRMSPed()
197 {
198  St_DataSet *dataSet;
199  dataSet = (TObjectSet*)GetDataSet("StSvtRMSPedestal");
200 
201  if (!dataSet) {
202  fRMSPedSet = new TObjectSet("StSvtRMSPedestal");
203  AddConst(fRMSPedSet);
204 
205  St_DataSet *dataSet2;
206  dataSet2 = GetDataSet("StSvtConfig");
207 
208  if (!fSvtRMSPed) {
209  if (dataSet2)
210  fSvtRMSPed = new StSvtDaqPed((StSvtConfig*)(dataSet2->GetObject()));
211  else
212  fSvtRMSPed = new StSvtDaqPed(fConfig);
213  fRMSPedSet->SetObject((TObject*)fSvtRMSPed);
214  //assert(fSvtPed);
215  }
216  }
217  else {
218  fSvtRMSPed = (StSvtDaqPed*)(dataSet->GetObject());
219  assert(fSvtRMSPed);
220  }
221 
222  return kStOK;
223 }
224 
225 //_____________________________________________________________________________
226 Int_t StSvtDaqMaker::SetHybridData()
227 {
228  fHybridSet = new TObjectSet("StHybridRawData");
229  AddData(fHybridSet);
230 
231  return kStOK;
232 }
233 
234 
235 //_____________________________________________________________________________
237 {
238  if (Debug()) gMessMgr->Debug() << "StSvtDaqMaker::Make" << endm;
239 
240  GetDaqReader();
241 
242  return GetSvtData();
243 }
244 
245 //_____________________________________________________________________________
246 Int_t StSvtDaqMaker::GetDaqReader()
247 {
248  St_DataSet *dataSet;
249  dataSet = GetDataSet("StDAQReader");
250  assert(dataSet);
251  daqReader = (StDAQReader*)(dataSet->GetObject());
252  assert(daqReader);
253  return kStOk;
254 }
255 
256 //_____________________________________________________________________________
257 Int_t StSvtDaqMaker::GetSvtData()
258 {
259 
260  if( !daqReader->SVTPresent ()){
261  gMessMgr->Warning() << "SVT -No SVT Present but trying to read it" << endm;
262  return kStWarn;
263  }
264  svtReader = daqReader->getSVTReader();
265  assert(svtReader);
266 
267  if( !fSvtSet) SetSvtData();
268 
269  fSvtData->setData(svtReader, fDataType);
270 
271  fSvtData->setRunNumber(daqReader->getRunNumber());
272  fSvtData->setEventNumber(daqReader->getEventNumber());
273  fSvtData->setTrigWord(daqReader->getTrigWord());
274  fSvtData->setUnixTime(daqReader->getUnixTime());
275 
276  return kStOK;
277 }
278 
279 //_____________________________________________________________________________
280 Int_t StSvtDaqMaker::GetSvtPed()
281 {
282 
283  if( !daqReader->SVTPresent ()){
284  gMessMgr->Warning() << "SVT -No SVT Present but trying to read it" << endm;
285  if( fSvtPed) Reset();
286  return kStWarn;
287  }
288  svtReader = daqReader->getSVTReader();
289  assert(svtReader);
290 
291  if (!fSvtPed) SetSvtPed();
292 
293  fSvtPed->setPed(svtReader);
294 
295  fSvtPed->setRunNumber(daqReader->getRunNumber());
296 
297  return kStOK;
298 }
299 
300 //_____________________________________________________________________________
301 Int_t StSvtDaqMaker::GetSvtRMSPed()
302 {
303 
304  if( !daqReader->SVTPresent ()){
305  gMessMgr->Warning() << "SVT -No SVT Present but trying to read it" << endm;
306  if( fSvtRMSPed) Reset();
307  return kStWarn;
308  }
309  svtReader = daqReader->getSVTReader();
310  assert(svtReader);
311 
312  if (!fSvtRMSPed) SetSvtRMSPed();
313 
314  fSvtRMSPed->setPed(svtReader,"RMS");
315 
316  fSvtRMSPed->setRunNumber(daqReader->getRunNumber());
317 
318  return kStOK;
319 }
320 
321 //_____________________________________________________________________________
322 Int_t StSvtDaqMaker::GetHybridData(int barrel, int ladder, int wafer, int hybrid)
323 {
324  if (Debug()) gMessMgr->Debug() << "StSvtDaqMaker::Make" << endm;
325 
326  int status = 0;
327 
328  if (!fData) {
329  fData = new StSvtHybridDaqData(barrel, ladder, wafer, hybrid);
330  fHybridSet->SetObject((TObject*)fData);
331  }
332 
333  svtReader = daqReader->getSVTReader();
334  assert(svtReader);
335 
336  if (fSvtData->getHybridIndex(barrel,ladder,wafer,hybrid) < 0)
337  delete fData;
338  else
339  status = fData->setHybridData(svtReader, fDataType);
340 
341  return kStOK;
342 }
343 
344 //_____________________________________________________________________________
345 Int_t StSvtDaqMaker::GetUnixTime()
346 {
347  if (daqReader)
348  return daqReader->getUnixTime();
349  else
350  return 0;
351 }
352 
353 //_____________________________________________________________________________
354 void StSvtDaqMaker::PrintEventInfo()
355 {
356  if (daqReader)
357  daqReader->printEventInfo();
358 }
359 
360 //_____________________________________________________________________________
361 void StSvtDaqMaker::Clear(const char*)
362 {
363  if (Debug()) gMessMgr->Debug() << "StSvtDaqMaker::Clear" << endm;
364 
365  fSvtData = NULL;
366  fHybridSet = NULL;
367  fSvtPed = NULL;
368  fSvtSet = NULL;
369 
370  StMaker::Clear();
371 }
372 
373 //_____________________________________________________________________________
374 Int_t StSvtDaqMaker::Reset()
375 {
376  if (Debug()) gMessMgr->Debug()<< "StSvtDaqMaker::Reset" << endm;
377  return kStOK;
378 }
379 
380 //_____________________________________________________________________________
382 {
383  if (Debug()) gMessMgr->Debug()<< "StSvtDaqMaker::Finish" << endm;
384 
385  return kStOK;
386 }
387 
388 //_____________________________________________________________________________
389 void StSvtDaqMaker::PrintInfo()
390 {
391  gMessMgr->Info() <<
392  "**************************************************************" << endm;
393  gMessMgr->Info() <<
394  "* $Id: StSvtDaqMaker.cxx,v 1.21 2016/04/21 01:36:24 perev Exp $" << endm;
395  gMessMgr->Info() <<
396  "**************************************************************" << endm;
397  if (Debug()) StMaker::PrintInfo();
398 }
399 
400 //_____________________________________________________________________________
401 void StSvtDaqMaker::UpdateReader()
402 {
403  if (svtReader)
404  svtReader->Update();
405 }
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StMaker.cxx:634
virtual Int_t Make()
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:59
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TDataSet.cxx:428
Definition: Stypes.h:42
Definition: Stypes.h:40
Definition: Stypes.h:41
virtual Int_t Finish()