CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.cc

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 //
00004 // Package:    PatShapeAna
00005 // Class:      PatShapeAna
00006 // 
00014 //
00015 // Original Author:  Tanja Rommerskirchen
00016 //         Created:  Sat Mar 22 12:58:04 CET 2008
00017 // $Id: PATHemisphereProducer.cc,v 1.9 2010/01/11 13:36:48 hegner Exp $
00018 //
00019 //
00020 
00021 
00022 //system
00023 #include <vector>
00024 #include <memory>
00025 //PAT
00026 #include "DataFormats/PatCandidates/interface/Jet.h"
00027 #include "DataFormats/PatCandidates/interface/MET.h"
00028 #include "DataFormats/PatCandidates/interface/Muon.h"
00029 #include "DataFormats/PatCandidates/interface/Electron.h"
00030 #include "DataFormats/PatCandidates/interface/Photon.h"
00031 #include "DataFormats/PatCandidates/interface/Tau.h"
00032 #include "DataFormats/PatCandidates/interface/Hemisphere.h"
00033 //DataFormats
00034 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00035 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00036 #include "DataFormats/TrackReco/interface/Track.h"
00037 #include "DataFormats/Candidate/interface/Particle.h"
00038 //User
00039 #include  "PhysicsTools/PatAlgos/plugins/PATHemisphereProducer.h"
00040 
00041 
00042 using namespace pat;
00043 
00044 
00045 //
00046 // constants, enums and typedefs
00047 //
00048 
00049 //
00050 // static data member definitions
00051 //
00052 
00053 //
00054 // constructors and destructor
00055 //
00056 PATHemisphereProducer::PATHemisphereProducer(const edm::ParameterSet& iConfig) :
00057   _patJets       ( iConfig.getParameter<edm::InputTag>( "patJets" ) ),
00058   _patMuons      ( iConfig.getParameter<edm::InputTag>( "patMuons" ) ),
00059   _patElectrons  ( iConfig.getParameter<edm::InputTag>( "patElectrons" ) ),
00060   _patPhotons    ( iConfig.getParameter<edm::InputTag>( "patPhotons" ) ),
00061   _patTaus       ( iConfig.getParameter<edm::InputTag>( "patTaus" ) ),
00062 
00063   _minJetEt       ( iConfig.getParameter<double>("minJetEt") ),
00064   _minMuonEt       ( iConfig.getParameter<double>("minMuonEt") ),
00065   _minElectronEt       ( iConfig.getParameter<double>("minElectronEt") ),
00066   _minTauEt       ( iConfig.getParameter<double>("minTauEt") ), 
00067   _minPhotonEt       ( iConfig.getParameter<double>("minPhotonEt") ),
00068 
00069   _maxJetEta       ( iConfig.getParameter<double>("maxJetEta") ),
00070   _maxMuonEta       ( iConfig.getParameter<double>("maxMuonEta") ),
00071   _maxElectronEta       ( iConfig.getParameter<double>("maxElectronEta") ),
00072   _maxTauEta       ( iConfig.getParameter<double>("maxTauEta") ), 
00073   _maxPhotonEta       ( iConfig.getParameter<double>("maxPhotonEta") ),
00074 
00075   _seedMethod    ( iConfig.getParameter<int>("seedMethod") ),
00076   _combinationMethod ( iConfig.getParameter<int>("combinationMethod") )
00077 
00078 {
00079 
00080 
00081   produces< std::vector<pat::Hemisphere> >();
00082 }
00083 
00084 
00085 PATHemisphereProducer::~PATHemisphereProducer()
00086 {
00087  
00088    // do anything here that needs to be done at desctruction time
00089    // (e.g. close files, deallocate resources etc.)
00090 
00091 }
00092 
00093 
00094 //
00095 // member functions
00096 //
00097 
00098 // ------------ method called to produce the data  ------------
00099 void
00100 PATHemisphereProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00101 {
00102    using namespace edm;
00103    using namespace std;
00104 
00105    //Jets   
00106    Handle<reco::CandidateView> pJets;
00107    iEvent.getByLabel(_patJets,pJets);
00108 
00109    //Muons   
00110    Handle<reco::CandidateView> pMuons;
00111    iEvent.getByLabel(_patMuons,pMuons);
00112 
00113    //Electrons   
00114    Handle<reco::CandidateView> pElectrons;
00115    iEvent.getByLabel(_patElectrons,pElectrons);
00116 
00117    //Photons   
00118    Handle<reco::CandidateView> pPhotons;
00119    iEvent.getByLabel(_patPhotons,pPhotons);
00120 
00121    //Taus   
00122    Handle<reco::CandidateView> pTaus;
00123    iEvent.getByLabel(_patTaus,pTaus);
00124 
00125 
00126    //fill e,p vector with information from all objects (hopefully cleaned before)
00127    for(int i = 0; i < (int) (*pJets).size() ; i++){
00128      if((*pJets)[i].pt() <  _minJetEt || fabs((*pJets)[i].eta()) >  _maxJetEta) continue;
00129    
00130      componentPtrs_.push_back(pJets->ptrAt(i));
00131    }
00132 
00133    for(int i = 0; i < (int) (*pMuons).size() ; i++){
00134      if((*pMuons)[i].pt() <  _minMuonEt || fabs((*pMuons)[i].eta()) >  _maxMuonEta) continue; 
00135  
00136      componentPtrs_.push_back(pMuons->ptrAt(i));
00137    }
00138   
00139    for(int i = 0; i < (int) (*pElectrons).size() ; i++){
00140      if((*pElectrons)[i].pt() <  _minElectronEt || fabs((*pElectrons)[i].eta()) >  _maxElectronEta) continue;  
00141     
00142      componentPtrs_.push_back(pElectrons->ptrAt(i));
00143    } 
00144 
00145    for(int i = 0; i < (int) (*pPhotons).size() ; i++){
00146      if((*pPhotons)[i].pt() <  _minPhotonEt || fabs((*pPhotons)[i].eta()) >  _maxPhotonEta) continue;   
00147     
00148      componentPtrs_.push_back(pPhotons->ptrAt(i));
00149    } 
00150 
00151    //aren't taus included in jets?
00152    for(int i = 0; i < (int) (*pTaus).size() ; i++){
00153      if((*pTaus)[i].pt() <  _minTauEt || fabs((*pTaus)[i].eta()) >  _maxTauEta) continue;   
00154     
00155      componentPtrs_.push_back(pTaus->ptrAt(i));
00156    }  
00157 
00158    // create product
00159    std::auto_ptr< std::vector<Hemisphere> > hemispheres(new std::vector<Hemisphere>);;
00160    hemispheres->reserve(2);
00161 
00162   //calls HemiAlgorithm for seed method 3 (transv. inv. Mass) and association method 3 (Lund algo)
00163   HemisphereAlgo myHemi(componentPtrs_,_seedMethod,_combinationMethod);
00164 
00165   //get Hemisphere Axis 
00166   vA1 = myHemi.getAxis1();
00167   vA2 = myHemi.getAxis2();
00168 
00169   reco::Particle::LorentzVector p1(vA1[0]*vA1[3],vA1[1]*vA1[3],vA1[2]*vA1[3],vA1[4]);
00170   hemispheres->push_back(Hemisphere(p1));
00171 
00172   reco::Particle::LorentzVector p2(vA2[0]*vA2[3],vA2[1]*vA2[3],vA2[2]*vA2[3],vA2[4]);
00173   hemispheres->push_back(Hemisphere(p2));
00174  
00175   //get information to which Hemisphere each object belongs
00176   vgroups = myHemi.getGrouping(); 
00177 
00178   for ( unsigned int i=0; i<vgroups.size(); ++i ) {
00179     if ( vgroups[i]==1 ) {
00180       (*hemispheres)[0].addDaughter(componentPtrs_[i]);
00181     }
00182     else {
00183       (*hemispheres)[1].addDaughter(componentPtrs_[i]);
00184     }
00185   }
00186 
00187 
00188   iEvent.put(hemispheres);
00189 
00190   //clean up
00191 
00192     vPx.clear();
00193     vPy.clear();
00194     vPz.clear();
00195     vE.clear();
00196     vgroups.clear();
00197     componentPtrs_.clear();
00198 }
00199 
00200 
00201 
00202 // ------------ method called once each job just after ending the event loop  ------------
00203 void 
00204 PATHemisphereProducer::endJob() {
00205   
00206 }
00207 
00208 //define this as a plug-in
00209 DEFINE_FWK_MODULE(PATHemisphereProducer);