CMS 3D CMS Logo

MultiplicityCorrelator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MultiplicityCorrelator
4 // Class: MultiplicityCorrelator
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Mon Oct 27 17:37:53 CET 2008
16 // $Id: MultiplicityCorrelator.cc,v 1.3 2011/12/11 10:04:09 venturia Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
25 
26 #include <vector>
27 #include <map>
28 #include <limits>
29 
38 
40 
41 //
42 // class decleration
43 //
44 
46  public:
48  ~MultiplicityCorrelator() override;
49 
50 
51 private:
52  void beginJob() override ;
53  void analyze(const edm::Event&, const edm::EventSetup&) override;
54  void beginRun(const edm::Run&, const edm::EventSetup&) override;
55  void endJob() override ;
56 
57  // ----------member data ---------------------------
58 
59  std::vector<MultiplicityCorrelatorHistogramMaker*> m_mchms;
60 
61  std::vector<edm::EDGetTokenT<std::map<unsigned int, int> > > m_xMultiplicityMapTokens;
62  std::vector<edm::EDGetTokenT<std::map<unsigned int, int> > > m_yMultiplicityMapTokens;
63  std::vector<std::string> m_xLabels;
64  std::vector<std::string> m_yLabels;
65  std::vector<unsigned int> m_xSelections;
66  std::vector<unsigned int> m_ySelections;
67 
68 
69 };
70 
71 //
72 // constants, enums and typedefs
73 //
74 
75 //
76 // static data member definitions
77 //
78 
79 //
80 // constructors and destructor
81 //
83  m_mchms(),
86 {
87  //now do what ever initialization is needed
88 
89  std::vector<edm::ParameterSet> correlationConfigs =
90  iConfig.getParameter<std::vector<edm::ParameterSet> >("correlationConfigurations");
91 
92  for(std::vector<edm::ParameterSet>::const_iterator ps=correlationConfigs.begin();ps!=correlationConfigs.end();++ps) {
93 
94  m_xMultiplicityMapTokens.push_back(consumes<std::map<unsigned int, int> >(ps->getParameter<edm::InputTag>("xMultiplicityMap")));
95  m_yMultiplicityMapTokens.push_back(consumes<std::map<unsigned int, int> >(ps->getParameter<edm::InputTag>("yMultiplicityMap")));
96  m_xLabels.push_back(ps->getParameter<std::string>("xDetLabel"));
97  m_yLabels.push_back(ps->getParameter<std::string>("yDetLabel"));
98  m_xSelections.push_back(ps->getParameter<unsigned int>("xDetSelection"));
99  m_ySelections.push_back(ps->getParameter<unsigned int>("yDetSelection"));
100 
102 
103  }
104 
105 }
106 
107 
109 {
110 
111  for(unsigned int i=0;i<m_mchms.size();++i) {
112  delete m_mchms[i];
113  }
114 
115 }
116 
117 
118 //
119 // member functions
120 //
121 
122 // ------------ method called to for each event ------------
123 void
125 {
126  using namespace edm;
127 
128  for(unsigned int i=0;i<m_mchms.size();++i) {
130  iEvent.getByToken(m_xMultiplicityMapTokens[i],xMults);
132  iEvent.getByToken(m_yMultiplicityMapTokens[i],yMults);
133 
134  // check if the selection exists
135 
136  std::map<unsigned int, int>::const_iterator xmult = xMults->find(m_xSelections[i]);
137  std::map<unsigned int, int>::const_iterator ymult = yMults->find(m_ySelections[i]);
138 
139  if(xmult!=xMults->end() && ymult!=yMults->end()) {
140 
141 
142  m_mchms[i]->fill(iEvent,xmult->second,ymult->second);
143 
144  }
145  else {
146  edm::LogWarning("DetSelectionNotFound") << " DetSelection "
147  << m_xSelections[i] << " "
148  << m_ySelections[i] << " not found";
149  }
150  }
151 
152 }
153 
154 
155 // ------------ method called once each job just before starting event loop ------------
156 void
158 {
159 
160 }
161 
162 void
164 
165  for(unsigned int i=0;i<m_mchms.size();++i) {
166  m_mchms[i]->beginRun(iRun);
167  }
168 }
169 // ------------ method called once each job just after ending the event loop ------------
170 void
172 }
173 //define this as a plug-in
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< std::map< unsigned int, int > > > m_yMultiplicityMapTokens
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< unsigned int > m_ySelections
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< std::string > m_yLabels
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
MultiplicityCorrelator(const edm::ParameterSet &)
std::vector< MultiplicityCorrelatorHistogramMaker * > m_mchms
std::vector< std::string > m_xLabels
HLT enums.
std::vector< edm::EDGetTokenT< std::map< unsigned int, int > > > m_xMultiplicityMapTokens
std::vector< unsigned int > m_xSelections
Definition: Run.h:45
void beginRun(const edm::Run &, const edm::EventSetup &) override