CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauMETAlgo.cc
Go to the documentation of this file.
1 // File: TauMETAlgo.cc
2 // Description: see TauMETAlgo.h
3 // Authors: Alfredo Gurrola, C.N.Nguyen
4 
7 
8 using namespace std;
9 using namespace reco;
10 
13 
16 
19  double jetPTthreshold,double jetEMfracLimit,
20  const JetCorrector& correctedjets,const std::vector<CaloMET>& uncorMET,double jetMatchDeltaR,
21  double tauMinEt,double tauEtaMax,bool useSeedTrack,double seedTrackPt,bool useTrackIsolation,double trackIsolationMinPt,
22  bool useECALIsolation,double gammaIsolationMinPt,bool useProngStructure,std::vector<CaloMET>* corrMET) {
23 
24  // std::cerr << "TauMETAlgo::run -> Test.. " << std::endl;
25 
26  double DeltaPx = 0.0;
27  double DeltaPy = 0.0;
28  double DeltaSumET = 0.0;
29  for(PFTauCollection::size_type iPFTau=0;iPFTau<tauHandle->size();iPFTau++) {
30  PFTauRef thePFTau(tauHandle,iPFTau);
31  bool matchFlag = false;
32  bool goodTau = false;
33  if((fabs(thePFTau->eta()) <= tauEtaMax) && (thePFTau->et() >= tauMinEt)) {
34  goodTau = true;
35  if(useSeedTrack) {
36  if(!(thePFTau->leadPFChargedHadrCand())) {goodTau = false;}
37  else {
38  if(thePFTau->leadPFChargedHadrCand()->et() < seedTrackPt) {goodTau = false;}
39  }
40  }
41  if(useTrackIsolation) {
42  PFCandidateRefVector PFTauProdIsolCHCands = (*thePFTau).isolationPFChargedHadrCands();
43  for(PFCandidateRefVector::const_iterator iChargedHadrCand=PFTauProdIsolCHCands.begin();
44  iChargedHadrCand!=PFTauProdIsolCHCands.end();++iChargedHadrCand) {
45  if((**iChargedHadrCand).pt() > trackIsolationMinPt) {goodTau = false;}
46  }
47  }
48  if(useECALIsolation) {
49  PFCandidateRefVector PFTauProdIsolGammaCands = (*thePFTau).isolationPFGammaCands();
50  for(PFCandidateRefVector::const_iterator iGammaCand=PFTauProdIsolGammaCands.begin();
51  iGammaCand!=PFTauProdIsolGammaCands.end();++iGammaCand) {
52  if((**iGammaCand).et() > gammaIsolationMinPt) {goodTau = false;}
53  }
54  }
55  if(useProngStructure) {
56  if((thePFTau->signalPFChargedHadrCands().size() != 1) && (thePFTau->signalPFChargedHadrCands().size() != 3)) {goodTau = false;}
57  }
58  }
59  if(goodTau) {
60  for(CaloJetCollection::const_iterator calojetIter = calojetHandle->begin();calojetIter != calojetHandle->end();++calojetIter) {
61  if(deltaR(calojetIter->p4(),thePFTau->p4())<jetMatchDeltaR) {
62  if( calojetIter->pt() > jetPTthreshold && calojetIter->emEnergyFraction() < jetEMfracLimit ) {
63  double correct = correctedjets.correction (*calojetIter);
64  DeltaPx += ((correct * calojetIter->px()) - thePFTau->px());
65  DeltaPy += ((correct * calojetIter->py()) - thePFTau->py());
66  DeltaSumET += ((correct * calojetIter->et()) - thePFTau->et());
67  } else {
68  DeltaPx += (calojetIter->px() - thePFTau->px());
69  DeltaPy += (calojetIter->py() - thePFTau->py());
70  DeltaSumET += (calojetIter->et() - thePFTau->et());
71  }
72  if(matchFlag) {std::cerr << "### TauMETAlgo - ERROR: Multiple jet matches!!!! " << std::endl;}
73  matchFlag = true;
74  }
75  }
76  }
77  }
79  delta.mex = DeltaPx;
80  delta.mey = DeltaPy;
81  delta.sumet = - DeltaSumET;
82  const CaloMET* u = &(uncorMET.front());
83  double corrMetPx = u->px() + delta.mex;
84  double corrMetPy = u->py() + delta.mey;
85  MET::LorentzVector correctedMET4vector( corrMetPx, corrMetPy, 0., sqrt(corrMetPx*corrMetPx + corrMetPy*corrMetPy));
86  std::vector<CorrMETData> corrections = u->mEtCorr();
87  corrections.push_back(delta);
89  result = CaloMET(u->getSpecific(), (u->sumEt() + delta.sumet), corrections, correctedMET4vector, u->vertex());
90  corrMET->push_back(result);
91  }
92 
95  double jetPTthreshold,double jetEMfracLimit,
96  const JetCorrector& correctedjets,const std::vector<MET>& uncorMET,double jetMatchDeltaR,
97  double tauMinEt,double tauEtaMax,bool useSeedTrack,double seedTrackPt,bool useTrackIsolation,double trackIsolationMinPt,
98  bool useECALIsolation,double gammaIsolationMinPt,bool useProngStructure,std::vector<MET>* corrMET) {
99 
100  std::cerr << "TauMETAlgo::run -> Test.. " << std::endl;
101 
102  double DeltaPx = 0.0;
103  double DeltaPy = 0.0;
104  double DeltaSumET = 0.0;
105  for(PFTauCollection::size_type iPFTau=0;iPFTau<tauHandle->size();iPFTau++) {
106  PFTauRef thePFTau(tauHandle,iPFTau);
107  bool matchFlag = false;
108  bool goodTau = false;
109  if((fabs(thePFTau->eta()) <= tauEtaMax) && (thePFTau->et() >= tauMinEt)) {
110  goodTau = true;
111  if(useSeedTrack) {
112  if(!(thePFTau->leadPFChargedHadrCand())) {goodTau = false;}
113  else {
114  if(thePFTau->leadPFChargedHadrCand()->et() < seedTrackPt) {goodTau = false;}
115  }
116  }
117  if(useTrackIsolation) {
118  PFCandidateRefVector PFTauProdIsolCHCands = (*thePFTau).isolationPFChargedHadrCands();
119  for(PFCandidateRefVector::const_iterator iChargedHadrCand=PFTauProdIsolCHCands.begin();
120  iChargedHadrCand!=PFTauProdIsolCHCands.end();++iChargedHadrCand) {
121  if((**iChargedHadrCand).pt() > trackIsolationMinPt) {goodTau = false;}
122  }
123  }
124  if(useECALIsolation) {
125  PFCandidateRefVector PFTauProdIsolGammaCands = (*thePFTau).isolationPFGammaCands();
126  for(PFCandidateRefVector::const_iterator iGammaCand=PFTauProdIsolGammaCands.begin();
127  iGammaCand!=PFTauProdIsolGammaCands.end();++iGammaCand) {
128  if((**iGammaCand).et() > gammaIsolationMinPt) {goodTau = false;}
129  }
130  }
131  if(useProngStructure) {
132  if((thePFTau->signalPFChargedHadrCands().size() != 1) && (thePFTau->signalPFChargedHadrCands().size() != 3)) {goodTau = false;}
133  }
134  }
135  if(goodTau) {
136  for(CaloJetCollection::const_iterator calojetIter = calojetHandle->begin();calojetIter != calojetHandle->end();++calojetIter) {
137  if(deltaR(calojetIter->p4(),thePFTau->p4())<jetMatchDeltaR) {
138  if( calojetIter->pt() > jetPTthreshold && calojetIter->emEnergyFraction() < jetEMfracLimit ) {
139  double correct = correctedjets.correction (*calojetIter);
140  DeltaPx += ((correct * calojetIter->px()) - thePFTau->px());
141  DeltaPy += ((correct * calojetIter->py()) - thePFTau->py());
142  DeltaSumET += ((correct * calojetIter->et()) - thePFTau->et());
143  } else {
144  DeltaPx += (calojetIter->px() - thePFTau->px());
145  DeltaPy += (calojetIter->py() - thePFTau->py());
146  DeltaSumET += (calojetIter->et() - thePFTau->et());
147  }
148  if(matchFlag) {std::cerr << "### TauMETAlgo - ERROR: Multiple jet matches!!!! " << std::endl;}
149  matchFlag = true;
150  }
151  }
152  }
153  }
155  delta.mex = DeltaPx;
156  delta.mey = DeltaPy;
157  delta.sumet = - DeltaSumET;
158  const MET* u = &(uncorMET.front());
159  double corrMetPx = u->px() + delta.mex;
160  double corrMetPy = u->py() + delta.mey;
161  MET::LorentzVector correctedMET4vector( corrMetPx, corrMetPy, 0., sqrt(corrMetPx*corrMetPx + corrMetPy*corrMetPy));
162  std::vector<CorrMETData> corrections = u->mEtCorr();
163  corrections.push_back(delta);
164  MET result;
165  result = MET((u->sumEt() + delta.sumet), corrections, correctedMET4vector, u->vertex());
166  corrMET->push_back(result);
167  }
168 
dbl * delta
Definition: mlp_gen.cc:36
virtual const Point & vertex() const
vertex position
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
std::pair< double, double > Point
Definition: CaloEllipse.h:18
uint16_t size_type
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
virtual ~TauMETAlgo()
Definition: TauMETAlgo.cc:15
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
SpecificCaloMETData getSpecific() const
Definition: CaloMET.h:79
int iEvent
Definition: GenABIO.cc:243
double sumEt() const
Definition: MET.h:48
Definition: MET.h:32
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
double sumet
Definition: CorrMETData.h:20
std::vector< CorrMETData > mEtCorr() const
Definition: MET.h:63
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual double px() const
x coordinate of momentum vector
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
a MET correction term
Definition: CorrMETData.h:14
virtual void run(edm::Event &, const edm::EventSetup &, edm::Handle< reco::PFTauCollection >, edm::Handle< reco::CaloJetCollection >, double, double, const JetCorrector &, const std::vector< reco::CaloMET > &, double, double, double, bool, double, bool, double, bool, double, bool, std::vector< reco::CaloMET > *corrMET)
Definition: TauMETAlgo.cc:17
double mey
Definition: CorrMETData.h:18
double mex
Definition: CorrMETData.h:17
virtual double py() const
y coordinate of momentum vector
math::PtEtaPhiELorentzVectorF LorentzVector