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
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 ()
 
- 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
 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
 
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
 
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
 
virtual void endJob () override
 
int multiplicity (typename T::const_iterator det) const
 
virtual 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,
DetIdSelector
m_subdetsels
 

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

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

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.

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(), edmNew::DetSetVector< T >::end(), and VarParsing::mult.

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(), edmNew::DetSetVector< T >::end(), and VarParsing::mult.

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 VarParsing::mult.

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 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 120 of file MultiplicityProducer.cc.

References cond::rpcobgas::detid, edm::Event::getByToken(), LogDebug, and edm::Event::put().

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::auto_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(mults);
162 
163 }
#define LogDebug(id)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
edm::EDGetTokenT< T > m_collectionToken
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
Definition: DetId.h:18
std::map< unsigned int, DetIdSelector > m_subdetsels
int multiplicity(typename T::const_iterator det) const
std::map< unsigned int, std::string > m_subdets

Member Data Documentation

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

Definition at line 65 of file MultiplicityProducer.cc.

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

Definition at line 64 of file MultiplicityProducer.cc.

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