CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
21 //system
22 #include <vector>
23 #include <memory>
24 //PAT
32 //DataFormats
37 //User
39 
40 
41 using namespace pat;
42 
43 
44 //
45 // constants, enums and typedefs
46 //
47 
48 //
49 // static data member definitions
50 //
51 
52 //
53 // constructors and destructor
54 //
56  _patJetsToken ( consumes<reco::CandidateView> ( iConfig.getParameter<edm::InputTag>( "patJets" ) ) ),
57  _patMuonsToken ( consumes<reco::CandidateView> ( iConfig.getParameter<edm::InputTag>( "patMuons" ) ) ),
58  _patElectronsToken ( consumes<reco::CandidateView> ( iConfig.getParameter<edm::InputTag>( "patElectrons" ) ) ),
59  _patPhotonsToken ( consumes<reco::CandidateView> ( iConfig.getParameter<edm::InputTag>( "patPhotons" ) ) ),
60  _patTausToken ( consumes<reco::CandidateView> ( iConfig.getParameter<edm::InputTag>( "patTaus" ) ) ),
61 
62  _minJetEt ( iConfig.getParameter<double>("minJetEt") ),
63  _minMuonEt ( iConfig.getParameter<double>("minMuonEt") ),
64  _minElectronEt ( iConfig.getParameter<double>("minElectronEt") ),
65  _minTauEt ( iConfig.getParameter<double>("minTauEt") ),
66  _minPhotonEt ( iConfig.getParameter<double>("minPhotonEt") ),
67 
68  _maxJetEta ( iConfig.getParameter<double>("maxJetEta") ),
69  _maxMuonEta ( iConfig.getParameter<double>("maxMuonEta") ),
70  _maxElectronEta ( iConfig.getParameter<double>("maxElectronEta") ),
71  _maxTauEta ( iConfig.getParameter<double>("maxTauEta") ),
72  _maxPhotonEta ( iConfig.getParameter<double>("maxPhotonEta") ),
73 
74  _seedMethod ( iConfig.getParameter<int>("seedMethod") ),
75  _combinationMethod ( iConfig.getParameter<int>("combinationMethod") )
76 
77 {
78 
79 
80  produces< std::vector<pat::Hemisphere> >();
81 }
82 
83 
85 {
86 
87  // do anything here that needs to be done at desctruction time
88  // (e.g. close files, deallocate resources etc.)
89 
90 }
91 
92 
93 //
94 // member functions
95 //
96 
97 // ------------ method called to produce the data ------------
98 void
100 {
101  using namespace edm;
102  using namespace std;
103 
104  //Jets
106  iEvent.getByToken(_patJetsToken,pJets);
107 
108  //Muons
110  iEvent.getByToken(_patMuonsToken,pMuons);
111 
112  //Electrons
113  Handle<reco::CandidateView> pElectrons;
114  iEvent.getByToken(_patElectronsToken,pElectrons);
115 
116  //Photons
118  iEvent.getByToken(_patPhotonsToken,pPhotons);
119 
120  //Taus
122  iEvent.getByToken(_patTausToken,pTaus);
123 
124 
125  //fill e,p vector with information from all objects (hopefully cleaned before)
126  for(int i = 0; i < (int) (*pJets).size() ; i++){
127  if((*pJets)[i].pt() < _minJetEt || fabs((*pJets)[i].eta()) > _maxJetEta) continue;
128 
129  componentPtrs_.push_back(pJets->ptrAt(i));
130  }
131 
132  for(int i = 0; i < (int) (*pMuons).size() ; i++){
133  if((*pMuons)[i].pt() < _minMuonEt || fabs((*pMuons)[i].eta()) > _maxMuonEta) continue;
134 
135  componentPtrs_.push_back(pMuons->ptrAt(i));
136  }
137 
138  for(int i = 0; i < (int) (*pElectrons).size() ; i++){
139  if((*pElectrons)[i].pt() < _minElectronEt || fabs((*pElectrons)[i].eta()) > _maxElectronEta) continue;
140 
141  componentPtrs_.push_back(pElectrons->ptrAt(i));
142  }
143 
144  for(int i = 0; i < (int) (*pPhotons).size() ; i++){
145  if((*pPhotons)[i].pt() < _minPhotonEt || fabs((*pPhotons)[i].eta()) > _maxPhotonEta) continue;
146 
147  componentPtrs_.push_back(pPhotons->ptrAt(i));
148  }
149 
150  //aren't taus included in jets?
151  for(int i = 0; i < (int) (*pTaus).size() ; i++){
152  if((*pTaus)[i].pt() < _minTauEt || fabs((*pTaus)[i].eta()) > _maxTauEta) continue;
153 
154  componentPtrs_.push_back(pTaus->ptrAt(i));
155  }
156 
157  // create product
158  std::auto_ptr< std::vector<Hemisphere> > hemispheres(new std::vector<Hemisphere>);;
159  hemispheres->reserve(2);
160 
161  //calls HemiAlgorithm for seed method 3 (transv. inv. Mass) and association method 3 (Lund algo)
163 
164  //get Hemisphere Axis
165  vA1 = myHemi.getAxis1();
166  vA2 = myHemi.getAxis2();
167 
168  reco::Particle::LorentzVector p1(vA1[0]*vA1[3],vA1[1]*vA1[3],vA1[2]*vA1[3],vA1[4]);
169  hemispheres->push_back(Hemisphere(p1));
170 
171  reco::Particle::LorentzVector p2(vA2[0]*vA2[3],vA2[1]*vA2[3],vA2[2]*vA2[3],vA2[4]);
172  hemispheres->push_back(Hemisphere(p2));
173 
174  //get information to which Hemisphere each object belongs
175  vgroups = myHemi.getGrouping();
176 
177  for ( unsigned int i=0; i<vgroups.size(); ++i ) {
178  if ( vgroups[i]==1 ) {
179  (*hemispheres)[0].addDaughter(componentPtrs_[i]);
180  }
181  else {
182  (*hemispheres)[1].addDaughter(componentPtrs_[i]);
183  }
184  }
185 
186 
187  iEvent.put(hemispheres);
188 
189  //clean up
190 
191  vPx.clear();
192  vPy.clear();
193  vPz.clear();
194  vE.clear();
195  vgroups.clear();
196  componentPtrs_.clear();
197 }
198 
199 
200 
201 // ------------ method called once each job just after ending the event loop ------------
202 void
204 
205 }
206 
207 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::CandidateView > _patElectronsToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< reco::CandidatePtr > componentPtrs_
std::vector< float > vPy
T eta() const
std::vector< float > getAxis1()
std::vector< int > vgroups
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< reco::CandidateView > _patPhotonsToken
virtual void produce(edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< reco::CandidateView > _patJetsToken
Input: All PAT objects that are to cross-clean or needed for that.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double p2[4]
Definition: TauolaWrapper.h:90
std::vector< int > getGrouping()
std::vector< float > vPz
std::vector< float > vE
std::vector< float > vA1
std::vector< float > vA2
PATHemisphereProducer(const edm::ParameterSet &)
std::vector< float > vPx
double p1[4]
Definition: TauolaWrapper.h:89
edm::EDGetTokenT< reco::CandidateView > _patMuonsToken
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:27
std::vector< float > getAxis2()
edm::EDGetTokenT< reco::CandidateView > _patTausToken