CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CTPPSPixelDataFormatter Class Reference

#include <CTPPSPixelDataFormatter.h>

Public Types

typedef edm::DetSetVector< CTPPSPixelDigiCollection
 
typedef std::vector< CTPPSPixelDigiDetDigis
 
typedef std::vector< CTPPSPixelDataErrorDetErrors
 
typedef std::map< uint32_t, DetErrorsErrors
 
typedef std::map< int, FEDRawDataRawData
 
typedef uint32_t Word32
 
typedef uint64_t Word64
 

Public Member Functions

 CTPPSPixelDataFormatter (std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > const &mapping)
 
void interpretRawData (bool &errorsInEvent, int fedId, const FEDRawData &data, Collection &digis, Errors &errors)
 
int nWords () const
 
void setErrorStatus (bool theErrorStatus)
 

Private Member Functions

int checkError (const Word32 &data) const
 
std::string print (const Word64 &word) const
 

Private Attributes

Word32 m_ADC_mask
 
int m_ADC_shift
 
Word32 m_DCOL_mask
 
int m_DCOL_shift
 
RPixErrorChecker m_ErrorCheck
 
bool m_IncludeErrors
 
Word32 m_LINK_mask
 
int m_LINK_shift
 
const std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > & m_Mapping
 
Word32 m_PXID_mask
 
int m_PXID_shift
 
Word32 m_ROC_mask
 
int m_ROC_shift
 
int m_WordCounter
 

Detailed Description

Transform CTPPSPixel raw data of a given FED to digi

FED OUTPUT DATA FORMAT (F.Ferro from SiPixel code)

The output is transmitted through a 64 bit S-link connection. The packet format is defined by the CMS RU group to be : 1st packet header, 64 bits, includes a 6 bit FED id. 2nd packet header, 64 bits. .......................... (detector data) packet trailer, 64 bits. of the 64 bit pixel data records consists of 2 32 bit words. Each 32 bit word includes data from 1 pixel, the bit fields are the following:

6 bit link ID (max 36) - this defines the input link within 1 FED. 5 bit ROC ID (max 24) - this defines the readout chip within one link. 5 bit DCOL ID (max 26) - this defines the double column index with 1 chip. 8 bit pixel ID (max 180) - this defines the pixel address within 1 DCOL. 8 bit ADC vales - this has the charge amplitude.

So, 1 pixel occupies 4 bytes. If the number of pixels is odd, one extra 32 bit word is added (value 0) to fill all 64 bits.

The CTPPSPixelDataFormatter interpret/format ONLY detector data words (not FED headers or trailer, which are treated elsewhere).

Definition at line 49 of file CTPPSPixelDataFormatter.h.

Member Typedef Documentation

Definition at line 53 of file CTPPSPixelDataFormatter.h.

Definition at line 56 of file CTPPSPixelDataFormatter.h.

Definition at line 58 of file CTPPSPixelDataFormatter.h.

typedef std::map<uint32_t, DetErrors> CTPPSPixelDataFormatter::Errors

Definition at line 59 of file CTPPSPixelDataFormatter.h.

Definition at line 55 of file CTPPSPixelDataFormatter.h.

Definition at line 61 of file CTPPSPixelDataFormatter.h.

Definition at line 62 of file CTPPSPixelDataFormatter.h.

Constructor & Destructor Documentation

CTPPSPixelDataFormatter::CTPPSPixelDataFormatter ( std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > const &  mapping)

Definition at line 32 of file CTPPSPixelDataFormatter.cc.

References m_ADC_mask, m_ADC_shift, m_DCOL_mask, m_DCOL_shift, m_IncludeErrors, m_LINK_mask, m_LINK_shift, m_PXID_mask, m_PXID_shift, m_ROC_mask, and m_ROC_shift.

33 {
34  int s32 = sizeof(Word32);
35  int s64 = sizeof(Word64);
36  int s8 = sizeof(char);
37  if ( s8 != 1 || s32 != 4*s8 || s64 != 2*s32) {
38  LogError("UnexpectedSizes")
39  <<" unexpected sizes: "
40  <<" size of char is: " << s8
41  <<", size of Word32 is: " << s32
42  <<", size of Word64 is: " << s64
43  <<", send exception" ;
44  }
45 
46  m_IncludeErrors = false;
47 
48  m_ADC_shift = 0;
49  m_PXID_shift = m_ADC_shift + m_ADC_bits;
50  m_DCOL_shift = m_PXID_shift + m_PXID_bits;
51  m_ROC_shift = m_DCOL_shift + m_DCOL_bits;
52 
53 
54  m_LINK_shift = m_ROC_shift + m_ROC_bits;
55  m_LINK_mask = ~(~CTPPSPixelDataFormatter::Word32(0) << m_LINK_bits);
56  m_ROC_mask = ~(~CTPPSPixelDataFormatter::Word32(0) << m_ROC_bits);
57 
58  m_DCOL_mask = ~(~CTPPSPixelDataFormatter::Word32(0) << m_DCOL_bits);
59  m_PXID_mask = ~(~CTPPSPixelDataFormatter::Word32(0) << m_PXID_bits);
60  m_ADC_mask = ~(~CTPPSPixelDataFormatter::Word32(0) << m_ADC_bits);
61 
62 }
const std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > & m_Mapping

Member Function Documentation

int CTPPSPixelDataFormatter::checkError ( const Word32 data) const
private
void CTPPSPixelDataFormatter::interpretRawData ( bool &  errorsInEvent,
int  fedId,
const FEDRawData data,
Collection digis,
Errors errors 
)

check CRC bit

check headers

check trailers

data words

Definition at line 72 of file CTPPSPixelDataFormatter.cc.

References ecalMGPA::adc(), RPixErrorChecker::checkCRC(), RPixErrorChecker::checkHeader(), RPixErrorChecker::checkROC(), RPixErrorChecker::checkTrailer(), RPixErrorChecker::conversionError(), FEDRawData::data(), edm::DetSet< T >::data, RPixErrorChecker::dummyDetId, edm::DetSetVector< T >::find_or_insert(), RecoTauValidation_cfi::header, CTPPSPixelROCInfo::iD, InvalidLinkId, InvalidPixelId, InvalidROCId, LIKELY, LogTrace, m_ADC_mask, m_ADC_shift, m_DCOL_mask, m_DCOL_shift, m_ErrorCheck, m_LINK_mask, m_LINK_shift, m_Mapping, m_PXID_mask, m_PXID_shift, m_ROC_mask, m_ROC_shift, m_WordCounter, nWords(), print(), CTPPSPixelROC::rawId(), CTPPSPixelROCInfo::roc, FEDRawData::size(), CTPPSPixelROC::toGlobalfromDcol(), reco::Unknown, and UNLIKELY.

Referenced by nWords(), and CTPPSPixelRawToDigi::produce().

74 {
75 
76  int nWords = rawData.size()/sizeof(Word64);
77  if (nWords==0) return;
78 
80  const Word64* trailer = reinterpret_cast<const Word64* >(rawData.data())+(nWords-1);
81  if(!m_ErrorCheck.checkCRC(errorsInEvent, fedId, trailer, errors)) return;
82 
84  const Word64* header = reinterpret_cast<const Word64* >(rawData.data()); header--;
85  bool moreHeaders = true;
86  while (moreHeaders) {
87  header++;
88  LogTrace("")<<"HEADER: " << print(*header);
89  bool headerStatus = m_ErrorCheck.checkHeader(errorsInEvent, fedId, header, errors);
90  moreHeaders = headerStatus;
91  }
92 
94  bool moreTrailers = true;
95  trailer++;
96  while (moreTrailers) {
97  trailer--;
98  LogTrace("")<<"TRAILER: " << print(*trailer);
99  bool trailerStatus = m_ErrorCheck.checkTrailer(errorsInEvent, fedId, nWords, trailer, errors);
100  moreTrailers = trailerStatus;
101  }
102 
104  m_WordCounter += 2*(nWords-2);
105  LogTrace("")<<"data words: "<< (trailer-header-1);
106 
107  int link = -1;
108  int roc = -1;
109 
110  bool skipROC=false;
111 
112  edm::DetSet<CTPPSPixelDigi> * detDigis=nullptr;
113 
114  const Word32 * bw =(const Word32 *)(header+1);
115  const Word32 * ew =(const Word32 *)(trailer);
116  if ( *(ew-1) == 0 ) { ew--; m_WordCounter--;}
117  for (auto word = bw; word < ew; ++word) {
118  LogTrace("")<<"DATA: " << print(*word);
119 
120  auto ww = *word;
121  if UNLIKELY(ww==0) { m_WordCounter--; continue;}
122  int nlink = (ww >> m_LINK_shift) & m_LINK_mask;
123  int nroc = (ww >> m_ROC_shift) & m_ROC_mask;
124 
125  int FMC = 0;
126  uint32_t iD = RPixErrorChecker::dummyDetId;//0xFFFFFFFF; //dummyDetId
127  int convroc = nroc-1;
128  CTPPSPixelFramePosition fPos(fedId, FMC, nlink, convroc);
129  std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>::const_iterator mit;
130  mit = m_Mapping.find(fPos);
131 
132  if (mit == m_Mapping.end()){
133  if(nlink >= maxLinkIndex){
135  }
136  else if((nroc-1)>=maxRocIndex){
138  }else{
140  }
141  continue; //skip word
142  }
143 
144  CTPPSPixelROCInfo rocInfo = (*mit).second;
145  iD = rocInfo.iD;
146  CTPPSPixelROC rocp(iD, rocInfo.roc, convroc);
147 
148  if ( (nlink!=link) | (nroc!=roc) ) { // new roc
149  link = nlink; roc=nroc;
150 
151  skipROC = LIKELY((roc-1)<maxRocIndex) ? false : !m_ErrorCheck.checkROC(errorsInEvent, fedId, iD, ww, errors);
152  if (skipROC) continue;
153 
154  auto rawId = rocp.rawId();
155 
156  detDigis = &digis.find_or_insert(rawId);
157  if ( (*detDigis).empty() ) (*detDigis).data.reserve(32); // avoid the first relocations
158 
159  }
160 
161  int adc = (ww >> m_ADC_shift) & m_ADC_mask;
162 
163  int dcol = (ww >> m_DCOL_shift) & m_DCOL_mask;
164  int pxid = (ww >> m_PXID_shift) & m_PXID_mask;
165 
166  if(dcol<min_Dcol || dcol>max_Dcol || pxid<min_Pixid || pxid>max_Pixid){
167  edm::LogError("CTPPSPixelDataFormatter")<< " unphysical dcol and/or pxid " << " nllink=" << nlink
168  << " nroc="<< nroc << " adc=" << adc << " dcol=" << dcol << " pxid=" << pxid;
169 
171 
172  continue;
173  }
174 
175  std::pair<int,int> rocPixel;
176  std::pair<int,int> modPixel;
177 
178  rocPixel = std::make_pair(dcol,pxid);
179 
180  modPixel = rocp.toGlobalfromDcol(rocPixel);
181 
182  CTPPSPixelDigi testdigi(modPixel.first, modPixel.second, adc);
183 
184  if(detDigis)
185  (*detDigis).data.emplace_back( modPixel.first, modPixel.second, adc);
186 
187  }
188 
189 }
Contains mappind data related to a ROC.
void conversionError(int fedId, uint32_t iD, const State &state, const Word32 &errorWord, Errors &errors) const
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer, Errors &errors) const
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header, Errors &errors) const
#define LIKELY(x)
Definition: Likely.h:20
const std::map< CTPPSPixelFramePosition, CTPPSPixelROCInfo > & m_Mapping
std::string print(const Word64 &word) const
uint32_t iD
the symbolic id
static constexpr Word32 dummyDetId
uint64_t Word64
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
#define LogTrace(id)
collection_type data
Definition: DetSet.h:80
bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords, const Word64 *trailer, Errors &errors) const
Definition: errors.py:1
#define UNLIKELY(x)
Definition: Likely.h:21
bool checkROC(bool &errorsInEvent, int fedId, uint32_t iD, const Word32 &errorWord, Errors &errors) const
int CTPPSPixelDataFormatter::nWords ( ) const
inline
std::string CTPPSPixelDataFormatter::print ( const Word64 word) const
private

Definition at line 192 of file CTPPSPixelDataFormatter.cc.

References str.

Referenced by interpretRawData().

193 {
194  std::ostringstream str;
195  str <<"word64: " << reinterpret_cast<const std::bitset<64>&> (word);
196  return str.str();
197 }
#define str(s)
void CTPPSPixelDataFormatter::setErrorStatus ( bool  theErrorStatus)

Member Data Documentation

Word32 CTPPSPixelDataFormatter::m_ADC_mask
private

Definition at line 83 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_ADC_shift
private

Definition at line 82 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

Word32 CTPPSPixelDataFormatter::m_DCOL_mask
private

Definition at line 83 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_DCOL_shift
private

Definition at line 82 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

RPixErrorChecker CTPPSPixelDataFormatter::m_ErrorCheck
private

Definition at line 80 of file CTPPSPixelDataFormatter.h.

Referenced by interpretRawData(), and setErrorStatus().

bool CTPPSPixelDataFormatter::m_IncludeErrors
private

Definition at line 79 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and setErrorStatus().

Word32 CTPPSPixelDataFormatter::m_LINK_mask
private

Definition at line 83 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_LINK_shift
private

Definition at line 82 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

const std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo>& CTPPSPixelDataFormatter::m_Mapping
private

Definition at line 90 of file CTPPSPixelDataFormatter.h.

Referenced by interpretRawData().

Word32 CTPPSPixelDataFormatter::m_PXID_mask
private

Definition at line 83 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_PXID_shift
private

Definition at line 82 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

Word32 CTPPSPixelDataFormatter::m_ROC_mask
private

Definition at line 83 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_ROC_shift
private

Definition at line 82 of file CTPPSPixelDataFormatter.h.

Referenced by CTPPSPixelDataFormatter(), and interpretRawData().

int CTPPSPixelDataFormatter::m_WordCounter
mutableprivate

Definition at line 77 of file CTPPSPixelDataFormatter.h.

Referenced by interpretRawData(), and nWords().