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
SiStripMeanCMExtractor Class Reference

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

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

Public Member Functions

 SiStripMeanCMExtractor (const edm::ParameterSet &)
 
 ~SiStripMeanCMExtractor ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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 (const std::string &iProcessName, std::vector< const char * > &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

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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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::EDProducer.

Definition at line 211 of file SiStripMeanCMExtractor.cc.

References _actualEvent, and _CMMap.

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

Definition at line 144 of file SiStripMeanCMExtractor.cc.

References sistrip::APV, edm::DetSetVector< T >::begin(), edm::DetSetVector< T >::end(), pedestalHandle_, and edm::DetSet< T >::push_back().

Referenced by produce().

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

Definition at line 196 of file SiStripMeanCMExtractor.cc.

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

Referenced by produce().

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

Reimplemented from edm::EDProducer.

Definition at line 220 of file SiStripMeanCMExtractor.cc.

220  {
221 
222 
223 }
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:55
void SiStripMeanCMExtractor::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

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  std::auto_ptr< edm::DetSetVector<SiStripProcessedRawDigi> > outputMeanCM(new edm::DetSetVector<SiStripProcessedRawDigi>(meancm) );
140  iEvent.put( outputMeanCM,"MEANAPVCM");
141 
142 }
void ConvertMeanMapToDetSetVector(std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
static std::string const input
Definition: EdmProvDump.cc:43
void init(const edm::EventSetup &)
void StoreMean(const edm::DetSetVector< SiStripProcessedRawDigi > &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
void CMExtractorFromPedestals(const edm::DetSetVector< SiStripRawDigi > &, std::vector< edm::DetSet< SiStripProcessedRawDigi > > &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
void SiStripMeanCMExtractor::StoreMean ( const edm::DetSetVector< SiStripProcessedRawDigi > &  Input)
private

Definition at line 167 of file SiStripMeanCMExtractor.cc.

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

Referenced by produce().

167  {
168 
169  uint32_t detId;
170  CMMap::iterator itMap;
172 
173  for(itInput = Input.begin(); itInput != Input.end(); ++itInput){
174  detId = itInput->id;
175  itMap = _CMMap.find(detId);
177  std::vector<float> MeanCMNValue;
178  MeanCMNValue.clear();
179  if(itMap!=_CMMap.end()){ //the detId was already found
180  std::vector< float >& MapContent = itMap->second;
181  std::vector<float>::iterator itMapVector = MapContent.begin();
182  for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM, ++itMapVector){
183  MeanCMNValue.push_back(itCM->adc() + *itMapVector);
184  }
185  _CMMap.erase(itMap);
186  _CMMap.insert(itMap, std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
187  } else { //no detId found
188  for(itCM = itInput->begin(); itCM != itInput->end(); ++itCM) MeanCMNValue.push_back(itCM->adc());
189  _CMMap.insert(std::pair<uint32_t, std::vector<float> >(detId,MeanCMNValue));
190  }
191  }
192 
193 }
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:365
iterator begin()
Return an iterator to the first DetSet.
Definition: DetSetVector.h:350
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:108

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