CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/RecoTBCalo/HcalTBObjectUnpacker/src/HcalTBTriggerDataUnpacker.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/HcalTBObjectUnpacker/interface/HcalTBTriggerDataUnpacker.h"
00002 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00003 #include "DataFormats/FEDRawData/interface/FEDRawData.h"
00004 #include <iostream>
00005 
00006 using namespace std;
00007 
00008 // Structure for "old" TriggerData - contains header and trailer
00009 //
00010 struct oldTriggerDataFormat {
00011   uint32_t cdfHeader[4];
00012   uint32_t triggerWord;
00013   uint32_t triggerNumber;
00014   uint32_t triggerTime_usec;
00015   uint32_t triggerTime_base;
00016   uint32_t spillNumber;
00017   uint32_t runNumber;
00018   char     runNumberSequenceId[16];
00019   uint32_t orbitNumber;
00020   uint32_t bunchNumber;
00021   uint32_t eventStatus;
00022   uint32_t filler1;
00023   uint32_t cdfTrailer[2];
00024 };
00025 
00026 // structures for "new" trigger data format - does NOT
00027 // contain header or trailer (header size is variable -
00028 // either 64 or 128 bits)
00029 //
00030 typedef struct StandardTrgMsgBlkStruct {
00031   uint32_t orbitNumber;
00032   uint32_t eventNumber;
00033   uint32_t flags_daq_ttype;
00034   uint32_t algo_bits_3;
00035   uint32_t algo_bits_2;
00036   uint32_t algo_bits_1;
00037   uint32_t algo_bits_0;
00038   uint32_t tech_bits;
00039   uint32_t gps_1234;
00040   uint32_t gps_5678;
00041 } StandardTrgMsgBlk;
00042 
00043 typedef struct newExtendedTrgMsgBlkStruct {
00044   StandardTrgMsgBlk stdBlock;
00045   uint32_t triggerWord;
00046   uint32_t triggerTime_usec;
00047   uint32_t triggerTime_base;
00048   uint32_t spillNumber;
00049   uint32_t runNumber;
00050   char     runNumberSequenceId[16];
00051   uint32_t eventStatus;
00052 } newExtendedTrgMsgBlk;
00053 
00054 
00055 namespace hcaltb {
00056 
00057   void HcalTBTriggerDataUnpacker::unpack(const FEDRawData& raw, HcalTBTriggerData& htbtd) const {
00058 
00059     // Use the size to determine which format we have received:
00060     //
00061     if (raw.size() == 80) { // "old" test beam trigger format
00062 
00063       const oldTriggerDataFormat *oldtrgblk = (const oldTriggerDataFormat *)(raw.data());
00064       htbtd.setStandardData(oldtrgblk->orbitNumber,
00065                             oldtrgblk->triggerNumber,
00066                             oldtrgblk->bunchNumber,
00067                             0,          // flags_daq_ttype
00068                             0, 0, 0, 0, // algo_bits_3->0
00069                             0,          // tech_bits
00070                             0, 0        // gps_1234, gps_5678
00071                             );
00072 
00073       htbtd.setExtendedData(oldtrgblk->triggerWord,
00074                             oldtrgblk->triggerTime_usec,
00075                             oldtrgblk->triggerTime_base,
00076                             oldtrgblk->spillNumber,
00077                             oldtrgblk->runNumber,
00078                             oldtrgblk->runNumberSequenceId);
00079     }
00080     else {
00081 
00082       const newExtendedTrgMsgBlk *newtrgblk;
00083 
00084       if (raw.size() == 96)  // "new" test beam trigger format,
00085                                    // 64-bit header
00086         newtrgblk = (const newExtendedTrgMsgBlk *)(raw.data()+8);
00087 
00088       else if (raw.size() == 104) // "new" test beam trigger format,
00089                                         // 128-bit header
00090         newtrgblk = (const newExtendedTrgMsgBlk *)(raw.data()+16);
00091       else {
00092         cerr << "HcalTBtdUnpacker.unpack: data of unknown size ";
00093         cerr << raw.size() << endl;
00094         return;
00095       }
00096 
00097       // get bunch number from the header
00098       //
00099       const uint32_t *cdflow = (const uint32_t *)raw.data();
00100       int bunch_id = (*cdflow)>>20;
00101 
00102       htbtd.setStandardData(newtrgblk->stdBlock.orbitNumber,
00103                             newtrgblk->stdBlock.eventNumber,
00104                             bunch_id,
00105                             newtrgblk->stdBlock.flags_daq_ttype,
00106                             newtrgblk->stdBlock.algo_bits_3,
00107                             newtrgblk->stdBlock.algo_bits_2,
00108                             newtrgblk->stdBlock.algo_bits_1,
00109                             newtrgblk->stdBlock.algo_bits_0,
00110                             newtrgblk->stdBlock.tech_bits,
00111                             newtrgblk->stdBlock.gps_1234,
00112                             newtrgblk->stdBlock.gps_5678);
00113 
00114       htbtd.setExtendedData(newtrgblk->triggerWord,
00115                             newtrgblk->triggerTime_usec,
00116                             newtrgblk->triggerTime_base,
00117                             newtrgblk->spillNumber,
00118                             newtrgblk->runNumber,
00119                             newtrgblk->runNumberSequenceId);
00120     }
00121 
00122   }
00123 }
00124