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