CMS 3D CMS Logo

CSCTFTBSPBlock.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     CSCTFTBRawData
00004 // Module:      CSCTFTBSPBlock
00005 // 
00006 // Description: SP Event Data Container class
00007 //
00008 // Implementation:
00009 //     <Notes on implementation>
00010 //
00011 // Author:      Lindsey
00012 // Created:     13.1.2005
00013 //
00014 // $Id: CSCTFTBSPBlock.cc,v 1.1 2007/04/26 23:39:19 kkotov Exp $
00015 //
00016 // Revision History
00017 // $Log: CSCTFTBSPBlock.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.1  2006/02/22 23:16:42  lgray
00029 // First commit of test beam data format from UF
00030 //
00031 // Revision 1.5  2005/06/22 22:03:27  lgray
00032 // update
00033 //
00034 // Revision 1.4  2005/05/13 08:29:59  lgray
00035 // Another bug fix.
00036 //
00037 // Revision 1.3  2005/05/10 21:57:22  lgray
00038 // Bugfixes, stability issues fixed
00039 //
00040 // Revision 1.2  2005/03/03 18:14:49  lgray
00041 // Added ability to pack data back into raw form. Added test program for this as well.
00042 //
00043 // Revision 1.1  2005/02/14 21:01:32  lgray
00044 // First Commit from UF
00045 //
00046 // Revision 1.10  2004/05/28 00:24:58  tfcvs
00047 // DEA: a working version of code for 4 chambers!
00048 //
00049 // Revision 1.9  2004/05/18 21:53:42  tfcvs
00050 // DEA: some print out
00051 //
00052 // Revision 1.8  2004/05/18 15:00:25  tfcvs
00053 // DEA: close to new SP data format
00054 //
00055 // Revision 1.7  2004/05/18 11:37:46  tfcvs
00056 // DEA: touch base
00057 //
00058 // Revision 1.6  2004/05/18 09:45:07  tfcvs
00059 // DEA: touch base
00060 //
00061 // Revision 1.5  2004/05/18 08:00:34  tfcvs
00062 // DEA: touch base
00063 //
00064 // Revision 1.4  2004/05/16 07:43:49  tfcvs
00065 // DEA: TB2003 version working with new software
00066 //
00067 // Revision 1.3  2003/09/19 20:22:55  tfcvs
00068 // latest
00069 //
00070 // Revision 1.2  2003/08/27 22:08:59  tfcvs
00071 // Added pretty-print  -Rick
00072 //
00073 // Revision 1.1  2003/05/25 10:13:02  tfcvs
00074 // first working version -DEA
00075 //
00076 // Revision 1.7  2003/05/22 17:27:20  tfcvs
00077 // HS - Some more minor changes
00078 //
00079 // Revision 1.6  2003/05/20 22:13:06  tfcvs
00080 // HS - Added Darin's changes
00081 //
00082 // Revision 1.5  2003/05/19 23:23:12  tfcvs
00083 // HS - Commit after some changes
00084 //
00085 // Revision 1.3  2003/05/19 15:47:18  tfcvs
00086 // HS - Some cleanup
00087 //
00088 // Revision 1.2  2003/05/15 23:58:40  tfcvs
00089 // HS - Some cosmetics
00090 //
00091 // 
00092 //
00093 
00094 // System include files
00095 #include <iostream>
00096 #include <vector>
00097 #include <string.h> //  memcpy
00098 
00099 // Package include files
00100 #include "EventFilter/CSCTFRawToDigi/src/CSCTFTBEventHeader.h"
00101 #include "EventFilter/CSCTFRawToDigi/src/CSCTFTBSPBlock.h"
00102 
00103 // External package include files
00104 //#include "Utilities/GenUtil/interface/BitVector.h"
00105 
00106 // STL classes
00107 
00108 // Constants, enums and typedefs
00109 
00110 // CVS-based strings (Id and Tag with which file was checked out)
00111 static const char* const kIdString  = "$Id: CSCTFTBSPBlock.cc,v 1.1 2007/04/26 23:39:19 kkotov Exp $";
00112 static const char* const kTagString = "$Name: V02-15-07 $";
00113 
00114 // Static data member definitions
00115 
00116 // Constructors and destructor
00117 CSCTFTBSPBlock::CSCTFTBSPBlock()
00118 {
00119   myBX_ = 0;
00120   size_ = 0;
00121 }
00122 
00123 //
00124 CSCTFTBSPBlock::CSCTFTBSPBlock(unsigned short *buf, int bx, 
00125                                  const CSCTFTBEventHeader& hdr)
00126 {
00127   myBX_ = bx;
00128   size_ = 0;
00129   unpackData(buf, hdr);
00130 }
00131 
00132 CSCTFTBSPBlock::CSCTFTBSPBlock(const CSCTFTBSPBlock &parent)
00133 {   
00134   //  spdata_ = parent.spdata_;
00135   /*for(int i = 0 ; i< parent.spdata_.size(); i++)
00136     {
00137       CSCTFTBSPData temp = parent.spdata_[i];
00138       spdata_.push_back(temp);
00139       }*/
00140   spdata_ = parent.spdata_;
00141   dtdata_ = parent.dtdata_;
00142   spheaderdata_ = parent.spheaderdata_;
00143   myBX_ = parent.myBX_;
00144   size_ = parent.size_;
00145   
00146 }
00147 
00148 CSCTFTBSPBlock::~CSCTFTBSPBlock()
00149 {
00150   spdata_.clear();
00151   dtdata_.clear();
00152 }
00153 
00154 // Member Functions
00155 
00156 int CSCTFTBSPBlock::unpackData(unsigned short *buf, 
00157                                 const CSCTFTBEventHeader& thehdr)
00158 {
00159   bool pt_present = false;
00160   unsigned mode = 0,link = 0;
00161   // store header data  
00162   memcpy(&spheaderdata_,buf,CSCTFTBSPHeader::size()*sizeof(short));
00163   buf += CSCTFTBSPHeader::size();
00164   size_ += CSCTFTBSPHeader::size();
00165   
00166   //store DT data and SP data....
00167   
00168   if(thehdr.getActiveDT()!=0) {
00169     for(unsigned i=1;i<=2;i++)
00170       {
00171         if(spheaderdata_.getVPDTBit(i)||thehdr.getZeroSupp()==0)
00172           {
00173             CSCTFTBDTData dtdata;
00174             memcpy(&dtdata,buf,CSCTFTBDTData::size()*sizeof(short));
00175             dtdata_.push_back(dtdata);
00176             buf += CSCTFTBDTData::size();
00177             size_ += CSCTFTBDTData::size();
00178           }
00179       }       
00180   }
00181      
00182   for(unsigned i=1;i<=3;i++)
00183     {
00184       if(spheaderdata_.getTrackMode(i)>0 || thehdr.getZeroSupp() == 0)
00185         {
00186           mode = spheaderdata_.getTrackMode(i);
00187           link = i;
00188           pt_present = (i == thehdr.getPtLutSpy());
00189           CSCTFTBSPData spdata(buf,pt_present,mode,link);  
00190           spdata_.push_back(spdata);
00191           buf += (pt_present) ? CSCTFTBSPData::size()+CSCTFTBPTData::size() : 
00192             CSCTFTBSPData::size();
00193           size_ += (pt_present) ? CSCTFTBSPData::size()+CSCTFTBPTData::size() :
00194             CSCTFTBSPData::size();
00195         }
00196     }
00197 
00198    return 0;
00199 
00200 }
00201 
00202 /*
00203 BitVector CSCTFTBSPBlock::pack()
00204 {
00205   BitVector result;
00206   
00207   BitVector header(reinterpret_cast<const unsigned*>(&spheaderdata_),
00208                    spheaderdata_.size()*sizeof(short)*8);
00209   result.assign(result.nBits(),header.nBits(),header);
00210 
00211   vector<CSCTFTBDTData>::const_iterator DTiter;
00212   vector<CSCTFTBSPData>::const_iterator SPiter;
00213 
00214   for(DTiter = dtdata_.begin();DTiter != dtdata_.end();DTiter++)
00215     {
00216       BitVector dt = DTiter->packVector();
00217       result.assign(result.nBits(),dt.nBits(),dt);
00218     }
00219 
00220   for(SPiter = spdata_.begin();SPiter != spdata_.end();SPiter++)
00221     {
00222       BitVector sp = SPiter->packVector();
00223       result.assign(result.nBits(),sp.nBits(),sp);
00224     }
00225 
00226   return result;
00227 }
00228 */
00229 
00230 std::ostream & operator<<(std::ostream & stream, const CSCTFTBSPBlock & bx) 
00231 { 
00232   //vector<CSCTFTBSPData> sp = bx.spData();
00233   std::vector<CSCTFTBDTData> dt = bx.dtData();
00234   CSCTFTBSPHeader hdr = bx.spHeader();
00235   stream << hdr;
00236   if(hdr.getTrackMode(1)||hdr.getTrackMode(2)||hdr.getTrackMode(3)
00237      ||hdr.getVPDTBit(1)||hdr.getVPDTBit(2))
00238     stream<<"\tSP Event Data (Tracks and DT Track Stubs):\n";
00239   for(unsigned i=0;i<dt.size();i++)
00240     {
00241       stream<<"\t Link "<< i << dt[i];
00242     }
00243   for(unsigned j=0;j<bx.spData().size();j++)
00244     {
00245       stream<<bx.spData()[j];
00246     }
00247   return stream;
00248 }
00249 

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