StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEMCPlots.cxx
1 #ifndef NEW_DAQ_READER
2 # include "evpReader.hh"
3 # include "emcReader.h"
4 # include "trgReader.h"
5 #else
6 # include "DAQ_READER/daqReader.h"
7 # include "DAQ_READER/daq_dta.h"
8 # include "DAQ_EMC/daq_emc.h"
9 # include "DAQ_ETOW/daq_etow.h"
10 # include "DAQ_ESMD/daq_esmd.h"
11 # include "DAQ_TRG/daq_trg.h"
12 # include "DAQ_READER/evpReaderClass.h"
13 # include "DAQ_EMC/emcReader.h"
14 # include <RTS/include/daqFormats.h>
15 #endif
16 
17 #include <TObjArray.h>
18 
19 #include "StEEmcUtil/database/StEEmcDb.h"
20 
21 #include "EEMCPlots.h"
22 #include "EEqaSorter.h"
23 #include "Tonko2Ezt.h"
24 
25 EEMCPlots *EEMCPlotsInstance = 0;
26 
27 //-------------------------------------------------------------------
28 void EEMCPlots::initHisto(TObjArray *list, const char *eemcDbDump, const char *eemcPathIn, const char *eemcPathOut) {
29  if (EEMCPlotsInstance) delete EEMCPlotsInstance; EEMCPlotsInstance = 0;
30  EEMCPlotsInstance = new EEMCPlots(list, eemcDbDump, eemcPathIn, eemcPathOut);
31  if (EEMCPlotsInstance) {
32  EEMCPlotsInstance->resetHistograms();
33  }
34 }
35 //-------------------------------------------------------------------
36 void EEMCPlots::resetHisto() {
37  if (EEMCPlotsInstance) {
38  EEMCPlotsInstance->resetHistograms();
39  }
40 }
41 //-------------------------------------------------------------------
42 void EEMCPlots::saveHisto(TFile *hfile) {
43  if (EEMCPlotsInstance) {
44  EEMCPlotsInstance->saveHistograms(hfile);
45  }
46 }
47 //-------------------------------------------------------------------
48 void EEMCPlots::fillHisto( char *rdr
49  , const unsigned char * dsm0inp
50  , const unsigned short int * dsm1inp
51  , const unsigned short int * dsm2inp
52  , const unsigned short int * dsm3inp
53  ) {
54  if (EEMCPlotsInstance) {
55  EEMCPlotsInstance->processEvent(rdr, dsm0inp, dsm1inp, dsm2inp, dsm3inp);
56  }
57 }
58 //-------------------------------------------------------------------
59 EEMCPlots::EEMCPlots(TObjArray *list, const char *eemcDbDump, const char *eemcPathIn, const char *eemcPathOut)
60  : eeqa(0), eeDb(0)
61 {
62  eeDb = new StEEmcDb();
63  eeDb->setSectors(1, 12);
64  eeDb->setAsciiDatabase(eemcDbDump); // use ASCII dump as input
65 
66  eeqa = new EEqaSorter(eeDb); // creates EEMC related histos
67  eeqa->setPath(eemcPathIn, eemcPathOut);
68  eeqa->initHisto(list, 200,1000); // nBins, maxAdc
69 
70  //Akio said it is not Ok for Run 9
71  //eeqa->initSpy(list, 60, 3); // time constant/sec & mode, //mode: 1=balewski@rcf,3=operator@evp
72 }
73 //-------------------------------------------------------------------
74 EEMCPlots::~EEMCPlots() {
75  if (eeqa) delete eeqa;
76  if (eeDb) delete eeDb;
77 }
78 //-------------------------------------------------------------------
79 //void EEMCPlots::init(unsigned int date, unsigned int time, const char *eemcDbDump, const char *eemcPathIn, const char *eemcPathOut) {}
80 //-------------------------------------------------------------------
81 void EEMCPlots::resetHistograms() {
82  if (eeqa) eeqa->resetHisto();
83 }
84 //-------------------------------------------------------------------
85 void EEMCPlots::saveHistograms(TFile *hfile) {
86  if (eeqa) eeqa->saveHisto(hfile);
87 }
88 //-------------------------------------------------------------------
89 void EEMCPlots::processEvent( char *datap
90  , const unsigned char * dsm0inp
91  , const unsigned short int * dsm1inp
92  , const unsigned short int * dsm2inp
93  , const unsigned short int * dsm3inp
94  ) {
95  if (eeqa) {
96 #ifdef NEW_DAQ_READER
97  daqReader *rdr = (daqReader*)(datap);
98 #else
99  int ret = emcReader(datap);
100 #endif
101 
102 #ifdef NEW_DAQ_READER
103  unsigned int runId = rdr->run;
104  unsigned int token = rdr->token;
105 // unsigned int eventId = rdr->seq;
106 // int isEvp = rdr->IsEvp();
107 #else
108  evpReader *evp = (evpReader*)(datap);
109  unsigned int runId = evp->run;
110  unsigned int token = evp->token;
111 // unsigned int eventId = evp->seq;
112 // int isEvp = evp->isevp;
113 #endif
114 
115  Tonko2Ezt ezt(datap);
116  eeqa->clear();
117  eeqa->sort(ezt.eETowPresent ? &ezt.eETow : 0, ezt.eESmdPresent ? &ezt.eESmd : 0, runId, token, TRG_VERSION, dsm0inp, dsm1inp, dsm2inp, dsm3inp);
118  //if (isEvp) eeqa->spy(&ezt.eETow, &ezt.eESmd, runId, eventId);
119  }
120 }
121 //-------------------------------------------------------------------