CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalPatternSource Class Reference

#include <HcalPatternSource.h>

Inheritance diagram for HcalPatternSource:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HcalPatternSource (const edm::ParameterSet &pset)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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)
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Author
J. Mans - Minnesota

Definition at line 12 of file HcalPatternSource.h.

Constructor & Destructor Documentation

◆ HcalPatternSource()

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

Definition at line 14 of file HcalPatternSource.cc.

15  : bunches_(pset.getUntrackedParameter<std::vector<int> >("Bunches", std::vector<int>())),
16  presamples_(pset.getUntrackedParameter<int>("Presamples", 4)),
17  samples_(pset.getUntrackedParameter<int>("Samples", 10)) {
18  loadPatterns(pset.getUntrackedParameter<std::string>("Patterns"));
19  produces<HBHEDigiCollection>();
20  produces<HODigiCollection>();
21  produces<HFDigiCollection>();
22 }

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

Member Function Documentation

◆ loadPatternFile()

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

Definition at line 103 of file HcalPatternSource.cc.

103  {
105  std::string buffer, element;
106  std::map<std::string, std::string> params;
107  std::vector<uint32_t> data;
108  FILE* f = fopen(filename.c_str(), "r");
109  if (f == nullptr)
110  return;
111  else {
112  char block[4096];
113  while (!feof(f)) {
114  int read = fread(block, 1, 4096, f);
115  buffer.append(block, block + read);
116  }
117  fclose(f);
118  }
119  if (buffer.find("<?xml") != 0) {
120  throw cms::Exception("InvalidFormat") << "Not a valid XML file: " << filename;
121  }
123  while (buffer.find("<CFGBrick>", i) != std::string::npos) {
124  i = buffer.find("<CFGBrick>", i);
125  j = buffer.find("</CFGBrick>", i);
126  element = "<?xml version='1.0'?>\n";
127  element.append(buffer, i, j - i);
128  element.append("</CFGBrick>");
129  // LogDebug("HCAL") << element;
130  params.clear();
131  data.clear();
132  parser.parse(element, params, data);
133  patterns_.push_back(HcalFiberPattern(params, data));
134  i = j + 5;
135  }
136 }

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

Referenced by loadPatterns().

◆ loadPatterns()

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

Definition at line 90 of file HcalPatternSource.cc.

90  {
91  wordexp_t p;
92  char** files;
93  wordexp(patspec.c_str(), &p, WRDE_NOCMD); // do not run shell commands!
94  files = p.we_wordv;
95  for (unsigned int i = 0; i < p.we_wordc; i++) {
96  LogDebug("HCAL") << "Reading pattern file '" << files[i] << "'";
98  LogDebug("HCAL") << "Fibers so far " << patterns_.size();
99  }
100  wordfree(&p);
101 }

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

Referenced by HcalPatternSource().

◆ produce()

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

Implements edm::EDProducer.

Definition at line 24 of file HcalPatternSource.cc.

24  {
25  if (e.id().event() > bunches_.size())
26  return;
27 
29  es.get<HcalElectronicsMapRcd>().get(item);
30  const HcalElectronicsMap* elecmap = item.product();
31 
32  auto hbhe = std::make_unique<HBHEDigiCollection>();
33  auto hf = std::make_unique<HFDigiCollection>();
34  auto ho = std::make_unique<HODigiCollection>();
35 
36  int bc = bunches_[e.id().event() - 1];
37  for (std::vector<HcalFiberPattern>::iterator i = patterns_.begin(); i != patterns_.end(); i++) {
38  std::vector<HcalQIESample> samples;
39  for (int fc = 0; fc < 3; fc++) {
40  samples = i->getSamples(bc, presamples_, samples_, fc);
41  HcalElectronicsId eid = i->getId(fc);
42 
43  HcalDetId did(elecmap->lookup(eid));
44 
45  if (did.null()) {
46  edm::LogWarning("HCAL") << "No electronics map match for id " << eid;
47  continue;
48  }
49 
50  switch (did.subdet()) {
51  case (HcalBarrel):
52  case (HcalEndcap):
53  hbhe->push_back(HBHEDataFrame(did));
54  hbhe->back().setSize(samples_);
55  hbhe->back().setPresamples(presamples_);
56  for (int i = 0; i < samples_; i++)
57  hbhe->back().setSample(i, samples[i]);
58  hbhe->back().setReadoutIds(eid);
59  break;
60  case (HcalForward):
61  hf->push_back(HFDataFrame(did));
62  hf->back().setSize(samples_);
63  hf->back().setPresamples(presamples_);
64  for (int i = 0; i < samples_; i++)
65  hf->back().setSample(i, samples[i]);
66  hf->back().setReadoutIds(eid);
67  break;
68  case (HcalOuter):
69  ho->push_back(HODataFrame(did));
70  ho->back().setSize(samples_);
71  ho->back().setPresamples(presamples_);
72  for (int i = 0; i < samples_; i++)
73  ho->back().setSample(i, samples[i]);
74  ho->back().setReadoutIds(eid);
75  break;
76  default:
77  continue;
78  }
79  }
80  }
81  hbhe->sort();
82  ho->sort();
83  hf->sort();
84 
85  e.put(std::move(hbhe));
86  e.put(std::move(ho));
87  e.put(std::move(hf));
88 }

References bunches_, MillePedeFileConverter_cfg::e, runTauDisplay::eid, benchmark_cfg::fc, edm::EventSetup::get(), get, photonIsolationHIProducer_cfi::hbhe, HcalBarrel, HcalEndcap, HcalForward, HcalOuter, photonIsolationHIProducer_cfi::hf, photonIsolationHIProducer_cfi::ho, mps_fire::i, B2GTnPMonitor_cfi::item, HcalElectronicsMap::lookup(), eostools::move(), patterns_, presamples_, EgammaValidation_cff::samples, and samples_.

Member Data Documentation

◆ bunches_

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

Definition at line 20 of file HcalPatternSource.h.

Referenced by produce().

◆ patterns_

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

Definition at line 21 of file HcalPatternSource.h.

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

◆ presamples_

int HcalPatternSource::presamples_
private

Definition at line 22 of file HcalPatternSource.h.

Referenced by produce().

◆ samples_

int HcalPatternSource::samples_
private

Definition at line 22 of file HcalPatternSource.h.

Referenced by produce().

mps_fire.i
i
Definition: mps_fire.py:355
HcalElectronicsMapRcd
Definition: HcalElectronicsMapRcd.h:8
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
writedatasetfile.parser
parser
Definition: writedatasetfile.py:7
HcalBarrel
Definition: HcalAssistant.h:33
HcalPatternXMLParser
Definition: HcalPatternXMLParser.h:12
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
HcalPatternSource::loadPatterns
void loadPatterns(const std::string &patspec)
Definition: HcalPatternSource.cc:90
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
MainPageGenerator.files
files
Definition: MainPageGenerator.py:256
edm::ESHandle
Definition: DTSurvey.h:22
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
benchmark_cfg.fc
fc
Definition: benchmark_cfg.py:15
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
HcalOuter
Definition: HcalAssistant.h:35
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalPatternSource::samples_
int samples_
Definition: HcalPatternSource.h:22
edm::LogWarning
Definition: MessageLogger.h:141
HBHEDataFrame
Definition: HBHEDataFrame.h:14
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
HcalPatternSource::bunches_
std::vector< int > bunches_
Definition: HcalPatternSource.h:20
HcalDetId
Definition: HcalDetId.h:12
HFDataFrame
Definition: HFDataFrame.h:14
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
HcalFiberPattern
Definition: HcalFiberPattern.h:14
groupFilesInBlocks.block
block
Definition: groupFilesInBlocks.py:150
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
get
#define get
readEcalDQMStatus.read
read
Definition: readEcalDQMStatus.py:38
HcalElectronicsMap
Definition: HcalElectronicsMap.h:31
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HcalForward
Definition: HcalAssistant.h:36
eostools.move
def move(src, dest)
Definition: eostools.py:511
HcalElectronicsMap::lookup
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
Definition: HcalElectronicsMap.cc:70
HcalEndcap
Definition: HcalAssistant.h:34
HcalPatternSource::patterns_
std::vector< HcalFiberPattern > patterns_
Definition: HcalPatternSource.h:21
HODataFrame
Definition: HODataFrame.h:14
Exception
Definition: hltDiff.cc:246
HcalPatternSource::presamples_
int presamples_
Definition: HcalPatternSource.h:22
HcalPatternSource::loadPatternFile
void loadPatternFile(const std::string &filename)
Definition: HcalPatternSource.cc:103
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37