CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
19 // system include files
20 #include <memory>
21 #include <string>
22 #include <map>
23 #include <vector>
24 
25 // user include files
28 
31 
35 
37 
38 //
39 // class decleration
40 //
42 
43 public:
46 
47 private:
48  virtual void beginJob() override ;
49  virtual void produce(edm::Event&, const edm::EventSetup&) override;
50  virtual void endJob() override ;
51 
52  // ----------member data ---------------------------
53 
55  std::map<unsigned int, std::string> m_subdets;
56  std::map<unsigned int, int> m_subdetenums;
57  std::map<unsigned int, std::string> m_subdetvars;
58  std::vector<std::string> m_clustsummvar;
59 
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 
67 //
68 // static data member definitions
69 //
70 
71 //
72 // constructors and destructor
73 //
75  m_collection(iConfig.getParameter<edm::InputTag>("clusterSummaryCollection")),
76  m_subdets(),m_subdetenums(),m_subdetvars(),m_clustsummvar()
77 {
78 
79  m_clustsummvar.push_back("cHits");
80  m_clustsummvar.push_back("cSize");
81  m_clustsummvar.push_back("cCharge");
82  m_clustsummvar.push_back("pHits");
83  m_clustsummvar.push_back("pSize");
84  m_clustsummvar.push_back("pCharge");
85 
86  produces<std::map<unsigned int,int> >();
87 
88  //now do what ever other initialization is needed
89 
90  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
91 
92  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
93  m_subdets[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("detLabel");
94  m_subdetenums[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<int >("subDetEnum");
95  m_subdetvars[ps->getParameter<unsigned int>("detSelection")] = ps->getParameter<std::string>("subDetVariable");
96  }
97 }
98 
100 {
101 
102  // do anything here that needs to be done at desctruction time
103  // (e.g. close files, deallocate resources etc.)
104 
105 }
106 
107 
108 //
109 // member functions
110 //
111 
112 // ------------ method called to produce the data ------------
113 void
115 {
116 
117  LogDebug("Multiplicity") << " Ready to go";
118 
119  using namespace edm;
120 
121  std::auto_ptr<std::map<unsigned int,int> > mults(new std::map<unsigned int,int> );
122 
123 
124  Handle<ClusterSummary> clustsumm;
125  iEvent.getByLabel(m_collection,clustsumm);
126 
127  clustsumm->SetUserContent(m_clustsummvar);
128 
129  for(std::map<unsigned int,std::string>::const_iterator sdet=m_subdets.begin();sdet!=m_subdets.end();++sdet) { (*mults)[sdet->first]=0; }
130 
131  for(std::map<unsigned int,int>::const_iterator detsel=m_subdetenums.begin();detsel!=m_subdetenums.end();++detsel) {
132 
133  // (*mults)[detsel->first] = int(clustsumm->GetGenericVariable(m_subdetvars[detsel->first])[clustsumm->GetModuleLocation(detsel->second)]);
134  (*mults)[detsel->first] = int(clustsumm->GetGenericVariable(m_subdetvars[detsel->first],detsel->second));
135  LogDebug("Multiplicity") << "GetModuleLocation result: " << detsel->second << " " << clustsumm->GetModuleLocation(detsel->second);
136  }
137 
138 
139 
140  for(std::map<unsigned int,int>::const_iterator it=mults->begin();it!=mults->end();++it) {
141  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first << " " << m_subdets[it->first];
142  }
143 
144  iEvent.put(mults);
145 
146 }
147 
148 // ------------ method called once each job just before starting event loop ------------
149 void
151 {
152 }
153 
154 // ------------ method called once each job just after ending the event loop ------------
155 void
157 }
158 
#define LogDebug(id)
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
virtual void produce(edm::Event &, const edm::EventSetup &) override