CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
44 
45 private:
46  void beginJob() override;
47  void produce(edm::Event&, const edm::EventSetup&) override;
48  void endJob() override;
49 
50  // ----------member data ---------------------------
51 
53  std::vector<ClusterSummary::CMSTracker> m_subdetenums;
54  std::vector<int> m_subdetsel;
56 };
57 
58 //
59 // constants, enums and typedefs
60 //
61 
62 //
63 // static data member definitions
64 //
65 
66 //
67 // constructors and destructor
68 //
70  : m_collectionToken(consumes<ClusterSummary>(iConfig.getParameter<edm::InputTag>("clusterSummaryCollection"))),
71  m_subdetenums(),
72  m_subdetsel(),
73  m_subdetvar(ClusterSummary::NCLUSTERS) {
74  produces<std::map<unsigned int, int> >();
75 
76  //now do what ever other initialization is needed
77 
78  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
79  m_subdetenums.reserve(wantedsubds.size());
80  m_subdetsel.reserve(wantedsubds.size());
81 
82  for (std::vector<edm::ParameterSet>::iterator ps = wantedsubds.begin(); ps != wantedsubds.end(); ++ps) {
83  m_subdetenums.push_back((ClusterSummary::CMSTracker)ps->getParameter<int>("subDetEnum"));
84  m_subdetsel.push_back(ps->getParameter<int>("subDetEnum"));
85  }
87 }
88 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 }
93 
94 //
95 // member functions
96 //
97 
98 // ------------ method called to produce the data ------------
100  LogDebug("Multiplicity") << " Ready to go";
101 
102  using namespace edm;
103 
104  std::unique_ptr<std::map<unsigned int, int> > mults(new std::map<unsigned int, int>);
105 
106  Handle<ClusterSummary> clustsumm;
107  iEvent.getByToken(m_collectionToken, clustsumm);
108 
109  switch (m_subdetvar) {
111  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
112  (*mults)[m_subdetsel[iS]] = int(clustsumm->getNClus(m_subdetenums[iS]));
113  break;
115  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
116  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusSize(m_subdetenums[iS]));
117  break;
119  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
120  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusCharge(m_subdetenums[iS]));
121  break;
122  default:
123  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
124  (*mults)[m_subdetsel[iS]] = -1;
125  }
126 
127  for (unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
128  LogDebug("Multiplicity") << "GetModuleLocation result: " << m_subdetenums[iS] << " "
129  << clustsumm->getModuleLocation(m_subdetenums[iS]);
130 
131  for (std::map<unsigned int, int>::const_iterator it = mults->begin(); it != mults->end(); ++it) {
132  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first;
133  }
134 
135  iEvent.put(std::move(mults));
136 }
137 
138 // ------------ method called once each job just before starting event loop ------------
140 
141 // ------------ method called once each job just after ending the event loop ------------
143 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
std::vector< ClusterSummary::CMSTracker > m_subdetenums
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void produce(edm::Event &, const edm::EventSetup &) override
#define LogDebug(id)