64 mutable std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
77 : tPixelDigi{consumes<edm::DetSetVector<PixelDigi>>(
pset.getParameter<
edm::InputTag>(
"InputLabel"))},
78 theBadPixelFEDChannelsToken{consumes<PixelFEDChannelCollection>(
pset.getParameter<
edm::InputTag>(
"InputLabel"))},
79 putToken_{produces<FEDRawDataCollection>()},
80 usePhase1{
pset.getParameter<
bool>(
"UsePhase1")} {
84 edm::LogInfo(
"SiPixelRawToDigi") <<
" Use pilot blade data (FED 40)";
90 while (lock_.test_and_set(std::memory_order_acquire))
92 auto rel = [](std::atomic_flag*
f) {
f->clear(std::memory_order_release); };
93 std::unique_ptr<std::atomic_flag, decltype(rel)> guard(&lock_,
rel);
95 if (recordWatcher.check(es)) {
98 previousCache_ = std::make_shared<pr::Cache>();
99 previousCache_->cablingTree_ = cablingMap->
cablingTree();
100 previousCache_->frameReverter_ = std::make_unique<SiPixelFrameReverter>(es, cablingMap.
product());
102 return previousCache_;
116 for (
auto const& di : *digiCollection) {
117 digiCounter += (di.data).
size();
118 digis[di.id] = di.data;
123 LogDebug(
"SiPixelDigiToRaw") <<
cache->cablingTree_->version();
127 if (usePhase1 && ev.
getByToken(theBadPixelFEDChannelsToken, pixelFEDChannelCollectionHandle)) {
128 for (
auto const& fedChannels : *pixelFEDChannelCollectionHandle) {
130 for (
const auto& fedChannel : fedChannels) {
132 if (
cache->cablingTree_->findItem(path) !=
nullptr) {
133 detBadChannels.push_back(fedChannel);
136 <<
" FED " << fedChannel.fed <<
" Link " << fedChannel.link <<
" for module " << fedChannels.detId()
137 <<
" marked bad, but this channel does not exist in the cabling map" << endl;
140 if (!detBadChannels.empty())
141 badChannels.insert({fedChannels.detId(), std::move(detBadChannels)});
154 formatter.formatRawData(ev.
id().
event(), rawdata, digis, badChannels);
157 for (
auto const* fed :
cache->cablingTree_->fedList()) {
158 LogDebug(
"SiPixelDigiToRaw") <<
" PRODUCE DATA FOR FED_id: " << fed->id();
160 PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find(fed->id());
161 if (fedbuffer != rawdata.end())
162 fedRawData = fedbuffer->second;
163 LogDebug(
"SiPixelDigiToRaw") <<
"size of data in fedRawData: " << fedRawData.
size();
166 LogDebug(
"SiPixelDigiToRaw").log([&](
auto&
l) {
167 l <<
"Words/Digis this ev: " << digiCounter <<
"(fm:" << formatter.nDigis() <<
")/" << formatter.nWords();
176 desc.
add<
bool>(
"UsePhase1",
false);
177 desc.
addUntracked<
bool>(
"Timing",
false)->setComment(
"deprecated");
178 descriptions.
add(
"siPixelRawData", desc);
EventNumber_t event() const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const final
get data, convert to raw event, attach again to Event
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
LuminosityBlockIndex index() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< SiPixelFedCablingTree > cablingTree_
size_t size() const
Lenght of the data buffer in bytes.
void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &iES) const final
#define DEFINE_FWK_MODULE(type)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
#define CMS_THREAD_GUARD(_var_)
LuminosityBlock const & getLuminosityBlock() const
std::shared_ptr< pr::Cache > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &iES) const final
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< SiPixelFrameReverter > frameReverter_
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T const * product() const