CMS 3D CMS Logo

FromClusterSummaryMultiplicityProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FromClusterSummaryMultiplicityProducer
4 // Class: FromClusterSummaryMultiplicityProducer
5 //
12 //
13 // Original Author: Andrea Venturi
14 // Created: Fri Dec 04 2009
15 //
16 //
17 
18 // system include files
19 #include <memory>
20 #include <string>
21 #include <map>
22 #include <vector>
23 
24 // user include files
27 
30 
34 
36 
37 //
38 // class decleration
39 //
41 public:
43 
44 private:
45  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
46 
47  // ----------member data ---------------------------
48 
50  std::vector<ClusterSummary::CMSTracker> m_subdetenums;
51  std::vector<int> m_subdetsel;
53 };
54 
55 //
56 // constants, enums and typedefs
57 //
58 
59 //
60 // static data member definitions
61 //
62 
63 //
64 // constructors and destructor
65 //
67  : m_collectionToken(consumes<ClusterSummary>(iConfig.getParameter<edm::InputTag>("clusterSummaryCollection"))),
68  m_subdetenums(),
69  m_subdetsel(),
70  m_subdetvar(ClusterSummary::NCLUSTERS) {
71  produces<std::map<unsigned int, int> >();
72 
73  //now do what ever other initialization is needed
74 
75  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
76  m_subdetenums.reserve(wantedsubds.size());
77  m_subdetsel.reserve(wantedsubds.size());
78 
79  for (std::vector<edm::ParameterSet>::iterator ps = wantedsubds.begin(); ps != wantedsubds.end(); ++ps) {
80  m_subdetenums.push_back((ClusterSummary::CMSTracker)ps->getParameter<int>("subDetEnum"));
81  m_subdetsel.push_back(ps->getParameter<int>("subDetEnum"));
82  }
84 }
85 
86 //
87 // member functions
88 //
89 
90 // ------------ method called to produce the data ------------
93  const edm::EventSetup& iSetup) const {
94  LogDebug("Multiplicity") << " Ready to go";
95 
96  using namespace edm;
97 
98  std::unique_ptr<std::map<unsigned int, int> > mults(new std::map<unsigned int, int>);
99 
100  Handle<ClusterSummary> clustsumm;
101  iEvent.getByToken(m_collectionToken, clustsumm);
102 
103  switch (m_subdetvar) {
105  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
106  (*mults)[m_subdetsel[iS]] = int(clustsumm->getNClus(m_subdetenums[iS]));
107  break;
109  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
110  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusSize(m_subdetenums[iS]));
111  break;
113  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
114  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusCharge(m_subdetenums[iS]));
115  break;
116  default:
117  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
118  (*mults)[m_subdetsel[iS]] = -1;
119  }
120 
121  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
122  LogDebug("Multiplicity") << "GetModuleLocation result: " << m_subdetenums[iS] << " "
123  << clustsumm->getModuleLocation(m_subdetenums[iS]);
124 
125  for (std::map<unsigned int, int>::const_iterator it = mults->begin(); it != mults->end(); ++it) {
126  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first;
127  }
128 
129  iEvent.put(std::move(mults));
130 }
131 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int getClusSize(const CMSTracker mod) const
float getClusCharge(const CMSTracker mod) const
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< ClusterSummary::CMSTracker > m_subdetenums
int getNClus(const CMSTracker mod) const
HLT enums.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int getModuleLocation(int mod, bool warn=true) const
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)