Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:19

0001 #include "DataFormats/HcalRecHit/interface/HcalSourcePositionData.h"
0002 #include <cstdio>
0003 
0004 using namespace std;
0005 
0006 HcalSourcePositionData::HcalSourcePositionData() {
0007   messageCounter_ = 0;
0008   indexCounter_ = 0;
0009   reelCounter_ = 0;
0010   timestamp1_sec_ = 0;
0011   timestamp1_usec_ = 0;
0012   timestamp2_sec_ = 0;
0013   timestamp2_usec_ = 0;
0014   status_ = 0;
0015   motorCurrent_ = 0;
0016   motorVoltage_ = 0;
0017   tubeId_ = -1;
0018   driverId_ = -1;
0019   sourceId_ = -1;
0020   tubeNameFromCoord_ = "";
0021   tubeDescriptionFromSD_ = "";
0022   lastCommand_ = "";
0023   message_ = "";
0024 }
0025 
0026 void HcalSourcePositionData::set(int message_counter,
0027                                  int timestamp1_sec,
0028                                  int timestamp1_usec,
0029                                  int timestamp2_sec,
0030                                  int timestamp2_usec,
0031                                  int status,
0032                                  int index_counter,
0033                                  int reel_counter,
0034                                  int motor_current,
0035                                  int motor_voltage,
0036                                  int driver_id,
0037                                  int source_id,
0038                                  std::string tubeNameFromCoord,
0039                                  std::string tubeDescFromSD,
0040                                  std::string lastCommand,
0041                                  std::string message) {
0042   messageCounter_ = message_counter;
0043   indexCounter_ = index_counter;
0044   reelCounter_ = reel_counter;
0045   timestamp1_sec_ = timestamp1_sec;
0046   timestamp1_usec_ = timestamp1_usec;
0047   timestamp2_sec_ = timestamp2_sec;
0048   timestamp2_usec_ = timestamp2_usec;
0049   status_ = status;
0050   motorCurrent_ = motor_current;
0051   motorVoltage_ = motor_voltage;
0052   driverId_ = driver_id;
0053   sourceId_ = source_id;
0054   tubeNameFromCoord_ = tubeNameFromCoord;
0055   tubeDescriptionFromSD_ = tubeDescFromSD;
0056   lastCommand_ = lastCommand;
0057   message_ = message;
0058 }
0059 
0060 void HcalSourcePositionData::getDriverTimestamp(int& seconds, int& useconds) const {
0061   seconds = timestamp1_sec_;
0062   useconds = timestamp1_usec_;
0063 }
0064 
0065 void HcalSourcePositionData::getDAQTimestamp(int& seconds, int& useconds) const {
0066   seconds = timestamp2_sec_;
0067   useconds = timestamp2_usec_;
0068 }
0069 
0070 ostream& operator<<(ostream& s, const HcalSourcePositionData& hspd) {
0071   s << "  Message Counter       =" << hspd.messageCounter() << endl;
0072   s << "  Index Counter         =" << hspd.indexCounter() << endl;
0073   s << "  Reel Counter          =" << hspd.reelCounter() << endl;
0074   s << "  Status                =" << hex << hspd.status() << dec << endl;
0075   s << "  Motor Current         =" << hspd.motorCurrent() << endl;
0076   s << "  Motor Voltage         =" << hspd.motorVoltage() << endl;
0077   s << "  Tube Id               =" << hspd.tubeId() << endl;
0078   s << "  Driver Id             =" << hspd.driverId() << endl;
0079   s << "  Source Id             =" << hspd.sourceId() << endl;
0080   s << "  TubeNameFromCoord     =" << hspd.tubeNameFromCoord() << endl;
0081   s << "  TubeDescriptionFromSD =" << hspd.tubeDescriptionFromSD() << endl;
0082   s << "  Last Command          =" << hspd.lastCommand() << endl;
0083   s << "  Message               =" << hspd.message() << endl;
0084 
0085   int timebase = 0;
0086   int timeusec = 0;
0087   hspd.getDriverTimestamp(timebase, timeusec);
0088   // trim seconds off of usec and add to base
0089   timeusec %= 1000000;
0090   timebase += timeusec / 1000000;
0091   char str[50];
0092   sprintf(str, "  Driver Timestamp : %s", ctime((time_t*)&timebase));
0093   s << str;
0094   timebase = 0;
0095   timeusec = 0;
0096   hspd.getDAQTimestamp(timebase, timeusec);
0097   timeusec %= 1000000;
0098   timebase += timeusec / 1000000;
0099 
0100   sprintf(str, "  DAQ Timestamp : %s", ctime((time_t*)&timebase));
0101   s << str;
0102 
0103   return s;
0104 }