File indexing completed on 2024-04-06 12:10:37
0001 #include <EventFilter/EcalTBRawToDigi/interface/EcalDCCHeaderRuntypeDecoder.h>
0002
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004
0005 #include <string>
0006 #include <iostream>
0007
0008 EcalDCCTBHeaderRuntypeDecoder::EcalDCCTBHeaderRuntypeDecoder() { ; }
0009 EcalDCCTBHeaderRuntypeDecoder::~EcalDCCTBHeaderRuntypeDecoder() { ; }
0010
0011 bool EcalDCCTBHeaderRuntypeDecoder::Decode(unsigned long headerWord, EcalDCCHeaderBlock* EcalDCCHeaderInfos) {
0012
0013
0014 unsigned long WhichHalfOffSet = 64;
0015 unsigned long TypeOffSet = 256;
0016 unsigned long SubTypeOffSet = 2048;
0017 unsigned long SettingOffSet = 131072;
0018 unsigned long GainModeOffSet = 16384;
0019
0020 unsigned long TwoBitsMask = 3;
0021 unsigned long ThreeBitsMask = 7;
0022 unsigned long ThirdBitMask = 4;
0023
0024
0025 EcalDCCHeaderInfos->setRtHalf(int((headerWord / WhichHalfOffSet) & TwoBitsMask));
0026 int type = int((headerWord / TypeOffSet) & ThreeBitsMask);
0027 int sequence = int((headerWord / SubTypeOffSet) & ThreeBitsMask);
0028 EcalDCCHeaderInfos->setMgpaGain(int((headerWord / GainModeOffSet) & TwoBitsMask));
0029 EcalDCCHeaderInfos->setMemGain(int((headerWord / GainModeOffSet) & ThirdBitMask) / ThirdBitMask);
0030
0031
0032 if (type == 0 && sequence == 0) {
0033 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::COSMIC);
0034 }
0035
0036 else if (type == 0 && sequence == 1) {
0037 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::COSMIC);
0038 } else if (type == 0 && sequence == 2) {
0039 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::BEAMH4);
0040 } else if (type == 0 && sequence == 3) {
0041 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::BEAMH2);
0042 } else if (type == 0 && sequence == 4) {
0043 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::MTCC);
0044 }
0045
0046 else if (type == 1 && sequence == 0) {
0047 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::LASER_STD);
0048 } else if (type == 1 && sequence == 1) {
0049 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::LASER_POWER_SCAN);
0050 } else if (type == 1 && sequence == 2) {
0051 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::LASER_DELAY_SCAN);
0052 } else if (type == 2 && sequence == 0) {
0053 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM);
0054 } else if (type == 2 && sequence == 1) {
0055 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::TESTPULSE_MGPA);
0056 } else if (type == 3 && sequence == 0) {
0057 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::PEDESTAL_STD);
0058 } else if (type == 3 && sequence == 1) {
0059 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN);
0060 } else if (type == 3 && sequence == 2) {
0061 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN);
0062 } else if (type == 4 && sequence == 0) {
0063 EcalDCCHeaderInfos->setRunType(EcalDCCHeaderBlock::LED_STD);
0064 } else {
0065 edm::LogWarning("EcalTBRawToDigi") << "@SUB=EcalDCCHeaderRuntypeDecoder::Decode unrecognized runtype and sequence: "
0066 << type << " " << sequence;
0067 EcalDCCHeaderInfos->setRunType(-1);
0068 WasDecodingOk_ = false;
0069 }
0070
0071 DecodeSetting(int(headerWord / SettingOffSet), EcalDCCHeaderInfos);
0072
0073 return WasDecodingOk_;
0074 }
0075
0076 void EcalDCCTBHeaderRuntypeDecoder::DecodeSetting(int Setting, EcalDCCHeaderBlock* theHeader) {
0077 EcalDCCHeaderBlock::EcalDCCEventSettings theSettings;
0078 CleanEcalDCCSettingsInfo(&theSettings);
0079
0080 if (theHeader->getRunType() == EcalDCCHeaderBlock::COSMIC || theHeader->getRunType() == EcalDCCHeaderBlock::BEAMH2 ||
0081 theHeader->getRunType() == EcalDCCHeaderBlock::BEAMH4 || theHeader->getRunType() == EcalDCCHeaderBlock::MTCC) {
0082 ;
0083 }
0084 else if (theHeader->getRunType() == EcalDCCHeaderBlock::LASER_STD) {
0085 theSettings.LaserPower = (Setting & 8128) / 64;
0086 theSettings.LaserFilter = (Setting & 56) / 8;
0087 theSettings.wavelength = Setting & 7;
0088 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::LASER_POWER_SCAN) {
0089 theSettings.LaserPower = (Setting & 8128) / 64;
0090 theSettings.LaserFilter = (Setting & 56) / 8;
0091 theSettings.wavelength = Setting & 7;
0092 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::LASER_DELAY_SCAN) {
0093 theSettings.wavelength = Setting & 7;
0094 theSettings.delay = (Setting & 2040) / 8;
0095 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::TESTPULSE_SCAN_MEM) {
0096 theSettings.MEMVinj = Setting & 511;
0097 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::TESTPULSE_MGPA) {
0098 theSettings.mgpa_content = Setting & 255;
0099 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::PEDESTAL_STD) {
0100 ;
0101 }
0102 else if (theHeader->getRunType() == EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN) {
0103 theSettings.ped_offset = Setting;
0104 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::PEDESTAL_25NS_SCAN) {
0105 theSettings.delay = (Setting & 255);
0106 } else if (theHeader->getRunType() == EcalDCCHeaderBlock::LED_STD) {
0107 theSettings.wavelength = Setting & 7;
0108 } else {
0109 edm::LogWarning("EcalTBRawToDigi") << "@SUB=EcalDCCTBHeaderRuntypeDecoder::DecodeSettings unrecognized run type: "
0110 << theHeader->getRunType();
0111 WasDecodingOk_ = false;
0112 }
0113 theHeader->setEventSettings(theSettings);
0114 }
0115
0116 void EcalDCCTBHeaderRuntypeDecoder::CleanEcalDCCSettingsInfo(EcalDCCHeaderBlock::EcalDCCEventSettings* dummySettings) {
0117 dummySettings->LaserPower = -1;
0118 dummySettings->LaserFilter = -1;
0119 dummySettings->wavelength = -1;
0120 dummySettings->delay = -1;
0121 dummySettings->MEMVinj = -1;
0122 dummySettings->mgpa_content = -1;
0123 dummySettings->ped_offset = -1;
0124 }