00001
00002
00003 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
00004 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include <iostream>
00007 #include <iomanip>
00008
00009 using namespace sistrip;
00010
00011
00012
00013 SiStripEventSummary::SiStripEventSummary() :
00014 valid_(true),
00015 triggerFed_(0),
00016 runType_(sistrip::UNDEFINED_RUN_TYPE),
00017 event_(0),
00018 bx_(0),
00019 spillNumber_(0),
00020 nDataSenders_(0),
00021 fedReadoutMode_(sistrip::UNDEFINED_FED_READOUT_MODE),
00022 apvReadoutMode_(sistrip::UNDEFINED_APV_READOUT_MODE),
00023 apveAddress_(0),
00024 nApvsInSync_(0),
00025 nApvsOutOfSync_(0),
00026 nApvsErrors_(0),
00027 params_(5,0)
00028 {;}
00029
00030
00031
00032 void SiStripEventSummary::commissioningInfo( const uint32_t* const buffer,
00033 const uint32_t& event ) {
00034
00035
00036 uint16_t run = static_cast<uint16_t>( buffer[10] & 0xFFFF );
00037 runType_ = SiStripEnumsAndStrings::runType(run);
00038
00039
00040 spillNumber_ = buffer[0];
00041
00042
00043 nDataSenders_ = buffer[20];
00044
00045
00046 if ( buffer[15] == 0 ) { fedReadoutMode_ = sistrip::FED_SCOPE_MODE; }
00047 else if ( buffer[15] == 1 ) { fedReadoutMode_ = sistrip::FED_VIRGIN_RAW; }
00048 else if ( buffer[15] == 2 ) { fedReadoutMode_ = sistrip::FED_PROC_RAW; }
00049 else if ( buffer[15] == 3 ) { fedReadoutMode_ = sistrip::FED_ZERO_SUPPR; }
00050 else if ( buffer[15] == 4 ) { fedReadoutMode_ = sistrip::FED_ZERO_SUPPR_LITE; }
00051 else { fedReadoutMode_ = sistrip::UNKNOWN_FED_READOUT_MODE; }
00052
00053
00054 if ( runType_ == sistrip::CALIBRATION ||
00055 runType_ == sistrip::CALIBRATION_DECO ||
00056 runType_ == sistrip::CALIBRATION_SCAN ||
00057 runType_ == sistrip::CALIBRATION_SCAN_DECO ||
00058 runType_ == sistrip::APV_LATENCY ) {
00059
00060 params_[0] = buffer[11];
00061 params_[1] = buffer[12];
00062 params_[2] = buffer[13];
00063 params_[3] = buffer[15];
00064 params_[4] = buffer[16];
00065
00066 } else if ( runType_ == sistrip::OPTO_SCAN ) {
00067
00068 params_[0] = buffer[11];
00069 params_[1] = buffer[12];
00070
00071 } else if ( runType_ == sistrip::APV_TIMING ||
00072 runType_ == sistrip::FED_TIMING ) {
00073 params_[0] = buffer[11];
00074 params_[1] = buffer[12];
00075 params_[2] = buffer[13];
00076 } else if ( runType_ == sistrip::FINE_DELAY ||
00077 runType_ == sistrip::FINE_DELAY_PLL ||
00078 runType_ == sistrip::FINE_DELAY_TTC ) {
00079 params_[0] = buffer[11];
00080 params_[1] = buffer[12];
00081 params_[2] = buffer[13];
00082 params_[3] = buffer[14];
00083
00084 } else if ( runType_ == sistrip::FAST_CABLING ) {
00085
00086 params_[0] = buffer[11];
00087 params_[1] = buffer[12];
00088 params_[2] = buffer[13];
00089 params_[3] = buffer[14];
00090
00091 } else if ( runType_ == sistrip::FED_CABLING ||
00092 runType_ == sistrip::QUITE_FAST_CABLING ) {
00093
00094 if ( runType_ == sistrip::QUITE_FAST_CABLING ) {
00095
00096 uint16_t ii = 0;
00097 bool found = false;
00098 while ( !found && ii < 20 ) {
00099 uint32_t dcu = buffer[21+3*ii];
00100 uint32_t key = buffer[21+3*ii+1];
00101 uint32_t evt = buffer[21+3*ii+2];
00102 if ( evt == event ) {
00103 params_[0] = key;
00104 params_[1] = 0;
00105 params_[2] = 0;
00106 params_[3] = dcu;
00107 found = true;
00108 }
00109 ii++;
00110 }
00111 std::stringstream ss;
00112 ss << "[SiStripEventSummary::" << __func__ << "]";
00113 if ( !found ) {
00114 ss << " Did not find DeviceId/DCUid for event "
00115 << event << "!";
00116 edm::LogWarning(mlDigis_) << ss.str();
00117 params_[0] = 0;
00118 params_[1] = 0;
00119 params_[2] = 0;
00120 params_[3] = 0;
00121 } else {
00122 ss << " Found DeviceId/DCUid for event "
00123 << event << ": 0x"
00124 << std::hex << std::setw(8) << std::setfill('0') << params_[0] << std::dec
00125 << "/0x"
00126 << std::hex << std::setw(8) << std::setfill('0') << params_[3] << std::dec;
00127 LogTrace(mlDigis_) << ss.str();
00128 }
00129
00130 } else {
00131
00132 params_[0] = buffer[11];
00133 params_[1] = buffer[12];
00134 params_[2] = buffer[13];
00135 params_[3] = buffer[14];
00136
00137 }
00138
00139 } else if ( runType_ == sistrip::VPSP_SCAN ) {
00140
00141 params_[0] = buffer[11];
00142 params_[1] = buffer[12];
00143
00144 } else if ( runType_ == sistrip::DAQ_SCOPE_MODE ) {
00145
00146
00147
00148 } else if ( runType_ == sistrip::PHYSICS ||
00149 runType_ == sistrip::PHYSICS_ZS ||
00150 runType_ == sistrip::PEDESTALS ) {
00151
00152
00153
00154 } else {
00155
00156 edm::LogWarning(mlDigis_)
00157 << "[SiStripEventSummary::" << __func__ << "]"
00158 << " Unexpected commissioning task: "
00159 << runType_;
00160
00161 }
00162
00163 }
00164
00165
00166
00167
00168
00169
00170 void SiStripEventSummary::commissioningInfo( const uint32_t& daq1,
00171 const uint32_t& daq2 ) {
00172
00173
00174 uint16_t temp = static_cast<uint16_t>( (daq1>>8)&0x3 );
00175 if ( temp == uint16_t(1) ) { valid_ = true; }
00176 else if ( temp == uint16_t(2) ) { valid_ = false; }
00177 else if ( temp == uint16_t(3) &&
00178 daq1 == sistrip::invalid32_ ) {
00179 edm::LogWarning(mlDigis_)
00180 << "[SiStripEventSummary::" << __func__ << "]"
00181 << " DAQ register contents set to invalid: 0x"
00182 << std::hex
00183 << std::setw(8) << std::setfill('0') << daq1
00184 << std::dec;
00185 valid_ = false;
00186 } else {
00187 edm::LogWarning(mlDigis_)
00188 << "[SiStripEventSummary::" << __func__ << "]"
00189 << " Unexpected bit pattern set in DAQ1: 0x"
00190 << std::hex
00191 << std::setw(8) << std::setfill('0') << daq1
00192 << std::dec;
00193 valid_ = false;
00194 }
00195
00196
00197 uint16_t run = static_cast<uint16_t>( daq1&0xFF );
00198 runType_ = SiStripEnumsAndStrings::runType(run);
00199
00200
00201 if ( runType_ == sistrip::PHYSICS ) {
00202 } else if ( runType_ == sistrip::PHYSICS_ZS ) {
00203 } else if ( runType_ == sistrip::PEDESTALS ) {
00204 } else if ( runType_ == sistrip::DAQ_SCOPE_MODE ) {
00205 } else if ( runType_ == sistrip::CALIBRATION ) {
00206 } else if ( runType_ == sistrip::CALIBRATION_DECO ) {
00207 params_[0] = (daq2>>8)&0xFF;
00208 params_[1] = (daq2>>4)&0x0F;
00209 params_[2] = (daq2>>0)&0x0F;
00210 } else if ( runType_ == sistrip::CALIBRATION_SCAN ) {
00211 params_[0] = (daq2>>8)&0xFF;
00212 params_[1] = (daq2>>4)&0x0F;
00213 params_[2] = (daq2>>0)&0x0F;
00214 } else if ( runType_ == sistrip::OPTO_SCAN ) {
00215 params_[0] = (daq2>>8)&0xFF;
00216 params_[1] = (daq2>>0)&0xFF;
00217 } else if ( runType_ == sistrip::APV_TIMING ) {
00218 params_[1] = (daq2>>0)&0xFF;
00219 } else if ( runType_ == sistrip::APV_LATENCY ) {
00220 params_[0] = (daq2>>0)&0xFF;
00221 } else if ( runType_ == sistrip::FINE_DELAY_PLL ) {
00222 } else if ( runType_ == sistrip::FINE_DELAY_TTC ) {
00223 } else if ( runType_ == sistrip::FINE_DELAY ) {
00224 params_[2] = (daq2>>0 )&0xFFFF;
00225 params_[0] = params_[2]/25;
00226 params_[1] = uint32_t((params_[2]%25)*24./25.);
00227 params_[3] = (daq2>>0)&0xFFFF0000;
00228 } else if ( runType_ == sistrip::FED_TIMING ) {
00229 params_[1] = (daq2>>0)&0xFF;
00230 } else if ( runType_ == sistrip::VPSP_SCAN ) {
00231 params_[0] = (daq2>>8)&0xFF;
00232 params_[1] = (daq2>>0)&0xFF;
00233 } else if ( runType_ == sistrip::FED_CABLING ) {
00234 } else if ( runType_ == sistrip::QUITE_FAST_CABLING ) {
00235 } else if ( runType_ == sistrip::FAST_CABLING ) {
00236 params_[0] = (daq2>>0)&0xFF;
00237 } else {
00238 edm::LogWarning(mlDigis_)
00239 << "[SiStripEventSummary::" << __func__ << "]"
00240 << " Unexpected commissioning task: "
00241 << runType_;
00242 }
00243
00244 }
00245
00246
00247
00248 void SiStripEventSummary::fedReadoutMode( const uint16_t& mode ) {
00249 if ( mode == 1 ) { fedReadoutMode_ = sistrip::FED_SCOPE_MODE; }
00250 else if ( mode == 2 ) { fedReadoutMode_ = sistrip::FED_VIRGIN_RAW; }
00251 else if ( mode == 6 ) { fedReadoutMode_ = sistrip::FED_PROC_RAW; }
00252 else if ( mode == 10 ) { fedReadoutMode_ = sistrip::FED_ZERO_SUPPR; }
00253 else if ( mode == 12 ) { fedReadoutMode_ = sistrip::FED_ZERO_SUPPR_LITE; }
00254 else { fedReadoutMode_ = sistrip::UNKNOWN_FED_READOUT_MODE; }
00255 }
00256
00257
00258
00259 std::ostream& operator<< ( std::ostream& os, const SiStripEventSummary& input ) {
00260 return os << "[SiStripEventSummary::" << __func__ << "]" << std::endl
00261 << " isSet : " << std::boolalpha << input.isSet() << std::noboolalpha << std::endl
00262 << " Trigger FED id : " << input.triggerFed() << std::endl
00263 << " isValid : " << std::boolalpha << input.valid() << std::noboolalpha << std::endl
00264 << " Run type : " << SiStripEnumsAndStrings::runType( input.runType() ) << std::endl
00265 << " Event number : " << input.event() << std::endl
00266 << " Bunch crossing : " << input.bx() << std::endl
00267 << " FED readout mode : " << SiStripEnumsAndStrings::fedReadoutMode( input.fedReadoutMode() ) << std::endl
00268 << " APV readout mode : " << SiStripEnumsAndStrings::apvReadoutMode( input.apvReadoutMode() ) << std::endl
00269 << " Commissioning params : "
00270 << input.params()[0] << ", "
00271 << input.params()[1] << ", "
00272 << input.params()[2] << ", "
00273 << input.params()[3]
00274 << std::endl;
00275 }