StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerDataMaker.cxx
1 #include "StTriggerDataMaker.h"
2 #include <stdlib.h>
3 //#include "StEventTypes.h"
4 #include "StDAQMaker/StDAQReader.h"
5 #include "StDAQMaker/StTRGReader.h"
6 #include "StDaqLib/TRG/trgStructures2003.h"
7 #include "StEvent/StTriggerData2003.h"
8 #include "StDaqLib/TRG/trgStructures2004.h"
9 #include "StEvent/StTriggerData2004.h"
10 #include "StDaqLib/TRG/trgStructures2005.h"
11 #include "StEvent/StTriggerData2005.h"
12 #include "StDaqLib/TRG/trgStructures2007.h"
13 #include "StEvent/StTriggerData2007.h"
14 #include "StDaqLib/TRG/trgStructures2008.h"
15 #include "StEvent/StTriggerData2008.h"
16 #include "StDaqLib/TRG/trgStructures2009.h"
17 #include "StEvent/StTriggerData2009.h"
18 #include "StDaqLib/TRG/trgStructures2012.h"
19 #include "StEvent/StTriggerData2012.h"
20 #include "StDaqLib/TRG/trgStructures2013.h"
21 #include "StEvent/StTriggerData2013.h"
22 #include "StDaqLib/TRG/trgStructures2016.h"
23 #include "StEvent/StTriggerData2016.h"
24 #include "StDaqLib/TRG/trgStructures2017.h"
25 #include "StEvent/StTriggerData2017.h"
26 #include "StDaqLib/TRG/trgStructures2018.h"
27 #include "StEvent/StTriggerData2018.h"
28 #include "StDaqLib/TRG/trgStructures2019.h"
29 #include "StEvent/StTriggerData2019.h"
30 #include "StDaqLib/TRG/trgStructures2022.h"
31 #include "StEvent/StTriggerData2022.h"
32 #include "TFile.h"
33 #include "TH1.h"
34 
35 ClassImp(StTriggerDataMaker)
36 
37 //_____________________________________________________________________________
38 
39 StTriggerDataMaker::StTriggerDataMaker(const char *name):StRTSBaseMaker("trg",name)
40 {
41  LOG_INFO << "Constructing StTriggerDataMaker with name=" << name << endm;
42  mDebug=0;
43 }
44 
45 //_____________________________________________________________________________
46 
48 {
49  LOG_DEBUG << "StTriggerDataMaker Make() starting..........Run="
50  << GetRunNumber() << " : Event=" << GetEventNumber() << endm;
51 
52  int year=0, run=0;
53  const TrgDataType2003 *trgdata2003=0;
54  const TrgDataType2004 *trgdata2004=0;
55  const TrgDataType2005 *trgdata2005=0;
56  const TrgDataType2007 *trgdata2007=0;
57  const TrgDataType2008 *trgdata2008=0;
58  const TriggerDataBlk2009 *trgdata2009=0;
59  const TriggerDataBlk2012 *trgdata2012=0;
60  const TriggerDataBlk2013 *trgdata2013=0;
61  const TriggerDataBlk2016 *trgdata2016=0;
62  const TriggerDataBlk2017 *trgdata2017=0;
63  const TriggerDataBlk2018 *trgdata2018=0;
64  const TriggerDataBlk2019 *trgdata2019=0;
65  const TriggerDataBlk2022 *trgdata2022=0;
66 
67  St_DataSet* daqReaderDS = GetDataSet("StDAQReader");
68  if (!daqReaderDS) return kStWarn;
69  StDAQReader* daqReader = (StDAQReader*)(daqReaderDS->GetObject());
70  if (!daqReader) return kStWarn;
71 
72  run = daqReader->getRunNumber();
73 
74  StTRGReader* trgReader = daqReader->getTRGReader();
75  if (trgReader && ( year = trgReader->getYear()) ){
76 
77  LOG_INFO << "StTriggerDataMaker Make() found old data for year " << year << endm;
78  switch(year){
79  case 2003:
80  trgdata2003=trgReader->getDataType2003();
81  if (!trgdata2003) return kStWarn;
82  AddData(new TObjectSet("StTriggerData",new StTriggerData2003(trgdata2003,run),kTRUE));
83  break;
84  case 2004:
85  trgdata2004=trgReader->getDataType2004();
86  if (!trgdata2004) return kStWarn;
87  AddData(new TObjectSet("StTriggerData",new StTriggerData2004(trgdata2004,run),kTRUE));
88  break;
89  case 2005:
90  trgdata2005=trgReader->getDataType2005();
91  if (!trgdata2005) return kStWarn;
92  AddData(new TObjectSet("StTriggerData",new StTriggerData2005(trgdata2005,run),kTRUE));
93  break;
94  case 2007:
95  trgdata2007=trgReader->getDataType2007();
96  if (!trgdata2007) return kStWarn;
97  AddData(new TObjectSet("StTriggerData",new StTriggerData2007(trgdata2007,run),kTRUE));
98  break;
99  case 2008:
100  trgdata2008=trgReader->getDataType2008();
101  if (!trgdata2008) return kStWarn;
102  AddData(new TObjectSet("StTriggerData",new StTriggerData2008(trgdata2008,run),kTRUE));
103  break;
104  }
105  } else {
106  if(mDebug>1) LOG_INFO << "StTriggerDataMaker Make() found no old format data, trying to get new data format" << endm;
107 
108  StRtsTable *daqData = GetNextRaw();
109  if ( daqData ){
110  char* data = daqData->GetTable();
111  if(data){
112  char version = data[3];
113  LOG_INFO << Form("StTriggerDataMaker Make() found new data formt with version = %02x%02x%02x%02x",
114  data[0],data[1],data[2],data[3]) << endm;
115  switch(version){
116  case 0x40:
117  year=2009;
118  trgdata2009 = (TriggerDataBlk2009*)data;
119  AddData(new TObjectSet("StTriggerData",new StTriggerData2009(trgdata2009,run,1,mDebug),kTRUE));
120  break;
121  case 0x41:
122  year=2012;
123  trgdata2012 = (TriggerDataBlk2012*)data;
124  AddData(new TObjectSet("StTriggerData",new StTriggerData2012(trgdata2012,run,1,mDebug),kTRUE));
125  break;
126  case 0x42:
127  year=2013;
128  trgdata2013 = (TriggerDataBlk2013*)data;
129  AddData(new TObjectSet("StTriggerData",new StTriggerData2013(trgdata2013,run,1,mDebug),kTRUE));
130  break;
131  case 0x43:
132  year=2016;
133  trgdata2016 = (TriggerDataBlk2016*)data;
134  AddData(new TObjectSet("StTriggerData",new StTriggerData2016(trgdata2016,run,1,mDebug),kTRUE));
135  break;
136  case 0x44:
137  year=2017;
138  trgdata2017 = (TriggerDataBlk2017*)data;
139  AddData(new TObjectSet("StTriggerData",new StTriggerData2017(trgdata2017,run,1,mDebug),kTRUE));
140  break;
141  case 0x45:
142  year=2018;
143  trgdata2018 = (TriggerDataBlk2018*)data;
144  AddData(new TObjectSet("StTriggerData",new StTriggerData2018(trgdata2018,run,1,mDebug),kTRUE));
145  break;
146  case 0x46:
147  year=2019;
148  trgdata2019 = (TriggerDataBlk2019*)data;
149  AddData(new TObjectSet("StTriggerData",new StTriggerData2019(trgdata2019,run,1,mDebug),kTRUE));
150  break;
151  case 0x47:
152  year=2022;
153  trgdata2022 = (TriggerDataBlk2022*)data;
154  AddData(new TObjectSet("StTriggerData",new StTriggerData2022(trgdata2022,run,1,mDebug),kTRUE));
155  break;
156  default:
157  LOG_INFO << "StTriggerDataMaker Make() found new data but with unknown version = " << version << endm;
158  }
159  } else {
160  LOG_INFO << "StTriggerDataMaker Make() found no new data format neither" << endm;
161  }
162  } else {
163  LOG_WARN << "StTriggerDataMaker Make() - GetNextRaw() returned nothing" << endm;
164  }
165  }
166 
167  if(year==0){
168  LOG_INFO << "StTriggerDataMaker Make() finished. Found no trigger data" << endm;
169  return kStWarn;
170  }else{
171  TObjectSet *os = (TObjectSet*)GetDataSet("StTriggerData");
172  if (os) {
173  StTriggerData* pTrg = (StTriggerData*)os->GetObject();
174  if(pTrg){
175  // if(mDebug>0) pTrg->dump();
176  unsigned int err = pTrg->errorFlag();
177  LOG_DEBUG << "StTriggerDataMaker Make() finished. Found trigger data for year "<< year <<" mErrorFlag="<<err<<endm;
178  if(err==0){
179  return kStOK;
180  }else{
181  LOG_INFO << "StTriggerDataMaker Make() found fatal decording error "<< endm;
182  pTrg->setDebug(1);
183  if(year>=2009) pTrg->readData();
184  pTrg->setDebug(mDebug);
185  return kStWarn;
186  }
187  }
188  }
189  LOG_INFO << "StTriggerDataMaker Make() finished. Failed to addData trigger data" << endm;
190  return kStWarn;
191  }
192 }
Class StRTSBaseMaker - is an abstract StMaker to define the interface to access the DAQ data from the...
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
virtual StRtsTable * GetNextRaw()
This is an overloaded member function, provided for convenience.
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
virtual Int_t GetRunNumber() const
Returns the current RunNumber.
Definition: StMaker.cxx:1054
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56