CMS 3D CMS Logo

PATHemisphereProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PhysicsTools/PatAlgos
4 // Class: PATHemisphereProducer
5 //
13 //
14 // Original Authors: Christian Autermann, Tanja Rommerskirchen
15 // Created: Sat Mar 22 12:58:04 CET 2008
16 //
17 //
18 
36 
37 #include <map>
38 #include <memory>
39 #include <utility>
40 #include <vector>
41 
43 public:
45  ~PATHemisphereProducer() override;
46 
47  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
48 
49 private:
50  // ----------member data ---------------------------
53  // edm::EDGetTokenT<reco::CandidateView> _patMetsToken;
58 
59  const float _minJetEt;
60  const float _minMuonEt;
61  const float _minElectronEt;
62  const float _minTauEt;
63  const float _minPhotonEt;
64 
65  const float _maxJetEta;
66  const float _maxMuonEta;
67  const float _maxElectronEta;
68  const float _maxTauEta;
69  const float _maxPhotonEta;
70 
71  const int _seedMethod;
72  const int _combinationMethod;
73 
74  typedef std::vector<float> HemiAxis;
75 };
76 
77 using namespace pat;
78 
79 //
80 // constants, enums and typedefs
81 //
82 
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
91  : _patJetsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patJets"))),
92  _patMuonsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patMuons"))),
93  _patElectronsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patElectrons"))),
94  _patPhotonsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patPhotons"))),
95  _patTausToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patTaus"))),
96 
97  _minJetEt(iConfig.getParameter<double>("minJetEt")),
98  _minMuonEt(iConfig.getParameter<double>("minMuonEt")),
99  _minElectronEt(iConfig.getParameter<double>("minElectronEt")),
100  _minTauEt(iConfig.getParameter<double>("minTauEt")),
101  _minPhotonEt(iConfig.getParameter<double>("minPhotonEt")),
102 
103  _maxJetEta(iConfig.getParameter<double>("maxJetEta")),
104  _maxMuonEta(iConfig.getParameter<double>("maxMuonEta")),
105  _maxElectronEta(iConfig.getParameter<double>("maxElectronEta")),
106  _maxTauEta(iConfig.getParameter<double>("maxTauEta")),
107  _maxPhotonEta(iConfig.getParameter<double>("maxPhotonEta")),
108 
109  _seedMethod(iConfig.getParameter<int>("seedMethod")),
110  _combinationMethod(iConfig.getParameter<int>("combinationMethod"))
111 
112 {
113  produces<std::vector<pat::Hemisphere>>();
114 }
115 
117  // do anything here that needs to be done at desctruction time
118  // (e.g. close files, deallocate resources etc.)
119 }
120 
121 //
122 // member functions
123 //
124 
125 // ------------ method called to produce the data ------------
127  using namespace edm;
128  using namespace std;
129 
130  std::vector<float> vPx, vPy, vPz, vE;
131  std::vector<float> vA1, vA2;
132  std::vector<int> vgroups;
133  std::vector<reco::CandidatePtr> componentPtrs;
134 
135  //Jets
137  iEvent.getByToken(_patJetsToken, pJets);
138 
139  //Muons
141  iEvent.getByToken(_patMuonsToken, pMuons);
142 
143  //Electrons
144  Handle<reco::CandidateView> pElectrons;
145  iEvent.getByToken(_patElectronsToken, pElectrons);
146 
147  //Photons
149  iEvent.getByToken(_patPhotonsToken, pPhotons);
150 
151  //Taus
153  iEvent.getByToken(_patTausToken, pTaus);
154 
155  //fill e,p vector with information from all objects (hopefully cleaned before)
156  for (int i = 0; i < (int)(*pJets).size(); i++) {
157  if ((*pJets)[i].pt() < _minJetEt || fabs((*pJets)[i].eta()) > _maxJetEta)
158  continue;
159 
160  componentPtrs.push_back(pJets->ptrAt(i));
161  }
162 
163  for (int i = 0; i < (int)(*pMuons).size(); i++) {
164  if ((*pMuons)[i].pt() < _minMuonEt || fabs((*pMuons)[i].eta()) > _maxMuonEta)
165  continue;
166 
167  componentPtrs.push_back(pMuons->ptrAt(i));
168  }
169 
170  for (int i = 0; i < (int)(*pElectrons).size(); i++) {
171  if ((*pElectrons)[i].pt() < _minElectronEt || fabs((*pElectrons)[i].eta()) > _maxElectronEta)
172  continue;
173 
174  componentPtrs.push_back(pElectrons->ptrAt(i));
175  }
176 
177  for (int i = 0; i < (int)(*pPhotons).size(); i++) {
178  if ((*pPhotons)[i].pt() < _minPhotonEt || fabs((*pPhotons)[i].eta()) > _maxPhotonEta)
179  continue;
180 
181  componentPtrs.push_back(pPhotons->ptrAt(i));
182  }
183 
184  //aren't taus included in jets?
185  for (int i = 0; i < (int)(*pTaus).size(); i++) {
186  if ((*pTaus)[i].pt() < _minTauEt || fabs((*pTaus)[i].eta()) > _maxTauEta)
187  continue;
188 
189  componentPtrs.push_back(pTaus->ptrAt(i));
190  }
191 
192  // create product
193  auto hemispheres = std::make_unique<std::vector<Hemisphere>>();
194  hemispheres->reserve(2);
195 
196  //calls HemiAlgorithm for seed method 3 (transv. inv. Mass) and association method 3 (Lund algo)
197  HemisphereAlgo myHemi(componentPtrs, _seedMethod, _combinationMethod);
198 
199  //get Hemisphere Axis
200  vA1 = myHemi.getAxis1();
201  vA2 = myHemi.getAxis2();
202 
203  reco::Particle::LorentzVector p1(vA1[0] * vA1[3], vA1[1] * vA1[3], vA1[2] * vA1[3], vA1[4]);
204  hemispheres->push_back(Hemisphere(p1));
205 
206  reco::Particle::LorentzVector p2(vA2[0] * vA2[3], vA2[1] * vA2[3], vA2[2] * vA2[3], vA2[4]);
207  hemispheres->push_back(Hemisphere(p2));
208 
209  //get information to which Hemisphere each object belongs
210  vgroups = myHemi.getGrouping();
211 
212  for (unsigned int i = 0; i < vgroups.size(); ++i) {
213  if (vgroups[i] == 1) {
214  (*hemispheres)[0].addDaughter(componentPtrs[i]);
215  } else {
216  (*hemispheres)[1].addDaughter(componentPtrs[i]);
217  }
218  }
219 
221 }
222 
223 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
reco::CandidateView
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23
mps_fire.i
i
Definition: mps_fire.py:428
PATHemisphereProducer::_minElectronEt
const float _minElectronEt
Definition: PATHemisphereProducer.cc:61
PATHemisphereProducer::_maxPhotonEta
const float _maxPhotonEta
Definition: PATHemisphereProducer.cc:69
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
Photon.h
PATHemisphereProducer::_seedMethod
const int _seedMethod
Definition: PATHemisphereProducer.cc:71
PATHemisphereProducer
Definition: PATHemisphereProducer.cc:42
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
PATHemisphereProducer::_combinationMethod
const int _combinationMethod
Definition: PATHemisphereProducer.cc:72
HemisphereAlgo::getAxis1
std::vector< float > getAxis1()
Definition: HemisphereAlgo.cc:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
edm::Handle
Definition: AssociativeIterator.h:50
Tau.h
PATHemisphereProducer::_minMuonEt
const float _minMuonEt
Definition: PATHemisphereProducer.cc:60
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
CandidateFwd.h
MakerMacros.h
PATHemisphereProducer::_patMuonsToken
const edm::EDGetTokenT< reco::CandidateView > _patMuonsToken
Definition: PATHemisphereProducer.cc:54
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PVValHelper::eta
Definition: PVValidationHelpers.h:70
p2
double p2[4]
Definition: TauolaWrapper.h:90
Particle.h
HemisphereAlgo.h
PATHemisphereProducer::_minJetEt
const float _minJetEt
Definition: PATHemisphereProducer.cc:59
pat::Hemisphere
Definition: Hemisphere.h:17
edm::global::EDProducer
Definition: EDProducer.h:32
PATHemisphereProducer::_maxJetEta
const float _maxJetEta
Definition: PATHemisphereProducer.cc:65
edm::ParameterSet
Definition: ParameterSet.h:47
razorHemispheres_cff.hemispheres
hemispheres
Definition: razorHemispheres_cff.py:3
Event.h
PATHemisphereProducer::_patJetsToken
const edm::EDGetTokenT< reco::CandidateView > _patJetsToken
Input: All PAT objects that are to cross-clean or needed for that.
Definition: PATHemisphereProducer.cc:52
PATHemisphereProducer::_maxElectronEta
const float _maxElectronEta
Definition: PATHemisphereProducer.cc:67
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
HemisphereAlgo::getGrouping
std::vector< int > getGrouping()
Definition: HemisphereAlgo.cc:39
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
PATHemisphereProducer::_minPhotonEt
const float _minPhotonEt
Definition: PATHemisphereProducer.cc:63
MET.h
Jet.h
ParameterAdapter.h
HemisphereAlgo
Definition: HemisphereAlgo.h:23
CaloTowerCollection.h
VertexFwd.h
PATHemisphereProducer::_patElectronsToken
const edm::EDGetTokenT< reco::CandidateView > _patElectronsToken
Definition: PATHemisphereProducer.cc:55
PATHemisphereProducer::_maxTauEta
const float _maxTauEta
Definition: PATHemisphereProducer.cc:68
PATHemisphereProducer::~PATHemisphereProducer
~PATHemisphereProducer() override
Definition: PATHemisphereProducer.cc:116
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
PATHemisphereProducer::_patTausToken
const edm::EDGetTokenT< reco::CandidateView > _patTausToken
Definition: PATHemisphereProducer.cc:57
PATHemisphereProducer::_maxMuonEta
const float _maxMuonEta
Definition: PATHemisphereProducer.cc:66
PATHemisphereProducer::_patPhotonsToken
const edm::EDGetTokenT< reco::CandidateView > _patPhotonsToken
Definition: PATHemisphereProducer.cc:56
Electron.h
Hemisphere.h
ParameterSet.h
HemisphereAlgo::getAxis2
std::vector< float > getAxis2()
Definition: HemisphereAlgo.cc:32
EDProducer.h
edm::Event
Definition: Event.h:73
edm::View::ptrAt
Ptr< value_type > ptrAt(size_type i) const
PATHemisphereProducer::HemiAxis
std::vector< float > HemiAxis
Definition: PATHemisphereProducer.cc:74
PATHemisphereProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PATHemisphereProducer.cc:126
PATHemisphereProducer::_minTauEt
const float _minTauEt
Definition: PATHemisphereProducer.cc:62
PATHemisphereProducer::PATHemisphereProducer
PATHemisphereProducer(const edm::ParameterSet &)
Definition: PATHemisphereProducer.cc:90