CMS 3D CMS Logo

SRBlockFormatter Class Reference

#include <EventFilter/EcalDigiToRaw/interface/SRBlockFormatter.h>

Inheritance diagram for SRBlockFormatter:

BlockFormatter

List of all members.

Public Member Functions

void DigiToRaw (int dccid, int dcc_channel, int flag, FEDRawData &rawdata)
 SRBlockFormatter ()
void StartEvent ()
 ~SRBlockFormatter ()

Private Attributes

std::map< int, intheader_


Detailed Description

Definition at line 16 of file SRBlockFormatter.h.


Constructor & Destructor Documentation

SRBlockFormatter::SRBlockFormatter (  ) 

Definition at line 9 of file SRBlockFormatter.cc.

00009                                    {
00010 
00011 }

SRBlockFormatter::~SRBlockFormatter (  ) 

Definition at line 13 of file SRBlockFormatter.cc.

00013                                     {
00014 
00015 }


Member Function Documentation

void SRBlockFormatter::DigiToRaw ( int  dccid,
int  dcc_channel,
int  flag,
FEDRawData rawdata 
)

Definition at line 25 of file SRBlockFormatter.cc.

References b1, b2, GenMuonPlsPt100GeV_cfg::cout, FEDRawData::data(), BlockFormatter::debug_, lat::endl(), header_, lv1, BlockFormatter::pbx_, BlockFormatter::plv1_, BlockFormatter::print(), FEDRawData::resize(), and FEDRawData::size().

00026 {
00027 
00028   if (debug_) cout << "enter in SRBlockFormatter::DigiToRaw " << endl;
00029   if (debug_) print(rawdata);
00030 
00031   int bx = *pbx_;
00032   int lv1 = *plv1_;
00033 
00034   int Nrows_SRP = 5;   // Both for Barrel and EndCap (without the header row)
00035   int SRid = (dccid -1) / 3 +1;
00036 
00037 
00038         // int Number_SRP_Flags = 68;
00039 
00040         int SRP_index;
00041         int icode = 1000 * dccid +  SRid;
00042         if (debug_) cout << "size of header_ map is " << header_.size() << endl;
00043 
00044         std::map<int, int>::const_iterator it_header = header_.find(icode);
00045 
00046         if ( it_header != header_.end() ) {
00047                 SRP_index = rawdata.size() / 8 - Nrows_SRP;
00048                 if (debug_) cout << "This SRid is already there." << endl; 
00049         }
00050         else {
00051                 if (debug_) cout << "New SR Block added on Raw data " << endl;
00052                 header_[icode] = 1;
00053                 SRP_index = rawdata.size() / 8;
00054                 rawdata.resize (rawdata.size() + 8 + 8*Nrows_SRP);  // 1 line for SRP header, 5 lines of data
00055                 unsigned char* ppData = rawdata.data();
00056                 ppData[8*SRP_index] = SRid & 0xFF;
00057                 ppData[8*SRP_index+2] = bx & 0xFF; 
00058                 ppData[8*SRP_index+3] = (bx & 0xF00)>>8;
00059                 ppData[8*SRP_index+3] |= 0x80;
00060                 ppData[8*SRP_index+4] = lv1 & 0xFF;
00061                 ppData[8*SRP_index+5] = (lv1 & 0xF00)>>8;
00062                 // ppData[8*SRP_index+6] = Number_SRP_Flags;  
00063                 ppData[8*SRP_index+6] = 0;
00064                 ppData[8*SRP_index+7] = 0x80;
00065                 SRP_index ++;
00066                 if (debug_) cout << "Added headers and empty lines : " << endl;
00067                 if (debug_) print(rawdata);
00068 
00069                 // -- put the B011 and B100 already, since for Endcap there can be empty
00070                 // -- lines in the TCC and the SRP blocks
00071                 unsigned char* Data = rawdata.data();
00072                 for (int iline=SRP_index; iline < SRP_index+Nrows_SRP; iline++) {
00073                  Data[8*iline + 7] |= 0x80;
00074                  Data[8*iline + 3] |= 0x80;
00075                 }
00076         }
00077 
00078         unsigned char* pData = rawdata.data();
00079 
00080         // -- Now the TCC Block :
00081 
00082         int nflags = pData[8*(SRP_index-1) +6] & 0x7F;
00083         nflags ++;
00084         pData[8*(SRP_index-1) + 6] = nflags & 0x7F;
00085 
00086         int jTT = (dcc_channel-1);
00087         int irow = jTT/16 ;
00088         int ival = jTT % 4;
00089         int kval = (jTT % 16) / 4;
00090         SRP_index += irow;
00091 
00092         if (debug_) cout << "Now add SC to SRBlock " << dec << dcc_channel << " irow ival " << dec << irow << " " << dec << ival << endl;
00093         if (debug_) cout << "new data will be added at line " << dec << SRP_index << endl;
00094 
00095  
00096         unsigned char* buff = &pData[8*SRP_index];
00097         Word64* pw = reinterpret_cast<Word64*>(const_cast<unsigned char*>(buff));
00098         int nbits = kval*16 + 3*ival;
00099          Word64 wflag = (Word64)((short int)flag & 0x7) << nbits;
00100          *pw |= wflag; 
00101          Word64 b1 = (Word64)((Word64)0x80 <<56);
00102          *pw |= b1 ;
00103          Word64 b2 = (Word64)((Word64)0x80 <<24);
00104          *pw |= b2 ;
00105 
00106         if (debug_) print(rawdata);
00107 
00108         
00109 }

void SRBlockFormatter::StartEvent (  ) 

Definition at line 18 of file SRBlockFormatter.cc.

References GenMuonPlsPt100GeV_cfg::cout, BlockFormatter::debug_, lat::endl(), and header_.

00018                                   {
00019   if (debug_) cout << "enter in StartEvent. header_ size is  " << header_.size() << endl;
00020   header_ .clear() ;
00021   if (debug_) cout << "after empty : header_ size is  " << header_.size() << endl;
00022   return;
00023 }


Member Data Documentation

std::map<int, int> SRBlockFormatter::header_ [private]

Definition at line 26 of file SRBlockFormatter.h.

Referenced by DigiToRaw(), and StartEvent().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:32:45 2009 for CMSSW by  doxygen 1.5.4