test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripProcessedRawDigiProducer.cc
Go to the documentation of this file.
2 
8 
11 
15 
16 #include "boost/bind.hpp"
17 
18 #include <functional>
19 
21  : inputTags(conf.getParameter<std::vector<edm::InputTag> >("DigiProducersList")),
22  inputTokensDigi(edm::vector_transform(inputTags, [this](edm::InputTag const & tag){return consumes<edm::DetSetVector<SiStripDigi> >(tag);})),
23  inputTokensRawDigi(edm::vector_transform(inputTags, [this](edm::InputTag const & tag){return consumes<edm::DetSetVector<SiStripRawDigi> >(tag);})),
26 
27  produces< edm::DetSetVector<SiStripProcessedRawDigi> >("");
28 }
29 
32 
33  std::unique_ptr< edm::DetSetVector<SiStripProcessedRawDigi> > output(new edm::DetSetVector<SiStripProcessedRawDigi>());
36 
37  es.get<SiStripGainRcd>().get(gainHandle);
38  subtractorPed->init(es);
39  subtractorCMN->init(es);
40 
41  std::string label = findInput(inputRawdigis, inputTokensRawDigi, e);
42  if( "VirginRaw" == label ) vr_process(*inputRawdigis, *output);
43  else if( "ProcessedRaw" == label ) pr_process(*inputRawdigis, *output);
44  else if( "ZeroSuppressed" == findInput(inputDigis, inputTokensDigi, e) ) zs_process(*inputDigis, *output);
45  else
46  edm::LogError("Input Not Found");
47 
48  e.put(std::move(output));
49 }
50 
51 template<class T>
52 inline
54 findInput(edm::Handle<T>& handle, const std::vector<edm::EDGetTokenT<T> >& tokens, const edm::Event& e ) {
55 
56  for( typename std::vector<edm::EDGetTokenT<T> >::const_iterator
57  token = tokens.begin(); token != tokens.end(); ++token ) {
58  unsigned index(token - tokens.begin());
59  e.getByToken(*token, handle);
60  if( handle.isValid() && !handle->empty() ) {
61  edm::LogInfo("Input") << inputTags.at(index);
62  return inputTags.at(index).instance();
63  }
64  }
65  return "Input Not Found";
66 }
67 
70  std::vector<float> digis;
71  for(edm::DetSetVector<SiStripDigi>::const_iterator detset = input.begin(); detset != input.end(); ++detset ) {
72  digis.clear();
73  for(edm::DetSet<SiStripDigi>::const_iterator digi = detset->begin(); digi != detset->end(); ++digi) {
74  digis.resize( digi->strip(), 0);
75  digis.push_back( digi->adc() );
76  }
77  common_process( detset->id, digis, output);
78  }
79 }
80 
83  for(edm::DetSetVector<SiStripRawDigi>::const_iterator detset=input.begin(); detset!=input.end(); ++detset) {
84  std::vector<float> digis;
85  transform(detset->begin(), detset->end(), back_inserter(digis), boost::bind(&SiStripRawDigi::adc , _1));
86  subtractorCMN->subtract(detset->id, 0, digis);
87  common_process( detset->id, digis, output);
88  }
89 }
90 
93  for(edm::DetSetVector<SiStripRawDigi>::const_iterator detset=input.begin(); detset!=input.end(); ++detset) {
94  std::vector<int16_t> int_digis(detset->size());
95  subtractorPed->subtract(*detset,int_digis);
96  std::vector<float> digis(int_digis.begin(), int_digis.end());
97  subtractorCMN->subtract(detset->id, 0, digis);
98  common_process( detset->id, digis, output);
99  }
100 }
101 
103 common_process(const uint32_t detId, std::vector<float> & digis, edm::DetSetVector<SiStripProcessedRawDigi>& output) {
104 
105  //Apply Gains
106  SiStripApvGain::Range detGainRange = gainHandle->getRange(detId);
107  for(std::vector<float>::iterator it=digis.begin(); it<digis.end(); ++it)
108  (*it)/= (gainHandle->getStripGain(it-digis.begin(), detGainRange));
109 
110  //Insert as DetSet
112  copy(digis.begin(), digis.end(), back_inserter(ds.data) );
113  output.insert(ds);
114 }
const uint16_t & adc() const
std::vector< edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > > inputTokensRawDigi
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::unique_ptr< SiStripPedestalsSubtractor > subtractorPed
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)
subtractorPed(SiStripRawProcessingFactory::create_SubtractorPed(conf))
inputTokensRawDigi(edm::vector_transform(inputTags, [this](edm::InputTag const &tag){return consumes< edm::DetSetVector< SiStripRawDigi > >(tag);}))
static std::auto_ptr< SiStripCommonModeNoiseSubtractor > create_SubtractorCMN(const edm::ParameterSet &)
static std::string const input
Definition: EdmProvDump.cc:44
void pr_process(const edm::DetSetVector< SiStripRawDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &)
SiStripProcessedRawDigiProducer(edm::ParameterSet const &)
subtractorCMN(SiStripRawProcessingFactory::create_SubtractorCMN(conf))
def move
Definition: eostools.py:510
tuple handle
Definition: patZpeak.py:22
std::pair< ContainerIterator, ContainerIterator > Range
void common_process(const uint32_t, std::vector< float > &, edm::DetSetVector< SiStripProcessedRawDigi > &)
bool isValid() const
Definition: HandleBase.h:75
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
std::vector< edm::EDGetTokenT< edm::DetSetVector< SiStripDigi > > > inputTokensDigi
void produce(edm::Event &e, const edm::EventSetup &es)
std::unique_ptr< SiStripCommonModeNoiseSubtractor > subtractorCMN
const T & get() const
Definition: EventSetup.h:56
string const
Definition: compareJSON.py:14
void zs_process(const edm::DetSetVector< SiStripDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &)
void insert(detset const &s)
Insert the given DetSet.
Definition: DetSetVector.h:235
collection_type data
Definition: DetSet.h:78
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
static std::auto_ptr< SiStripPedestalsSubtractor > create_SubtractorPed(const edm::ParameterSet &)
void vr_process(const edm::DetSetVector< SiStripRawDigi > &, edm::DetSetVector< SiStripProcessedRawDigi > &)