CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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,
DetIdSelector
m_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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

template<class T>
class MultiplicityProducer< T >

Description: EDProducer of multiplicity maps Implementation:

Definition at line 48 of file MultiplicityProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 80 of file MultiplicityProducer.cc.

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

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

Definition at line 99 of file MultiplicityProducer.cc.

99  {
100  // do anything here that needs to be done at desctruction time
101  // (e.g. close files, deallocate resources etc.)
102 }

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 155 of file MultiplicityProducer.cc.

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

Definition at line 176 of file MultiplicityProducer.cc.

176  {
177  return det->size();
178 }
template<>
int MultiplicityProducer< edmNew::DetSetVector< SiStripCluster > >::detSetMultiplicity ( edmNew::DetSetVector< SiStripCluster >::const_iterator  det) const
private

Definition at line 181 of file MultiplicityProducer.cc.

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

182  {
183  int mult = 0;
184 
185  for (edmNew::DetSet<SiStripCluster>::const_iterator clus = det->begin(); clus != det->end(); ++clus) {
186  // edm::LogInfo("multiplicitywithcustersize") << "sono qua";
187  mult += clus->amplitudes().size();
188  }
189 
190  return mult;
191 }
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:31
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 194 of file MultiplicityProducer.cc.

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

195  {
196  int mult = 0;
197 
198  for (edmNew::DetSet<SiPixelCluster>::const_iterator clus = det->begin(); clus != det->end(); ++clus) {
199  mult += clus->size();
200  }
201 
202  return mult;
203 }
const_iterator end(bool update=false) const
data_type const * const_iterator
Definition: DetSetNew.h:31
const_iterator begin(bool update=false) const
template<class T >
void MultiplicityProducer< T >::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 159 of file MultiplicityProducer.cc.

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

Definition at line 162 of file MultiplicityProducer.cc.

References VarParsing::mult.

162  {
163  int mult = 0;
164  if (m_clustersize) {
165  // edm::LogInfo("multiplicitywithcustersize") << "sono qua: with size";
166  mult = detSetMultiplicity(det);
167 
168  } else {
169  mult = det->size();
170  // edm::LogInfo("multiplicitywithcustersize") << "sono qua senza size";
171  }
172  return mult;
173 }
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 110 of file MultiplicityProducer.cc.

References edm::Event::getByToken(), LogDebug, eostools::move(), edm::Event::put(), and DetId::subdetId().

110  {
111  LogDebug("Multiplicity") << " Ready to loop";
112 
113  using namespace edm;
114 
115  std::unique_ptr<std::map<unsigned int, int> > mults(new std::map<unsigned int, int>);
116 
117  Handle<T> digis;
118  iEvent.getByToken(m_collectionToken, digis);
119 
120  for (std::map<unsigned int, std::string>::const_iterator sdet = m_subdets.begin(); sdet != m_subdets.end(); ++sdet) {
121  (*mults)[sdet->first] = 0;
122  }
123 
124  for (typename T::const_iterator det = digis->begin(); det != digis->end(); ++det) {
125  // if(m_subdets.find(0)!=m_subdets.end()) (*mults)[0]+= det->size();
126  if (m_subdets.find(0) != m_subdets.end())
127  (*mults)[0] += multiplicity(det);
128 
129  DetId detid(det->detId());
130  unsigned int subdet = detid.subdetId();
131 
132  // if(m_subdets.find(subdet)!=m_subdets.end() && !m_subdetsels[subdet].isValid() ) (*mults)[subdet] += det->size();
133  if (m_subdets.find(subdet) != m_subdets.end() && !m_subdetsels[subdet].isValid())
134  (*mults)[subdet] += multiplicity(det);
135 
136  for (std::map<unsigned int, DetIdSelector>::const_iterator detsel = m_subdetsels.begin();
137  detsel != m_subdetsels.end();
138  ++detsel) {
139  // if(detsel->second.isValid() && detsel->second.isSelected(detid)) (*mults)[detsel->first] += det->size();
140  if (detsel->second.isValid() && detsel->second.isSelected(detid))
141  (*mults)[detsel->first] += multiplicity(det);
142  }
143  }
144 
145  for (std::map<unsigned int, int>::const_iterator it = mults->begin(); it != mults->end(); ++it) {
146  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first << " "
147  << m_subdets[it->first];
148  }
149 
150  iEvent.put(std::move(mults));
151 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< T > m_collectionToken
def move
Definition: eostools.py:511
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: DetId.h:17
std::map< unsigned int, DetIdSelector > m_subdetsels
int multiplicity(typename T::const_iterator det) const
std::map< unsigned int, std::string > m_subdets
#define LogDebug(id)

Member Data Documentation

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

Definition at line 63 of file MultiplicityProducer.cc.

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

Definition at line 62 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