CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoTauTag/HLTProducers/src/L1HLTTauMatching.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/HLTProducers/interface/L1HLTTauMatching.h"
00002 #include "Math/GenVector/VectorUtil.h"
00003 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00004 #include "DataFormats/L1Trigger/interface/L1JetParticleFwd.h"
00005 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
00006 #include "FWCore/Utilities/interface/EDMException.h"
00007 #include "DataFormats/TauReco/interface/PFTau.h"
00008 
00009 //
00010 // class decleration
00011 //
00012 using namespace reco;
00013 using namespace std;
00014 using namespace edm;
00015 using namespace l1extra;
00016 
00017 L1HLTTauMatching::L1HLTTauMatching(const edm::ParameterSet& iConfig)
00018 {
00019   jetSrc = iConfig.getParameter<InputTag>("JetSrc");
00020   tauTrigger = iConfig.getParameter<InputTag>("L1TauTrigger");
00021   mEt_Min = iConfig.getParameter<double>("EtMin");
00022   
00023   produces<PFTauCollection>();
00024 }
00025 L1HLTTauMatching::~L1HLTTauMatching(){ }
00026 
00027 void L1HLTTauMatching::produce(edm::Event& iEvent, const edm::EventSetup& iES)
00028 {
00029         
00030         using namespace edm;
00031         using namespace std;
00032         using namespace reco;
00033         using namespace trigger;
00034         using namespace l1extra;
00035         
00036           auto_ptr<PFTauCollection> tauL2jets(new PFTauCollection);
00037         
00038         double deltaR = 1.0;
00039         double matchingR = 0.5;
00040         //Getting HLT jets to be matched
00041         edm::Handle<PFTauCollection > tauJets;
00042         iEvent.getByLabel( jetSrc, tauJets );
00043 
00044 //              std::cout <<"Size of input jet collection "<<tauJets->size()<<std::endl;
00045                 
00046         edm::Handle<trigger::TriggerFilterObjectWithRefs> l1TriggeredTaus;
00047     iEvent.getByLabel(tauTrigger,l1TriggeredTaus);
00048                 
00049                 
00050                 tauCandRefVec.clear();
00051                 jetCandRefVec.clear();
00052                 
00053                 l1TriggeredTaus->getObjects( trigger::TriggerL1TauJet,tauCandRefVec);
00054                 l1TriggeredTaus->getObjects( trigger::TriggerL1CenJet,jetCandRefVec);
00055                 math::XYZPoint a(0.,0.,0.);
00056                 CaloJet::Specific f;
00057                 
00058                 for( unsigned int iL1Tau=0; iL1Tau <tauCandRefVec.size();iL1Tau++)
00059                 {  
00060                         for(unsigned int iJet=0;iJet<tauJets->size();iJet++)
00061                         {
00062                                 //Find the relative L2TauJets, to see if it has been reconstructed
00063                                 const PFTau &  myJet = (*tauJets)[iJet];
00064                                 deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect());
00065                                 if(deltaR < matchingR ) {
00066                                         //               LeafCandidate myLC(myJet);
00067                     if(myJet.leadPFChargedHadrCand().isNonnull()){
00068                         a =  myJet.leadPFChargedHadrCand()->vertex();  
00069                     }
00070                                   PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(), myJet.p4(), a);
00071                                         if(myJet.pt() > mEt_Min) {
00072                                                 //                tauL2LC->push_back(myLC);
00073                                                 tauL2jets->push_back(myPFTau);
00074                                         }
00075                                         break;
00076                                 }
00077                         }
00078                 }  
00079                 
00080                 for(unsigned int iL1Tau=0; iL1Tau <jetCandRefVec.size();iL1Tau++)
00081                 {  
00082                         for(unsigned int iJet=0;iJet<tauJets->size();iJet++)
00083                         {
00084                                 const PFTau &  myJet = (*tauJets)[iJet];
00085                                 //Find the relative L2TauJets, to see if it has been reconstructed
00086                                 deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect());
00087                                 if(deltaR < matchingR ) {
00088                                         //               LeafCandidate myLC(myJet);
00089                     if(myJet.leadPFChargedHadrCand().isNonnull()){
00090                         a =  myJet.leadPFChargedHadrCand()->vertex();  
00091                     }
00092                     
00093                                   PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(), myJet.p4(),a);
00094                                         if(myJet.pt() > mEt_Min) {
00095                                                 //tauL2LC->push_back(myLC);
00096                                                 tauL2jets->push_back(myPFTau);
00097                                         }
00098                                         break;
00099                                 }
00100                         }
00101                 }
00102         
00103 
00104 //std::cout <<"Size of L1HLT matched jets "<<tauL2jets->size()<<std::endl;
00105 
00106 iEvent.put(tauL2jets);
00107 // iEvent.put(tauL2LC);
00108 }