StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFcsRawHitMaker.cxx
1 /*
2  *
3  * \class StFcsRawHitMaker
4  *
5  */
6 
7 #include "StFcsRawHitMaker.h"
8 #include "StRoot/StEvent/StEvent.h"
9 #include "StRoot/St_base/StMessMgr.h"
10 #include "StChain/StRtsTable.h"
11 #include "StRoot/StEvent/StFcsCollection.h"
12 #include "StRoot/StEvent/StFcsHit.h"
13 #include "StRoot/StFcsDbMaker/StFcsDb.h"
14 #include "StMuDSTMaker/COMMON/StMuTypes.hh"
15 #include "StMuDSTMaker/COMMON/StMuFcsUtil.h"
16 
17 StFcsRawHitMaker::StFcsRawHitMaker( const char* name) :
18  StRTSBaseMaker("fcs",name){
19 };
20 
21 StFcsRawHitMaker::~StFcsRawHitMaker(){};
22 
23 int StFcsRawHitMaker::InitRun(int runNumber){
24  mRun=runNumber;
25  mFcsDb = static_cast<StFcsDb*>(GetDataSet("fcsDb"));
26  if(!mFcsDb){
27  LOG_FATAL << "Error finding StFcsDbMaker"<< endm;
28  return kStFatal;
29  }
30  return kStOK;
31 };
32 
34  mEvent = (StEvent*)GetInputDS("StEvent");
35  if(mEvent) {
36  LOG_DEBUG<<"Found StEvent"<<endm;
37  } else {
38  mEvent=new StEvent();
39  AddData(mEvent);
40  LOG_INFO <<"Added StEvent"<<endm;
41  }
42 
43  if(mReadMuDst>0) return readMuDst();
44 
45  mFcsCollectionPtr=mEvent->fcsCollection();
46  if(!mFcsCollectionPtr) {
47  mFcsCollectionPtr=new StFcsCollection();
48  mEvent->setFcsCollection(mFcsCollectionPtr);
49  LOG_INFO <<"Added StFcsCollection"<<endm;
50  } else {
51  mFcsCollectionPtr=mEvent->fcsCollection();
52  LOG_DEBUG <<"Found StFcsCollection"<<endm;
53  }
54 
55 
56  StRtsTable* dd=0;
57  int nData=0, nValidData=0;
58  const char* mode[2]={"adc","zs"};
59  char node[20];
60  sprintf(node,"fcs/%s",mode[mReadMode]);
61  while((dd = GetNextDaqElement(node))){
62  int s = dd->Sector();
63  int sec = ((s >> 11) & 0x1F) + 1; // sector = fcs DAQ computer (1~10)
64  int rdo = ((s >> 8) & 0x7) + 1; // fiber connecion # (0~7)
65  int ehp = (s >> 6) & 0x3; // 0=Ecal/1=Hcal/2=Pres
66  int ns = (s >> 5) & 1; // 0=north/1=south
67  int dep = dd->Row() ; // DEP Board# (0-23)
68  int ch = dd->Pad() ; // Channel (0-31)
69  uint32_t n=dd->GetNRows();
70  int detid,id,crt,sub;
71  mFcsDb->getIdfromDep(ehp,ns,dep,ch,detid,id,crt,sub);
72  uint16_t *d16 = (uint16_t *)dd->GetTable();
73  StFcsHit* hit=0;
74  if(mReadMode==0){
75  hit = new StFcsHit(0,detid,id,ns,ehp,dep,ch,n,d16);
76  }else{
77  hit = new StFcsHit(1,detid,id,ns,ehp,dep,ch,2*n,d16);
78  }
79  mFcsCollectionPtr->addHit(detid,hit);
80  nData++;
81  if(detid<6) nValidData++;
82  if(GetDebug()){
83  printf("FCS %3s : S%d:%d [det %d, ns %d, dep %d ch %2d] det=%1d id=%4d : size=%2d : adc=",
84  mode[mReadMode],sec,rdo,ehp,ns,dep,ch,detid,id,n) ;
85  int sum=0;
86  for(int tb=0; tb<hit->nTimeBin(); tb++) {
87  printf("%4d ", hit->adc(tb));
88  sum+=hit->adc(tb);
89  }
90  //for(int tb=0; tb<3; tb++) printf("%4d ", hit->adc(tb));
91  printf(" sum=%d\n",sum);
92  }
93  }
94  LOG_INFO <<Form("FCS found %d data lines, and %d valid data lines",
95  nData,nValidData)<<endm;
96  if(nData>0 && GetDebug()) mFcsCollectionPtr->print(3);
97  return kStOK;
98 };
99 
100 int StFcsRawHitMaker::readMuDst() {
101  StMuDst* mudst = (StMuDst*)GetInputDS("MuDst");
102  if(!mudst){LOG_ERROR<<"StFcsRawHitMaker::readMuDst() found no MuDst"<<endm; return kStErr;}
103  StMuFcsCollection* mufcsColl= mudst->muFcsCollection();
104  if(!mufcsColl){LOG_ERROR<<"StFcsRawHitMaker::readMuDst found no MuFcsCollection"<<endm; return kStErr;}
105  StMuFcsUtil util;
106  mFcsCollectionPtr = util.getFcs(mufcsColl);
107  mEvent->setFcsCollection(mFcsCollectionPtr);
108 }
109 
110 void StFcsRawHitMaker::Clear( Option_t *opts ){};
111 
112 ClassImp(StFcsRawHitMaker);
113 
114 /*
115  * $Id: StFcsRawHitMaker.cxx,v 1.1 2021/03/30 13:40:12 akio Exp $
116  * $Log: StFcsRawHitMaker.cxx,v $
117  * Revision 1.1 2021/03/30 13:40:12 akio
118  * FCS code after peer review and moved from $CVSROOT/offline/upgrades/akio
119  *
120  * Revision 1.6 2021/02/25 21:55:32 akio
121  * Int_t -> int
122  *
123  * Revision 1.5 2021/02/25 19:27:10 akio
124  * Modified for STAR code review (Hongwei)
125  *
126  * Revision 1.4 2019/08/01 18:38:00 akio
127  * added debug info
128  *
129  * Revision 1.3 2019/07/15 16:58:51 akio
130  * clean up
131  *
132  * Revision 1.2 2019/07/05 15:00:52 akio
133  * small corrections
134  *
135  * Revision 1.1 2019/07/03 17:02:45 akio
136  * Initial version of FCS offline daq file reader
137  *
138  *
139  */
static StMuFcsCollection * muFcsCollection()
returns pointer to current StMuFcsCollection
Definition: StMuDst.h:395
StRtsTable * GetNextDaqElement(const char *elementPath)
Query the STAR production chain for the DAQ data.
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
void getIdfromDep(int ehp, int ns, int dep, int ch, int &detectorId, int &id, int &crt, int &slt) const
Get DEP map.
Definition: StFcsDb.cxx:1031
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
Definition: Stypes.h:40
Definition: Stypes.h:44
void Clear(Option_t *opts="")
User defined functions.