68 mutable std::atomic_flag lock_ = ATOMIC_FLAG_INIT;
74 const
bool usePilotBlade =
false;
81 tPixelDigi{ consumes<edm::DetSetVector<PixelDigi> >(
pset.getParameter<
edm::InputTag>(
"InputLabel")) },
82 theBadPixelFEDChannelsToken{ consumes<PixelFEDChannelCollection>(
pset.getParameter<
edm::InputTag>(
"InputLabel")) },
83 putToken_{produces<FEDRawDataCollection>()},
84 usePhase1{
pset.getParameter<
bool> (
"UsePhase1") }
90 if(usePhase1)
edm::LogInfo(
"SiPixelRawToDigi") <<
" Use pilot blade data (FED 40)";
95 std::shared_ptr<pr::Cache>
98 while(lock_.test_and_set(std::memory_order_acquire));
99 auto rel = [](std::atomic_flag*
f) {
f->clear(std::memory_order_release); };
100 std::unique_ptr<std::atomic_flag, decltype(rel)> guard(&lock_,
rel);
102 if (recordWatcher.check( es )) {
105 previousCache_ = std::make_shared<pr::Cache>();
106 previousCache_->cablingTree_= cablingMap->
cablingTree();
107 previousCache_->frameReverter_ = std::make_unique<SiPixelFrameReverter>( es, cablingMap.
product() );
109 return previousCache_;
127 for (
auto const& di : *digiCollection) {
128 digiCounter += (di.data).
size();
129 digis[ di.id] = di.data;
135 LogDebug(
"SiPixelDigiToRaw") <<
cache->cablingTree_->version();
139 if (usePhase1 && ev.
getByToken(theBadPixelFEDChannelsToken, pixelFEDChannelCollectionHandle)){
140 for (
auto const& fedChannels: *pixelFEDChannelCollectionHandle) {
142 for(
const auto& fedChannel: fedChannels) {
144 if (
cache->cablingTree_->findItem(path)!=
nullptr) {
145 detBadChannels.push_back(fedChannel);
148 <<
" FED "<<fedChannel.fed<<
" Link "<<fedChannel.link<<
" for module "<<fedChannels.detId()
149 <<
" marked bad, but this channel does not exist in the cabling map" <<endl;
152 if (!detBadChannels.empty()) badChannels.insert({fedChannels.detId(), std::move(detBadChannels)});
165 formatter.formatRawData( ev.
id().
event(),
rawdata, digis, badChannels);
168 for (
auto const* fed:
cache->cablingTree_->fedList()) {
169 LogDebug(
"SiPixelDigiToRaw")<<
" PRODUCE DATA FOR FED_id: " << fed->id();
171 PixelDataFormatter::RawData::iterator fedbuffer = rawdata.find( fed->id() );
172 if( fedbuffer != rawdata.end() ) fedRawData = fedbuffer->second;
173 LogDebug(
"SiPixelDigiToRaw")<<
"size of data in fedRawData: "<<fedRawData.
size();
176 LogDebug(
"SiPixelDigiToRaw").log([&](
auto &
l) {
178 l <<
"Words/Digis this ev: "<<digiCounter<<
"(fm:"<<formatter.nDigis()<<
")/" 179 <<formatter.nWords();
189 desc.
add<
bool>(
"UsePhase1",
false);
190 desc.
addUntracked<
bool>(
"Timing",
false)->setComment(
"deprecated");
191 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