File indexing completed on 2025-08-03 08:20:51
0001 #include <packet_cdevring.h>
0002
0003 Packet_cdevring::Packet_cdevring(PACKET_ptr data)
0004 : Packet_w4 (data)
0005 {
0006 ps = 0;
0007 haspoldata = 0;
0008 hasfilldata = 0;
0009 decoded = 0;
0010 }
0011
0012 int *Packet_cdevring::decode ( int *nwout)
0013 {
0014 if (decoded) {
0015 *nwout = 0;
0016 return 0;
0017 }
0018
0019 decoded = 1;
0020
0021 int *k;
0022 k = (int *) findPacketDataStart(packet);
0023 if (k == 0)
0024 {
0025 ps = 0;
0026 *nwout = 0;
0027 return 0;
0028 }
0029
0030 if ( getHitFormat() == IDCDEVRING)
0031 {
0032 haspoldata = 0;
0033 ps = ( struct cdevRingData *) k;
0034 }
0035 else if (getHitFormat() == IDCDEVRINGPOL )
0036 {
0037 haspoldata = 1;
0038 ps = ( struct cdevRingData *) k;
0039 }
0040 else if (getHitFormat() == IDCDEVRINGFILL )
0041 {
0042 hasfilldata = 1;
0043 ps = ( struct cdevRingData *) k;
0044 }
0045
0046
0047
0048 *nwout = 0;
0049 return 0;
0050 }
0051
0052 int Packet_cdevring::iValue(const int ich, const char *what)
0053 {
0054 int i;
0055 decode (&i);
0056
0057 if ( strcmp(what, "ringState") == 0 ) {
0058 if (ich >=0 && ich < 256) {
0059 return ps->m_ringState[ich] ;
0060 }
0061 }
0062
0063 if ( strcmp(what, "ionSpecies") == 0 ) {
0064 if (ich>=0 && ich<1024) {
0065 return ps->m_ionSpecies[ich] ;
0066 }
0067 }
0068
0069 if ( strcmp(what, "stoneType") == 0 ) return ps->m_stoneType ;
0070
0071 if ( strcmp(what, "intendedFillPattern") == 0 ) {
0072 if (ich >= 0 && ich < 360 ) {
0073 return ps->m_intendedFillPattern[ich];
0074 }
0075 }
0076
0077 if ( strcmp(what, "measuredFillPattern") == 0 ) {
0078 if (ich >= 0 && ich < 360 ) {
0079 return ps->m_measuredFillPattern[ich];
0080 }
0081 }
0082
0083 if ( strcmp(what, "polarizationFillPattern") == 0 ) {
0084 if (ich >= 0 && ich < 360 ) {
0085 return ps->m_polarizationFillPattern[ich];
0086 }
0087 }
0088
0089
0090 if ( strcmp(what, "timeOfFillStart") == 0 ) return ps->m_timeOfFillStart;
0091 if ( strcmp(what, "timeOfLuminosityStart") == 0 ) return ps->m_timeOfLuminosityStart;
0092
0093 if (hasfilldata )
0094 {
0095 if ( strcmp(what, "fillNumber") == 0 ) return ps->m_fillNumber;
0096 if ( strcmp(what, "datavalidMask") == 0 ) return ps->m_datavalidMask;
0097 haspoldata = 1;
0098 }
0099
0100 if (haspoldata )
0101 {
0102 if ( strcmp(what, "measuredPolarizationUp") == 0 ) {
0103 if (ich >= 0 && ich < 360 ) {
0104 return ps->m_measuredPolarizationUp[ich];
0105 }
0106 }
0107 if ( strcmp(what, "measuredPolarizationDown") == 0 ) {
0108 if (ich >= 0 && ich < 360 ) {
0109 return ps->m_measuredPolarizationDown[ich];
0110 }
0111 }
0112
0113
0114 }
0115
0116
0117 std::cout << "packet_cdevring::iValue error unknown datum: " << what << std::endl;
0118 return 0;
0119
0120 }
0121
0122
0123 double Packet_cdevring::dValue(const int channel,const char *what)
0124 {
0125 int i;
0126 decode (&i);
0127
0128 if ( strcmp(what, "beamEnergy") == 0 ) return ps->m_beamEnergy;
0129 if ( strcmp(what, "gamma") == 0 ) return ps->m_gamma;
0130 if ( strcmp(what, "momentumSpread") == 0 ) return ps->m_momentumSpread;
0131 if ( strcmp(what, "bunchLength") == 0 ) return ps->m_bunchLength;
0132 if ( strcmp(what, "bunchOneRelativePhase") == 0 ) return ps->m_bunchOneRelativePhase;
0133 if ( strcmp(what, "synchrotronTune") == 0 ) return ps->m_synchrotronTune;
0134 if ( strcmp(what, "chromaticityVertical") == 0 ) return ps->m_chromaticityVertical;
0135 if ( strcmp(what, "chromaticityHorizontal") == 0 ) return ps->m_chromaticityHorizontal;
0136 if ( strcmp(what, "emittanceVertical") == 0 ) return ps->m_emittanceVertical;
0137 if ( strcmp(what, "emittanceHorizontal") == 0 ) return ps->m_emittanceHorizontal;
0138 if ( strcmp(what, "betaIPMHorizontal") == 0 ) return ps->m_betaIPMHorizontal;
0139 if ( strcmp(what, "betaIPMVertical") == 0 ) return ps->m_betaIPMVertical;
0140
0141 std::cout << "packet_cdevring::dValue error unknown datum: " << what << std::endl;
0142 return 0;
0143 }
0144
0145
0146
0147 void Packet_cdevring::dump ( OSTREAM& os)
0148 {
0149 int i;
0150 decode (&i);
0151
0152 this->identify(os);
0153
0154 os << "m_ringState " << ps->m_ringState << std::endl;
0155 os << "m_ionSpecies " << ps->m_ionSpecies << std::endl;
0156 os << "m_beamEnergy " << ps->m_beamEnergy << std::endl;
0157 os << "m_gamma " << ps->m_gamma << std::endl;
0158 os << "m_stoneType " << ps->m_stoneType << std::endl;
0159 os << "m_momentumSpread " << ps->m_momentumSpread << std::endl;
0160 os << "m_bunchLength " << ps->m_bunchLength << std::endl;
0161 os << "m_chromaticityVertical " << ps->m_chromaticityVertical << std::endl;
0162 os << "m_chromaticityHorizontal " << ps->m_chromaticityHorizontal << std::endl;
0163 os << "m_emittanceVertical " << ps->m_emittanceVertical << std::endl;
0164
0165
0166 if (hasfilldata)
0167 {
0168 os << "fillNumber " << iValue(i,"fillNumber") << std::endl;
0169 os << "datavalidMask " << iValue(i,"datavalidMask") << std::endl;
0170 haspoldata = 1;
0171 }
0172
0173 if (haspoldata )
0174 {
0175 os << "index " <<" intendedFillPattern " << " measuredFillPattern "<< " polarizationFillPattern "<< " measuredPolarizationUp" << " measuredPolarizationDown"<< std::endl;
0176 for (i = 0 ; i < 360 ;i++)
0177 {
0178 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");
0179 os << std::endl;
0180 }
0181 os << std::endl;
0182
0183
0184 } else
0185 {
0186
0187 os << "index " <<" intendedFillPattern " << " measuredFillPattern "<< " polarizationFillPattern "<< std::endl;
0188 for (i = 0; i< 360; i++) {
0189 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");
0190 os << std::endl;
0191 }
0192 os << std::endl;
0193
0194 }
0195
0196 }
0197