CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalPatternSource Class Reference
Inheritance diagram for HcalPatternSource:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HcalPatternSource (const edm::ParameterSet &pset)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~HcalPatternSource () override
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void loadPatternFile (const std::string &filename)
 
void loadPatterns (const std::string &patspec)
 

Private Attributes

std::vector< int > bunches_
 
std::vector< HcalFiberPatternpatterns_
 
int presamples_
 
int samples_
 
const edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcdtheHcalElectronicsMapToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 17 of file HcalPatternSource.cc.

Constructor & Destructor Documentation

◆ HcalPatternSource()

HcalPatternSource::HcalPatternSource ( const edm::ParameterSet pset)

Definition at line 32 of file HcalPatternSource.cc.

References loadPatterns(), muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

33  : bunches_(pset.getUntrackedParameter<std::vector<int> >("Bunches", std::vector<int>())),
34  presamples_(pset.getUntrackedParameter<int>("Presamples", 4)),
35  samples_(pset.getUntrackedParameter<int>("Samples", 10)),
37  loadPatterns(pset.getUntrackedParameter<std::string>("Patterns"));
38  produces<HBHEDigiCollection>();
39  produces<HODigiCollection>();
40  produces<HFDigiCollection>();
41 }
void loadPatterns(const std::string &patspec)
std::vector< int > bunches_
const edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > theHcalElectronicsMapToken_

◆ ~HcalPatternSource()

HcalPatternSource::~HcalPatternSource ( )
overridedefault

Member Function Documentation

◆ loadPatternFile()

void HcalPatternSource::loadPatternFile ( const std::string &  filename)
private

Definition at line 123 of file HcalPatternSource.cc.

References groupFilesInBlocks::block, edmScanValgrind::buffer, data, Exception, f, corrVsCorr::filename, mps_fire::i, dqmiolumiharvest::j, submitPVValidationJobs::params, writedatasetfile::parser, patterns_, fileinputsource_cfi::read, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by loadPatterns().

123  {
125  std::string buffer, element;
126  std::map<std::string, std::string> params;
127  std::vector<uint32_t> data;
128  FILE* f = fopen(filename.c_str(), "r");
129  if (f == nullptr)
130  return;
131  else {
132  char block[4096];
133  while (!feof(f)) {
134  int read = fread(block, 1, 4096, f);
135  buffer.append(block, block + read);
136  }
137  fclose(f);
138  }
139  if (buffer.find("<?xml") != 0) {
140  throw cms::Exception("InvalidFormat") << "Not a valid XML file: " << filename;
141  }
143  while (buffer.find("<CFGBrick>", i) != std::string::npos) {
144  i = buffer.find("<CFGBrick>", i);
145  j = buffer.find("</CFGBrick>", i);
146  element = "<?xml version='1.0'?>\n";
147  element.append(buffer, i, j - i);
148  element.append("</CFGBrick>");
149  // LogDebug("HCAL") << element;
150  params.clear();
151  data.clear();
152  parser.parse(element, params, data);
153  patterns_.push_back(HcalFiberPattern(params, data));
154  i = j + 5;
155  }
156 }
uint16_t size_type
double f[11][100]
std::vector< HcalFiberPattern > patterns_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80

◆ loadPatterns()

void HcalPatternSource::loadPatterns ( const std::string &  patspec)
private

Definition at line 110 of file HcalPatternSource.cc.

References submitPVResolutionJobs::files, mps_fire::i, loadPatternFile(), LogDebug, AlCaHLTBitMon_ParallelJobs::p, and patterns_.

Referenced by HcalPatternSource().

110  {
111  wordexp_t p;
112  char** files;
113  wordexp(patspec.c_str(), &p, WRDE_NOCMD); // do not run shell commands!
114  files = p.we_wordv;
115  for (unsigned int i = 0; i < p.we_wordc; i++) {
116  LogDebug("HCAL") << "Reading pattern file '" << files[i] << "'";
118  LogDebug("HCAL") << "Fibers so far " << patterns_.size();
119  }
120  wordfree(&p);
121 }
void loadPatternFile(const std::string &filename)
std::vector< HcalFiberPattern > patterns_
#define LogDebug(id)

◆ produce()

void HcalPatternSource::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 45 of file HcalPatternSource.cc.

References bunches_, MillePedeFileConverter_cfg::e, runTauDisplay::eid, edm::EventSetup::getData(), photonIsolationHIProducer_cfi::hbhe, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, photonIsolationHIProducer_cfi::hf, photonIsolationHIProducer_cfi::ho, mps_fire::i, eostools::move(), patterns_, presamples_, EgammaValidation_cff::samples, samples_, and theHcalElectronicsMapToken_.

45  {
46  if (e.id().event() > bunches_.size())
47  return;
48 
49  // Get HcalElectronicsMap from the Event setup
50  const auto elecmap = &iSetup.getData(theHcalElectronicsMapToken_);
51 
52  auto hbhe = std::make_unique<HBHEDigiCollection>();
53  auto hf = std::make_unique<HFDigiCollection>();
54  auto ho = std::make_unique<HODigiCollection>();
55 
56  int bc = bunches_[e.id().event() - 1];
57  for (std::vector<HcalFiberPattern>::iterator i = patterns_.begin(); i != patterns_.end(); i++) {
58  std::vector<HcalQIESample> samples;
59  for (int fc = 0; fc < 3; fc++) {
60  samples = i->getSamples(bc, presamples_, samples_, fc);
61  HcalElectronicsId eid = i->getId(fc);
62 
63  HcalDetId did(elecmap->lookup(eid));
64 
65  if (did.null()) {
66  edm::LogWarning("HcalPatternSource") << "No electronics map match for id " << eid;
67  continue;
68  }
69 
70  switch (did.subdet()) {
71  case (HcalBarrel):
72  case (HcalEndcap):
73  hbhe->push_back(HBHEDataFrame(did));
74  hbhe->back().setSize(samples_);
75  hbhe->back().setPresamples(presamples_);
76  for (int i = 0; i < samples_; i++)
77  hbhe->back().setSample(i, samples[i]);
78  hbhe->back().setReadoutIds(eid);
79  break;
80  case (HcalForward):
81  hf->push_back(HFDataFrame(did));
82  hf->back().setSize(samples_);
83  hf->back().setPresamples(presamples_);
84  for (int i = 0; i < samples_; i++)
85  hf->back().setSample(i, samples[i]);
86  hf->back().setReadoutIds(eid);
87  break;
88  case (HcalOuter):
89  ho->push_back(HODataFrame(did));
90  ho->back().setSize(samples_);
91  ho->back().setPresamples(presamples_);
92  for (int i = 0; i < samples_; i++)
93  ho->back().setSample(i, samples[i]);
94  ho->back().setReadoutIds(eid);
95  break;
96  default:
97  continue;
98  }
99  }
100  }
101  hbhe->sort();
102  ho->sort();
103  hf->sort();
104 
105  e.put(std::move(hbhe));
106  e.put(std::move(ho));
107  e.put(std::move(hf));
108 }
std::vector< int > bunches_
const edm::ESGetToken< HcalElectronicsMap, HcalElectronicsMapRcd > theHcalElectronicsMapToken_
std::vector< HcalFiberPattern > patterns_
Log< level::Warning, false > LogWarning
Readout chain identification for Hcal.
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ bunches_

std::vector<int> HcalPatternSource::bunches_
private

Definition at line 26 of file HcalPatternSource.cc.

Referenced by produce().

◆ patterns_

std::vector<HcalFiberPattern> HcalPatternSource::patterns_
private

Definition at line 27 of file HcalPatternSource.cc.

Referenced by loadPatternFile(), loadPatterns(), and produce().

◆ presamples_

int HcalPatternSource::presamples_
private

Definition at line 28 of file HcalPatternSource.cc.

Referenced by produce().

◆ samples_

int HcalPatternSource::samples_
private

Definition at line 28 of file HcalPatternSource.cc.

Referenced by produce().

◆ theHcalElectronicsMapToken_

const edm::ESGetToken<HcalElectronicsMap, HcalElectronicsMapRcd> HcalPatternSource::theHcalElectronicsMapToken_
private

Definition at line 29 of file HcalPatternSource.cc.

Referenced by produce().