CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DataFormats/Scalers/src/BeamSpotOnline.cc

Go to the documentation of this file.
00001 /*
00002  *   File: DataFormats/Scalers/src/BeamSpotOnline.cc   (W.Badgett)
00003  */
00004 
00005 #include "DataFormats/Scalers/interface/BeamSpotOnline.h"
00006 #include "DataFormats/Scalers/interface/ScalersRaw.h"
00007 #include <cstdio>
00008 #include <ostream>
00009 
00010 BeamSpotOnline::BeamSpotOnline() : 
00011    trigType_(0),
00012    eventID_(0),
00013    sourceID_(0),
00014    bunchNumber_(0),
00015    version_(0),
00016    collectionTime_(0,0),
00017    x_((float)0.0),
00018    y_((float)0.0),
00019    z_((float)0.0),
00020    dxdz_((float)0.0),
00021    dydz_((float)0.0),
00022    err_x_((float)0.0),
00023    err_y_((float)0.0),
00024    err_z_((float)0.0),
00025    err_dxdz_((float)0.0),
00026    err_dydz_((float)0.0),
00027    width_x_((float)0.0),
00028    width_y_((float)0.0),
00029    sigma_z_((float)0.0),
00030    err_width_x_((float)0.0),
00031    err_width_y_((float)0.0),
00032    err_sigma_z_((float)0.0)
00033 { 
00034 }
00035 
00036 BeamSpotOnline::BeamSpotOnline(const unsigned char * rawData)
00037 { 
00038   BeamSpotOnline();
00039 
00040   struct ScalersEventRecordRaw_v4 * raw 
00041     = (struct ScalersEventRecordRaw_v4 *)rawData;
00042   trigType_     = ( raw->header >> 56 ) &        0xFULL;
00043   eventID_      = ( raw->header >> 32 ) & 0x00FFFFFFULL;
00044   sourceID_     = ( raw->header >>  8 ) & 0x00000FFFULL;
00045   bunchNumber_  = ( raw->header >> 20 ) &      0xFFFULL;
00046 
00047   version_ = raw->version;
00048   if ( version_ >= 4 )
00049   {
00050     collectionTime_.set_tv_sec(static_cast<long>(raw->beamSpotOnline.collectionTime_sec));
00051     collectionTime_.set_tv_nsec(raw->beamSpotOnline.collectionTime_nsec);
00052     x_           = raw->beamSpotOnline.x;
00053     y_           = raw->beamSpotOnline.y;
00054     z_           = raw->beamSpotOnline.z;
00055     dxdz_        = raw->beamSpotOnline.dxdz;
00056     dydz_        = raw->beamSpotOnline.dydz;
00057     err_x_       = raw->beamSpotOnline.err_x;
00058     err_y_       = raw->beamSpotOnline.err_y;
00059     err_z_       = raw->beamSpotOnline.err_z;
00060     err_dxdz_    = raw->beamSpotOnline.err_dxdz;
00061     err_dydz_    = raw->beamSpotOnline.err_dydz;
00062     width_x_     = raw->beamSpotOnline.width_x;
00063     width_y_     = raw->beamSpotOnline.width_y;
00064     sigma_z_     = raw->beamSpotOnline.sigma_z;
00065     err_width_x_ = raw->beamSpotOnline.err_width_x;
00066     err_width_y_ = raw->beamSpotOnline.err_width_y;
00067     err_sigma_z_ = raw->beamSpotOnline.err_sigma_z;
00068   }
00069 }
00070 
00071 BeamSpotOnline::~BeamSpotOnline() { } 
00072 
00073 
00075 std::ostream& operator<<(std::ostream& s, const BeamSpotOnline& c) 
00076 {
00077   char zeit[128];
00078   char line[128];
00079   struct tm * hora;
00080 
00081   s << "BeamSpotOnline    Version: " << c.version() << 
00082     "   SourceID: "<< c.sourceID() << std::endl;
00083 
00084   timespec ts = c.collectionTime();
00085   hora = gmtime(&ts.tv_sec);
00086   strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
00087   sprintf(line, " CollectionTime: %s.%9.9d", zeit, 
00088           (int)ts.tv_nsec);
00089   s << line << std::endl;
00090 
00091   sprintf(line, " TrigType: %d   EventID: %d    BunchNumber: %d", 
00092           c.trigType(), c.eventID(), c.bunchNumber());
00093   s << line << std::endl;
00094 
00095   sprintf(line,"    x: %e +/- %e   width: %e +/- %e",
00096           c.x(), c.err_x(), c.width_x(), c.err_width_x());
00097   s << line << std::endl;
00098 
00099   sprintf(line,"    y: %e +/- %e   width: %e +/- %e",
00100           c.y(), c.err_y(), c.width_y(), c.err_width_y());
00101   s << line << std::endl;
00102 
00103   sprintf(line,"    z: %e +/- %e   sigma: %e +/- %e",
00104           c.z(), c.err_z(), c.sigma_z(), c.err_sigma_z());
00105   s << line << std::endl;
00106 
00107   sprintf(line," dxdy: %e +/- %e    dydz: %e +/- %e",
00108           c.dxdz(), c.err_dxdz(), c.dydz(), c.err_dydz());
00109   s << line << std::endl;
00110   return s;
00111 }