Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore FED error treatment for phase0 (required for UL Rereco of 2016) #26606

Closed
49 changes: 20 additions & 29 deletions EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
#define ErrorChecker_H
/** \class ErrorChecker
*
*
*
*/

#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h"
#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h"
#include "FWCore/Utilities/interface/typedefs.h"

#include <vector>
#include <map>

class FEDRawData;

class SiPixelFrameConverter;
class SiPixelFedCabling;

class ErrorChecker {

class ErrorChecker : public ErrorCheckerBase {
public:
// typedef unsigned int Word32;
// typedef long long Word64;
// typedef unsigned int Word32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code when not needed

// typedef long long Word64;
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

Expand All @@ -29,30 +20,30 @@ class ErrorChecker {

ErrorChecker();

void setErrorStatus(bool ErrorStatus);
void setErrorStatus(bool ErrorStatus) override;

bool checkCRC(bool& errorsInEvent, int fedId, const Word64* trailer, Errors& errors);
bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer,
Errors &errors) override;

bool checkHeader(bool& errorsInEvent, int fedId, const Word64* header, Errors& errors);
bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header,
Errors &errors) override;

bool checkTrailer(bool& errorsInEvent, int fedId, unsigned int nWords, const Word64* trailer, Errors& errors);
bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords,
const Word64 *trailer, Errors &errors) override;

bool checkROC(bool& errorsInEvent, int fedId, const SiPixelFrameConverter* converter,
const SiPixelFedCabling* theCablingTree,
Word32& errorWord, Errors& errors);
bool checkROC(bool &errorsInEvent, int fedId,
const SiPixelFrameConverter *converter,
const SiPixelFedCabling *theCablingTree, Word32 &errorWord,
Errors &errors) override;



void conversionError(int fedId, const SiPixelFrameConverter* converter,
int status, Word32& errorWord, Errors& errors);
void conversionError(int fedId, const SiPixelFrameConverter *converter,
int status, Word32 &errorWord, Errors &errors) override;

private:

bool includeErrors;

cms_uint32_t errorDetId(const SiPixelFrameConverter* converter,
int errorType, const Word32 & word) const;

cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType,
const Word32 &word) const override;
};

#endif
54 changes: 54 additions & 0 deletions EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#ifndef ErrorCheckerBase_H
#define ErrorCheckerBase_H
/** \class ErrorCheckerBase
*
*
*/

#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h"

#include <map>
#include <vector>

class SiPixelFrameConverter;
class SiPixelFedCabling;

class ErrorCheckerBase {
public:
// typedef unsigned int Word32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code when not needed

// typedef long long Word64;
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

typedef std::vector<SiPixelRawDataError> DetErrors;
typedef std::map<cms_uint32_t, DetErrors> Errors;

virtual ~ErrorCheckerBase(){};

virtual void setErrorStatus(bool ErrorStatus) = 0;

virtual bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer,
Errors &errors) = 0;

virtual bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header,
Errors &errors) = 0;

virtual bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords,
const Word64 *trailer, Errors &errors) = 0;

virtual bool checkROC(bool &errorsInEvent, int fedId,
const SiPixelFrameConverter *converter,
const SiPixelFedCabling *theCablingTree,
Word32 &errorWord, Errors &errors) = 0;

virtual void conversionError(int fedId,
const SiPixelFrameConverter *converter,
int status, Word32 &errorWord,
Errors &errors) = 0;

private:
virtual cms_uint32_t errorDetId(const SiPixelFrameConverter *converter,
int errorType, const Word32 &word) const = 0;
};

#endif
49 changes: 49 additions & 0 deletions EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#ifndef ErrorCheckerPhase0_H
#define ErrorCheckerPhase0_H
/** \class ErrorCheckerPhase0
*
*
*/

#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerBase.h"
#include "FWCore/Utilities/interface/typedefs.h"

class ErrorCheckerPhase0 : public ErrorCheckerBase {
public:
// typedef unsigned int Word32;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove commented out code when not needed

// typedef long long Word64;
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

typedef std::vector<SiPixelRawDataError> DetErrors;
typedef std::map<cms_uint32_t, DetErrors> Errors;

ErrorCheckerPhase0();

void setErrorStatus(bool ErrorStatus) override;

bool checkCRC(bool &errorsInEvent, int fedId, const Word64 *trailer,
Errors &errors) override;

bool checkHeader(bool &errorsInEvent, int fedId, const Word64 *header,
Errors &errors) override;

bool checkTrailer(bool &errorsInEvent, int fedId, unsigned int nWords,
const Word64 *trailer, Errors &errors) override;

bool checkROC(bool &errorsInEvent, int fedId,
const SiPixelFrameConverter *converter,
const SiPixelFedCabling *theCablingTree, Word32 &errorWord,
Errors &errors) override;

void conversionError(int fedId, const SiPixelFrameConverter *converter,
int status, Word32 &errorWord, Errors &errors) override;

private:
bool includeErrors;

cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int errorType,
const Word32 &word) const override;
};

#endif
83 changes: 40 additions & 43 deletions EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
// Add the phase1 format
//
#include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h"
#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h"
#include "FWCore/Utilities/interface/typedefs.h"
#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"

#include <vector>
#include <map>
#include <set>
#include <vector>

class FEDRawData;
class SiPixelFedCabling;
Expand All @@ -54,15 +54,13 @@ class SiPixelFrameReverter;
class SiPixelFedCablingTree;

class PixelDataFormatter {

public:

typedef edm::DetSetVector<PixelDigi> Collection;

typedef std::map<int, FEDRawData> RawData;
typedef std::vector<PixelDigi> DetDigis;
typedef std::map<cms_uint32_t, DetDigis> Digis;
typedef std::pair<DetDigis::const_iterator, DetDigis::const_iterator> Range;
typedef std::pair<DetDigis::const_iterator, DetDigis::const_iterator> Range;
typedef std::vector<SiPixelRawDataError> DetErrors;
typedef std::map<cms_uint32_t, DetErrors> Errors;
typedef std::vector<PixelFEDChannel> DetBadChannels;
Expand All @@ -71,68 +69,67 @@ class PixelDataFormatter {
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

PixelDataFormatter(const SiPixelFedCabling* map, bool phase1=false);
PixelDataFormatter(const SiPixelFedCabling *map, bool phase1 = false);

void setErrorStatus(bool ErrorStatus);
void setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo);
void setModulesToUnpack(const std::set<unsigned int> * moduleIds);
void passFrameReverter(const SiPixelFrameReverter* reverter);
void setQualityStatus(bool QualityStatus, const SiPixelQuality *QualityInfo);
void setModulesToUnpack(const std::set<unsigned int> *moduleIds);
void passFrameReverter(const SiPixelFrameReverter *reverter);

int nDigis() const { return theDigiCounter; }
int nWords() const { return theWordCounter; }

void interpretRawData(bool& errorsInEvent, int fedId, const FEDRawData & data, Collection & digis, Errors & errors);
void interpretRawData(bool &errorsInEvent, int fedId, const FEDRawData &data,
Collection &digis, Errors &errors);

void formatRawData( unsigned int lvl1_ID, RawData & fedRawData, const Digis & digis, const BadChannels & badChannels);
void formatRawData(unsigned int lvl1_ID, RawData &fedRawData,
const Digis &digis, const BadChannels &badChannels);

cms_uint32_t linkId(cms_uint32_t word32) { return (word32 >> LINK_shift) & LINK_mask; }
cms_uint32_t linkId(cms_uint32_t word32) {
return (word32 >> LINK_shift) & LINK_mask;
}

private:
mutable int theDigiCounter;
mutable int theWordCounter;

SiPixelFedCabling const * theCablingTree;
const SiPixelFrameReverter* theFrameReverter;
const SiPixelQuality* badPixelInfo;
const std::set<unsigned int> * modulesToUnpack;
SiPixelFedCabling const *theCablingTree;
const SiPixelFrameReverter *theFrameReverter;
const SiPixelQuality *badPixelInfo;
const std::set<unsigned int> *modulesToUnpack;

bool includeErrors;
bool useQualityInfo;
bool debug;
int allDetDigis;
int hasDetDigis;
ErrorChecker errorcheck;

// For the 32bit data format (moved from *.cc namespace, keep uppercase for compatibility)
// Add special layer 1 roc for phase1
int ADC_shift, PXID_shift, DCOL_shift, ROC_shift, LINK_shift,
ROW_shift, COL_shift;
Word32 LINK_mask, ROC_mask, DCOL_mask, PXID_mask, ADC_mask,
ROW_mask, COL_mask;
std::unique_ptr<ErrorCheckerBase> errorcheck;

// For the 32bit data format (moved from *.cc namespace, keep uppercase for
// compatibility) Add special layer 1 roc for phase1
int ADC_shift, PXID_shift, DCOL_shift, ROC_shift, LINK_shift, ROW_shift,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this way of splitting the lines of code.
I understand that this is not you, but rather clang... Let it as such, then.

COL_shift;
Word32 LINK_mask, ROC_mask, DCOL_mask, PXID_mask, ADC_mask, ROW_mask,
COL_mask;
int maxROCIndex;
bool phase1;

int checkError(const Word32 &data) const;

int checkError(const Word32& data) const;

int digi2word( cms_uint32_t detId, const PixelDigi& digi,
std::map<int, std::vector<Word32> > & words) const;
int digi2wordPhase1Layer1( cms_uint32_t detId, const PixelDigi& digi,
std::map<int, std::vector<Word32> > & words) const;

int word2digi( const int fedId,
const SiPixelFrameConverter* converter,
const bool includeError,
const bool useQuality,
const Word32& word,
Digis & digis) const;
int digi2word(cms_uint32_t detId, const PixelDigi &digi,
std::map<int, std::vector<Word32>> &words) const;
int digi2wordPhase1Layer1(cms_uint32_t detId, const PixelDigi &digi,
std::map<int, std::vector<Word32>> &words) const;

std::string print(const PixelDigi & digi) const;
std::string print(const Word64 & word) const;
int word2digi(const int fedId, const SiPixelFrameConverter *converter,
const bool includeError, const bool useQuality,
const Word32 &word, Digis &digis) const;

cms_uint32_t errorDetId(const SiPixelFrameConverter* converter,
int fedId, int errorType, const Word32 & word) const;
std::string print(const PixelDigi &digi) const;
std::string print(const Word64 &word) const;

cms_uint32_t errorDetId(const SiPixelFrameConverter *converter, int fedId,
int errorType, const Word32 &word) const;
};

#endif
Loading