Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:39

0001 #include <packet_cdevpolarimeter.h>
0002 #include <stdio.h>
0003 
0004 Packet_cdevpolarimeter::Packet_cdevpolarimeter(PACKET_ptr data)
0005   : Packet_w4 (data)
0006 {
0007   ps = 0;
0008   haspoldata = 0;
0009 }
0010   
0011 int *Packet_cdevpolarimeter::decode ( int *nwout)
0012 {
0013 
0014   if (ps != 0) return 0; 
0015 
0016   int *k = (int *) findPacketDataStart(packet);
0017   if (k == 0) 
0018     {
0019       ps = 0;
0020       *nwout = 0;
0021       return 0;
0022     }
0023 
0024   if ( getHitFormat() == IDCDEVPOLARIMETER ) 
0025     {
0026       haspoldata = 0;
0027       ps = ( struct cdevPolarimeterData *) &k[1];
0028     }
0029   else if (getHitFormat() == IDCDEVPOLARIMETERZ )
0030     {
0031       haspoldata = 1;
0032       ps =  ( struct cdevPolarimeterData *) &k[1];
0033     }
0034 
0035   //  fix_endianess (&ps->m_cdevCaptureTimeStamp);
0036   // ejd 4/26/03 strings are garbled do not byte swap
0037   //  fix_endianess (&ps->runIdS);
0038   //fix_endianess ( ps->daqVersionS, 80);
0039   //fix_endianess ( ps->cutIdS, 80);
0040   //fix_endianess ( ps->targetIdS, 80);
0041   //fix_endianess ( ps->statusStringS, 80);
0042 
0043 
0044   //  fix_endianess(&ps->startTimeS);   // Unix time
0045   //  fix_endianess(&ps->stopTimeS);    // Unix time
0046     
0047   //  for (i=0; i<2; i++) fix_endianess(&ps->encoderPositionS[i]);
0048   //  fix_endianess(&ps->statusS);  // bit pattern if <0 data is not usable
0049   //  fix_endianess(&ps->totalCountsS);
0050   //  fix_endianess(&ps->upCountsS);
0051   //  fix_endianess(&ps->downCountsS);
0052   //  fix_endianess(&ps->unpolCountsS);
0053         
0054 //    for (i=0; i<360; i++) fix_endianess(&ps->countsUpLeftS[i]);
0055 //    for (i=0; i<360; i++) fix_endianess(&ps->countsLeftS[i]);
0056 //    for (i=0; i<360; i++)fix_endianess(&ps->countsDownLeftS[i]);
0057 //    for (i=0; i<360; i++)fix_endianess(&ps->countsDownRightS[i]);
0058 //    for (i=0; i<360; i++)fix_endianess(&ps->countsRightS[i]);
0059 //    for (i=0; i<360; i++)fix_endianess(&ps->countsUpRightS[i]);
0060 
0061 
0062 
0063 //    fix_endianess(&ps->numberEventsS);    // provided by MCR before measurement
0064 //    fix_endianess(&ps->maxTimeS); 
0065 
0066   *nwout = 0;
0067 
0068   return 0;
0069 }
0070 
0071 
0072 // ------------------------------------------------------
0073 
0074 
0075 void Packet_cdevpolarimeter::dump ( OSTREAM &os) 
0076 {
0077 
0078   int i;
0079 
0080   decode (&i);
0081 
0082   this->identify(os);
0083 
0084   os << "daqVersionS   " <<  ps->daqVersionS  << std::endl;
0085   os << "cutIdS        " <<  ps->cutIdS  << std::endl;
0086   os << "targetIdS     " <<  ps->targetIdS << std::endl;
0087   os << "statusStringS " <<  ps->statusStringS << std::endl;
0088 
0089   os << "m_cdevCaptureTimeStamp   " <<  ps->m_cdevCaptureTimeStamp << std::endl;
0090   os << "runIdS                   " <<  ps->runIdS << std::endl;    // FILL.XXX --- where XXX is the run number 
0091   os << "startTimeS               " <<  ps->startTimeS << std::endl;    // Unix time
0092   os << "stopTimeS                " <<  ps->stopTimeS << std::endl; // Unix time
0093   os << "encoderPositionS         " <<  ps->encoderPositionS[0] <<"     " <<  ps->encoderPositionS[1] << std::endl;
0094 
0095   //  os <<  ps->daqVersionS << std::endl;
0096   // os <<  ps->cutIdS << std::endl;
0097   //os <<  ps->targetIdS << std::endl;
0098 
0099   os << "statusS                  " <<  ps->statusS << std::endl;   // bit pattern if <0 data is not usable
0100   os << "totalCountsS             " <<  ps->totalCountsS << std::endl;
0101   os << "upCountsS                " <<  ps->upCountsS << std::endl;
0102   os << "downCountsS              " <<  ps->downCountsS << std::endl;
0103   os << "unpolCountsS             " <<  ps->unpolCountsS << std::endl;
0104   os << "avgAsymXS                " <<  ps->avgAsymXS << std::endl;
0105   os << "avgAsymX45S              " <<  ps->avgAsymX45S << std::endl;
0106   os << "avgAsymX90S              " <<  ps->avgAsymX90S << std::endl;    
0107   os << "avgAsymYS                " <<  ps->avgAsymYS << std::endl;
0108   os << "avgAsymErrorXS           " <<  ps->avgAsymErrorXS << std::endl;
0109   os << "avgAsymErrorX45S         " <<  ps->avgAsymErrorX45S << std::endl;
0110   os << "avgAsymErrorX90S         " <<  ps->avgAsymErrorX90S << std::endl;
0111   os << "avgAsymErrorYS           " <<  ps->avgAsymErrorYS << std::endl;
0112 
0113   os << "beamEnergyS              " <<  ps->beamEnergyS << std::endl;   // the same as ringSpec.color:beamEnergyM just for reference
0114 
0115   
0116   os << "analyzingPowerS          " <<  ps->analyzingPowerS << std::endl;
0117   os << "analyzingPowerErrorS     " <<  ps->analyzingPowerErrorS << std::endl;
0118   os << "numberEventsS            " <<  ps->numberEventsS << std::endl; // provided by MCR before measurement
0119   os << "maxTimeS                 " <<  ps->maxTimeS << std::endl;  
0120   if (haspoldata )
0121     {
0122       os << "polarizationM        " << ps->polarizationM << std::endl;
0123     }
0124 
0125 
0126 
0127 
0128   os << " index        AsymXS      AsymYS AsymErrorXS  AsymErrorYS    UpLeftS       LeftS   DownLeftS  DownRightS      RightS    UpRightS" << std::endl;
0129 
0130 
0131   for (i=0; i< 360; i++)
0132   {
0133     
0134     os << std::setw(5) << i << " | "; 
0135 
0136     
0137     os << std::setw(12) << rValue(i,"bunchAsymXS"); //ps->bunchAsymXS[i];
0138     os << std::setw(12) << rValue(i,"bunchAsymYS"); //ps->bunchAsymYS[i];
0139     os << std::setw(12) << ps->bunchAsymErrorXS[i];
0140     os << std::setw(12) << ps->bunchAsymErrorYS[i];
0141 
0142     os << std::setw(12) << ps->countsUpLeftS[i];
0143     os << std::setw(12) << ps->countsLeftS[i];
0144     os << std::setw(12) << ps->countsDownLeftS[i];
0145     os << std::setw(12) << ps->countsDownRightS[i];
0146     os << std::setw(12) << ps->countsRightS[i];
0147     os << std::setw(12) << ps->countsUpRightS[i] << std::endl;
0148   }
0149 
0150 
0151   dumpErrorBlock(os);
0152   dumpDebugBlock(os);
0153 }
0154 
0155 
0156 int   Packet_cdevpolarimeter::iValue(const int ich, const char *what)
0157 {
0158 
0159   int i;
0160   decode (&i);
0161 
0162   if ( strcmp(what, "cdevCaptureTimeStamp") == 0 ) return   ps->m_cdevCaptureTimeStamp ;  // is this not an int??
0163   if ( strcmp(what, "startTimeS") == 0 ) return   ps->startTimeS ;  // Unix time
0164   if ( strcmp(what, "stopTimeS") == 0 ) return   ps->stopTimeS ;    // Unix time
0165 
0166   if ( strcmp(what,"daqVersionS") == 0)
0167     {
0168       if ( ich >= 0 && ich < 80)
0169     return  ps->daqVersionS[ich];
0170     }
0171 
0172   if ( strcmp(what,"cutIdS") == 0)
0173     {
0174       if ( ich >= 0 && ich < 80)
0175     return  ps->cutIdS[ich];
0176     }
0177 
0178   if ( strcmp(what,"targetIdS") == 0)
0179     {
0180       if ( ich >= 0 && ich < 80)
0181     return  ps->targetIdS[ich];
0182     }
0183 
0184   if ( strcmp(what, "encoderPositionS") == 0 ) 
0185     {
0186       if ( ich >= 0 && ich < 2 ) 
0187     return ps->encoderPositionS[ich];
0188     }
0189 
0190   if ( strcmp(what, "statusS") == 0 ) return   ps->statusS ;
0191 
0192   if ( strcmp(what, "statusStringS") == 0 ) 
0193     {
0194       if ( ich >= 0 && ich < 2 ) 
0195     return ps->statusStringS[ich];
0196     }
0197 
0198   if ( strcmp(what, "totalCountsS") == 0 ) return   ps->totalCountsS ;
0199   if ( strcmp(what, "upCountsS") == 0 ) return   ps->upCountsS ;
0200   if ( strcmp(what, "downCountsS") == 0 ) return   ps->downCountsS ;
0201   if ( strcmp(what, "unpolCountsS") == 0 ) return   ps->unpolCountsS ;
0202   if ( strcmp(what,"countsUpLeftS") == 0)
0203     {
0204       if ( ich >= 0 && ich < 360)
0205     return  ps->countsUpLeftS[ich];
0206     }
0207 
0208 
0209   if ( strcmp(what,"countsLeftS") == 0)
0210     {
0211       if ( ich >= 0 && ich < 360)
0212     return ps->countsLeftS[ich];
0213     }
0214   
0215   if ( strcmp(what,"countsDownLeftS") == 0)
0216     {
0217       if ( ich >= 0 && ich < 360)
0218     return  ps->countsDownLeftS[ich];
0219     }
0220   
0221   if ( strcmp(what,"countsDownRightS") == 0)
0222     {
0223       if ( ich >= 0 && ich < 360)
0224     return  ps->countsDownRightS[ich];
0225     }
0226   
0227   if ( strcmp(what,"countsRightS") == 0)
0228     {
0229       if ( ich >= 0 && ich < 360)
0230     return  ps->countsRightS[ich];
0231     }
0232   
0233   if ( strcmp(what,"countsUpRightS") == 0)
0234     {
0235       if ( ich >= 0 && ich < 360)
0236     return  ps->countsUpRightS[ich];
0237     }
0238 
0239   if ( strcmp(what, "numberEventsS") == 0 ) return   ps->numberEventsS ;
0240   if ( strcmp(what, "maxTimeS")      == 0 ) return   ps->maxTimeS ;
0241 
0242   std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
0243   return 0;
0244 }
0245 
0246 
0247 float   Packet_cdevpolarimeter::rValue(const int ich, const char *what)
0248 {
0249 
0250 
0251   //  std::cout << "IN  Packet_cdevpolarimeter::rValue " << std::endl;
0252   int i;
0253   decode (&i);
0254 
0255   if ( strcmp(what, "avgAsymXS") == 0 ) return   ps->avgAsymXS ;
0256   if ( strcmp(what, "avgAsymX45S") == 0 ) return   ps->avgAsymX45S ;
0257   if ( strcmp(what, "avgAsymX90S") == 0 ) return   ps->avgAsymX90S ;    
0258   if ( strcmp(what, "avgAsymYS") == 0 ) return   ps->avgAsymYS ;
0259   if ( strcmp(what, "avgAsymErrorXS") == 0 ) return   ps->avgAsymErrorXS ;
0260   if ( strcmp(what, "avgAsymErrorX45S") == 0 ) return   ps->avgAsymErrorX45S ;
0261   if ( strcmp(what, "avgAsymErrorX90S") == 0 ) return   ps->avgAsymErrorX90S ;
0262   if ( strcmp(what, "avgAsymErrorYS") == 0 ) return   ps->avgAsymErrorYS ;
0263 
0264 
0265   if ( strcmp(what,"bunchAsymXS") == 0)
0266     {
0267       if ( ich >= 0 && ich < 360)
0268     return ps->bunchAsymXS[ich];
0269     }
0270   
0271   if ( strcmp(what,"bunchAsymYS") == 0)
0272     {
0273       if ( ich >= 0 && ich < 360)
0274     return  ps->bunchAsymYS[ich];
0275     }
0276   
0277   if ( strcmp(what,"bunchAsymErrorXS") == 0)
0278     {
0279       if ( ich >= 0 && ich < 360)
0280     return  ps->bunchAsymErrorXS[ich];
0281     }
0282   
0283   if ( strcmp(what,"bunchAsymErrorYS") == 0)
0284     {
0285       if ( ich >= 0 && ich < 360)
0286     return  ps->bunchAsymErrorYS[ich];
0287     }
0288   
0289   
0290   if ( strcmp(what, "beamEnergyS") == 0 ) return   ps->beamEnergyS ;
0291   if ( strcmp(what, "analyzingPowerS") == 0 ) return   ps->analyzingPowerS ;
0292   if ( strcmp(what, "analyzingPowerErrorS") == 0 ) return   ps->analyzingPowerErrorS ;
0293   if (haspoldata )
0294     {
0295        if ( strcmp(what, "polarizationM") == 0 ) return ps->polarizationM ;
0296     }
0297 
0298   std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
0299   return 0.;  
0300 }
0301 
0302 
0303 double   Packet_cdevpolarimeter::dValue(const int ich, const char *what)
0304 {
0305 
0306 
0307   //  std::cout << "IN  Packet_cdevpolarimeter::rValue " << std::endl;
0308   int i;
0309   decode (&i);
0310 
0311   if ( strcmp(what, "runIdS") == 0 ) return   ps->runIdS ;  // FILL.XXX --- where XXX is the run number 
0312 
0313   std::cout << "packet_cdevpolarimeter::iValue error unknown datum: " << what << std::endl;
0314   return 0;
0315 }
0316 
0317 
0318