StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DSMLayer_E001_2009.cc
1 #include "DSMAlgo_EE001_2009.hh"
2 #include "DSMAlgo_EE002_2009.hh"
3 #include "DSMLayer_E001_2009.hh"
4 
5 //DSMLayer_E001_2009::DSMLayer_E001_2009() : StDSMLayer(9) //DSMLayer<TriggerDataBlk>(9)
6 DSMLayer_E001_2009::DSMLayer_E001_2009() : DSMLayer<TriggerDataBlk>(9)
7 {
8  for (size_t dsm = 0; dsm < size(); ++dsm)
9  (*this)[dsm].setName("EE", 0, dsm);
10 }
11 
12 bool DSMLayer_E001_2009::read(const TriggerDataBlk& event)
13 {
14  bool bc1_in = event.MainX[BC1_CONF_NUM].offset && event.MainX[BC1_CONF_NUM].length;
15 
16  if (bc1_in) {
17  // 9 DSMs * 16 channels
18  char cbuffer[9*16];
19  BELayerBlock* bc1 = (BELayerBlock*)((char*)&event+event.MainX[BC1_CONF_NUM].offset);
20  for (size_t dsm = 0; dsm < size(); ++dsm) {
21  copy_and_swap16(&cbuffer[dsm*16], &bc1->EEMC[dsm*16]);
22  char* cpMin = cbuffer+dsm*16;
23  char* cpMax = cpMin+15;
24  short* sp = (*this)[dsm].channels;
25  for (char* cp = cpMin; cp < cpMax; cp += 3) {
26  int* ip = (int*)cp;
27  *sp++ = *ip & 0xfff;
28  *sp++ = *ip >> 12 & 0xfff;
29  }
30  }
31  }
32 
33  return bc1_in;
34 }
35 
36 void DSMLayer_E001_2009::write(DSMLayer<TriggerDataBlk>& layer)
37 {
38  // EE101
39 
40  layer[0].channels[0] = (*this)[0].output; // EE001
41  layer[0].channels[1] = (*this)[1].output & 0xffff; // EE002 JP1 (0-15)
42  layer[0].channels[2] = (*this)[1].output >> 16 & 0xffff; // EE002 JP6 (16-31)
43  layer[0].channels[3] = (*this)[2].output; // EE003
44  layer[0].channels[4] = (*this)[3].output; // EE004
45  layer[0].channels[5] = (*this)[4].output & 0xffff; // EE005 JP1 (0-15)
46 
47  // EE102
48 
49  layer[1].channels[0] = (*this)[4].output >> 16 & 0xffff; // EE005 JP6 (16-31)
50  layer[1].channels[1] = (*this)[5].output; // EE006
51  layer[1].channels[2] = (*this)[6].output; // EE007
52  layer[1].channels[3] = (*this)[7].output & 0xffff; // EE008 JP1 (0-15)
53  layer[1].channels[4] = (*this)[7].output >> 16 & 0xffff; // EE008 JP6 (16-31)
54  layer[1].channels[5] = (*this)[8].output; // EE009
55 }
56 
57 void DSMLayer_E001_2009::run()
58 {
59  DSMAlgo_EE001_2009()((*this)[0]); // EE001
60  DSMAlgo_EE002_2009()((*this)[1]); // EE002
61  DSMAlgo_EE001_2009()((*this)[2]); // EE003
62  DSMAlgo_EE001_2009()((*this)[3]); // EE004
63  DSMAlgo_EE002_2009()((*this)[4]); // EE005
64  DSMAlgo_EE001_2009()((*this)[5]); // EE006
65  DSMAlgo_EE001_2009()((*this)[6]); // EE007
66  DSMAlgo_EE002_2009()((*this)[7]); // EE008
67  DSMAlgo_EE001_2009()((*this)[8]); // EE009
68 }