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

Pixel local reco: reduce code duplication between SiPixelDigiErrorsFromSoA and SiPixelRawToDigi #33526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions EventFilter/SiPixelRawToDigi/interface/PixelDataFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "DataFormats/SiPixelDigi/interface/PixelDigi.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/SiPixelRawData/interface/SiPixelRawDataError.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/DetId/interface/DetIdCollection.h"
#include "EventFilter/SiPixelRawToDigi/interface/ErrorChecker.h"
#include "EventFilter/SiPixelRawToDigi/interface/ErrorCheckerPhase0.h"
#include "FWCore/Utilities/interface/typedefs.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ class PixelDataFormatter {
typedef cms_uint32_t Word32;
typedef cms_uint64_t Word64;

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

void setErrorStatus(bool ErrorStatus);
void setQualityStatus(bool QualityStatus, const SiPixelQuality* QualityInfo);
Expand All @@ -84,20 +84,28 @@ class PixelDataFormatter {

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; }
void unpackFEDErrors(Errors const& errors,
std::vector<int> const& tkerrorlist,
std::vector<int> const& usererrorlist,
edm::DetSetVector<SiPixelRawDataError>& errorcollection,
DetIdCollection& tkerror_detidcollection,
DetIdCollection& usererror_detidcollection,
edmNew::DetSetVector<PixelFEDChannel>& disabled_channelcollection,
DetErrors& nodeterrors);

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

private:
mutable int theDigiCounter;
mutable int theWordCounter;

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

bool includeErrors;
bool useQualityInfo;
bool debug;
int allDetDigis;
int hasDetDigis;
std::unique_ptr<ErrorCheckerBase> errorcheck;
Expand All @@ -116,13 +124,6 @@ class PixelDataFormatter {
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;

std::string print(const PixelDigi& digi) const;
std::string print(const Word64& word) const;

Expand Down
76 changes: 10 additions & 66 deletions EventFilter/SiPixelRawToDigi/plugins/SiPixelDigiErrorsFromSoA.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,72 +104,16 @@ void SiPixelDigiErrorsFromSoA::produce(edm::Event& iEvent, const edm::EventSetup
}
}

constexpr uint32_t dummydetid = 0xffffffff;
typedef PixelDataFormatter::Errors::iterator IE;
for (auto& error : errors) {
uint32_t errordetid = error.first;
if (errordetid == dummydetid) { // errors given dummy detId must be sorted by Fed
nodeterrors.insert(nodeterrors.end(), errors[errordetid].begin(), errors[errordetid].end());
} else {
edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection.find_or_insert(errordetid);
errorDetSet.data.insert(errorDetSet.data.end(), error.second.begin(), error.second.end());
// Fill detid of the detectors where there is error AND the error number is listed
// in the configurable error list in the job option cfi.
// Code needs to be here, because there can be a set of errors for each
// entry in the for loop over PixelDataFormatter::Errors

std::vector<PixelFEDChannel> disabledChannelsDetSet;

for (auto const& aPixelError : errorDetSet) {
// For the time being, we extend the error handling functionality with ErrorType 25
// In the future, we should sort out how the usage of tkerrorlist can be generalized
if (aPixelError.getType() == 25) {
int fedId = aPixelError.getFedId();
const sipixelobjects::PixelFEDCabling* fed = cabling_->fed(fedId);
if (fed) {
cms_uint32_t linkId = formatter.linkId(aPixelError.getWord32());
const sipixelobjects::PixelFEDLink* link = fed->link(linkId);
if (link) {
// The "offline" 0..15 numbering is fixed by definition, also, the FrameConversion depends on it
// in contrast, the ROC-in-channel numbering is determined by hardware --> better to use the "offline" scheme
PixelFEDChannel ch = {fed->id(), linkId, 25, 0};
for (unsigned int iRoc = 1; iRoc <= link->numberOfROCs(); iRoc++) {
const sipixelobjects::PixelROC* roc = link->roc(iRoc);
if (roc->idInDetUnit() < ch.roc_first)
ch.roc_first = roc->idInDetUnit();
if (roc->idInDetUnit() > ch.roc_last)
ch.roc_last = roc->idInDetUnit();
}
disabledChannelsDetSet.push_back(ch);
}
}
} else {
// fill list of detIds to be turned off by tracking
if (!tkerrorlist_.empty()) {
auto it_find = std::find(tkerrorlist_.begin(), tkerrorlist_.end(), aPixelError.getType());
if (it_find != tkerrorlist_.end()) {
tkerror_detidcollection.push_back(errordetid);
}
}
}

// fill list of detIds with errors to be studied
if (!usererrorlist_.empty()) {
auto it_find = std::find(usererrorlist_.begin(), usererrorlist_.end(), aPixelError.getType());
if (it_find != usererrorlist_.end()) {
usererror_detidcollection.push_back(errordetid);
}
}

} // loop on DetSet of errors

if (!disabledChannelsDetSet.empty()) {
disabled_channelcollection.insert(errordetid, disabledChannelsDetSet.data(), disabledChannelsDetSet.size());
}

} // if error assigned to a real DetId
} // loop on errors in event for this FED

formatter.unpackFEDErrors(errors,
tkerrorlist_,
usererrorlist_,
errorcollection,
tkerror_detidcollection,
usererror_detidcollection,
disabled_channelcollection,
nodeterrors);

const uint32_t dummydetid = 0xffffffff;
edm::DetSet<SiPixelRawDataError>& errorDetSet = errorcollection.find_or_insert(dummydetid);
errorDetSet.data = nodeterrors;

Expand Down
Loading