StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuEzTree.cxx
1 /****************************************************************
2  * $Id: StMuEzTree.cxx,v 1.4 2007/04/27 17:07:16 mvl Exp $
3  *
4  * Author: Wei-Ming Zhang KSU Aug. 2004
5  *
6  *****************************************************************
7  * Description:
8  * Interface between ezTree and MuDst
9  *
10  ****************************************************************/
11 
12 #include <TArrayC.h>
13 
14 #include "StMuEzTree.h"
15 
16 #include "StEvent/StEvent.h"
17 #include "StEvent/StRunInfo.h"
18 #include "StEvent/StEmcCollection.h"
19 
20 #include "StEvent/StTriggerData.h"
21 //#include "StDaqLib/TRG/trgStructures2004.h"// tmp, untill AKio adds trigData->getRawSize()
22 
23 #include "StEvent/StTriggerDetectorCollection.h"
24 #include "StEvent/StCtbTriggerDetector.h"
25 #include "StEvent/StEmcTriggerDetector.h"
26 #include "StEvent/StL0Trigger.h"
27 
28 #include "EztEventHeader.h"
29 #include "EztEmcRawData.h"
30 #include "EztTrigBlob.h"
31 #include "EztFpdBlob.h"
32 
33 ClassImp(StMuEzTree)
34 
36  /* noop */
37 }
38 
39 StMuEzTree::~StMuEzTree() {}
40 
41 // event header cheked by JB
42 //---------------------------------------------------------
43 //---------------------------------------------------------
44 EztEventHeader* StMuEzTree::copyHeader(StEvent* ev){
45  EztEventHeader* header = new EztEventHeader;
46  header->setRunNumber(ev->runId());
47  header->setEventNumber(ev->id());
48  unsigned short token=ev->l0Trigger()->triggerToken();
49  header->setToken(token);
50  header->setTimeStamp(ev->time());
51  header->setComment("Ezt-branch from StEvent");
52  header->setProcessingTime(time(0));
53  header->setStatus(0); // probably not used, JB
54 
55  /* token in the header should be taken for real event header.
56  It is used to check for corruption in the data blocks later.
57  TimeStamp - event time
58  ProcessingTime - when this muDst was produced
59  EventNumber - real event ID
60  JB */
61 
62  return header;
63 }
64 
65 // trig new ok, JB
66 //--------------------------------------------------------
67 //--------------------------------------------------------
68 EztTrigBlob* StMuEzTree::copyTrig(StEvent* ev){
69  EztTrigBlob * trigBlob = new EztTrigBlob;
70 
71  StTriggerData* trigData = ev->triggerData();
72  if (trigData == 0)
73  return 0;
74  char *rawData= trigData->getTriggerStructure();
75  int rawSize=trigData->getRawSize();
76 
77  trigBlob->trgd->Set(rawSize, rawData);
78  trigBlob->setVersion((UChar_t)trigData->version());
79 
80  // int year =trigData->year();
81  // printf("JJJ trgSize=%d token=%d year=%d\n",rawSize ,trigData->token(),year );
82 
83  return trigBlob;
84 }
85 
86 //--------------------------------------------------------
87 //--------------------------------------------------------
88 EztEmcRawData* StMuEzTree::copyETow(StEmcRawData *inp){
89  return copy(inp,0,mxETowCrate);
90 }
91 
92 //--------------------------------------------------------
93 //--------------------------------------------------------
94 EztEmcRawData* StMuEzTree::copyESmd(StEmcRawData *inp){
95  return copy(inp,mxETowCrate,inp->getNBlocks());
96 }
97 
98 //--------------------------------------------------------
99 //--------------------------------------------------------
100 EztEmcRawData* StMuEzTree::copy(StEmcRawData *inp, int ib1, int ib2){
101  EztEmcRawData* raw = new EztEmcRawData;
102 
103  int j=0;
104  for (int i = ib1; i <ib2; i++,j++) {
105  if(i>=inp->getNBlocks()) break;// do not read beyond existing data
106  if(inp->sizeData(i) <= 0) continue;
107  raw->createBank(j,inp->sizeHeader(i),inp->sizeData(i));
108  raw->setHeader(j,inp->header(i));
109  raw->setData(j,inp->data(i));
110  }
111  return raw;
112 
113 }
114 
115 
116 // FPD is dummy, Akio must fill it right, JB
117 //--------------------------------------------------------
118 //--------------------------------------------------------
119 EztFpdBlob* StMuEzTree::copyFpd(StEvent* ev){
120  EztFpdBlob * fpdBlob = new EztFpdBlob;
121  unsigned short int dummData[5]={1,3,5,7,9}; // Akio, drop it
122  unsigned short int *rawData= dummData; // Akio, fix it
123  int rawSize=5; // Akio, fix it
124  fpdBlob->smd->Set(rawSize, (short*)rawData);
125  return fpdBlob;
126 }
127