Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:13

0001 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
0002 #include <cstdio>
0003 #include <cstdint>
0004 
0005 using namespace std;
0006 
0007 const uint32_t HcalTBTriggerData::bit_BeamTrigger = 1;
0008 const uint32_t HcalTBTriggerData::bit_InSpillPedestalTrigger = 2;
0009 const uint32_t HcalTBTriggerData::bit_OutSpillPedestalTrigger = 3;
0010 const uint32_t HcalTBTriggerData::bit_LaserTrigger = 4;
0011 const uint32_t HcalTBTriggerData::bit_spillIgnorantPedestalTrigger = 5;
0012 const uint32_t HcalTBTriggerData::bit_LEDTrigger = 6;
0013 
0014 const uint32_t HcalTBTriggerData::bit_FakeTrigger = 15;
0015 
0016 const uint32_t HcalTBTriggerData::bit_InSpill = 0x10;
0017 
0018 HcalTBTriggerData::HcalTBTriggerData()
0019     : runNumberSequenceId_(""),
0020       runNumber_(0),
0021       triggerWord_(0),
0022       triggerTimeUsec_(0),
0023       triggerTimeBase_(0),
0024       spillNumber_(0),
0025       orbitNumber_(0),
0026       bunchNumber_(0),
0027       eventNumber_(0),
0028       flagsDaqTtype_(0),
0029       algoBits3_(0),
0030       algoBits2_(0),
0031       algoBits1_(0),
0032       algoBits0_(0),
0033       techBits_(0),
0034       gps1234_(0),
0035       gps5678_(0) {}
0036 
0037 void HcalTBTriggerData::setStandardData(uint32_t orbitNumber,
0038                                         uint32_t eventNumber,
0039                                         uint16_t bunchNumber,
0040                                         uint32_t flags_daq_ttype,
0041                                         uint32_t algo_bits_3,
0042                                         uint32_t algo_bits_2,
0043                                         uint32_t algo_bits_1,
0044                                         uint32_t algo_bits_0,
0045                                         uint32_t tech_bits,
0046                                         uint32_t gps_1234,
0047                                         uint32_t gps_5678) {
0048   orbitNumber_ = orbitNumber;
0049   eventNumber_ = eventNumber & 0x00ffffff;  // only lower 24 bits active
0050   bunchNumber_ = bunchNumber;
0051   flagsDaqTtype_ = flags_daq_ttype;
0052   algoBits3_ = algo_bits_3;
0053   algoBits2_ = algo_bits_2;
0054   algoBits1_ = algo_bits_1;
0055   algoBits0_ = algo_bits_0;
0056   techBits_ = tech_bits;
0057   gps1234_ = gps_1234;
0058   gps5678_ = gps_5678;
0059 }
0060 
0061 void HcalTBTriggerData::setExtendedData(uint32_t triggerWord,
0062                                         uint32_t triggerTime_usec,
0063                                         uint32_t triggerTime_base,
0064                                         uint32_t spillNumber,
0065                                         uint32_t runNumber,
0066                                         const char* runNumberSequenceId) {
0067   triggerWord_ = triggerWord;
0068   triggerTimeUsec_ = triggerTime_usec;
0069   triggerTimeBase_ = triggerTime_base;
0070   spillNumber_ = spillNumber;
0071   runNumber_ = runNumber;
0072   runNumberSequenceId_ = runNumberSequenceId;
0073 }
0074 
0075 ostream& operator<<(ostream& s, const HcalTBTriggerData& htbtd) {
0076   char str[50];
0077   s << htbtd.runNumberSequenceId() << ":";
0078   s << htbtd.runNumber() << ":";
0079   s << htbtd.eventNumber() << endl;
0080 
0081   s << "  Spill# =" << htbtd.spillNumber() << endl;
0082   s << "  Bunch# =" << htbtd.bunchNumber() << endl;
0083   s << "  Orbit# =" << htbtd.orbitNumber() << endl;
0084 
0085   sprintf(str, "  Trigger word = %08x\n", htbtd.triggerWord());
0086   s << str;
0087 
0088   int32_t trigtimebase = (int32_t)htbtd.triggerTimeBase();
0089   uint32_t trigtimeusec = htbtd.triggerTimeUsec();
0090 
0091   // trim seconds off of usec and add to base
0092   trigtimebase += trigtimeusec / 1000000;
0093   trigtimeusec %= 1000000;
0094 
0095   sprintf(str, "  Trigger time: %s", ctime((time_t*)&trigtimebase));
0096   s << str;
0097   sprintf(str, "                %d us\n", trigtimeusec);
0098   s << str;
0099 
0100   return s;
0101 }