Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:18

0001 #include "RecoTBCalo/HcalTBObjectUnpacker/interface/HcalTBTriggerDataUnpacker.h"
0002 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
0003 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
0004 #include <iostream>
0005 
0006 using namespace std;
0007 
0008 // Structure for "old" TriggerData - contains header and trailer
0009 //
0010 struct oldTriggerDataFormat {
0011   uint32_t cdfHeader[4];
0012   uint32_t triggerWord;
0013   uint32_t triggerNumber;
0014   uint32_t triggerTime_usec;
0015   uint32_t triggerTime_base;
0016   uint32_t spillNumber;
0017   uint32_t runNumber;
0018   char runNumberSequenceId[16];
0019   uint32_t orbitNumber;
0020   uint32_t bunchNumber;
0021   uint32_t eventStatus;
0022   uint32_t filler1;
0023   uint32_t cdfTrailer[2];
0024 };
0025 
0026 // structures for "new" trigger data format - does NOT
0027 // contain header or trailer (header size is variable -
0028 // either 64 or 128 bits)
0029 //
0030 typedef struct StandardTrgMsgBlkStruct {
0031   uint32_t orbitNumber;
0032   uint32_t eventNumber;
0033   uint32_t flags_daq_ttype;
0034   uint32_t algo_bits_3;
0035   uint32_t algo_bits_2;
0036   uint32_t algo_bits_1;
0037   uint32_t algo_bits_0;
0038   uint32_t tech_bits;
0039   uint32_t gps_1234;
0040   uint32_t gps_5678;
0041 } StandardTrgMsgBlk;
0042 
0043 typedef struct newExtendedTrgMsgBlkStruct {
0044   StandardTrgMsgBlk stdBlock;
0045   uint32_t triggerWord;
0046   uint32_t triggerTime_usec;
0047   uint32_t triggerTime_base;
0048   uint32_t spillNumber;
0049   uint32_t runNumber;
0050   char runNumberSequenceId[16];
0051   uint32_t eventStatus;
0052 } newExtendedTrgMsgBlk;
0053 
0054 namespace hcaltb {
0055 
0056   void HcalTBTriggerDataUnpacker::unpack(const FEDRawData &raw, HcalTBTriggerData &htbtd) const {
0057     // Use the size to determine which format we have received:
0058     //
0059     if (raw.size() == 80) {  // "old" test beam trigger format
0060 
0061       const oldTriggerDataFormat *oldtrgblk = (const oldTriggerDataFormat *)(raw.data());
0062       htbtd.setStandardData(oldtrgblk->orbitNumber,
0063                             oldtrgblk->triggerNumber,
0064                             oldtrgblk->bunchNumber,
0065                             0,  // flags_daq_ttype
0066                             0,
0067                             0,
0068                             0,
0069                             0,  // algo_bits_3->0
0070                             0,  // tech_bits
0071                             0,
0072                             0  // gps_1234, gps_5678
0073       );
0074 
0075       htbtd.setExtendedData(oldtrgblk->triggerWord,
0076                             oldtrgblk->triggerTime_usec,
0077                             oldtrgblk->triggerTime_base,
0078                             oldtrgblk->spillNumber,
0079                             oldtrgblk->runNumber,
0080                             oldtrgblk->runNumberSequenceId);
0081     } else {
0082       const newExtendedTrgMsgBlk *newtrgblk;
0083 
0084       if (raw.size() == 96)  // "new" test beam trigger format,
0085                              // 64-bit header
0086         newtrgblk = (const newExtendedTrgMsgBlk *)(raw.data() + 8);
0087 
0088       else if (raw.size() == 104)  // "new" test beam trigger format,
0089                                    // 128-bit header
0090         newtrgblk = (const newExtendedTrgMsgBlk *)(raw.data() + 16);
0091       else {
0092         cerr << "HcalTBtdUnpacker.unpack: data of unknown size ";
0093         cerr << raw.size() << endl;
0094         return;
0095       }
0096 
0097       // get bunch number from the header
0098       //
0099       const uint32_t *cdflow = (const uint32_t *)raw.data();
0100       int bunch_id = (*cdflow) >> 20;
0101 
0102       htbtd.setStandardData(newtrgblk->stdBlock.orbitNumber,
0103                             newtrgblk->stdBlock.eventNumber,
0104                             bunch_id,
0105                             newtrgblk->stdBlock.flags_daq_ttype,
0106                             newtrgblk->stdBlock.algo_bits_3,
0107                             newtrgblk->stdBlock.algo_bits_2,
0108                             newtrgblk->stdBlock.algo_bits_1,
0109                             newtrgblk->stdBlock.algo_bits_0,
0110                             newtrgblk->stdBlock.tech_bits,
0111                             newtrgblk->stdBlock.gps_1234,
0112                             newtrgblk->stdBlock.gps_5678);
0113 
0114       htbtd.setExtendedData(newtrgblk->triggerWord,
0115                             newtrgblk->triggerTime_usec,
0116                             newtrgblk->triggerTime_base,
0117                             newtrgblk->spillNumber,
0118                             newtrgblk->runNumber,
0119                             newtrgblk->runNumberSequenceId);
0120     }
0121   }
0122 }  // namespace hcaltb