CMS 3D CMS Logo

CSCTFTBEventData.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     CSCTFTBRawFormat
00004 // Module:      CSCTFTBEventData
00005 // 
00006 // Description: SR/SP Event Data class
00007 //
00008 // Implementation:
00009 //     <Notes on implementation>
00010 //
00011 // Author:      Lindsey Gray
00012 // Created:     13.1.2005
00013 //
00014 // $Id: CSCTFTBEventData.cc,v 1.1 2007/04/26 23:39:19 kkotov Exp $
00015 //
00016 // Revision History
00017 // $Log: CSCTFTBEventData.cc,v $
00018 // Revision 1.1  2007/04/26 23:39:19  kkotov
00019 //
00020 // Moved old TB data format to a separate folder, attempted to unpack status digi
00021 //
00022 // Revision 1.2  2006/06/22 14:46:05  lgray
00023 // Forced commit of all code
00024 //
00025 // Revision 1.1  2006/06/22 00:34:18  lgray
00026 // Moved all data format classes here. Removed old Packages from nightly
00027 //
00028 // Revision 1.2  2006/02/27 10:43:57  lgray
00029 // Print changes.
00030 //
00031 // Revision 1.1  2006/02/22 23:16:42  lgray
00032 // First commit of test beam data format from UF
00033 //
00034 // Revision 1.6  2005/06/22 22:03:27  lgray
00035 // update
00036 //
00037 // Revision 1.5  2005/05/10 21:57:22  lgray
00038 // Bugfixes, stability issues fixed
00039 //
00040 // Revision 1.4  2005/03/03 19:52:27  lgray
00041 // Minor changes
00042 //
00043 // Revision 1.3  2005/03/03 18:14:48  lgray
00044 // Added ability to pack data back into raw form. Added test program for this as well.
00045 //
00046 // Revision 1.2  2005/02/15 17:29:45  lgray
00047 // Getting ready for SP DDU
00048 //
00049 // Revision 1.1  2005/02/14 21:01:32  lgray
00050 // First Commit from UF
00051 //
00052 // Revision 1.8  2004/11/30 02:59:27  tfcvs
00053 // (LAG) Better way.
00054 //
00055 // Revision 1.7  2004/11/30 02:55:27  tfcvs
00056 // (LAG) fixed small problem with CDF headers.
00057 //
00058 // Revision 1.6  2004/11/29 23:01:03  tfcvs
00059 // (LAG) Added static bool to account for data with CDF header/trailer
00060 //
00061 // Revision 1.5  2004/05/18 15:00:25  tfcvs
00062 // DEA: close to new SP data format
00063 //
00064 // Revision 1.4  2004/05/18 11:37:46  tfcvs
00065 // DEA: touch base
00066 //
00067 // Revision 1.3  2004/05/18 08:00:35  tfcvs
00068 // DEA: touch base
00069 //
00070 // Revision 1.2  2004/05/17 08:25:52  tfcvs
00071 // DEA: switch to SR BX data
00072 //
00073 // Revision 1.1  2004/05/16 12:17:17  tfcvs
00074 // DEA: call overall data block 
00075 //
00076 // Revision 1.12  2004/05/16 07:43:49  tfcvs
00077 // DEA: TB2003 version working with new software
00078 //
00079 // Revision 1.11  2003/09/19 20:22:55  tfcvs
00080 // latest
00081 //
00082 // Revision 1.10  2003/08/27 22:09:04  tfcvs
00083 // Added pretty-print  -Rick
00084 //
00085 // Revision 1.9  2003/05/27 12:45:00  tfcvs
00086 // add BXN and L1A # to SPEvent -DEA
00087 //
00088 // Revision 1.8  2003/05/25 10:13:02  tfcvs
00089 // first working version -DEA
00090 //
00091 // Revision 1.7  2003/05/22 17:27:20  tfcvs
00092 // HS - Some more minor changes
00093 //
00094 // Revision 1.6  2003/05/20 22:13:06  tfcvs
00095 // HS - Added Darin's changes
00096 //
00097 // Revision 1.5  2003/05/19 23:23:12  tfcvs
00098 // HS - Commit after some changes
00099 //
00100 // Revision 1.3  2003/05/19 15:47:18  tfcvs
00101 // HS - Some cleanup
00102 //
00103 // Revision 1.2  2003/05/15 23:58:40  tfcvs
00104 // HS - Some cosmetics
00105 //
00106 // 
00107 //
00108 
00109 // System include files
00110 #include <iostream>
00111 #include <vector>
00112 
00113 // Package include files
00114 #include "EventFilter/CSCTFRawToDigi/src/CSCTFTBEventData.h"
00115 #include "Utilities/Timing/interface/TimingReport.h"
00116 
00117 // External package include files
00118 
00119 // STL classes
00120 
00121 // Constants, enums and typedefs
00122 
00123 // CVS-based strings (Id and Tag with which file was checked out)
00124 static const char* const kIdString  = "$Id: CSCTFTBEventData.cc,v 1.1 2007/04/26 23:39:19 kkotov Exp $";
00125 static const char* const kTagString = "$Name: V02-15-07 $";
00126 
00127 // Static data member definitions
00128 bool CSCTFTBEventData::hasCDF_ = false;
00129 unsigned CSCTFTBEventData::trigBX_ = 0;
00130 bool CSCTFTBEventData::onlyTrigBX_ = false;
00131 
00132 // Constructors and destructor
00133 CSCTFTBEventData::CSCTFTBEventData()
00134 {
00135 }
00136 
00137 //
00138 CSCTFTBEventData::CSCTFTBEventData(unsigned short *buf)
00139 {
00140 // Then unpack the rest of the data
00141 
00142   unpackData(buf);
00143 }
00144 
00145 CSCTFTBEventData::~CSCTFTBEventData()
00146 {
00147   frontBlocks_.clear();
00148   spBlocks_.clear();
00149 }
00150 
00151 
00152 // Member Functions
00153 
00154 int CSCTFTBEventData::unpackData(unsigned short *buf) 
00155 {
00156 //   cout << " CSCTFTBEventData_unpackData-INFO: Unpacking event data" << endl;
00157   unsigned short *inputbuf = buf;
00158 
00159   TimeMe t("CSCTFTBEventData::unpack"); 
00160   
00161   memcpy(&spHead_,buf,CSCTFTBEventHeader::size()*sizeof(unsigned short));
00162   
00163   buf += CSCTFTBEventHeader::size();
00164 
00165   frontBlocks_.clear();
00166   spBlocks_.clear();
00167   if (spHead_.numBX() > 0) {
00168      for (int bx = 1; bx<=spHead_.numBX(); bx++)
00169        {
00170          CSCTFTBFrontBlock aFrontBlock(buf, bx,spHead_);
00171          frontBlocks_.push_back(aFrontBlock);
00172          buf+= aFrontBlock.size();       
00173          CSCTFTBSPBlock aSPBlock(buf, bx,spHead_);
00174          spBlocks_.push_back(aSPBlock);
00175          buf+= aSPBlock.size(); 
00176        }
00177    }
00178   
00179   size_ = buf - inputbuf;
00180   inputbuf = NULL;
00181   return 0;
00182 
00183 }
00184 
00185 void CSCTFTBEventData::setEventInformation(unsigned bxnum,unsigned lvl1num)
00186 {
00187   spHead_.bunch_cntr_ = bxnum;
00188   spHead_.l1a_lsb_ = (lvl1num & 0xFFF);
00189   spHead_.l1a_msb_ = ((lvl1num>>12) & 0xFFF);
00190 }
00191 
00192 /* put back in when BitVector is back.
00193 BitVector CSCTFTBEventData::pack()
00194 {
00195   BitVector result;
00196 
00197   BitVector evhdr(reinterpret_cast<unsigned*>(&spHead_),spHead_.size()*sizeof(short)*8);
00198   result.assign(result.nBits(),evhdr.nBits(),evhdr);
00199 
00200   for(int i = 0; i< spHead_.numBX();i++)
00201     {
00202       BitVector front = frontBlocks_[i].pack();
00203       BitVector sp = spBlocks_[i].pack();
00204       result.assign(result.nBits(),front.nBits(),front);
00205       result.assign(result.nBits(),sp.nBits(),sp);
00206     }
00207   return result;
00208 }
00209 */
00210 
00211 std::ostream & operator<<(std::ostream & stream, const CSCTFTBEventData & data) {
00212   stream << data.eventHeader();
00213   std::vector<CSCTFTBFrontBlock> srBxData = data.frontData();
00214   std::vector<CSCTFTBSPBlock> spBxData = data.spData();
00215   for(unsigned bx = 0; bx < srBxData.size(); ++bx) {
00216     if((bx+1)==data.trigBX_ || !data.onlyTrigBX_)
00217       {
00218         stream << "Event data for bx: " << bx+1 << std::endl;
00219         stream << srBxData[bx];
00220         stream << spBxData[bx];
00221       }
00222   }
00223   stream << std::endl;
00224   return stream;
00225 }

Generated on Tue Jun 9 17:34:26 2009 for CMSSW by  doxygen 1.5.4