CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual void produce (edm::Event &e, const edm::EventSetup &c)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
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)
 
- 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 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

Author
J. Mans - Minnesota

Definition at line 12 of file HcalPatternSource.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file HcalPatternSource.cc.

References edm::ParameterSet::getUntrackedParameter(), loadPatterns(), and AlCaHLTBitMon_QueryRunRegistry::string.

14  :
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 {
20  produces<HBHEDigiCollection>();
21  produces<HODigiCollection>();
22  produces<HFDigiCollection>();
23 }
T getUntrackedParameter(std::string const &, T const &) const
void loadPatterns(const std::string &patspec)
std::vector< int > bunches_

Member Function Documentation

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

Definition at line 99 of file HcalPatternSource.cc.

References createPayload::block, data, Exception, f, lut2db_cfg::filename, i, j, HcalPatternXMLParser::parse(), mps_alisetup::parser, patterns_, SiPixelLorentzAngle_cfi::read, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by loadPatterns().

99  {
101  std::string buffer, element;
102  std::map<std::string,std::string> params;
103  std::vector<uint32_t> data;
104  FILE* f=fopen(filename.c_str(), "r");
105  if (f==0) return;
106  else {
107  char block[4096];
108  while (!feof(f)) {
109  int read=fread(block,1,4096,f);
110  buffer.append(block,block+read);
111  }
112  fclose(f);
113  }
114  if (buffer.find("<?xml")!=0) {
115  throw cms::Exception("InvalidFormat") << "Not a valid XML file: " << filename;
116  }
118  while (buffer.find("<CFGBrick>",i)!=std::string::npos) {
119  i=buffer.find("<CFGBrick>",i);
120  j=buffer.find("</CFGBrick>",i);
121  element="<?xml version='1.0'?>\n";
122  element.append(buffer,i,j-i);
123  element.append("</CFGBrick>");
124  // LogDebug("HCAL") << element;
125  params.clear();
126  data.clear();
127  parser.parse(element,params,data);
128  patterns_.push_back(HcalFiberPattern(params,data));
129  i=j+5;
130  }
131 
132 
133 }
int i
Definition: DBlmapReader.cc:9
void parse(const std::string &xmlDocument, std::map< std::string, std::string > &parameters, std::vector< std::string > &items, std::string &encoding)
uint16_t size_type
int j
Definition: DBlmapReader.cc:9
double f[11][100]
std::vector< HcalFiberPattern > patterns_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
tuple filename
Definition: lut2db_cfg.py:20
void HcalPatternSource::loadPatterns ( const std::string &  patspec)
private

Definition at line 86 of file HcalPatternSource.cc.

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

Referenced by HcalPatternSource().

86  {
87  wordexp_t p;
88  char** files;
89  wordexp(patspec.c_str(),&p, WRDE_NOCMD); // do not run shell commands!
90  files=p.we_wordv;
91  for (unsigned int i=0; i<p.we_wordc; i++) {
92  LogDebug ("HCAL") << "Reading pattern file '" << files[i] << "'";
93  loadPatternFile(files[i]);
94  LogDebug ("HCAL") << "Fibers so far " << patterns_.size();
95  }
96  wordfree(&p);
97 }
#define LogDebug(id)
void loadPatternFile(const std::string &filename)
int i
Definition: DBlmapReader.cc:9
std::vector< HcalFiberPattern > patterns_
void HcalPatternSource::produce ( edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDProducer.

Definition at line 25 of file HcalPatternSource.cc.

References bunches_, edm::EventID::event(), benchmark_cfg::fc, edm::EventSetup::get(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, edm::EventBase::id(), HcalElectronicsMap::lookup(), patterns_, presamples_, edm::ESHandle< class >::product(), edm::Event::put(), and samples_.

25  {
26  if (e.id().event()>bunches_.size()) return;
27 
29  es.get<HcalElectronicsMapRcd>().get(item);
30  const HcalElectronicsMap *elecmap=item.product();
31 
32  std::auto_ptr<HBHEDigiCollection> hbhe(new HBHEDigiCollection());
33  std::auto_ptr<HFDigiCollection> hf(new HFDigiCollection());
34  std::auto_ptr<HODigiCollection> ho(new 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++) hbhe->back().setSample(i,samples[i]);
57  hbhe->back().setReadoutIds(eid);
58  break;
59  case (HcalForward):
60  hf->push_back(HFDataFrame(did));
61  hf->back().setSize(samples_);
62  hf->back().setPresamples(presamples_);
63  for (int i=0; i<samples_; i++) hf->back().setSample(i,samples[i]);
64  hf->back().setReadoutIds(eid);
65  break;
66  case (HcalOuter) :
67  ho->push_back(HODataFrame(did));
68  ho->back().setSize(samples_);
69  ho->back().setPresamples(presamples_);
70  for (int i=0; i<samples_; i++) ho->back().setSample(i,samples[i]);
71  ho->back().setReadoutIds(eid);
72  break;
73  default: continue;
74  }
75  }
76  }
77  hbhe->sort();
78  ho->sort();
79  hf->sort();
80 
81  e.put(hbhe);
82  e.put(ho);
83  e.put(hf);
84 }
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
edm::SortedCollection< HODataFrame > HODigiCollection
std::vector< int > bunches_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< HcalFiberPattern > patterns_
T const * product() const
Definition: ESHandle.h:86
edm::EventID id() const
Definition: EventBase.h:59
edm::SortedCollection< HFDataFrame > HFDigiCollection
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection

Member Data Documentation

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

Definition at line 19 of file HcalPatternSource.h.

Referenced by produce().

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

Definition at line 20 of file HcalPatternSource.h.

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

int HcalPatternSource::presamples_
private

Definition at line 21 of file HcalPatternSource.h.

Referenced by produce().

int HcalPatternSource::samples_
private

Definition at line 21 of file HcalPatternSource.h.

Referenced by produce().