CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/TBDataFormats/HcalTBObjects/src/HcalTBTriggerData.cc

Go to the documentation of this file.
00001 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00002 #include <cstdio>
00003 #include <stdint.h>
00004 
00005 using namespace std;
00006 
00007 
00008 const uint32_t HcalTBTriggerData::bit_BeamTrigger                   = 1;
00009 const uint32_t HcalTBTriggerData::bit_InSpillPedestalTrigger        = 2;
00010 const uint32_t HcalTBTriggerData::bit_OutSpillPedestalTrigger       = 3;
00011 const uint32_t HcalTBTriggerData::bit_LaserTrigger                  = 4;
00012 const uint32_t HcalTBTriggerData::bit_spillIgnorantPedestalTrigger  = 5;
00013 const uint32_t HcalTBTriggerData::bit_LEDTrigger                    = 6;
00014 
00015 const uint32_t HcalTBTriggerData::bit_FakeTrigger                   = 15;
00016 
00017 const uint32_t HcalTBTriggerData::bit_InSpill = 0x10;
00018 
00019   HcalTBTriggerData::HcalTBTriggerData() :
00020     runNumberSequenceId_(""),
00021     runNumber_(0),
00022     triggerWord_(0),
00023     triggerTimeUsec_(0),
00024     triggerTimeBase_(0),
00025     spillNumber_(0),
00026     orbitNumber_(0),
00027     bunchNumber_(0),
00028     eventNumber_(0),
00029     flagsDaqTtype_(0),
00030     algoBits3_(0),
00031     algoBits2_(0),
00032     algoBits1_(0),
00033     algoBits0_(0),
00034     techBits_(0),
00035     gps1234_(0),
00036     gps5678_(0) {
00037   }
00038 
00039   
00040   void HcalTBTriggerData::setStandardData(  uint32_t orbitNumber,
00041                                             uint32_t eventNumber,
00042                                             uint16_t bunchNumber,
00043                                             uint32_t flags_daq_ttype,
00044                                             uint32_t algo_bits_3,
00045                                             uint32_t algo_bits_2,
00046                                             uint32_t algo_bits_1,
00047                                             uint32_t algo_bits_0,
00048                                             uint32_t tech_bits,
00049                                             uint32_t gps_1234,
00050                                             uint32_t gps_5678) {
00051 
00052     orbitNumber_   = orbitNumber;
00053     eventNumber_   = eventNumber & 0x00ffffff; // only lower 24 bits active
00054     bunchNumber_   = bunchNumber;
00055     flagsDaqTtype_ = flags_daq_ttype;
00056     algoBits3_     = algo_bits_3;
00057     algoBits2_     = algo_bits_2;
00058     algoBits1_     = algo_bits_1;
00059     algoBits0_     = algo_bits_0;
00060     techBits_      = tech_bits;
00061     gps1234_       = gps_1234;
00062     gps5678_       = gps_5678;
00063   }
00064 
00065   void HcalTBTriggerData::setExtendedData(  uint32_t triggerWord,
00066                                             uint32_t triggerTime_usec,
00067                                             uint32_t triggerTime_base,
00068                                             uint32_t spillNumber,
00069                                             uint32_t runNumber,
00070                                             const char *runNumberSequenceId ) {
00071     triggerWord_         = triggerWord;
00072     triggerTimeUsec_     = triggerTime_usec;
00073     triggerTimeBase_     = triggerTime_base;
00074     spillNumber_         = spillNumber;
00075     runNumber_           = runNumber;
00076     runNumberSequenceId_ = runNumberSequenceId;
00077   }
00078 
00079   ostream& operator<<(ostream& s, const HcalTBTriggerData& htbtd) {
00080     char str[50];
00081     s << htbtd.runNumberSequenceId() << ":";
00082     s << htbtd.runNumber() << ":";
00083     s << htbtd.eventNumber() << endl;
00084 
00085     s << "  Spill# =" << htbtd.spillNumber() << endl;
00086     s << "  Bunch# =" << htbtd.bunchNumber() << endl;
00087     s << "  Orbit# =" << htbtd.orbitNumber() << endl;
00088 
00089     sprintf(str, "  Trigger word = %08x\n", htbtd.triggerWord());
00090     s << str;
00091 
00092     int32_t  trigtimebase = (int32_t)htbtd.triggerTimeBase();
00093     uint32_t trigtimeusec = htbtd.triggerTimeUsec();
00094 
00095     // trim seconds off of usec and add to base
00096     trigtimebase += trigtimeusec/1000000;
00097     trigtimeusec %= 1000000;
00098     
00099     sprintf(str, "  Trigger time: %s", ctime((time_t *)&trigtimebase));
00100     s << str;
00101     sprintf(str, "                %d us\n", trigtimeusec);
00102     s << str;
00103 
00104     return s;
00105   }