CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/DataFormats/Scalers/src/DcsStatus.cc

Go to the documentation of this file.
00001 /*
00002  *   File: DataFormats/Scalers/src/DcsStatus.cc   (W.Badgett)
00003  */
00004 
00005 #include "DataFormats/Scalers/interface/DcsStatus.h"
00006 #include "DataFormats/Scalers/interface/ScalersRaw.h"
00007 #include <cstdio>
00008 #include <ostream>
00009 
00010 const int DcsStatus::partitionList[DcsStatus::nPartitions] = {
00011   EBp         ,
00012   EBm         ,
00013   EEp         ,
00014   EEm         ,
00015   HBHEa       ,
00016   HBHEb       ,
00017   HBHEc       ,
00018   HF          ,
00019   HO          ,
00020   RPC         ,
00021   DT0         ,
00022   DTp         ,
00023   DTm         ,
00024   CSCp        ,
00025   CSCm        ,
00026   CASTOR      ,
00027   ZDC         ,
00028   TIBTID      ,
00029   TOB         ,
00030   TECp        ,
00031   TECm        ,
00032   BPIX        ,
00033   FPIX        ,
00034   ESp         ,
00035   ESm };
00036 
00037 const char * DcsStatus::partitionName[DcsStatus::nPartitions] = {
00038   "EBp"         ,
00039   "EBm"         ,
00040   "EEp"         ,
00041   "EEm"         ,
00042   "HBHEa"       ,
00043   "HBHEb"       ,
00044   "HBHEc"       ,
00045   "HF"          ,
00046   "HO"          ,
00047   "RPC"         ,
00048   "DT0"         ,
00049   "DTp"         ,
00050   "DTm"         ,
00051   "CSCp"        ,
00052   "CSCm"        ,
00053   "CASTOR"      ,
00054   "ZDC"         ,
00055   "TIBTID"      ,
00056   "TOB"         ,
00057   "TECp"        ,
00058   "TECm"        ,
00059   "BPIX"        ,
00060   "FPIX"        ,
00061   "ESp"         ,
00062   "ESm" };
00063 
00064 DcsStatus::DcsStatus() : 
00065    trigType_(0),
00066    eventID_(0),
00067    sourceID_(0),
00068    bunchNumber_(0),
00069    version_(0),
00070    collectionTime_(0,0),
00071    ready_(0),
00072    magnetCurrent_((float)0.0),
00073    magnetTemperature_((float)0.0)
00074 { 
00075 }
00076 
00077 DcsStatus::DcsStatus(const unsigned char * rawData)
00078 { 
00079   DcsStatus();
00080 
00081   struct ScalersEventRecordRaw_v4 * raw 
00082     = (struct ScalersEventRecordRaw_v4 *)rawData;
00083   trigType_     = ( raw->header >> 56 ) &        0xFULL;
00084   eventID_      = ( raw->header >> 32 ) & 0x00FFFFFFULL;
00085   sourceID_     = ( raw->header >>  8 ) & 0x00000FFFULL;
00086   bunchNumber_  = ( raw->header >> 20 ) &      0xFFFULL;
00087 
00088   version_ = raw->version;
00089   if ( version_ >= 4 )
00090   {
00091     collectionTime_.set_tv_sec(static_cast<long>(raw->dcsStatus.collectionTime_sec));
00092     collectionTime_.set_tv_nsec(raw->dcsStatus.collectionTime_nsec);
00093     ready_             = raw->dcsStatus.ready;
00094     magnetCurrent_     = raw->dcsStatus.magnetCurrent;
00095     magnetTemperature_ = raw->dcsStatus.magnetTemperature;
00096   }
00097 }
00098 
00099 DcsStatus::~DcsStatus() { } 
00100 
00101 
00103 std::ostream& operator<<(std::ostream& s, const DcsStatus& c) 
00104 {
00105   char zeit[128];
00106   char line[128];
00107   struct tm * hora;
00108 
00109   s << "DcsStatus    Version: " << c.version() << 
00110     "   SourceID: "<< c.sourceID() << std::endl;
00111 
00112   timespec ts = c.collectionTime();
00113   hora = gmtime(&ts.tv_sec);
00114   strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
00115   sprintf(line, " CollectionTime: %s.%9.9d", zeit, 
00116           (int)ts.tv_nsec);
00117   s << line << std::endl;
00118 
00119   sprintf(line, " TrigType: %d   EventID: %d    BunchNumber: %d", 
00120           c.trigType(), c.eventID(), c.bunchNumber());
00121   s << line << std::endl;
00122 
00123   sprintf(line," MagnetCurrent: %e    MagnetTemperature: %e", 
00124           c.magnetCurrent(), c.magnetTemperature());
00125   s << line << std::endl;
00126 
00127   sprintf(line," Ready: %d  0x%8.8X", c.ready(), c.ready());
00128   s << line << std::endl;
00129 
00130   for ( int i=0; i<DcsStatus::nPartitions; i++)
00131   {
00132     if ( c.ready(DcsStatus::partitionList[i]))
00133     {
00134       sprintf(line,"  %2d %6s: READY", i, DcsStatus::partitionName[i]);
00135     }
00136     else
00137     {
00138       sprintf(line,"  %2d %6s: NOT READY", i, DcsStatus::partitionName[i]);
00139     }
00140   s << line << std::endl;
00141   }
00142   return s;
00143 }