CMS 3D CMS Logo

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

#include <RecoLocalTracker/SiStripMeanCMExtractor/src/SiStripMeanCMExtractor.cc>

Inheritance diagram for SiStripMeanCMExtractor:
edm::one::EDProducer<> edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 SiStripMeanCMExtractor (const edm::ParameterSet &)
 
 ~SiStripMeanCMExtractor ()
 
- Public Member Functions inherited from edm::one::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

virtual void beginJob () override
 
void CMExtractorFromPedestals (const edm::DetSetVector< SiStripRawDigi > &, std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
 
void ConvertMeanMapToDetSetVector (std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
 
virtual void endJob () override
 
void init (const edm::EventSetup &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 
void StoreMean (const edm::DetSetVector< SiStripProcessedRawDigi > &)
 

Private Attributes

uint16_t _actualEvent
 
std::string _Algorithm
 
CMMap _CMMap
 
edm::InputTag _inputTag
 
uint16_t _nEventsToUse
 
uint32_t pedestal_cache_id_
 
edm::ESHandle< SiStripPedestalspedestalHandle_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase 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::one::EDProducerBase
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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 53 of file SiStripMeanCMExtractor.cc.

Constructor & Destructor Documentation

SiStripMeanCMExtractor::SiStripMeanCMExtractor ( const edm::ParameterSet conf)
explicit

Definition at line 80 of file SiStripMeanCMExtractor.cc.

References _nEventsToUse.

80  :
81  _inputTag(conf.getParameter<edm::InputTag> ("CMCollection")),
82  _Algorithm(conf.getParameter<std::string>("Algorithm")),
83  _nEventsToUse(conf.getParameter<uint32_t>("NEvents"))
84 {
85 
86 
87  if(_nEventsToUse < 1) _nEventsToUse=1;
88  produces< edm::DetSetVector<SiStripProcessedRawDigi> > ("MEANAPVCM");
89 }
T getParameter(std::string const &) const
SiStripMeanCMExtractor::~SiStripMeanCMExtractor ( )

Definition at line 92 of file SiStripMeanCMExtractor.cc.

93 {
94 
95 }

Member Function Documentation

void SiStripMeanCMExtractor::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 210 of file SiStripMeanCMExtractor.cc.

References _actualEvent, and _CMMap.

211 {
212  _actualEvent =1;
213 
214  _CMMap.clear();
215 
216 }
void SiStripMeanCMExtractor::CMExtractorFromPedestals ( const edm::DetSetVector< SiStripRawDigi > &  input,
std::vector< edm::DetSet< SiStripProcessedRawDigi > > &  meancm 
)
private

Definition at line 143 of file SiStripMeanCMExtractor.cc.

References sistrip::APV, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), SiStripPedestals::getPed(), SiStripPedestals::getRange(), pedestalHandle_, edm::DetSet< T >::push_back(), and digi_MixPreMix_cfi::strip.

Referenced by produce().

143  {
144  meancm.clear();
145  meancm.reserve(15000);
146 
148  rawDigis = input.begin(); rawDigis != input.end(); rawDigis++) {
149  SiStripPedestals::Range detPedestalRange = pedestalHandle_->getRange(rawDigis->id);
150  edm::DetSet<SiStripProcessedRawDigi> MeanCMDetSet(rawDigis->id);
151 
152  for(uint16_t APV = 0; APV < rawDigis->size()/128; ++APV){
153  uint16_t MinPed =0;
154  for(uint16_t strip = APV*128; strip< (APV+1)*128; ++strip){
155  uint16_t ped = (uint16_t)pedestalHandle_->getPed(strip,detPedestalRange);
156  if(ped < MinPed) MinPed = ped;
157  }
158  if(MinPed>128) MinPed=128;
159  MeanCMDetSet.push_back(MinPed);
160  }
161 
162  meancm.push_back(MeanCMDetSet);
163  }
164 }
std::pair< ContainerIterator, ContainerIterator > Range
edm::ESHandle< SiStripPedestals > pedestalHandle_
float getPed(const uint16_t &strip, const Range &range) const
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:346
const Range getRange(const uint32_t &detID) const
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
void SiStripMeanCMExtractor::ConvertMeanMapToDetSetVector ( std::vector< edm::DetSet< SiStripProcessedRawDigi > > &  meancm)
private

Definition at line 195 of file SiStripMeanCMExtractor.cc.

References _actualEvent, _CMMap, end, and edm::DetSet< T >::push_back().

Referenced by produce().

195  {
196  CMMap::iterator itMap;
197  std::vector<float>::const_iterator itMapVector;
198 
199  meancm.clear();
200  meancm.reserve(15000);
201 
202  for(itMap = _CMMap.begin(); itMap != _CMMap.end(); ++itMap){
203  edm::DetSet<SiStripProcessedRawDigi> MeanCMDetSet(itMap->first);
204  for(itMapVector = (itMap->second).begin(); itMapVector != (itMap->second).end(); ++itMapVector) MeanCMDetSet.push_back(*itMapVector/(float)_actualEvent);
205  meancm.push_back(MeanCMDetSet);
206  }
207 
208 }
#define end
Definition: vmac.h:37
void SiStripMeanCMExtractor::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 219 of file SiStripMeanCMExtractor.cc.

References DEFINE_FWK_MODULE.

219  {
220 
221 
222 }
void SiStripMeanCMExtractor::init ( const edm::EventSetup es)
private

Definition at line 97 of file SiStripMeanCMExtractor.cc.

References edm::EventSetup::get(), pedestal_cache_id_, and pedestalHandle_.

Referenced by produce().

97  {
98 
99  uint32_t p_cache_id = es.get<SiStripPedestalsRcd>().cacheIdentifier();
100 
101  if(p_cache_id != pedestal_cache_id_) {
103  pedestal_cache_id_ = p_cache_id;
104  }
105 }
edm::ESHandle< SiStripPedestals > pedestalHandle_
const T & get() const
Definition: EventSetup.h:56
void SiStripMeanCMExtractor::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Definition at line 109 of file SiStripMeanCMExtractor.cc.

References _actualEvent, _Algorithm, _inputTag, CMExtractorFromPedestals(), ConvertMeanMapToDetSetVector(), edm::Event::getByLabel(), init(), input, edm::Event::put(), and StoreMean().

110 {
111  using namespace edm;
112 
113 
114  //if(_actualEvent > _nEventsToUse) return;
115 
116  std::vector<edm::DetSet<SiStripProcessedRawDigi> > meancm;
117 
118  if(_Algorithm == "StoredCM"){
120  iEvent.getByLabel(_inputTag,inputCM);
121 
122  this->StoreMean(*inputCM);
123  this->ConvertMeanMapToDetSetVector(meancm);
124 
125  } else if (_Algorithm == "Pedestals"){
126  this->init(iSetup);
127 
129  iEvent.getByLabel(_inputTag,input);
130 
131  this->CMExtractorFromPedestals(*input,meancm);
132  }
133 
134  ++_actualEvent;
135 
136 
137 
138 
139  iEvent.put(std::make_unique<edm::DetSetVector<SiStripProcessedRawDigi>>(meancm),"MEANAPVCM");
140 
141 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void ConvertMeanMapToDetSetVector(std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
static std::string const input
Definition: EdmProvDump.cc:44
void init(const edm::EventSetup &)
void StoreMean(const edm::DetSetVector< SiStripProcessedRawDigi > &)
void CMExtractorFromPedestals(const edm::DetSetVector< SiStripRawDigi > &, std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
HLT enums.
void SiStripMeanCMExtractor::StoreMean ( const edm::DetSetVector< SiStripProcessedRawDigi > &  Input)
private

Definition at line 166 of file SiStripMeanCMExtractor.cc.

References _CMMap, edm::DetSetVector< T >::begin(), and edm::DetSetVector< T >::end().

Referenced by produce().

166  {
167 
168  uint32_t detId;
169  CMMap::iterator itMap;
171 
172  for(itInput = Input.begin(); itInput != Input.end(); ++itInput){
173  detId = itInput->id;
174  itMap = _CMMap.find(detId);
176  std::vector<float> MeanCMNValue;
177  MeanCMNValue.clear();
178  if(itMap!=_CMMap.end()){ //the detId was already found
179  std::vector< float >& MapContent = itMap->second;
180  std::vector<float>::iterator itMapVector = MapContent.begin();
181  for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM, ++itMapVector){
182  MeanCMNValue.push_back(itCM->adc() + *itMapVector);
183  }
184  _CMMap.erase(itMap);
185  _CMMap.insert(itMap, std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
186  } else { //no detId found
187  for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM) MeanCMNValue.push_back(itCM->adc());
188  _CMMap.insert(std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
189  }
190  }
191 
192 }
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
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

Member Data Documentation

uint16_t SiStripMeanCMExtractor::_actualEvent
private

Definition at line 74 of file SiStripMeanCMExtractor.cc.

Referenced by beginJob(), ConvertMeanMapToDetSetVector(), and produce().

std::string SiStripMeanCMExtractor::_Algorithm
private

Definition at line 72 of file SiStripMeanCMExtractor.cc.

Referenced by produce().

CMMap SiStripMeanCMExtractor::_CMMap
private

Definition at line 76 of file SiStripMeanCMExtractor.cc.

Referenced by beginJob(), ConvertMeanMapToDetSetVector(), and StoreMean().

edm::InputTag SiStripMeanCMExtractor::_inputTag
private

Definition at line 71 of file SiStripMeanCMExtractor.cc.

Referenced by produce().

uint16_t SiStripMeanCMExtractor::_nEventsToUse
private

Definition at line 73 of file SiStripMeanCMExtractor.cc.

Referenced by SiStripMeanCMExtractor().

uint32_t SiStripMeanCMExtractor::pedestal_cache_id_
private

Definition at line 66 of file SiStripMeanCMExtractor.cc.

Referenced by init().

edm::ESHandle<SiStripPedestals> SiStripMeanCMExtractor::pedestalHandle_
private

Definition at line 65 of file SiStripMeanCMExtractor.cc.

Referenced by CMExtractorFromPedestals(), and init().