CMS 3D CMS Logo

TCCBlockFormatter Class Reference

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

Inheritance diagram for TCCBlockFormatter:

BlockFormatter

List of all members.

Public Member Functions

void DigiToRaw (const EcalTriggerPrimitiveDigi &trigprim, FEDRawData &rawdata, const EcalElectronicsMapping *TheMapping)
 TCCBlockFormatter ()
 ~TCCBlockFormatter ()

Static Public Attributes

static const int kCardsPerTower = 5

Private Attributes

bool AllTPsamples_


Detailed Description

Definition at line 22 of file TCCBlockFormatter.h.


Constructor & Destructor Documentation

TCCBlockFormatter::TCCBlockFormatter (  ) 

Definition at line 11 of file TCCBlockFormatter.cc.

References AllTPsamples_.

00011                                      {
00012 
00013  AllTPsamples_ = false;
00014 }

TCCBlockFormatter::~TCCBlockFormatter (  ) 

Definition at line 16 of file TCCBlockFormatter.cc.

00016                                       {
00017 
00018 }


Member Function Documentation

void TCCBlockFormatter::DigiToRaw ( const EcalTriggerPrimitiveDigi trigprim,
FEDRawData rawdata,
const EcalElectronicsMapping TheMapping 
)

Definition at line 20 of file TCCBlockFormatter.cc.

References AllTPsamples_, EcalTriggerPrimitiveDigi::compressedEt(), GenMuonPlsPt100GeV_cfg::cout, FEDRawData::data(), BlockFormatter::debug_, BlockFormatter::doBarrel_, BlockFormatter::doEndCap_, EcalBarrel, EcalEndcap, BlockFormatter::EcalFEDIds, lat::endl(), L1Comparator_cfi::FEDid, EcalTriggerPrimitiveDigi::fineGrain(), EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), SurfaceOrientation::inner, int, EcalTrigTowerDetId::iphi(), lv1, EcalElectronicsId::MAX_DCCID_EEM, EcalElectronicsId::MAX_DCCID_EEP, EcalElectronicsMapping::MAX_TCCID, EcalElectronicsId::MIN_DCCID_EEM, EcalElectronicsId::MIN_DCCID_EEP, BlockFormatter::pbx_, BlockFormatter::plv1_, BlockFormatter::print(), FEDRawData::resize(), FEDRawData::size(), EcalTriggerPrimitiveDigi::size(), EcalTrigTowerDetId::subDet(), and EcalTriggerPrimitiveDigi::ttFlag().

00022 {
00023 
00024   if (debug_) cout << "enter in TCCBlockFormatter::DigiToRaw " << endl;
00025 
00026   int HEADER_SIZE = 8 * 9;
00027   int bx = *pbx_;
00028   int lv1 = *plv1_;
00029 
00030 
00031         const EcalTrigTowerDetId& detid = trigprim.id();
00032 
00033            if ( (detid.subDet() == EcalBarrel) && (! doBarrel_) ) return;
00034            if ( (detid.subDet() == EcalEndcap) && (! doEndCap_) ) return;
00035 
00036         int iDCC = TheMapping -> DCCid(detid);
00037         int TCCid = TheMapping -> TCCid(detid);
00038 
00039 
00040         if (TCCid < EcalElectronicsMapping::MIN_TCCID || TCCid > EcalElectronicsMapping::MAX_TCCID) 
00041                 cout << "Wrong TCCid in TCCBlockFormatter::DigiToRaw " << endl;
00042         bool IsEndCap = ( (EcalElectronicsId::MIN_DCCID_EEM <= iDCC && iDCC <= EcalElectronicsId::MAX_DCCID_EEM) ||
00043                           (EcalElectronicsId::MIN_DCCID_EEP <= iDCC && iDCC <= EcalElectronicsId::MAX_DCCID_EEP) );
00044 
00045         int FEDid = EcalFEDIds.first + iDCC;
00046 
00047 
00048         int NTT_max = 68;       // Barrel case
00049         int Nrows_TCC = 17;     // Barrel case    (without the header row)
00050         int NTCC = 1;           // Barrel case; number of TCC blocks
00051         int itcc_block = 1;     // Barrel case
00052 
00053         if (IsEndCap) {
00054                 Nrows_TCC = 8;
00055                 NTCC = 4;               // 4 TTC in EndCap case. Use some custom numbering since
00056                 int pair = TCCid % 2;   // the TCCid is written to the RawData.
00057                 int inner = ( detid.ietaAbs() >= 22) ? 1 : 0;
00058                 itcc_block = 2 * pair + inner + 1;
00059                 if (inner == 1) NTT_max = 28;
00060                 else NTT_max = 16;
00061         }
00062 
00063         
00064         int nsamples = trigprim.size();
00065         if (! AllTPsamples_) nsamples = 1;
00066 
00067         int iTT = TheMapping -> iTT(detid);
00068         if (debug_) cout << "This is a TrigTower  iDCC iTT iTCCBlock TCCid " << dec << 
00069                 iDCC << " " << iTT << " " << itcc_block << " " << TCCid << endl;
00070         if (debug_) cout << "ieta iphi " << dec << detid.ieta() << " " << detid.iphi() << endl;
00071         if (iTT <= 0 || iTT > NTT_max)  {
00072                 cout << "invalid iTT " << iTT << endl;
00073                 return;
00074         }
00075 
00076         int FE_index;
00077 
00078         if ((int)rawdata.size() != HEADER_SIZE) {
00079                 FE_index = rawdata.size() / 8 - NTCC*(Nrows_TCC+1);
00080                 FE_index ++;
00081                 if (debug_) cout << "TCCid already there. FE_index = " << FE_index << endl;
00082         }
00083         else {
00084                 if (debug_) cout << "New TTCid added on Raw data, TTCid = " << dec << TCCid << " 0x" << hex << TCCid << endl;
00085                 FE_index = rawdata.size() / 8;
00086                 int fe_index = FE_index;
00087                 for (int iblock=0; iblock < NTCC; iblock++) {
00088                    rawdata.resize (rawdata.size() + 8);
00089                    unsigned char* ppData = rawdata.data();
00090                    ppData[8*fe_index] = TCCid & 0xFF;
00091                    ppData[8*fe_index+2] = bx & 0xFF;
00092                    ppData[8*fe_index+3] = (bx & 0xF00)>>8;
00093                    ppData[8*fe_index+3] |= 0x60;
00094                    ppData[8*fe_index+4] = lv1 & 0xFF;
00095                    ppData[8*fe_index+5] = (lv1 & 0xF00)>>8;
00096                    ppData[8*fe_index+6] = NTT_max;
00097                    ppData[8*fe_index+6] |= ((nsamples & 0x1)<<7);
00098                    ppData[8*fe_index+7] = ((nsamples & 0xE)>>1);
00099                    ppData[8*fe_index+7] |= 0x60;
00100                    if (iblock == 0) FE_index ++;
00101                    fe_index += Nrows_TCC+1;
00102                    rawdata.resize (rawdata.size() + 8*Nrows_TCC);    // 17 lines TPG data 
00103                 }
00104                 if (debug_) cout << "Added headers and empty lines : " << endl;
00105                 if (debug_) print(rawdata);
00106 
00107                 // -- put the B011 already, since for Endcap there can be empty
00108                 // -- lines in the TCC and the SRP blocks
00109                 unsigned char* ppData = rawdata.data();
00110                 for (int iline=FE_index-1; iline < FE_index + (Nrows_TCC+1)*NTCC -1 ; iline++) {
00111                  ppData[8*iline + 7] |= 0x60;
00112                  ppData[8*iline + 3] = 0x60;
00113                 }
00114         }
00115 
00116         unsigned char* pData = rawdata.data();
00117 
00118         // -- Now the TCC Block :
00119 
00120         int jTT = (iTT-1);
00121         int irow = jTT/4 + (itcc_block-1)*(Nrows_TCC+1);
00122         int ival = jTT % 4;
00123         FE_index += irow;
00124 
00125         if (debug_) cout << "Now add tower " << dec << iTT << " irow ival " << dec << irow << " " << dec << ival << endl;
00126         if (debug_) cout << "new data will be added at line " << dec << FE_index << endl;
00127 
00128         int fg = trigprim.fineGrain();
00129         int et = trigprim.compressedEt();
00130         int ttflag = trigprim.ttFlag();
00131 
00132         if (debug_ && (ttflag != 0)) {
00133                 cout << "in TCCBlock : this tower has a non zero flag" << endl;
00134                 cout << "Fedid  iTT  flag " << dec << FEDid << " " << iTT << " " << "0x" << hex << ttflag << endl;
00135         }
00136         pData[8*FE_index + ival*2] = et & 0xFF;
00137         pData[8*FE_index + ival*2+1] = (ttflag<<1) + (fg&0x1); 
00138         if (IsEndCap) {
00139                 // re-write the TCCid  and N_Tower_Max :
00140                 int ibase = 8*(FE_index - (int)(jTT/4) -1);
00141                 pData[ibase] = TCCid & 0xFF;
00142                 pData[ibase+6] = NTT_max;
00143                 pData[ibase+6] |= ((nsamples & 0x1)<<7);
00144                 pData[ibase+7] |= ((nsamples & 0xE)>>1);
00145         }
00146         if (debug_) cout << "pData[8*FE_index + ival*2+1] = " << hex << (int)pData[8*FE_index + ival*2+1] << endl;
00147         if (debug_) cout << "ttflag ttflag<<1 " << hex << ttflag << " " << hex << (ttflag<<1) << endl;
00148         if (debug_) cout << "fg&0x1 " << hex << (fg&0x1) << endl;
00149         if (debug_) cout << "sum " << hex << ( (ttflag<<1) + (fg&0x1) ) << endl;
00150         if (ival %2 == 1) pData[8*FE_index + ival*2+1] |= 0x60;
00151         if (debug_) cout << "ttflag et fgbit " << hex << ttflag << " " << hex << et << " " << hex << fg << endl;
00152         if (debug_) print(rawdata);
00153 
00154         
00155 }


Member Data Documentation

bool TCCBlockFormatter::AllTPsamples_ [private]

Definition at line 31 of file TCCBlockFormatter.h.

Referenced by DigiToRaw(), and TCCBlockFormatter().

const int TCCBlockFormatter::kCardsPerTower = 5 [static]

Reimplemented from BlockFormatter.

Definition at line 27 of file TCCBlockFormatter.h.


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