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 
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  void beginJob() override ;
49  void produce(edm::Event&, const edm::EventSetup&) override;
50  void endJob() override ;
51 
52  // ----------member data ---------------------------
53 
55  std::vector<ClusterSummary::CMSTracker> m_subdetenums;
56  std::vector<int> m_subdetsel;
58 
59 };
60 
61 //
62 // constants, enums and typedefs
63 //
64 
65 
66 //
67 // static data member definitions
68 //
69 
70 //
71 // constructors and destructor
72 //
74  m_collectionToken(consumes<ClusterSummary>(iConfig.getParameter<edm::InputTag>("clusterSummaryCollection"))),
76 {
77  produces<std::map<unsigned int,int> >();
78 
79  //now do what ever other initialization is needed
80 
81  std::vector<edm::ParameterSet> wantedsubds(iConfig.getParameter<std::vector<edm::ParameterSet> >("wantedSubDets"));
82  m_subdetenums.reserve(wantedsubds.size());
83  m_subdetsel.reserve(wantedsubds.size());
84 
85  for(std::vector<edm::ParameterSet>::iterator ps=wantedsubds.begin();ps!=wantedsubds.end();++ps) {
86  m_subdetenums.push_back((ClusterSummary::CMSTracker)ps->getParameter<int >("subDetEnum"));
87  m_subdetsel.push_back(ps->getParameter<int >("subDetEnum"));
88  }
90 }
91 
93 {
94 
95  // do anything here that needs to be done at desctruction time
96  // (e.g. close files, deallocate resources etc.)
97 
98 }
99 
100 
101 //
102 // member functions
103 //
104 
105 // ------------ method called to produce the data ------------
106 void
108 {
109 
110  LogDebug("Multiplicity") << " Ready to go";
111 
112  using namespace edm;
113 
114  std::unique_ptr<std::map<unsigned int,int> > mults(new std::map<unsigned int,int> );
115 
116 
117  Handle<ClusterSummary> clustsumm;
118  iEvent.getByToken(m_collectionToken,clustsumm);
119 
120  switch(m_subdetvar){
122  for(unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
123  (*mults)[m_subdetsel[iS]] = int(clustsumm->getNClus (m_subdetenums[iS]));
124  break;
126  for(unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
127  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusSize (m_subdetenums[iS]));
128  break;
130  for(unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
131  (*mults)[m_subdetsel[iS]] = int(clustsumm->getClusCharge (m_subdetenums[iS]));
132  break;
133  default :
134  for(unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
135  (*mults)[m_subdetsel[iS]] = -1;
136  }
137 
138  for(unsigned int iS = 0; iS < m_subdetenums.size(); ++iS)
139  LogDebug("Multiplicity") << "GetModuleLocation result: " << m_subdetenums[iS] << " " << clustsumm->getModuleLocation(m_subdetenums[iS]);
140 
141  for(std::map<unsigned int,int>::const_iterator it=mults->begin();it!=mults->end();++it) {
142  LogDebug("Multiplicity") << " Found " << it->second << " digis/clusters in " << it->first;
143  }
144 
145  iEvent.put(std::move(mults));
146 
147 }
148 
149 // ------------ method called once each job just before starting event loop ------------
150 void
152 {
153 }
154 
155 // ------------ method called once each job just after ending the event loop ------------
156 void
158 }
159 
#define LogDebug(id)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
float getClusCharge(const CMSTracker mod) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
int getModuleLocation(int mod, bool warn=true) const
std::vector< ClusterSummary::CMSTracker > m_subdetenums
int getClusSize(const CMSTracker mod) const
int getNClus(const CMSTracker mod) const
void produce(edm::Event &, const edm::EventSetup &) override
HLT enums.
def move(src, dest)
Definition: eostools.py:511