StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDAQMaker.cxx
1 // //
3 // StDAQMaker class for Makers //
4 // Author Victor Perev //
5 // //
7 #include <Stiostream.h>
8 #include "TObjectSet.h"
9 #include "StDAQMaker.h"
10 #include "StDAQReader.h"
11 #include "StTPCReader.h"
12 #include "StSCReader.h"
13 #include "StRtsTable.h"
14 #include "StRtsReaderMaker.h"
15 
16 ClassImp(StDAQMaker)
17 
18 //_____________________________________________________________________________
19  StDAQMaker::StDAQMaker(const char *name, const char *inputFile):
20  StIOInterFace(name),fEvtHddr(0),fDAQReader(0),fDAQReaderSet(0),fRtsMaker(0)
21 {
22  if (inputFile && inputFile[0]) SetFile(inputFile);
23  fRtsMaker = new StRtsReaderMaker; // Create StRtsMaker to assure its correct position
24 }
25 //_____________________________________________________________________________
26 StDAQMaker::~StDAQMaker()
27 {
28  delete fDAQReader;
29  //delete fEvtHddr; Better small leak than crash
30  fDAQReaderSet=0;
31 }
32 //_____________________________________________________________________________
33 Int_t StDAQMaker::Init()
34 {
35  if (fDAQReaderSet) return 0;
36  fDAQReaderSet = new TObjectSet("StDAQReader",0,kFALSE);
37  AddConst(fDAQReaderSet); SetOutput(fDAQReaderSet); //Declare for output
38 
39  fEvtHddr = GetEvtHddr();
40 // Get run parameters from input file
41 
42  return Open();
43 }
44 //_____________________________________________________________________________
45 Int_t StDAQMaker::Open(const char*)
46 {
47  if (fDAQReader && fDAQReader->isOpened()) return 0;
48  LOG_INFO << "Open Input file" << GetFile() << endm;
49  if(!fDAQReader) fDAQReader = new StDAQReader(0,fRtsMaker);
50  if (GetDebug()>1) fDAQReader->setVerbose(1);
51  fDAQReader->open(GetFile());
52  fDAQReaderSet->SetObject((TObject*)fDAQReader,kFALSE);
53  return 0;
54 }
55 //_____________________________________________________________________________
56 void StDAQMaker::Close(Option_t *)
57 {
58  Clear();
59  fDAQReader->close();
60 }
61 //_____________________________________________________________________________
62 Int_t StDAQMaker::Skip(int nskip){
63  return fDAQReader->skipEvent(nskip);
64 }
65 //_____________________________________________________________________________
67 
68  int iret = fDAQReader->Make();
69 
70  if (iret==kStErr) return kStErr; // Herb, July 5 2000. Skip "Token 0" events.
71  if (iret) iret = kStEOF;
72  if (iret) return iret;
73 
74 
75  fEvtHddr->SetRunNumber ( fDAQReader->getRunNumber() );
76  fEvtHddr->SetEventNumber ( fDAQReader->getEventNumber() );
77  fEvtHddr->SetInputTriggerMask ( fDAQReader->getTrigInputWord());
78  fEvtHddr->SetTriggerMask ( fDAQReader->getTrigWord() );
79  fEvtHddr->SetGMTime ( fDAQReader->getUnixTime() );
80  fEvtHddr->SetEventSize ( fDAQReader->getEventSize() );
81  if (Debug()) {
82  fDAQReader->printEventInfo();
83  fEvtHddr->Print();
84  }
85 
86  if ( !( fDAQReader->getUnixTime() || fDAQReader->getEventSize() ) ) {
87  LOG_ERROR << " The run: " << fDAQReader->getRunNumber()
88  << "/ event: " << fDAQReader->getEventNumber()
89  << ((!fDAQReader->getUnixTime()) ? " timestamp " : " size" )
90  << " is not correct "
91  << endm;
92  fDAQReader->printEventInfo();
93  fEvtHddr->Print();
94  iret = kStEOF;
95  return iret;
96  }
97 
98  StRtsTable *daqTofTable = GetNextLegacy();
99  if (daqTofTable) {
100  sc_t *c = (sc_t*)*DaqDta()->begin();
101  StSCReader scReader(c,fDAQReader->getUnixTime());
102  AddData(scReader.getSCTable());
103  }
104  int adcOnly = IAttr("adcOnly");
105  if (GetDebug()<=1 && !adcOnly) return 0;
106 
107 
108  StTPCReader *myTPCReader = fDAQReader->getTPCReader();
109 
110  int nPads=0;
111  if ( myTPCReader ) {
112  for (int sector =1; sector <=12; sector++)
113  {
114  unsigned char* padList;
115  for (int padRow=1; padRow<=45; padRow++)
116  {
117  int npad = myTPCReader->getPadList(sector,padRow,padList);
118  if (npad <0) break;
119  if (npad==0) continue;
120  nPads+=npad;
121  if (GetDebug()>1)
122  LOG_INFO << Form("Sector=%2d PadRow=%2d nPads=%3d\n",sector,padRow,npad) << endm;
123  }
124  }
125  }
126  if (nPads==0 && adcOnly) return kStSKIP;
127  return 0;
128 }
129 //_____________________________________________________________________________
130 void StDAQMaker::Clear(const char*)
131 {
132  if (fDAQReader) fDAQReader->clear();
133  StMaker::Clear();
134 }
135 
136 
137 
Definition: Stypes.h:48
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 void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:59
Definition: daq_sc.h:6
virtual Int_t Make()
Definition: StDAQMaker.cxx:66
StRtsTable * DaqDta()
Return the current DAQ data block. This member function is provided for convenience.
Definition: Stypes.h:43
virtual StRtsTable * GetNextLegacy()
This is an overloaded member function, provided for convenience.
Definition: Stypes.h:44