CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/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 #include <string>
00023 
00024 class ClusterSummarySingleMultiplicity {
00025 
00026  public:
00027   ClusterSummarySingleMultiplicity();
00028   ClusterSummarySingleMultiplicity(const edm::ParameterSet& iConfig);
00029 
00030   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00031   int mult() const;
00032 
00033  private:
00034   edm::InputTag m_collection;
00035   int m_subdetenum;
00036   std::string m_subdetvar;
00037   std::vector<std::string> m_clustsummvar;
00038   int m_mult;
00039     
00040 };
00041 
00042 
00043 
00044 template <class T>
00045 class SingleMultiplicity {
00046   
00047  public:
00048   SingleMultiplicity();
00049   SingleMultiplicity(const edm::ParameterSet& iConfig);
00050   
00051   
00052   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00053   int mult() const;
00054   //  int mult;
00055   
00056  private:
00057   
00058   edm::InputTag m_collection;
00059   int m_modthr;
00060   bool m_useQuality;
00061   std::string m_qualityLabel;
00062   int m_mult;
00063 };
00064 
00065 template <class T>
00066 SingleMultiplicity<T>::SingleMultiplicity():
00067   //  mult(0), 
00068   m_collection(), m_modthr(-1), m_useQuality(false),  m_qualityLabel(),
00069   m_mult(0)
00070 { }
00071 
00072 template <class T>
00073 SingleMultiplicity<T>::SingleMultiplicity(const edm::ParameterSet& iConfig):
00074   //  mult(0),
00075   m_collection(iConfig.getParameter<edm::InputTag>("collectionName")),
00076   m_modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
00077   m_useQuality(iConfig.getUntrackedParameter<bool>("useQuality",false)),
00078   m_qualityLabel(iConfig.getUntrackedParameter<std::string>("qualityLabel","")),
00079   m_mult(0)
00080 { }
00081 
00082 template <class T>
00083 void
00084 SingleMultiplicity<T>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00085 
00086   m_mult = 0;
00087   //  mult = 0;
00088 
00089   edm::ESHandle<SiStripQuality> qualityHandle;
00090    if( m_useQuality) {
00091      iSetup.get<SiStripQualityRcd>().get(m_qualityLabel,qualityHandle);
00092    }
00093 
00094    edm::Handle<T> digis;
00095    iEvent.getByLabel(m_collection,digis);
00096 
00097 
00098    for(typename T::const_iterator it = digis->begin();it!=digis->end();it++) {
00099 
00100      if(!m_useQuality || !qualityHandle->IsModuleBad(it->detId()) ) {
00101        if(m_modthr < 0 || int(it->size()) < m_modthr ) {
00102          m_mult += it->size();
00103          //      mult += it->size();
00104        }
00105      }
00106    }
00107 }
00108 
00109 
00110 template<class T>
00111 int SingleMultiplicity<T>::mult() const { return m_mult; }
00112 
00113 template <class T1, class T2>
00114   class MultiplicityPair {
00115     
00116  public:
00117     MultiplicityPair();
00118     MultiplicityPair(const edm::ParameterSet& iConfig);
00119     
00120     void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
00121     int mult1() const;
00122     int mult2() const;
00123     //    int mult1;
00124     //    int mult2;
00125     
00126  private:
00127     
00128     T1 m_multiplicity1;
00129     T2 m_multiplicity2;
00130     
00131   };
00132 
00133 template <class T1, class T2>
00134   MultiplicityPair<T1,T2>::MultiplicityPair():
00135     //    mult1(0),mult2(0),  
00136     m_multiplicity1(),  m_multiplicity2()
00137 { }
00138 
00139 template <class T1, class T2>
00140   MultiplicityPair<T1,T2>::MultiplicityPair(const edm::ParameterSet& iConfig):
00141     //    mult1(0),mult2(0),
00142     m_multiplicity1(iConfig.getParameter<edm::ParameterSet>("firstMultiplicityConfig")),
00143     m_multiplicity2(iConfig.getParameter<edm::ParameterSet>("secondMultiplicityConfig"))
00144 { }
00145 
00146 template <class T1, class T2>
00147   void
00148   MultiplicityPair<T1,T2>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00149   
00150   m_multiplicity1.getEvent(iEvent,iSetup);
00151   m_multiplicity2.getEvent(iEvent,iSetup);
00152 
00153   //  mult1=m_multiplicity1.mult;
00154   //  mult2=m_multiplicity2.mult;
00155   
00156 }
00157 
00158 template<class T1, class T2>
00159   int MultiplicityPair<T1,T2>::mult1() const { return m_multiplicity1.mult(); }
00160 
00161 template<class T1, class T2>
00162   int MultiplicityPair<T1,T2>::mult2() const { return m_multiplicity2.mult(); }
00163 
00164 typedef SingleMultiplicity<edm::DetSetVector<SiStripDigi> > SingleSiStripDigiMultiplicity;
00165 typedef SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > SingleSiStripClusterMultiplicity;
00166 typedef SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> > SingleSiPixelClusterMultiplicity;
00167 typedef MultiplicityPair<SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> > ,SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > > 
00168 SiPixelClusterSiStripClusterMultiplicityPair; 
00169 typedef MultiplicityPair<ClusterSummarySingleMultiplicity,ClusterSummarySingleMultiplicity> ClusterSummaryMultiplicityPair; 
00170 
00171 
00172 #endif // DPGAnalysis_SiStripTools_Multiplicities_H