CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MultiplicityProducer< T > Class Template Reference

#include <DPGAnalysis/SiStripTools/plugins/MultiplicityProducer.cc>

Inheritance diagram for MultiplicityProducer< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 MultiplicityProducer (const edm::ParameterSet &)
 
 ~MultiplicityProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void beginJob () override
 
int detSetMultiplicity (typename T::const_iterator det) const
 
template<>
int detSetMultiplicity (edmNew::DetSetVector< SiStripCluster >::const_iterator det) const
 
template<>
int detSetMultiplicity (edmNew::DetSetVector< SiPixelCluster >::const_iterator det) const
 
void endJob () override
 
int multiplicity (typename T::const_iterator det) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool m_clustersize
 
edm::EDGetTokenT< Tm_collectionToken
 
std::map< unsigned int, std::string > m_subdets
 
std::map< unsigned int, DetIdSelectorm_subdetsels
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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

template<class T>
class MultiplicityProducer< T >

Description: EDProducer of multiplicity maps Implementation:

Definition at line 49 of file MultiplicityProducer.cc.

Constructor & Destructor Documentation

template<class T >
MultiplicityProducer< T >::MultiplicityProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 84 of file MultiplicityProducer.cc.

References edm::ParameterSet::getParameter(), MultiplicityProducer< T >::m_subdets, MultiplicityProducer< T >::m_subdetsels, and AlCaHLTBitMon_QueryRunRegistry::string.

84  :
85  m_collectionToken(consumes<T>(iConfig.getParameter<edm::InputTag>("clusterdigiCollection"))),
86  m_clustersize(iConfig.getUntrackedParameter<bool>("withClusterSize",false)),
88 {
89 
90  produces<std::map<unsigned int,int> >();
91 
92  //now do what ever other initialization is needed
93 
94  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
95 
96  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
97  m_subdets[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
98  m_subdetsels[ps->getParameter<unsigned int>("detSelection")] =
99  DetIdSelector(ps->getUntrackedParameter<std::vector<std::string> >("selection",std::vector<std::string>()));
100  }
101 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< T > m_collectionToken
std::map< unsigned int, DetIdSelector > m_subdetsels
std::map< unsigned int, std::string > m_subdets
template<class T >
MultiplicityProducer< T >::~MultiplicityProducer ( )
override

Definition at line 104 of file MultiplicityProducer.cc.

105 {
106 
107  // do anything here that needs to be done at desctruction time
108  // (e.g. close files, deallocate resources etc.)
109 
110 }

Member Function Documentation

template<class T >
void MultiplicityProducer< T >::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 168 of file MultiplicityProducer.cc.

169 {
170 }
template<class T >
int MultiplicityProducer< T >::detSetMultiplicity ( typename T::const_iterator  det) const
private

Definition at line 202 of file MultiplicityProducer.cc.

Referenced by MultiplicityProducer< T >::multiplicity().

202  {
203 
204  return det->size();
205 
206 }
template<>
int MultiplicityProducer< edmNew::DetSetVector< SiStripCluster > >::detSetMultiplicity ( edmNew::DetSetVector< SiStripCluster >::const_iterator  det) const
private

Definition at line 211 of file MultiplicityProducer.cc.

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

211  {
212 
213  int mult = 0;
214 
215  for(edmNew::DetSet<SiStripCluster>::const_iterator clus=det->begin();clus!=det->end();++clus) {
216 
217  // edm::LogInfo("multiplicitywithcustersize") << "sono qua";
218  mult += clus->amplitudes().size();
219 
220 
221 
222  }
223 
224  return mult;
225 
226 }
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:30
const_iterator begin(bool update=false) const
template<>
int MultiplicityProducer< edmNew::DetSetVector< SiPixelCluster > >::detSetMultiplicity ( edmNew::DetSetVector< SiPixelCluster >::const_iterator  det) const
private

Definition at line 230 of file MultiplicityProducer.cc.

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

230  {
231 
232  int mult = 0;
233 
234  for(edmNew::DetSet<SiPixelCluster>::const_iterator clus=det->begin();clus!=det->end();++clus) {
235 
236  mult += clus->size();
237 
238  }
239 
240  return mult;
241 
242 }
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:30
const_iterator begin(bool update=false) const
template<class T >
void MultiplicityProducer< T >::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 175 of file MultiplicityProducer.cc.

175  {
176 }
template<class T >
int MultiplicityProducer< T >::multiplicity ( typename T::const_iterator  det) const
private

Definition at line 180 of file MultiplicityProducer.cc.

References MultiplicityProducer< T >::detSetMultiplicity(), and MultiplicityProducer< T >::m_clustersize.

Referenced by MultiplicityProducer< T >::produce().

180  {
181 
182  int mult = 0;
183  if(m_clustersize) {
184 
185 
186  // edm::LogInfo("multiplicitywithcustersize") << "sono qua: with size";
187  mult = detSetMultiplicity(det);
188 
189  }
190  else {
191 
192  mult = det->size();
193  // edm::LogInfo("multiplicitywithcustersize") << "sono qua senza size";
194 
195  }
196  return mult;
197 }
int detSetMultiplicity(typename T::const_iterator det) const
template<class T >
void MultiplicityProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 120 of file MultiplicityProducer.cc.

References edm::Event::getByToken(), LogDebug, MultiplicityProducer< T >::m_collectionToken, MultiplicityProducer< T >::m_subdets, MultiplicityProducer< T >::m_subdetsels, eostools::move(), MultiplicityProducer< T >::multiplicity(), edm::Event::put(), and DetId::subdetId().

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

121 {
122 
123  LogDebug("Multiplicity") << " Ready to loop";
124 
125  using namespace edm;
126 
127  std::unique_ptr<std::map<unsigned int,int> > mults(new std::map<unsigned int,int> );
128 
129 
130  Handle<T> digis;
131  iEvent.getByToken(m_collectionToken,digis);
132 
133  for(std::map<unsigned int,std::string>::const_iterator sdet=m_subdets.begin();sdet!=m_subdets.end();++sdet) { (*mults)[sdet->first]=0; }
134 
135 
136  for(typename T::const_iterator det = digis->begin();det!=digis->end();++det) {
137 
138  // if(m_subdets.find(0)!=m_subdets.end()) (*mults)[0]+= det->size();
139  if(m_subdets.find(0)!=m_subdets.end()) (*mults)[0]+= multiplicity(det);
140 
141  DetId detid(det->detId());
142  unsigned int subdet = detid.subdetId();
143 
144  // if(m_subdets.find(subdet)!=m_subdets.end() && !m_subdetsels[subdet].isValid() ) (*mults)[subdet] += det->size();
145  if(m_subdets.find(subdet)!=m_subdets.end() && !m_subdetsels[subdet].isValid() ) (*mults)[subdet] += multiplicity(det);
146 
147  for(std::map<unsigned int,DetIdSelector>::const_iterator detsel=m_subdetsels.begin();detsel!=m_subdetsels.end();++detsel) {
148 
149  // if(detsel->second.isValid() && detsel->second.isSelected(detid)) (*mults)[detsel->first] += det->size();
150  if(detsel->second.isValid() && detsel->second.isSelected(detid)) (*mults)[detsel->first] += multiplicity(det);
151 
152  }
153 
154  }
155 
156 
157  for(std::map<unsigned int,int>::const_iterator it=mults->begin();it!=mults->end();++it) {
158  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first << " " << m_subdets[it->first];
159  }
160 
161  iEvent.put(std::move(mults));
162 
163 }
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
edm::EDGetTokenT< T > m_collectionToken
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
std::map< unsigned int, DetIdSelector > m_subdetsels
int multiplicity(typename T::const_iterator det) const
HLT enums.
std::map< unsigned int, std::string > m_subdets
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<class T >
bool MultiplicityProducer< T >::m_clustersize
private

Definition at line 65 of file MultiplicityProducer.cc.

Referenced by MultiplicityProducer< T >::multiplicity().

template<class T >
edm::EDGetTokenT<T> MultiplicityProducer< T >::m_collectionToken
private

Definition at line 64 of file MultiplicityProducer.cc.

Referenced by MultiplicityProducer< T >::produce().

template<class T >
std::map<unsigned int, std::string> MultiplicityProducer< T >::m_subdets
private
template<class T >
std::map<unsigned int, DetIdSelector> MultiplicityProducer< T >::m_subdetsels
private