CMS 3D CMS Logo

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::ProductRegistryHelper

List of all members.

Public Member Functions

 MultiplicityProducer (const edm::ParameterSet &)
 ~MultiplicityProducer ()

Private Member Functions

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

Private Attributes

bool m_clustersize
edm::InputTag m_collection
std::map< unsigned int,
std::string > 
m_subdets
std::map< unsigned int,
DetIdSelector
m_subdetsels

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, and MultiplicityProducer< T >::m_subdetsels.

                                                                           :
  m_collection(iConfig.getParameter<edm::InputTag>("clusterdigiCollection")),
  m_clustersize(iConfig.getUntrackedParameter<bool>("withClusterSize",false)),
  m_subdets(),m_subdetsels()
{

  produces<std::map<unsigned int,int> >();

   //now do what ever other initialization is needed

  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
                                             
  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
    m_subdets[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
    m_subdetsels[ps->getParameter<unsigned int>("detSelection")] = 
      DetIdSelector(ps->getUntrackedParameter<std::vector<std::string> >("selection",std::vector<std::string>()));
  }
}
template<class T >
MultiplicityProducer< T >::~MultiplicityProducer ( )

Definition at line 104 of file MultiplicityProducer.cc.

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

}

Member Function Documentation

template<class T >
void MultiplicityProducer< T >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 168 of file MultiplicityProducer.cc.

{
}
template<>
int MultiplicityProducer< edmNew::DetSetVector< SiPixelCluster > >::detSetMultiplicity ( edmNew::DetSetVector< SiPixelCluster >::const_iterator  det) const [private]

Definition at line 230 of file MultiplicityProducer.cc.

References VarParsing::mult.

                                                                                                                                        {

  int mult = 0;
  
  for(edmNew::DetSet<SiPixelCluster>::const_iterator clus=det->begin();clus!=det->end();++clus) {

    mult += clus->size();

  }

  return mult;

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

Definition at line 202 of file MultiplicityProducer.cc.

                                                                              {

  return det->size();

}
template<>
int MultiplicityProducer< edmNew::DetSetVector< SiStripCluster > >::detSetMultiplicity ( edmNew::DetSetVector< SiStripCluster >::const_iterator  det) const [private]

Definition at line 211 of file MultiplicityProducer.cc.

References VarParsing::mult.

                                                                                                                                        {

  int mult = 0;
  
  for(edmNew::DetSet<SiStripCluster>::const_iterator clus=det->begin();clus!=det->end();++clus) {

    //    edm::LogInfo("multiplicitywithcustersize") << "sono qua";
    mult += clus->amplitudes().size();



  }

  return mult;

}
template<class T >
void MultiplicityProducer< T >::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 175 of file MultiplicityProducer.cc.

                                {
}
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.

                                                                        {

  int mult = 0;
  if(m_clustersize) {


    //    edm::LogInfo("multiplicitywithcustersize") << "sono qua: with size";
    mult = detSetMultiplicity(det);

  }
  else {

    mult = det->size();
    //    edm::LogInfo("multiplicitywithcustersize") << "sono qua senza size";

  }
  return mult;
}
template<class T >
void MultiplicityProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 120 of file MultiplicityProducer.cc.

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

{

  LogDebug("Multiplicity") << " Ready to loop";

  using namespace edm;

  std::auto_ptr<std::map<unsigned int,int> > mults(new std::map<unsigned int,int> );
  
  
  Handle<T> digis;
  iEvent.getByLabel(m_collection,digis);
  
  for(std::map<unsigned int,std::string>::const_iterator sdet=m_subdets.begin();sdet!=m_subdets.end();++sdet) { (*mults)[sdet->first]=0; }

  
  for(typename T::const_iterator det = digis->begin();det!=digis->end();++det) {
    
    //    if(m_subdets.find(0)!=m_subdets.end()) (*mults)[0]+= det->size();
    if(m_subdets.find(0)!=m_subdets.end()) (*mults)[0]+= multiplicity(det);

    DetId detid(det->detId());
    unsigned int subdet = detid.subdetId();

    //    if(m_subdets.find(subdet)!=m_subdets.end() && !m_subdetsels[subdet].isValid() ) (*mults)[subdet] += det->size();
    if(m_subdets.find(subdet)!=m_subdets.end() && !m_subdetsels[subdet].isValid() ) (*mults)[subdet] += multiplicity(det);

    for(std::map<unsigned int,DetIdSelector>::const_iterator detsel=m_subdetsels.begin();detsel!=m_subdetsels.end();++detsel) {

      //      if(detsel->second.isValid() && detsel->second.isSelected(detid)) (*mults)[detsel->first] += det->size();
      if(detsel->second.isValid() && detsel->second.isSelected(detid)) (*mults)[detsel->first] += multiplicity(det);

    }

  }
  
  
  for(std::map<unsigned int,int>::const_iterator it=mults->begin();it!=mults->end();++it) {
    LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first << " " << m_subdets[it->first];
  }
  
  iEvent.put(mults);
  
}

Member Data Documentation

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

Definition at line 65 of file MultiplicityProducer.cc.

template<class T >
edm::InputTag MultiplicityProducer< T >::m_collection [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]