CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripProcessedRawDigiProducer.cc
Go to the documentation of this file.
2 
8 
12 
13 #include <functional>
14 
16  : inputTags_(conf.getParameter<std::vector<edm::InputTag> >("DigiProducersList")),
17  inputTokensDigi_(edm::vector_transform(
18  inputTags_, [this](edm::InputTag const& tag) { return consumes<edm::DetSetVector<SiStripDigi> >(tag); })),
20  inputTags_, [this](edm::InputTag const& tag) { return consumes<edm::DetSetVector<SiStripRawDigi> >(tag); })),
24  produces<edm::DetSetVector<SiStripProcessedRawDigi> >("");
25 }
26 
28  std::unique_ptr<edm::DetSetVector<SiStripProcessedRawDigi> > output(new edm::DetSetVector<SiStripProcessedRawDigi>());
31 
32  const auto& gain = es.getData(gainToken_);
33  subtractorPed_->init(es);
34  subtractorCMN_->init(es);
35 
36  std::string label = findInput(inputRawdigis, inputTokensRawDigi_, e);
37  if ("VirginRaw" == label)
38  vr_process(*inputRawdigis, *output, gain);
39  else if ("ProcessedRaw" == label)
40  pr_process(*inputRawdigis, *output, gain);
41  else if ("ZeroSuppressed" == findInput(inputDigis, inputTokensDigi_, e))
42  zs_process(*inputDigis, *output, gain);
43  else
44  edm::LogError("Input Not Found");
45 
46  e.put(std::move(output));
47 }
48 
49 template <class T>
51  const std::vector<edm::EDGetTokenT<T> >& tokens,
52  const edm::Event& e) {
53  for (typename std::vector<edm::EDGetTokenT<T> >::const_iterator token = tokens.begin(); token != tokens.end();
54  ++token) {
55  unsigned index(token - tokens.begin());
56  e.getByToken(*token, handle);
57  if (handle.isValid() && !handle->empty()) {
58  edm::LogInfo("Input") << inputTags_.at(index);
59  return inputTags_.at(index).instance();
60  }
61  }
62  return "Input Not Found";
63 }
64 
67  const SiStripGain& gain) {
68  std::vector<float> digis;
69  for (edm::DetSetVector<SiStripDigi>::const_iterator detset = input.begin(); detset != input.end(); ++detset) {
70  digis.clear();
71  for (edm::DetSet<SiStripDigi>::const_iterator digi = detset->begin(); digi != detset->end(); ++digi) {
72  digis.resize(digi->strip(), 0);
73  digis.push_back(digi->adc());
74  }
75  common_process(detset->id, digis, output, gain);
76  }
77 }
78 
81  const SiStripGain& gain) {
82  for (edm::DetSetVector<SiStripRawDigi>::const_iterator detset = input.begin(); detset != input.end(); ++detset) {
83  std::vector<float> digis;
84  transform(
85  detset->begin(), detset->end(), back_inserter(digis), std::bind(&SiStripRawDigi::adc, std::placeholders::_1));
86  subtractorCMN_->subtract(detset->id, 0, digis);
87  common_process(detset->id, digis, output, gain);
88  }
89 }
90 
93  const SiStripGain& gain) {
94  for (edm::DetSetVector<SiStripRawDigi>::const_iterator detset = input.begin(); detset != input.end(); ++detset) {
95  std::vector<int16_t> int_digis(detset->size());
96  subtractorPed_->subtract(*detset, int_digis);
97  std::vector<float> digis(int_digis.begin(), int_digis.end());
98  subtractorCMN_->subtract(detset->id, 0, digis);
99  common_process(detset->id, digis, output, gain);
100  }
101 }
102 
104  std::vector<float>& digis,
106  const SiStripGain& gain) {
107  //Apply Gains
108  SiStripApvGain::Range detGainRange = gain.getRange(detId);
109  for (std::vector<float>::iterator it = digis.begin(); it < digis.end(); ++it)
110  (*it) /= (gain.getStripGain(it - digis.begin(), detGainRange));
111 
112  //Insert as DetSet
114  copy(digis.begin(), digis.end(), back_inserter(ds.data));
115  output.insert(ds);
116 }
subtractorPed_(SiStripRawProcessingFactory::create_SubtractorPed(conf, consumesCollector()))
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void zs_process(const edm::DetSetVector< SiStripDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &, const SiStripGain &)
void common_process(const uint32_t, std::vector< float > &, edm::DetSetVector< SiStripProcessedRawDigi > &, const SiStripGain &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
gainToken_(esConsumes())
std::unique_ptr< SiStripCommonModeNoiseSubtractor > subtractorCMN_
Log< level::Error, false > LogError
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::string findInput(edm::Handle< T > &handle, const std::vector< edm::EDGetTokenT< T > > &tokens, const edm::Event &e)
static std::string const input
Definition: EdmProvDump.cc:47
static std::unique_ptr< SiStripCommonModeNoiseSubtractor > create_SubtractorCMN(const edm::ParameterSet &, edm::ConsumesCollector)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
char const * label
SiStripProcessedRawDigiProducer(edm::ParameterSet const &)
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:77
def move
Definition: eostools.py:511
tuple handle
Definition: patZpeak.py:23
std::pair< ContainerIterator, ContainerIterator > Range
void pr_process(const edm::DetSetVector< SiStripRawDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &, const SiStripGain &)
bool isValid() const
Definition: HandleBase.h:70
std::vector< edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > > inputTokensDigi_
subtractorCMN_(SiStripRawProcessingFactory::create_SubtractorCMN(conf, consumesCollector()))
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
uint16_t adc() const
inputTokensRawDigi_(edm::vector_transform(inputTags_, [this](edm::InputTag const &tag){return consumes< edm::DetSetVector< SiStripRawDigi > >(tag);}))
edm::ESGetToken< SiStripGain, SiStripGainRcd > gainToken_
static std::unique_ptr< SiStripPedestalsSubtractor > create_SubtractorPed(const edm::ParameterSet &, edm::ConsumesCollector)
void produce(edm::Event &e, const edm::EventSetup &es) override
Log< level::Info, false > LogInfo
void insert(detset const &s)
Insert the given DetSet.
Definition: DetSetVector.h:220
collection_type data
Definition: DetSet.h:80
std::unique_ptr< SiStripPedestalsSubtractor > subtractorPed_
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:314
collection_type::const_iterator const_iterator
Definition: DetSet.h:31
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
void vr_process(const edm::DetSetVector< SiStripRawDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &, const SiStripGain &)
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > > inputTokensRawDigi_
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:75
unsigned transform(const HcalDetId &id, unsigned transformCode)