StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEfeeRawEvent.cxx
1 #include <cassert>
2 #include <ctime>
3 
4 #include "EEfeeDataBlock.h"
5 #include "EEfeeRawEvent.h"
6 
7 #include "EEfeeRawEvent.h"
8 ClassImp(EEfeeRawEvent)
9 
10 
11 //--------------------------------------------------
12 //--------------------------------------------------
13 //--------------------------------------------------
14 
16  ID=-1;
17  block= new TClonesArray("EEfeeDataBlock",10);
18  block->Clear();
19  // printf("EEfeeRawEvent constructed, add=%p\n",this);
20 }
21 
22 //--------------------------------------------------
23 //--------------------------------------------------
24 //--------------------------------------------------
25 
26 EEfeeRawEvent :: ~EEfeeRawEvent() {
27  delete block;
28 
29 }
30 
31 //--------------------------------------------------
32 //--------------------------------------------------
33 //--------------------------------------------------
34 
35 void EEfeeRawEvent :: clear(){
36  ID=-1;
37  block->Delete(); // preserve memory
38 
39 }
40 
41 //--------------------------------------------------
42 //--------------------------------------------------
43 //--------------------------------------------------
44 
45 void EEfeeRawEvent :: print(int flag) const{
46  printf("\nEEfeeRawEvent ID=%d with DataBlock entered=%d of %d\n",
47  ID,block->GetEntries(),block->GetSize());
48 
49  int i;
50  for(i=0;i<block->GetEntries();i++) {
51  printf("%d-",i+1);
52  ((EEfeeDataBlock *)(block->At(i)))->print(flag);
53  }
54 
55 }
56 
57 //--------------------------------------------------
58 //--------------------------------------------------
59 //--------------------------------------------------
60 
61 void EEfeeRawEvent ::addFeeDataBlock(EEfeeDataBlock* b){
62  // To avoid calling the very time consuming operator new for each track,
63  // the standard but not well know C++ operator "new with placement"
64  // is called. If tracks[i] is 0, a new Track object will be created
65  // otherwise the previous Track[i] will be overwritten.
66 
67  assert(b);
68 
69  TClonesArray &Block=*block;
70  int nB=Block.GetEntries();
71  EEfeeDataBlock *bl1= new(Block[nB]) EEfeeDataBlock();
72  bl1->set(b);
73  // bl1->print();
74 }
75 
76 
77 //--------------------------------------------------
78 //--------------------------------------------------
79 //--------------------------------------------------
80 
81 int EEfeeRawEvent::getNGoodBlock() {
82  int ic;
83  int nOK=0;
84  for(ic=0;ic<block->GetEntries();ic++) {
85  EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
86  if(!b->isValid()) continue;
87  // printf("icr=%d san=%d ok=%d\n",ic,b->getSanity(),nOK);
88  nOK++;
89  }
90  return nOK;
91 }
92 
93 
94 
95 //--------------------------------------------------
96 //--------------------------------------------------
97 //--------------------------------------------------
98 
99 int EEfeeRawEvent::maskWrongCrates( long timeStamp, unsigned headToken, HeadVer headVersion) {
100 
101  /* check for:
102  - token in every data block
103  - crateID vs. positon in event
104  - RETURN # of good crate headers
105  */
106 
107  if(timeStamp< 1068744930) {// Thu Nov 13 12:35:30 2003
108  printf(" maskWrongCrates() not implemented for time stamp : %ld / %s",timeStamp,ctime((const time_t *)& timeStamp));
109  assert(1==2);
110  }
111 
112  // add more patterns below
113  int listA[]={1,2,3,4,5,6};
114  int listB[]={1,2,3,4,5,6,84,85,86};
115  int listC[]={1,2,3,4,5,6,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,
116  18,17,16,30,29,28,27,26,25,24,23,22,21,20,19,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; // etow+esmd+btow
117  // summer 2004 shut down
118  int listD[]={1,2,3,4,5,6,100,101,102,103,1,2,3,4,1,2,3,4,1,2,3,4}; // Renee, put here 4 carte ID's
119 
120 
121  int *list, dim;
122  if (timeStamp< 1068761131) //Thu Nov 13 17:05:31 2003
123  { list=listA; dim=sizeof(listA)/sizeof(int); }
124  else if (timeStamp< 1070474417 ) // Wed Dec 3 13:00:17 2003
125  { list=listB; dim=sizeof(listB)/sizeof(int); }
126  else if (timeStamp< 1093360000 )// about Aug 24 14:56:04 2004
127  { list=listC; dim=sizeof(listC)/sizeof(int); }
128  else
129  { list=listD; dim=sizeof(listD)/sizeof(int); }
130 
131 
132  // printf("\n Header check:\n");
133  int ic;
134  int nOK=0;
135  for(ic=0;ic<block->GetEntries();ic++) {
136  EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
137  assert(ic<dim); // fix it, use DB for crIdSwitch
138  // tmp, should be taken from DB as in StEEmcDataMaker.cxx
139  int lenCount=0;
140  int errFlag=0;
141  int trigCommand=4; // physics, 9=laser/LED, 8=??
142 
143  if(ic<6) {// ETOW
144  //lenCount=4+5*32; // real .daq content
145  lenCount=5*32; // old ezTree header
146  } else if (ic<22) { // ESMD //tmp
147  //lenCount=4+192;// real .daq content
148  lenCount=12*16;// old ezTree header
149  errFlag=0x28;
150  } else { //BTOW
151  lenCount=10*16;// old ezTree header
152  };
153 
154  // this is messy, contact Jan before you change between ezTree header & .daq header
155 
156  UChar_t sick=0;
157  switch (headVersion) {
158  case headVer1: // real .daq content
159  sick =b->isHeadValid(headToken,list[ic],lenCount,trigCommand,errFlag);
160  break;
161  case headVer2: // old ezTree header from siew
162  sick=b->isHeadValid(headToken,list[ic],errFlag,lenCount,trigCommand);
163  break;
164  case headVer3: // miniDaq2004 ezTree header
165  errFlag=9;
166  if(ic<6) errFlag=4; else errFlag=9; // yes, October 2004, JB
167  sick=b->isHeadValid(headToken,list[ic],trigCommand,errFlag,lenCount);
168  break;
169  default:
170  assert(1==2); // make up your mind men!
171  }
172 
173  // printf(" ic=%d crID=%d sick=0x%02x\n",ic,b->getCrateID(),sick);
174 
175  // printf("XXX b=%d crID=%d=%d tok=%d=%d ok=%d\n",ic, b->getCrateID() ,list[ic],b->getToken(), headToken,ok);
176 
177  if(!sick) nOK++;
178 
179  }
180  // printf("nOK=%d\n",nOK);
181  return nOK;
182 }
183 
184 //--------------------------------------------------
185 //--------------------------------------------------
186 //--------------------------------------------------
187 
188 void EEfeeRawEvent :: maskBEMC(){ // kill BTOW crates
189 
190  // tmp,22 should be taken from DB as in StEEmcDataMaker.cxx
191  for(int ic=22;ic<block->GetEntries();ic++) {
192  EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(ic);
193  b->maskCrate();
194  }
195 
196 }
197 
198 //--------------------------------------------------
199 //--------------------------------------------------
200 //--------------------------------------------------
201 
202 UShort_t EEfeeRawEvent::getValue(int crateID, int channel) const {
203  int i;
204  for(i=0;i<block->GetEntries();i++) {
205  EEfeeDataBlock *b=(EEfeeDataBlock *)block->At(i);
206  if( crateID!=b->getCrateID()) continue;
207  int nd=b->getValidDataLen();
208  assert(channel>=0 );
209  assert(channel<nd );
210  UShort_t* data=b->getData();
211  return data[channel];
212  }
213  return 0xffff;
214 }
215 
216 
217 /*
218  * $Log: EEfeeRawEvent.cxx,v $
219  * Revision 1.21 2004/10/13 17:14:31 balewski
220  * one more header change for miniDaq
221  *
222  * Revision 1.20 2004/09/07 20:32:01 balewski
223  * more methods, remove questionable spin bits interpetation
224  *
225  * Revision 1.19 2004/08/24 20:30:08 balewski
226  * for Renne LED test with mini
227  *
228  * Revision 1.18 2004/07/10 20:12:13 balewski
229  * match miniDaq
230  *
231  * Revision 1.17 2004/07/09 02:38:05 balewski
232  * BTOW data are not masked out any more but headres are checked as for EEMC
233  *
234  * Revision 1.16 2004/06/21 19:50:21 balewski
235  * mre detailed monitoring of data corruption
236  *
237  * Revision 1.15 2004/06/01 16:05:18 balewski
238  * forgoten update of data block headers check
239  *
240  * Revision 1.14 2004/04/16 17:26:46 balewski
241  * more header checking, some mess introduced
242  *
243  * Revision 1.13 2004/01/27 15:13:57 balewski
244  * it is tricky with BTOW
245  *
246  * Revision 1.12 2004/01/13 16:32:28 balewski
247  * fix bug for sector 8 mapmt
248  *
249  * Revision 1.11 2003/12/10 04:43:19 balewski
250  * first QA
251  *
252  * Revision 1.10 2003/12/04 18:29:25 balewski
253  * I forgot
254  *
255  * Revision 1.9 2003/12/02 17:22:08 balewski
256  * fix after version mixup
257  *
258  * Revision 1.7 2003/11/24 18:26:47 balewski
259  * *** empty log message ***
260  *
261  * Revision 1.6 2003/11/24 05:40:55 balewski
262  * new stuff for miniDaq
263  *
264  * Revision 1.5 2003/11/20 22:59:40 balewski
265  * *** empty log message ***
266  *
267  * Revision 1.4 2003/11/20 16:01:46 balewski
268  * towars run 4
269  *
270  */