CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
SiPixelDigiToRaw Class Referencefinal
Inheritance diagram for SiPixelDigiToRaw:
edm::global::EDProducer< edm::LuminosityBlockCache< pr::Cache > > edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

std::shared_ptr< pr::CacheglobalBeginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &iES) const final
 
void globalEndLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &iES) const final
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const final
 get data, convert to raw event, attach again to Event More...
 
 SiPixelDigiToRaw (const edm::ParameterSet &)
 ctor More...
 
- Public Member Functions inherited from edm::global::EDProducer< edm::LuminosityBlockCache< pr::Cache > >
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

std::atomic_flag lock_ = ATOMIC_FLAG_INIT
 
std::shared_ptr< pr::CachepreviousCache_
 
const edm::EDPutTokenT< FEDRawDataCollectionputToken_
 
edm::ESWatcher< SiPixelFedCablingMapRcdrecordWatcher
 
const edm::EDGetTokenT< PixelFEDChannelCollectiontheBadPixelFEDChannelsToken
 
const edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
 
const bool usePhase1
 
const bool usePilotBlade = false
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 47 of file SiPixelDigiToRaw.cc.

Constructor & Destructor Documentation

SiPixelDigiToRaw::SiPixelDigiToRaw ( const edm::ParameterSet pset)
explicit

ctor

Definition at line 80 of file SiPixelDigiToRaw.cc.

References muonDTDigis_cfi::pset.

80  :
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") }
85 {
86 
87 
88  // Define EDProduct type
89 
90  if(usePhase1) edm::LogInfo("SiPixelRawToDigi") << " Use pilot blade data (FED 40)";
91 
92 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
const edm::EDPutTokenT< FEDRawDataCollection > putToken_
const edm::EDGetTokenT< PixelFEDChannelCollection > theBadPixelFEDChannelsToken

Member Function Documentation

void SiPixelDigiToRaw::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 186 of file SiPixelDigiToRaw.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and DEFINE_FWK_MODULE.

186  {
188  desc.add<edm::InputTag>("InputLabel");
189  desc.add<bool>("UsePhase1", false);
190  desc.addUntracked<bool>("Timing", false)->setComment("deprecated");
191  descriptions.add("siPixelRawData", desc);
192 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::shared_ptr< pr::Cache > SiPixelDigiToRaw::globalBeginLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iES 
) const
final

Definition at line 96 of file SiPixelDigiToRaw.cc.

References SiPixelFedCablingMap::cablingTree(), f, edm::EventSetup::get(), edm::ESHandle< T >::product(), and RefreshWebPage::rel.

97  {
98  while(lock_.test_and_set(std::memory_order_acquire)); //spin
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);
101 
102  if (recordWatcher.check( es )) {
104  es.get<SiPixelFedCablingMapRcd>().get( cablingMap );
105  previousCache_ = std::make_shared<pr::Cache>();
106  previousCache_->cablingTree_= cablingMap->cablingTree();
107  previousCache_->frameReverter_ = std::make_unique<SiPixelFrameReverter>( es, cablingMap.product() );
108  }
109  return previousCache_;
110 }
std::atomic_flag lock_
double f[11][100]
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
edm::ESWatcher< SiPixelFedCablingMapRcd > recordWatcher
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
T const * product() const
Definition: ESHandle.h:86
std::shared_ptr< pr::Cache > previousCache_
void SiPixelDigiToRaw::globalEndLuminosityBlock ( edm::LuminosityBlock const &  ,
edm::EventSetup const &  iES 
) const
inlinefinal

Definition at line 60 of file SiPixelDigiToRaw.cc.

References fillDescriptions().

61  {}
void SiPixelDigiToRaw::produce ( edm::StreamID  ,
edm::Event ev,
const edm::EventSetup es 
) const
final

get data, convert to raw event, attach again to Event

Definition at line 115 of file SiPixelDigiToRaw.cc.

References utilities::cache(), hgcalDigitizer_cfi::digiCollection, edm::Event::emplace(), edm::EventID::event(), FEDRawDataCollection::FEDData(), edm::Event::getByToken(), edm::Event::getLuminosityBlock(), edm::EventBase::id(), edm::LuminosityBlock::index(), checklumidiff::l, LogDebug, eostools::move(), PixelDataFormatter::passFrameReverter(), callgraph::path, matplotRender::rawdata, FEDRawData::size(), and findQualityFiles::size.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

117 {
118  using namespace sipixelobjects;
119 
121  ev.getByToken( tPixelDigi, digiCollection);
122 
125 
126  int digiCounter = 0;
127  for (auto const& di : *digiCollection) {
128  digiCounter += (di.data).size();
129  digis[ di.id] = di.data;
130  }
131 
132  auto cache = luminosityBlockCache(ev.getLuminosityBlock().index());
133 
134 
135  LogDebug("SiPixelDigiToRaw") << cache->cablingTree_->version();
136 
138  edm::Handle<PixelFEDChannelCollection> pixelFEDChannelCollectionHandle;
139  if (usePhase1 && ev.getByToken(theBadPixelFEDChannelsToken, pixelFEDChannelCollectionHandle)){
140  for (auto const& fedChannels: *pixelFEDChannelCollectionHandle) {
141  PixelDataFormatter::DetBadChannels detBadChannels;
142  for(const auto& fedChannel: fedChannels) {
143  sipixelobjects::CablingPathToDetUnit path={fedChannel.fed, fedChannel.link, 1};
144  if (cache->cablingTree_->findItem(path)!=nullptr) {
145  detBadChannels.push_back(fedChannel);
146  } else {
147  edm::LogError("SiPixelDigiToRaw")
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;
150  }
151  } // channels reading a module
152  if (!detBadChannels.empty()) badChannels.insert({fedChannels.detId(), std::move(detBadChannels)});
153  } // loop on detId-s
154  }
155 
156  //PixelDataFormatter formatter(cablingTree_.get());
157  PixelDataFormatter formatter(cache->cablingTree_.get(), usePhase1);
158 
159  formatter.passFrameReverter(cache->frameReverter_.get());
160 
161  // create product (raw data)
162  FEDRawDataCollection buffers;
163 
164  // convert data to raw
165  formatter.formatRawData( ev.id().event(), rawdata, digis, badChannels);
166 
167  // pack raw data into collection
168  for (auto const* fed: cache->cablingTree_->fedList()) {
169  LogDebug("SiPixelDigiToRaw")<<" PRODUCE DATA FOR FED_id: " << fed->id();
170  FEDRawData& fedRawData = buffers.FEDData( 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();
174  }
175 
176  LogDebug("SiPixelDigiToRaw").log([&](auto &l) {
177 
178  l << "Words/Digis this ev: "<<digiCounter<<"(fm:"<<formatter.nDigis()<<")/"
179  <<formatter.nWords();
180  });
181  ev.emplace(putToken_, std::move(buffers));
182 
183 }
#define LogDebug(id)
size
Write out results.
EventNumber_t event() const
Definition: EventID.h:41
std::map< cms_uint32_t, DetDigis > Digis
LuminosityBlockIndex index() const
void passFrameReverter(const SiPixelFrameReverter *reverter)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > tPixelDigi
const edm::EDPutTokenT< FEDRawDataCollection > putToken_
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
std::map< cms_uint32_t, DetBadChannels > BadChannels
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
LuminosityBlock const & getLuminosityBlock() const
Definition: Event.h:97
const edm::EDGetTokenT< PixelFEDChannelCollection > theBadPixelFEDChannelsToken
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:413
std::map< int, FEDRawData > RawData
std::vector< PixelFEDChannel > DetBadChannels
edm::EventID id() const
Definition: EventBase.h:59
def cache(function)
Definition: utilities.py:3
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::atomic_flag SiPixelDigiToRaw::lock_ = ATOMIC_FLAG_INIT
mutableprivate

Definition at line 68 of file SiPixelDigiToRaw.cc.

std::shared_ptr<pr::Cache> SiPixelDigiToRaw::previousCache_
mutableprivate

Definition at line 70 of file SiPixelDigiToRaw.cc.

const edm::EDPutTokenT<FEDRawDataCollection> SiPixelDigiToRaw::putToken_
private

Definition at line 73 of file SiPixelDigiToRaw.cc.

edm::ESWatcher<SiPixelFedCablingMapRcd> SiPixelDigiToRaw::recordWatcher
mutableprivate

Definition at line 69 of file SiPixelDigiToRaw.cc.

const edm::EDGetTokenT<PixelFEDChannelCollection> SiPixelDigiToRaw::theBadPixelFEDChannelsToken
private

Definition at line 72 of file SiPixelDigiToRaw.cc.

const edm::EDGetTokenT<edm::DetSetVector<PixelDigi> > SiPixelDigiToRaw::tPixelDigi
private

Definition at line 71 of file SiPixelDigiToRaw.cc.

const bool SiPixelDigiToRaw::usePhase1
private

Definition at line 75 of file SiPixelDigiToRaw.cc.

const bool SiPixelDigiToRaw::usePilotBlade = false
private

Definition at line 74 of file SiPixelDigiToRaw.cc.