Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:58

0001 #ifndef DPGAnalysis_SiStripTools_Multiplicities_H
0002 #define DPGAnalysis_SiStripTools_Multiplicities_H
0003 
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "FWCore/Framework/interface/ConsumesCollector.h"
0007 #include "CalibTracker/Records/interface/SiStripQualityRcd.h"
0008 
0009 #include "DataFormats/Common/interface/DetSetVector.h"
0010 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0011 #include "DataFormats/Common/interface/DetSet.h"
0012 
0013 #include "DataFormats/SiStripDigi/interface/SiStripDigi.h"
0014 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0015 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0016 #include "DataFormats/TrackerCommon/interface/ClusterSummary.h"
0017 
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 
0020 #include "DataFormats/Common/interface/Handle.h"
0021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0022 #include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"
0023 
0024 namespace edm {
0025   class EventSetup;
0026 };
0027 
0028 #include <string>
0029 
0030 class ClusterSummarySingleMultiplicity {
0031 public:
0032   ClusterSummarySingleMultiplicity();
0033   ClusterSummarySingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
0034   ClusterSummarySingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC);
0035 
0036   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0037   int mult() const;
0038 
0039 private:
0040   ClusterSummary::CMSTracker m_subdetenum;
0041   ClusterSummary::VariablePlacement m_varenum;
0042   int m_mult;
0043   edm::EDGetTokenT<ClusterSummary> m_collection;
0044 };
0045 
0046 template <class T>
0047 class SingleMultiplicity {
0048 public:
0049   SingleMultiplicity();
0050   SingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
0051   SingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC);
0052 
0053   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0054   int mult() const;
0055   //  int mult;
0056 
0057 private:
0058   int m_modthr;
0059   bool m_useQuality;
0060   edm::ESGetToken<SiStripQuality, SiStripQualityRcd> m_qualityToken;
0061   int m_mult;
0062   edm::EDGetTokenT<T> m_collection;
0063 };
0064 
0065 template <class T>
0066 SingleMultiplicity<T>::SingleMultiplicity() : m_modthr(-1), m_useQuality(false), m_mult(0), m_collection() {}
0067 
0068 template <class T>
0069 SingleMultiplicity<T>::SingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0070     : m_modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
0071       m_useQuality(iConfig.getUntrackedParameter<bool>("useQuality", false)),
0072       m_qualityToken(m_useQuality
0073                          ? decltype(m_qualityToken){iC.esConsumes<SiStripQuality, SiStripQualityRcd>(
0074                                edm::ESInputTag{"", iConfig.getUntrackedParameter<std::string>("qualityLabel", "")})}
0075                          : decltype(m_qualityToken){}),
0076       m_mult(0),
0077       m_collection(iC.consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))) {}
0078 template <class T>
0079 SingleMultiplicity<T>::SingleMultiplicity(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC)
0080     : m_modthr(iConfig.getUntrackedParameter<int>("moduleThreshold")),
0081       m_useQuality(iConfig.getUntrackedParameter<bool>("useQuality", false)),
0082       m_qualityToken(m_useQuality
0083                          ? decltype(m_qualityToken){iC.esConsumes<SiStripQuality, SiStripQualityRcd>(
0084                                edm::ESInputTag(iConfig.getUntrackedParameter<std::string>("qualityLabel", "")))}
0085                          : decltype(m_qualityToken){}),
0086       m_mult(0),
0087       m_collection(iC.consumes<T>(iConfig.getParameter<edm::InputTag>("collectionName"))) {}
0088 
0089 template <class T>
0090 void SingleMultiplicity<T>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0091   m_mult = 0;
0092 
0093   const SiStripQuality* quality = nullptr;
0094   if (m_useQuality) {
0095     quality = &iSetup.getData(m_qualityToken);
0096   }
0097 
0098   edm::Handle<T> digis;
0099   iEvent.getByToken(m_collection, digis);
0100 
0101   for (typename T::const_iterator it = digis->begin(); it != digis->end(); it++) {
0102     if (!m_useQuality || !quality->IsModuleBad(it->detId())) {
0103       if (m_modthr < 0 || int(it->size()) < m_modthr) {
0104         m_mult += it->size();
0105         //      mult += it->size();
0106       }
0107     }
0108   }
0109 }
0110 
0111 template <class T>
0112 int SingleMultiplicity<T>::mult() const {
0113   return m_mult;
0114 }
0115 
0116 template <class T1, class T2>
0117 class MultiplicityPair {
0118 public:
0119   MultiplicityPair();
0120   MultiplicityPair(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC);
0121   MultiplicityPair(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC);
0122 
0123   void getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup);
0124   int mult1() const;
0125   int mult2() const;
0126 
0127 private:
0128   T1 m_multiplicity1;
0129   T2 m_multiplicity2;
0130 };
0131 
0132 template <class T1, class T2>
0133 MultiplicityPair<T1, T2>::MultiplicityPair() : m_multiplicity1(), m_multiplicity2() {}
0134 
0135 template <class T1, class T2>
0136 MultiplicityPair<T1, T2>::MultiplicityPair(const edm::ParameterSet& iConfig, edm::ConsumesCollector&& iC)
0137     : m_multiplicity1(iConfig.getParameter<edm::ParameterSet>("firstMultiplicityConfig"), iC),
0138       m_multiplicity2(iConfig.getParameter<edm::ParameterSet>("secondMultiplicityConfig"), iC) {}
0139 template <class T1, class T2>
0140 MultiplicityPair<T1, T2>::MultiplicityPair(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC)
0141     : m_multiplicity1(iConfig.getParameter<edm::ParameterSet>("firstMultiplicityConfig"), iC),
0142       m_multiplicity2(iConfig.getParameter<edm::ParameterSet>("secondMultiplicityConfig"), iC) {}
0143 
0144 template <class T1, class T2>
0145 void MultiplicityPair<T1, T2>::getEvent(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0146   m_multiplicity1.getEvent(iEvent, iSetup);
0147   m_multiplicity2.getEvent(iEvent, iSetup);
0148 }
0149 
0150 template <class T1, class T2>
0151 int MultiplicityPair<T1, T2>::mult1() const {
0152   return m_multiplicity1.mult();
0153 }
0154 
0155 template <class T1, class T2>
0156 int MultiplicityPair<T1, T2>::mult2() const {
0157   return m_multiplicity2.mult();
0158 }
0159 
0160 typedef SingleMultiplicity<edm::DetSetVector<SiStripDigi> > SingleSiStripDigiMultiplicity;
0161 typedef SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > SingleSiStripClusterMultiplicity;
0162 typedef SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> > SingleSiPixelClusterMultiplicity;
0163 typedef MultiplicityPair<SingleMultiplicity<edmNew::DetSetVector<SiPixelCluster> >,
0164                          SingleMultiplicity<edmNew::DetSetVector<SiStripCluster> > >
0165     SiPixelClusterSiStripClusterMultiplicityPair;
0166 typedef MultiplicityPair<ClusterSummarySingleMultiplicity, ClusterSummarySingleMultiplicity>
0167     ClusterSummaryMultiplicityPair;
0168 
0169 #endif  // DPGAnalysis_SiStripTools_Multiplicities_H