EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packet_cdevring.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file packet_cdevring.cc
1 #include <packet_cdevring.h>
2 
4  : Packet_w4 (data)
5 {
6  ps = 0;
7  haspoldata = 0;
8  hasfilldata = 0;
9  decoded = 0; // only decode once...
10 }
11 
12 int *Packet_cdevring::decode ( int *nwout)
13 {
14  if (decoded) {
15  *nwout = 0;
16  return 0;
17  }
18 
19  decoded = 1;
20 
21  int *k;
22  k = (int *) findPacketDataStart(packet);
23  if (k == 0)
24  {
25  ps = 0;
26  *nwout = 0;
27  return 0;
28  }
29 
30  if ( getHitFormat() == IDCDEVRING)
31  {
32  haspoldata = 0;
33  ps = ( struct cdevRingData *) k;
34  }
35  else if (getHitFormat() == IDCDEVRINGPOL )
36  {
37  haspoldata = 1;
38  ps = ( struct cdevRingData *) k;
39  }
40  else if (getHitFormat() == IDCDEVRINGFILL )
41  {
42  hasfilldata = 1;
43  ps = ( struct cdevRingData *) k;
44  }
45 
46 
47 
48  *nwout = 0;
49  return 0;
50 }
51 
52 int Packet_cdevring::iValue(const int ich, const char *what)
53 {
54  int i;
55  decode (&i);
56 
57  if ( strcmp(what, "ringState") == 0 ) {
58  if (ich >=0 && ich < 256) {
59  return ps->m_ringState[ich] ;
60  }
61  }
62 
63  if ( strcmp(what, "ionSpecies") == 0 ) {
64  if (ich>=0 && ich<1024) {
65  return ps->m_ionSpecies[ich] ;
66  }
67  }
68 
69  if ( strcmp(what, "stoneType") == 0 ) return ps->m_stoneType ;
70 
71  if ( strcmp(what, "intendedFillPattern") == 0 ) {
72  if (ich >= 0 && ich < 360 ) {
73  return ps->m_intendedFillPattern[ich];
74  }
75  }
76 
77  if ( strcmp(what, "measuredFillPattern") == 0 ) {
78  if (ich >= 0 && ich < 360 ) {
79  return ps->m_measuredFillPattern[ich];
80  }
81  }
82 
83  if ( strcmp(what, "polarizationFillPattern") == 0 ) {
84  if (ich >= 0 && ich < 360 ) {
85  return ps->m_polarizationFillPattern[ich];
86  }
87  }
88 
89 
90  if ( strcmp(what, "timeOfFillStart") == 0 ) return ps->m_timeOfFillStart;
91  if ( strcmp(what, "timeOfLuminosityStart") == 0 ) return ps->m_timeOfLuminosityStart;
92 
93  if (hasfilldata )
94  {
95  if ( strcmp(what, "fillNumber") == 0 ) return ps->m_fillNumber;
96  if ( strcmp(what, "datavalidMask") == 0 ) return ps->m_datavalidMask;
97  haspoldata = 1; // fill data is a superset of poldata
98  }
99 
100  if (haspoldata )
101  {
102  if ( strcmp(what, "measuredPolarizationUp") == 0 ) {
103  if (ich >= 0 && ich < 360 ) {
104  return ps->m_measuredPolarizationUp[ich];
105  }
106  }
107  if ( strcmp(what, "measuredPolarizationDown") == 0 ) {
108  if (ich >= 0 && ich < 360 ) {
109  return ps->m_measuredPolarizationDown[ich];
110  }
111  }
112 
113 
114  } // haspoldata test
115 
116 
117  std::cout << "packet_cdevring::iValue error unknown datum: " << what << std::endl;
118  return 0;
119 
120 }
121 
122 
123 double Packet_cdevring::dValue(const int channel,const char *what)
124 {
125  int i;
126  decode (&i);
127 
128  if ( strcmp(what, "beamEnergy") == 0 ) return ps->m_beamEnergy;
129  if ( strcmp(what, "gamma") == 0 ) return ps->m_gamma;
130  if ( strcmp(what, "momentumSpread") == 0 ) return ps->m_momentumSpread;
131  if ( strcmp(what, "bunchLength") == 0 ) return ps->m_bunchLength;
132  if ( strcmp(what, "bunchOneRelativePhase") == 0 ) return ps->m_bunchOneRelativePhase;
133  if ( strcmp(what, "synchrotronTune") == 0 ) return ps->m_synchrotronTune;
134  if ( strcmp(what, "chromaticityVertical") == 0 ) return ps->m_chromaticityVertical;
135  if ( strcmp(what, "chromaticityHorizontal") == 0 ) return ps->m_chromaticityHorizontal;
136  if ( strcmp(what, "emittanceVertical") == 0 ) return ps->m_emittanceVertical;
137  if ( strcmp(what, "emittanceHorizontal") == 0 ) return ps->m_emittanceHorizontal;
138  if ( strcmp(what, "betaIPMHorizontal") == 0 ) return ps->m_betaIPMHorizontal;
139  if ( strcmp(what, "betaIPMVertical") == 0 ) return ps->m_betaIPMVertical;
140 
141  std::cout << "packet_cdevring::dValue error unknown datum: " << what << std::endl;
142  return 0;
143 }
144 
145 
146 
148 {
149  int i;
150  decode (&i);
151 
152  this->identify(os);
153 
154  os << "m_ringState " << ps->m_ringState << std::endl;
155  os << "m_ionSpecies " << ps->m_ionSpecies << std::endl;
156  os << "m_beamEnergy " << ps->m_beamEnergy << std::endl;
157  os << "m_gamma " << ps->m_gamma << std::endl;
158  os << "m_stoneType " << ps->m_stoneType << std::endl;
159  os << "m_momentumSpread " << ps->m_momentumSpread << std::endl;
160  os << "m_bunchLength " << ps->m_bunchLength << std::endl;
161  os << "m_chromaticityVertical " << ps->m_chromaticityVertical << std::endl;
162  os << "m_chromaticityHorizontal " << ps->m_chromaticityHorizontal << std::endl;
163  os << "m_emittanceVertical " << ps->m_emittanceVertical << std::endl;
164 
165 
166  if (hasfilldata)
167  {
168  os << "fillNumber " << iValue(i,"fillNumber") << std::endl;
169  os << "datavalidMask " << iValue(i,"datavalidMask") << std::endl;
170  haspoldata = 1;
171  }
172 
173  if (haspoldata )
174  {
175  os << "index " <<" intendedFillPattern " << " measuredFillPattern "<< " polarizationFillPattern "<< " measuredPolarizationUp" << " measuredPolarizationDown"<< std::endl;
176  for (i = 0 ; i < 360 ;i++)
177  {
178  os << std::setw(3) <<i << std::setw(3)<< "|" << std::setw(10) << iValue(i,"intendedFillPattern")<< std::setw( 20)<< iValue(i,"measuredFillPattern")<< std::setw( 23)<<iValue(i,"polarizationFillPattern")<< std::setw(25) <<iValue(i,"measuredPolarizationUp")<< std::setw(23) << iValue(i,"measuredPolarizationDown");
179  os << std::endl;
180  }
181  os << std::endl;
182 
183 
184  } else // haspoldata test
185  {
186 
187  os << "index " <<" intendedFillPattern " << " measuredFillPattern "<< " polarizationFillPattern "<< std::endl;
188  for (i = 0; i< 360; i++) {
189  os << std::setw(3) <<i << std::setw(3)<< "|" << std::setw(10) << iValue(i,"intendedFillPattern")<< std::setw( 20)<< iValue(i,"measuredFillPattern")<< std::setw( 15)<<iValue(i,"polarizationFillPattern"); //ps->m_intendedFillPattern[i] ;
190  os << std::endl;
191  }
192  os << std::endl;
193 
194  } // no polarity data
195 
196 }
197