CMS 3D CMS Logo

PATHemisphereProducer.cc
Go to the documentation of this file.
1 
2 // -*- C++ -*-
3 //
4 // Package: PatShapeAna
5 // Class: PatShapeAna
6 //
14 //
15 // Original Author: Tanja Rommerskirchen
16 // Created: Sat Mar 22 12:58:04 CET 2008
17 //
18 //
19 
20 //system
21 #include <vector>
22 #include <memory>
23 //PAT
31 //DataFormats
36 //User
38 
39 using namespace pat;
40 
41 //
42 // constants, enums and typedefs
43 //
44 
45 //
46 // static data member definitions
47 //
48 
49 //
50 // constructors and destructor
51 //
53  : _patJetsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patJets"))),
54  _patMuonsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patMuons"))),
55  _patElectronsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patElectrons"))),
56  _patPhotonsToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patPhotons"))),
57  _patTausToken(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("patTaus"))),
58 
59  _minJetEt(iConfig.getParameter<double>("minJetEt")),
60  _minMuonEt(iConfig.getParameter<double>("minMuonEt")),
61  _minElectronEt(iConfig.getParameter<double>("minElectronEt")),
62  _minTauEt(iConfig.getParameter<double>("minTauEt")),
63  _minPhotonEt(iConfig.getParameter<double>("minPhotonEt")),
64 
65  _maxJetEta(iConfig.getParameter<double>("maxJetEta")),
66  _maxMuonEta(iConfig.getParameter<double>("maxMuonEta")),
67  _maxElectronEta(iConfig.getParameter<double>("maxElectronEta")),
68  _maxTauEta(iConfig.getParameter<double>("maxTauEta")),
69  _maxPhotonEta(iConfig.getParameter<double>("maxPhotonEta")),
70 
71  _seedMethod(iConfig.getParameter<int>("seedMethod")),
72  _combinationMethod(iConfig.getParameter<int>("combinationMethod"))
73 
74 {
75  produces<std::vector<pat::Hemisphere>>();
76 }
77 
79  // do anything here that needs to be done at desctruction time
80  // (e.g. close files, deallocate resources etc.)
81 }
82 
83 //
84 // member functions
85 //
86 
87 // ------------ method called to produce the data ------------
89  using namespace edm;
90  using namespace std;
91 
92  std::vector<float> vPx, vPy, vPz, vE;
93  std::vector<float> vA1, vA2;
94  std::vector<int> vgroups;
95  std::vector<reco::CandidatePtr> componentPtrs;
96 
97  //Jets
99  iEvent.getByToken(_patJetsToken, pJets);
100 
101  //Muons
103  iEvent.getByToken(_patMuonsToken, pMuons);
104 
105  //Electrons
106  Handle<reco::CandidateView> pElectrons;
107  iEvent.getByToken(_patElectronsToken, pElectrons);
108 
109  //Photons
111  iEvent.getByToken(_patPhotonsToken, pPhotons);
112 
113  //Taus
115  iEvent.getByToken(_patTausToken, pTaus);
116 
117  //fill e,p vector with information from all objects (hopefully cleaned before)
118  for (int i = 0; i < (int)(*pJets).size(); i++) {
119  if ((*pJets)[i].pt() < _minJetEt || fabs((*pJets)[i].eta()) > _maxJetEta)
120  continue;
121 
122  componentPtrs.push_back(pJets->ptrAt(i));
123  }
124 
125  for (int i = 0; i < (int)(*pMuons).size(); i++) {
126  if ((*pMuons)[i].pt() < _minMuonEt || fabs((*pMuons)[i].eta()) > _maxMuonEta)
127  continue;
128 
129  componentPtrs.push_back(pMuons->ptrAt(i));
130  }
131 
132  for (int i = 0; i < (int)(*pElectrons).size(); i++) {
133  if ((*pElectrons)[i].pt() < _minElectronEt || fabs((*pElectrons)[i].eta()) > _maxElectronEta)
134  continue;
135 
136  componentPtrs.push_back(pElectrons->ptrAt(i));
137  }
138 
139  for (int i = 0; i < (int)(*pPhotons).size(); i++) {
140  if ((*pPhotons)[i].pt() < _minPhotonEt || fabs((*pPhotons)[i].eta()) > _maxPhotonEta)
141  continue;
142 
143  componentPtrs.push_back(pPhotons->ptrAt(i));
144  }
145 
146  //aren't taus included in jets?
147  for (int i = 0; i < (int)(*pTaus).size(); i++) {
148  if ((*pTaus)[i].pt() < _minTauEt || fabs((*pTaus)[i].eta()) > _maxTauEta)
149  continue;
150 
151  componentPtrs.push_back(pTaus->ptrAt(i));
152  }
153 
154  // create product
155  auto hemispheres = std::make_unique<std::vector<Hemisphere>>();
156  hemispheres->reserve(2);
157 
158  //calls HemiAlgorithm for seed method 3 (transv. inv. Mass) and association method 3 (Lund algo)
159  HemisphereAlgo myHemi(componentPtrs, _seedMethod, _combinationMethod);
160 
161  //get Hemisphere Axis
162  vA1 = myHemi.getAxis1();
163  vA2 = myHemi.getAxis2();
164 
165  reco::Particle::LorentzVector p1(vA1[0] * vA1[3], vA1[1] * vA1[3], vA1[2] * vA1[3], vA1[4]);
166  hemispheres->push_back(Hemisphere(p1));
167 
168  reco::Particle::LorentzVector p2(vA2[0] * vA2[3], vA2[1] * vA2[3], vA2[2] * vA2[3], vA2[4]);
169  hemispheres->push_back(Hemisphere(p2));
170 
171  //get information to which Hemisphere each object belongs
172  vgroups = myHemi.getGrouping();
173 
174  for (unsigned int i = 0; i < vgroups.size(); ++i) {
175  if (vgroups[i] == 1) {
176  (*hemispheres)[0].addDaughter(componentPtrs[i]);
177  } else {
178  (*hemispheres)[1].addDaughter(componentPtrs[i]);
179  }
180  }
181 
183 }
184 
185 //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.h:59
PATHemisphereProducer::_maxPhotonEta
const float _maxPhotonEta
Definition: PATHemisphereProducer.h:67
edm
HLT enums.
Definition: AlignableModifier.h:19
Muon.h
Photon.h
PATHemisphereProducer::_seedMethod
const int _seedMethod
Definition: PATHemisphereProducer.h:69
PATHemisphereProducer
Definition: PATHemisphereProducer.h:40
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
PATHemisphereProducer::_combinationMethod
const int _combinationMethod
Definition: PATHemisphereProducer.h:70
HemisphereAlgo::getAxis1
std::vector< float > getAxis1()
Definition: HemisphereAlgo.cc:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
Tau.h
PATHemisphereProducer::_minMuonEt
const float _minMuonEt
Definition: PATHemisphereProducer.h:58
reco::Particle::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21
PATHemisphereProducer::_patMuonsToken
const edm::EDGetTokenT< reco::CandidateView > _patMuonsToken
Definition: PATHemisphereProducer.h:52
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
PATHemisphereProducer::_minJetEt
const float _minJetEt
Definition: PATHemisphereProducer.h:57
pat::Hemisphere
Definition: Hemisphere.h:17
PATHemisphereProducer::_maxJetEta
const float _maxJetEta
Definition: PATHemisphereProducer.h:63
edm::ParameterSet
Definition: ParameterSet.h:47
razorHemispheres_cff.hemispheres
hemispheres
Definition: razorHemispheres_cff.py:3
PATHemisphereProducer::_patJetsToken
const edm::EDGetTokenT< reco::CandidateView > _patJetsToken
Input: All PAT objects that are to cross-clean or needed for that.
Definition: PATHemisphereProducer.h:50
PATHemisphereProducer.h
PATHemisphereProducer::_maxElectronEta
const float _maxElectronEta
Definition: PATHemisphereProducer.h:65
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.h:61
MET.h
Jet.h
HemisphereAlgo
Definition: HemisphereAlgo.h:23
CaloTowerCollection.h
VertexFwd.h
PATHemisphereProducer::_patElectronsToken
const edm::EDGetTokenT< reco::CandidateView > _patElectronsToken
Definition: PATHemisphereProducer.h:53
PATHemisphereProducer::_maxTauEta
const float _maxTauEta
Definition: PATHemisphereProducer.h:66
PATHemisphereProducer::~PATHemisphereProducer
~PATHemisphereProducer() override
Definition: PATHemisphereProducer.cc:78
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.h:55
PATHemisphereProducer::_maxMuonEta
const float _maxMuonEta
Definition: PATHemisphereProducer.h:64
PATHemisphereProducer::_patPhotonsToken
const edm::EDGetTokenT< reco::CandidateView > _patPhotonsToken
Definition: PATHemisphereProducer.h:54
Electron.h
Hemisphere.h
HemisphereAlgo::getAxis2
std::vector< float > getAxis2()
Definition: HemisphereAlgo.cc:32
edm::Event
Definition: Event.h:73
edm::View::ptrAt
Ptr< value_type > ptrAt(size_type i) const
PATHemisphereProducer::produce
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: PATHemisphereProducer.cc:88
PATHemisphereProducer::_minTauEt
const float _minTauEt
Definition: PATHemisphereProducer.h:60
PATHemisphereProducer::PATHemisphereProducer
PATHemisphereProducer(const edm::ParameterSet &)
Definition: PATHemisphereProducer.cc:52