1 |
// -*- C++ -*-
|
2 |
//
|
3 |
// Package: MPT
|
4 |
// Class: MPT
|
5 |
//
|
6 |
/**\class MPT MPT.cc Ntuples/MPT/src/MPT.cc
|
7 |
|
8 |
Description: simple calculation of the track-based missing momentum
|
9 |
|
10 |
Implementation:
|
11 |
results of the calculation are stored in a class SimpleEt that simply holds two floats (pt and phi)
|
12 |
*/
|
13 |
//
|
14 |
// Original Author: Joshua Thompson,6 R-029,+41227678914,
|
15 |
// Created: Thu Jul 14 15:14:59 CEST 2011
|
16 |
// $Id$
|
17 |
//
|
18 |
//
|
19 |
|
20 |
|
21 |
// system include files
|
22 |
#include <memory>
|
23 |
|
24 |
// user include files
|
25 |
#include "FWCore/Framework/interface/Frameworkfwd.h"
|
26 |
#include "FWCore/Framework/interface/EDProducer.h"
|
27 |
|
28 |
#include "FWCore/Framework/interface/Event.h"
|
29 |
#include "FWCore/Framework/interface/MakerMacros.h"
|
30 |
|
31 |
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
32 |
|
33 |
|
34 |
#include "DataFormats/TrackReco/interface/Track.h"
|
35 |
#include "DataFormats/TrackReco/interface/TrackFwd.h"
|
36 |
|
37 |
#include "MyDataFormats/RA2bDataFormats/interface/SimpleEt.h"
|
38 |
//
|
39 |
// class declaration
|
40 |
//
|
41 |
|
42 |
class MPT : public edm::EDProducer {
|
43 |
public:
|
44 |
explicit MPT(const edm::ParameterSet&);
|
45 |
~MPT();
|
46 |
|
47 |
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
|
48 |
|
49 |
private:
|
50 |
virtual void beginJob() ;
|
51 |
virtual void produce(edm::Event&, const edm::EventSetup&);
|
52 |
virtual void endJob() ;
|
53 |
|
54 |
virtual void beginRun(edm::Run&, edm::EventSetup const&);
|
55 |
virtual void endRun(edm::Run&, edm::EventSetup const&);
|
56 |
virtual void beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
|
57 |
virtual void endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&);
|
58 |
|
59 |
// ----------member data ---------------------------
|
60 |
|
61 |
double minpt_;
|
62 |
|
63 |
};
|
64 |
|
65 |
|
66 |
|
67 |
//
|
68 |
// constants, enums and typedefs
|
69 |
//
|
70 |
|
71 |
|
72 |
//
|
73 |
// static data member definitions
|
74 |
//
|
75 |
|
76 |
//
|
77 |
// constructors and destructor
|
78 |
//
|
79 |
MPT::MPT(const edm::ParameterSet& iConfig) :
|
80 |
minpt_ (iConfig.getParameter<double>("minpt"))
|
81 |
{
|
82 |
//register your products
|
83 |
/* Examples
|
84 |
produces<ExampleData2>();
|
85 |
|
86 |
//if do put with a label
|
87 |
produces<ExampleData2>("label");
|
88 |
|
89 |
//if you want to put into the Run
|
90 |
produces<ExampleData2,InRun>();
|
91 |
*/
|
92 |
|
93 |
produces< SimpleEt >();
|
94 |
|
95 |
//now do what ever other initialization is needed
|
96 |
|
97 |
}
|
98 |
|
99 |
|
100 |
MPT::~MPT()
|
101 |
{
|
102 |
|
103 |
}
|
104 |
|
105 |
|
106 |
//
|
107 |
// member functions
|
108 |
//
|
109 |
|
110 |
// ------------ method called to produce the data ------------
|
111 |
void
|
112 |
MPT::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
|
113 |
{
|
114 |
|
115 |
edm::Handle<reco::TrackCollection> generalTracks;
|
116 |
iEvent.getByLabel("generalTracks", generalTracks);
|
117 |
|
118 |
float mptx=0,mpty=0;
|
119 |
|
120 |
for (reco::TrackCollection::const_iterator trit=generalTracks->begin(); trit!=generalTracks->end() ; ++trit) {
|
121 |
|
122 |
if (trit->pt() >= minpt_ && fabs(trit->eta()) < 5) {
|
123 |
mptx -= trit->pt() * cos(trit->phi());
|
124 |
mpty -= trit->pt() * sin(trit->phi());
|
125 |
}
|
126 |
}
|
127 |
|
128 |
//std::cout<<"MPT["<<int(minpt_)<<"] = "<<sqrt(mptx*mptx + mpty*mpty) <<std::endl;
|
129 |
|
130 |
std::auto_ptr<SimpleEt> thempt(new SimpleEt(-99));
|
131 |
thempt->pt = sqrt(mptx*mptx + mpty*mpty) ;
|
132 |
thempt->phi = atan2(mpty,mptx);
|
133 |
|
134 |
iEvent.put(thempt);
|
135 |
|
136 |
}
|
137 |
|
138 |
// ------------ method called once each job just before starting event loop ------------
|
139 |
void
|
140 |
MPT::beginJob()
|
141 |
{
|
142 |
}
|
143 |
|
144 |
// ------------ method called once each job just after ending the event loop ------------
|
145 |
void
|
146 |
MPT::endJob() {
|
147 |
}
|
148 |
|
149 |
// ------------ method called when starting to processes a run ------------
|
150 |
void
|
151 |
MPT::beginRun(edm::Run&, edm::EventSetup const&)
|
152 |
{
|
153 |
}
|
154 |
|
155 |
// ------------ method called when ending the processing of a run ------------
|
156 |
void
|
157 |
MPT::endRun(edm::Run&, edm::EventSetup const&)
|
158 |
{
|
159 |
}
|
160 |
|
161 |
// ------------ method called when starting to processes a luminosity block ------------
|
162 |
void
|
163 |
MPT::beginLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
|
164 |
{
|
165 |
}
|
166 |
|
167 |
// ------------ method called when ending the processing of a luminosity block ------------
|
168 |
void
|
169 |
MPT::endLuminosityBlock(edm::LuminosityBlock&, edm::EventSetup const&)
|
170 |
{
|
171 |
}
|
172 |
|
173 |
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
|
174 |
void
|
175 |
MPT::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
|
176 |
//The following says we do not know what parameters are allowed so do no validation
|
177 |
// Please change this to state exactly what you do use, even if it is no parameters
|
178 |
edm::ParameterSetDescription desc;
|
179 |
desc.setUnknown();
|
180 |
descriptions.addDefault(desc);
|
181 |
}
|
182 |
|
183 |
//define this as a plug-in
|
184 |
DEFINE_FWK_MODULE(MPT);
|