CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DPGAnalysis/SiStripTools/interface/Multiplicities.h

Go to the documentation of this file.
00001 #ifndef DPGAnalysis_SiStripTools_Multiplicities_H
00002 #define DPGAnalysis_SiStripTools_Multiplicities_H
00003 
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "DataFormats/Common/interface/DetSetVector.h"
00007 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00008 #include "DataFormats/Common/interface/DetSet.h"
00009 
00010 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
00011 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00012 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00013 
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 
00016 #include "DataFormats/Common/interface/Handle.h"
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
00020 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
00021 
00022 
00023 template <class T>
00024 class SingleMultiplicity {
00025   
00026  public:
00027   SingleMultiplicity();
00028   SingleMultiplicity(const edm::ParameterSet& iConfig);
00029   
00030   
00031   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00032   int mult() const;
00033   //  int mult;
00034   
00035  private:
00036   
00037   edm::InputTag m_collection;
00038   int m_modthr;
00039   bool m_useQuality;
00040   std::string m_qualityLabel;
00041   int m_mult;
00042 };
00043 
00044 template <class T>
00045 SingleMultiplicity<T>::SingleMultiplicity():
00046   //  mult(0), 
00047   m_collection(), m_modthr(-1), m_useQuality(false),  m_qualityLabel(),
00048   m_mult(0)
00049 { }
00050 
00051 template <class T>
00052 SingleMultiplicity<T>::SingleMultiplicity(const edm::ParameterSet& iConfig):
00053   //  mult(0),
00054   m_collection(iConfig.getParameter<edm::InputTag>("collectionName")),
00055   m_modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
00056   m_useQuality(iConfig.getUntrackedParameter<bool>("useQuality",false)),
00057   m_qualityLabel(iConfig.getUntrackedParameter<std::string>("qualityLabel","")),
00058   m_mult(0)
00059 { }
00060 
00061 template <class T>
00062 void
00063 SingleMultiplicity<T>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00064 
00065   m_mult = 0;
00066   //  mult = 0;
00067 
00068   edm::ESHandle<SiStripQuality> qualityHandle;
00069    if( m_useQuality) {
00070      iSetup.get<SiStripQualityRcd>().get(m_qualityLabel,qualityHandle);
00071    }
00072 
00073    edm::Handle<T> digis;
00074    iEvent.getByLabel(m_collection,digis);
00075 
00076 
00077    for(typename T::const_iterator it = digis->begin();it!=digis->end();it++) {
00078 
00079      if(!m_useQuality || !qualityHandle->IsModuleBad(it->detId()) ) {
00080        if(m_modthr < 0 || int(it->size()) < m_modthr ) {
00081          m_mult += it->size();
00082          //      mult += it->size();
00083        }
00084      }
00085    }
00086 }
00087 
00088 
00089 template<class T>
00090 int SingleMultiplicity<T>::mult() const { return m_mult; }
00091 
00092 template <class T1, class T2>
00093   class MultiplicityPair {
00094     
00095  public:
00096     MultiplicityPair();
00097     MultiplicityPair(const edm::ParameterSet& iConfig);
00098     
00099     void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00100     int mult1() const;
00101     int mult2() const;
00102     //    int mult1;
00103     //    int mult2;
00104     
00105  private:
00106     
00107     SingleMultiplicity<T1> m_multiplicity1;
00108     SingleMultiplicity<T2> m_multiplicity2;
00109     
00110   };
00111 
00112 template <class T1, class T2>
00113   MultiplicityPair<T1,T2>::MultiplicityPair():
00114     //    mult1(0),mult2(0),  
00115     m_multiplicity1(),  m_multiplicity2()
00116 { }
00117 
00118 template <class T1, class T2>
00119   MultiplicityPair<T1,T2>::MultiplicityPair(const edm::ParameterSet& iConfig):
00120     //    mult1(0),mult2(0),
00121     m_multiplicity1(iConfig.getParameter<edm::ParameterSet>("firstMultiplicityConfig")),
00122     m_multiplicity2(iConfig.getParameter<edm::ParameterSet>("secondMultiplicityConfig"))
00123 { }
00124 
00125 template <class T1, class T2>
00126   void
00127   MultiplicityPair<T1,T2>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00128   
00129   m_multiplicity1.getEvent(iEvent,iSetup);
00130   m_multiplicity2.getEvent(iEvent,iSetup);
00131 
00132   //  mult1=m_multiplicity1.mult;
00133   //  mult2=m_multiplicity2.mult;
00134   
00135 }
00136 
00137 template<class T1, class T2>
00138   int MultiplicityPair<T1,T2>::mult1() const { return m_multiplicity1.mult(); }
00139 
00140 template<class T1, class T2>
00141   int MultiplicityPair<T1,T2>::mult2() const { return m_multiplicity2.mult(); }
00142 
00143 typedef SingleMultiplicity<edm::DetSetVector<SiStripDigi> > SingleSiStripDigiMultiplicity;
00144 typedef SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > SingleSiStripClusterMultiplicity;
00145 typedef SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> > SingleSiPixelClusterMultiplicity;
00146 typedef MultiplicityPair<edmNew::DetSetVector<SiPixelCluster>,edmNew::DetSetVector<SiStripCluster> > SiPixelClusterSiStripClusterMultiplicityPair; 
00147 
00148 
00149 #endif // DPGAnalysis_SiStripTools_Multiplicities_H