CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1HLTTauMatching.cc
Go to the documentation of this file.
2 #include "Math/GenVector/VectorUtil.h"
8 
9 //
10 // class decleration
11 //
12 using namespace reco;
13 using namespace std;
14 using namespace edm;
15 using namespace l1extra;
16 
18 {
19  jetSrc = consumes<PFTauCollection>(iConfig.getParameter<InputTag>("JetSrc") );
20  tauTrigger = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<InputTag>("L1TauTrigger") );
21  mEt_Min = iConfig.getParameter<double>("EtMin");
22 
23  produces<PFTauCollection>();
24 }
26 
28 {
29 
30  using namespace edm;
31  using namespace std;
32  using namespace reco;
33  using namespace trigger;
34  using namespace l1extra;
35 
36  auto_ptr<PFTauCollection> tauL2jets(new PFTauCollection);
37 
38  double deltaR = 1.0;
39  double matchingR = 0.5;
40  //Getting HLT jets to be matched
42  iEvent.getByToken( jetSrc, tauJets );
43 
44  // std::cout <<"Size of input jet collection "<<tauJets->size()<<std::endl;
45 
47  iEvent.getByToken(tauTrigger,l1TriggeredTaus);
48 
49 
50  tauCandRefVec.clear();
51  jetCandRefVec.clear();
52 
53  l1TriggeredTaus->getObjects( trigger::TriggerL1TauJet,tauCandRefVec);
54  l1TriggeredTaus->getObjects( trigger::TriggerL1CenJet,jetCandRefVec);
55  math::XYZPoint a(0.,0.,0.);
57 
58  for( unsigned int iL1Tau=0; iL1Tau <tauCandRefVec.size();iL1Tau++)
59  {
60  for(unsigned int iJet=0;iJet<tauJets->size();iJet++)
61  {
62  //Find the relative L2TauJets, to see if it has been reconstructed
63  const PFTau & myJet = (*tauJets)[iJet];
64  deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect());
65  if(deltaR < matchingR ) {
66  // LeafCandidate myLC(myJet);
67  if(myJet.leadPFChargedHadrCand().isNonnull()){
68  a = myJet.leadPFChargedHadrCand()->vertex();
69  }
70  PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(), myJet.p4(), a);
71  if(myJet.pt() > mEt_Min) {
72  // tauL2LC->push_back(myLC);
73  tauL2jets->push_back(myPFTau);
74  }
75  break;
76  }
77  }
78  }
79 
80  for(unsigned int iL1Tau=0; iL1Tau <jetCandRefVec.size();iL1Tau++)
81  {
82  for(unsigned int iJet=0;iJet<tauJets->size();iJet++)
83  {
84  const PFTau & myJet = (*tauJets)[iJet];
85  //Find the relative L2TauJets, to see if it has been reconstructed
86  deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect());
87  if(deltaR < matchingR ) {
88  // LeafCandidate myLC(myJet);
89  if(myJet.leadPFChargedHadrCand().isNonnull()){
90  a = myJet.leadPFChargedHadrCand()->vertex();
91  }
92 
93  PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(), myJet.p4(),a);
94  if(myJet.pt() > mEt_Min) {
95  //tauL2LC->push_back(myLC);
96  tauL2jets->push_back(myPFTau);
97  }
98  break;
99  }
100  }
101  }
102 
103 
104  //std::cout <<"Size of L1HLT matched jets "<<tauL2jets->size()<<std::endl;
105 
106  iEvent.put(tauL2jets);
107  // iEvent.put(tauL2LC);
108 }
T getParameter(std::string const &) const
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
const PFCandidatePtr & leadPFChargedHadrCand() const
Definition: PFTau.cc:61
virtual float pt() const
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
L1HLTTauMatching(const edm::ParameterSet &)
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double f[11][100]
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
virtual void produce(edm::Event &, const edm::EventSetup &) override
double a
Definition: hdecay.h:121
virtual const LorentzVector & p4() const
four-momentum Lorentz vector