CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Attributes | Private Attributes
TCCBlockFormatter Class Reference

#include <TCCBlockFormatter.h>

Inheritance diagram for TCCBlockFormatter:
BlockFormatter

Public Member Functions

void DigiToRaw (const EcalTriggerPrimitiveDigi &trigprim, FEDRawData &rawdata, const EcalElectronicsMapping *TheMapping)
 
 TCCBlockFormatter (BlockFormatter::Config const &, BlockFormatter::Params const &)
 
- Public Member Functions inherited from BlockFormatter
 BlockFormatter (Config const &iC, Params const &iP)
 
void CleanUp (FEDRawDataCollection *productRawData, std::map< int, std::map< int, int > > *FEDorder)
 
void DigiToRaw (FEDRawDataCollection *productRawData)
 
void print (FEDRawData &rawdata)
 
void PrintSizes (FEDRawDataCollection *productRawData)
 

Static Public Attributes

static const int kCardsPerTower = 5
 
- Static Public Attributes inherited from BlockFormatter
static const int kCardsPerTower = 5
 

Private Attributes

bool AllTPsamples_
 

Additional Inherited Members

- Public Types inherited from BlockFormatter
typedef uint16_t Word16
 
typedef uint64_t Word64
 
- Protected Attributes inherited from BlockFormatter
int bx_
 
int counter_
 
const bool debug_
 
const bool doBarrel_
 
const bool doEndCap_
 
const bool doSR_
 
const bool doTCC_
 
const bool doTower_
 
int lv1_
 
int orbit_number_
 
const std::vector< int32_t > * plistDCCId_
 
int runnumber_
 

Detailed Description

Definition at line 22 of file TCCBlockFormatter.h.

Constructor & Destructor Documentation

TCCBlockFormatter::TCCBlockFormatter ( BlockFormatter::Config const &  iC,
BlockFormatter::Params const &  iP 
)

Definition at line 15 of file TCCBlockFormatter.cc.

References AllTPsamples_.

15  : BlockFormatter(iC, iP) {
16 
17  AllTPsamples_ = false;
18 }
BlockFormatter(Config const &iC, Params const &iP)

Member Function Documentation

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

Definition at line 20 of file TCCBlockFormatter.cc.

References AllTPsamples_, BlockFormatter::bx_, EcalTriggerPrimitiveDigi::compressedEt(), gather_cfg::cout, FEDRawData::data(), BlockFormatter::debug_, TauDecayModes::dec, BlockFormatter::doBarrel_, BlockFormatter::doEndCap_, EcalBarrel, EcalEndcap, stringResolutionProvider_cfi::et, EcalTriggerPrimitiveDigi::fineGrain(), EcalTriggerPrimitiveDigi::id(), EcalTrigTowerDetId::ieta(), EcalTrigTowerDetId::ietaAbs(), ntuplemaker::iline, SurfaceOrientation::inner, createfilelist::int, EcalTrigTowerDetId::iphi(), BlockFormatter::lv1_, EcalElectronicsId::MAX_DCCID_EEM, EcalElectronicsId::MAX_DCCID_EEP, EcalElectronicsMapping::MAX_TCCID, EcalElectronicsId::MIN_DCCID_EEM, EcalElectronicsId::MIN_DCCID_EEP, FEDNumbering::MINECALFEDID, NUMB_SM_EB_PLU_MAX, NUMB_SM_EB_PLU_MIN, BlockFormatter::print(), FEDRawData::resize(), EcalTriggerPrimitiveDigi::size(), FEDRawData::size(), EcalTrigTowerDetId::subDet(), EcalTriggerPrimitiveDigi::ttFlag(), and globals_cff::x1.

Referenced by EcalDigiToRaw::produce().

22 {
23 
24  if (debug_) cout << "enter in TCCBlockFormatter::DigiToRaw " << endl;
25 
26  int HEADER_SIZE = 8 * 9;
27  int bx = bx_;
28  int lv1 = lv1_;
29 
30 
31  const EcalTrigTowerDetId& detid = trigprim.id();
32 
33  if ( (detid.subDet() == EcalBarrel) && (! doBarrel_) ) return;
34  if ( (detid.subDet() == EcalEndcap) && (! doEndCap_) ) return;
35 
36  int iDCC = TheMapping -> DCCid(detid);
37  int TCCid = TheMapping -> TCCid(detid);
38 
39 
40  if (TCCid < EcalElectronicsMapping::MIN_TCCID || TCCid > EcalElectronicsMapping::MAX_TCCID)
41  cout << "Wrong TCCid in TCCBlockFormatter::DigiToRaw " << endl;
42  bool IsEndCap = ( (EcalElectronicsId::MIN_DCCID_EEM <= iDCC && iDCC <= EcalElectronicsId::MAX_DCCID_EEM) ||
44 
45  int FEDid = FEDNumbering::MINECALFEDID + iDCC;
46 
47  // note: row is a 64 bit word
48  int NTT_max = 68; // Barrel case
49  int Nrows_TCC = 17; // Barrel case (without the header row)
50  int NTCC = 1; // Barrel case; number of TCC blocks
51  int itcc_block = 1; // Barrel case
52 
53  if (IsEndCap) {
54  Nrows_TCC = 8; // one row is a 64 bit word
55  NTCC = 4; // 4 TTC in EndCap case. Use some custom numbering since
56  int pair = TCCid % 2; // the TCCid is written to the RawData.
57  int inner = ( detid.ietaAbs() >= 22) ? 1 : 0;
58  itcc_block = 2 * pair + inner + 1;
59  if (inner == 1) NTT_max = 28;
60  else NTT_max = 16;
61  }
62 
63 
64  int nsamples = trigprim.size();
65  if (! AllTPsamples_) nsamples = 1;
66 
67  int iTT = TheMapping -> iTT(detid); // number of tp inside a fed
68  if (debug_) cout << "This is a TrigTower iDCC iTT iTCCBlock TCCid " << dec <<
69  iDCC << " " << iTT << " " << itcc_block << " " << TCCid << endl;
70  if (debug_) cout << "ieta iphi " << dec << detid.ieta() << " " << detid.iphi() << endl;
71  if (iTT <= 0 || iTT > NTT_max) {
72  cout << "invalid iTT " << iTT << endl;
73  return;
74  }
75 
76  int FE_index;
77 
78  // rawdata points to the block which will be built for TCC data
79  if ((int)rawdata.size() != HEADER_SIZE) {
80  FE_index = rawdata.size() / 8 - NTCC*(Nrows_TCC+1); // as far as raw data have been generated
81  FE_index ++; // infer position in TCC block
82  if (debug_) cout << "TCCid already there. FE_index = " << FE_index << endl;
83  }
84  else {
85  if (debug_) cout << "New TTCid added on Raw data, TTCid = " << dec << TCCid << " 0x" << hex << TCCid << endl;
86  FE_index = rawdata.size() / 8; // size in unites of 64 bits word
87  int fe_index = FE_index;
88  for (int iblock=0; iblock < NTCC; iblock++) { // do this once per fed in EB, four times in EE
89  rawdata.resize (rawdata.size() + 8);
90  unsigned char* ppData = rawdata.data(); // use this to navigate and create the binary
91  ppData[8*fe_index] = TCCid & 0xFF; // fed_index increases in units of bytes
92  ppData[8*fe_index+2] = bx & 0xFF; // bx takes bits 0-11: 0-7+8-11
93  ppData[8*fe_index+3] = (bx & 0xF00)>>8;
94  ppData[8*fe_index+3] |= 0x60;
95  ppData[8*fe_index+4] = lv1 & 0xFF; // same game done for lv1, which takes bits 0-11: 0-7+8-11
96  ppData[8*fe_index+5] = (lv1 & 0xF00)>>8; // lv1
97  ppData[8*fe_index+6] = NTT_max;
98  ppData[8*fe_index+6] |= ((nsamples & 0x1)<<7); // nsamples: number time samples
99  ppData[8*fe_index+7] = ((nsamples & 0xE)>>1);
100  ppData[8*fe_index+7] |= 0x60;
101  if (iblock == 0) FE_index ++;
102  fe_index += Nrows_TCC+1;
103  rawdata.resize (rawdata.size() + 8*Nrows_TCC); // 17 lines of TPG data in EB, 8 in EE
104  }
105  if (debug_) cout << "Added headers and empty lines : " << endl;
106  if (debug_) print(rawdata);
107 
108  // -- put the B011 already, since for Endcap there can be empty
109  // -- lines in the TCC and the SRP blocks
110  unsigned char* ppData = rawdata.data();
111  for (int iline=FE_index-1; iline < FE_index + (Nrows_TCC+1)*NTCC -1 ; iline++) {
112  ppData[8*iline + 7] |= 0x60;
113  ppData[8*iline + 3] |= 0x60;
114  }
115  }
116 
117  unsigned char* pData = rawdata.data();
118 
119  // -- Now the TCC Block :
120 
121  int jTT = (iTT-1); // jTT is the TP number insided a block;
122  int irow = jTT/4 + (itcc_block-1)*(Nrows_TCC+1); // you fit 4 TP's per row; move forward if you're not in the first block;
123  int ival = jTT % 4; // for each block you have to skip, move of (Nrows_TCC +1) - 1 is for the TCC header
124 
125  // RTC required TP's tp follow global phi also in EB+, thus swap them inside the single TCC
126  // here you could swap ival -> 3-ival to swap phi insied EB+ supermodules
127  if(NUMB_SM_EB_PLU_MIN <= iDCC && iDCC <= NUMB_SM_EB_PLU_MAX)
128  {ival = 3-ival;}
129 
130  FE_index += irow; // ival is location inside a TP row; varies between 0-3
131 
132  if (debug_) cout << "Now add tower " << dec << iTT << " irow ival " << dec << irow << " " << dec << ival << endl;
133  if (debug_) cout << "new data will be added at line " << dec << FE_index << endl;
134 
135  int fg = trigprim.fineGrain();
136  int et = trigprim.compressedEt();
137  int ttflag = trigprim.ttFlag();
138 
139  if (debug_ && (ttflag != 0)) {
140  cout << "in TCCBlock : this tower has a non zero flag" << endl;
141  cout << "Fedid iTT flag " << dec << FEDid << " " << iTT << " " << "0x" << hex << ttflag << endl;
142  }
143  pData[8*FE_index + ival*2] = et & 0xFF; // ival is location inside a TP row; varies between 0-3; tp goes in bits 0-7
144  pData[8*FE_index + ival*2+1] = (ttflag<<1) + (fg&0x1); // fg follows in bit 8; ttfg is in bits 9-11
145  if (IsEndCap) {
146  // re-write the TCCid and N_Tower_Max :
147  int ibase = 8*(FE_index - (int)(jTT/4) -1);
148  pData[ibase] = TCCid & 0xFF;
149  pData[ibase+6] = NTT_max;
150  pData[ibase+6] |= ((nsamples & 0x1)<<7);
151  pData[ibase+7] |= ((nsamples & 0xE)>>1);
152  }
153  if (debug_) cout << "pData[8*FE_index + ival*2+1] = " << hex << (int)pData[8*FE_index + ival*2+1] << endl;
154  if (debug_) cout << "ttflag ttflag<<1 " << hex << ttflag << " " << hex << (ttflag<<1) << endl;
155  if (debug_) cout << "fg&0x1 " << hex << (fg&0x1) << endl;
156  if (debug_) cout << "sum " << hex << ( (ttflag<<1) + (fg&0x1) ) << endl;
157  if (ival %2 == 1) pData[8*FE_index + ival*2+1] |= 0x60;
158  if (debug_) cout << "ttflag et fgbit " << hex << ttflag << " " << hex << et << " " << hex << fg << endl;
159  if (debug_) print(rawdata);
160 
161 
162 }
const bool doBarrel_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void print(FEDRawData &rawdata)
int ieta() const
get the tower ieta
int compressedEt() const
get the encoded/compressed Et of interesting sample
int ietaAbs() const
get the absolute value of the tower ieta
void resize(size_t newsize)
Definition: FEDRawData.cc:32
const bool debug_
const bool doEndCap_
static const int MAX_DCCID_EEM
int iphi() const
get the tower iphi
const EcalTrigTowerDetId & id() const
et
define resolution functions of each parameter
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
static const int MAX_DCCID_EEP
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
bool fineGrain() const
get the fine-grain bit of interesting sample
int ttFlag() const
get the Trigger tower Flag of interesting sample
static const int MIN_DCCID_EEM
static const int MIN_DCCID_EEP

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

Definition at line 27 of file TCCBlockFormatter.h.