CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFRecoTauAlgorithm.cc
Go to the documentation of this file.
2 
3 // Turn off filtering by pt. Min pt is set to zero,
4 // as this functionality is implemented in the underlying
5 // PFTauTagInfo production. Additional pt filters are applied
6 // the discriminators.
7 
8 #define PFTauAlgo_NeutrHadrCand_minPt_ (0.0)
9 #define PFTauAlgo_GammaCand_minPt_ (0.0)
10 #define PFTauAlgo_PFCand_minPt_ (0.0)
11 #define PFTauAlgo_Track_minPt_ (0.0)
12 #define PFTauAlgo_ChargedHadrCand_minPt_ (0.0)
13 
14 using namespace reco;
15 
18  LeadPFCand_minPt_ = iConfig.getParameter<double>("LeadPFCand_minPt");
19 
21  = iConfig.getParameter<bool>("UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint");
22 
24  = iConfig.getParameter<double>("ChargedHadrCandLeadChargedHadrCand_tksmaxDZ");
25 
26  LeadTrack_minPt_ = iConfig.getParameter<double>("LeadTrack_minPt");
27  UseTrackLeadTrackDZconstraint_ = iConfig.getParameter<bool>("UseTrackLeadTrackDZconstraint");
28  TrackLeadTrack_maxDZ_ = iConfig.getParameter<double>("TrackLeadTrack_maxDZ");
29 
30  MatchingConeMetric_ = iConfig.getParameter<std::string>("MatchingConeMetric");
31  MatchingConeSizeFormula_ = iConfig.getParameter<std::string>("MatchingConeSizeFormula");
32  MatchingConeSize_min_ = iConfig.getParameter<double>("MatchingConeSize_min");
33  MatchingConeSize_max_ = iConfig.getParameter<double>("MatchingConeSize_max");
34  TrackerSignalConeMetric_ = iConfig.getParameter<std::string>("TrackerSignalConeMetric");
35  TrackerSignalConeSizeFormula_ = iConfig.getParameter<std::string>("TrackerSignalConeSizeFormula");
36  TrackerSignalConeSize_min_ = iConfig.getParameter<double>("TrackerSignalConeSize_min");
37  TrackerSignalConeSize_max_ = iConfig.getParameter<double>("TrackerSignalConeSize_max");
38  TrackerIsolConeMetric_ = iConfig.getParameter<std::string>("TrackerIsolConeMetric");
39  TrackerIsolConeSizeFormula_ = iConfig.getParameter<std::string>("TrackerIsolConeSizeFormula");
40  TrackerIsolConeSize_min_ = iConfig.getParameter<double>("TrackerIsolConeSize_min");
41  TrackerIsolConeSize_max_ = iConfig.getParameter<double>("TrackerIsolConeSize_max");
42  ECALSignalConeMetric_ = iConfig.getParameter<std::string>("ECALSignalConeMetric");
43  ECALSignalConeSizeFormula_ = iConfig.getParameter<std::string>("ECALSignalConeSizeFormula");
44  ECALSignalConeSize_min_ = iConfig.getParameter<double>("ECALSignalConeSize_min");
45  ECALSignalConeSize_max_ = iConfig.getParameter<double>("ECALSignalConeSize_max");
46  ECALIsolConeMetric_ = iConfig.getParameter<std::string>("ECALIsolConeMetric");
47  ECALIsolConeSizeFormula_ = iConfig.getParameter<std::string>("ECALIsolConeSizeFormula");
48  ECALIsolConeSize_min_ = iConfig.getParameter<double>("ECALIsolConeSize_min");
49  ECALIsolConeSize_max_ = iConfig.getParameter<double>("ECALIsolConeSize_max");
50  HCALSignalConeMetric_ = iConfig.getParameter<std::string>("HCALSignalConeMetric");
51  HCALSignalConeSizeFormula_ = iConfig.getParameter<std::string>("HCALSignalConeSizeFormula");
52  HCALSignalConeSize_min_ = iConfig.getParameter<double>("HCALSignalConeSize_min");
53  HCALSignalConeSize_max_ = iConfig.getParameter<double>("HCALSignalConeSize_max");
54  HCALIsolConeMetric_ = iConfig.getParameter<std::string>("HCALIsolConeMetric");
55  HCALIsolConeSizeFormula_ = iConfig.getParameter<std::string>("HCALIsolConeSizeFormula");
56  HCALIsolConeSize_min_ = iConfig.getParameter<double>("HCALIsolConeSize_min");
57  HCALIsolConeSize_max_ = iConfig.getParameter<double>("HCALIsolConeSize_max");
58 
59  putNeutralHadronsInP4_ = iConfig.exists("putNeutralHadronsInP4") ?
60  iConfig.getParameter<bool>("putNeutralHadronsInP4") : false;
61 
62  // get paramaeters for ellipse EELL
63  Rphi_ = iConfig.getParameter<double>("Rphi");
64  MaxEtInEllipse_ = iConfig.getParameter<double>("MaxEtInEllipse");
65  AddEllipseGammas_ = iConfig.getParameter<bool>("AddEllipseGammas");
66  // EELL
67 
68  AreaMetric_recoElements_maxabsEta_ = iConfig.getParameter<double>("AreaMetric_recoElements_maxabsEta");
69  ChargedHadrCand_IsolAnnulus_minNhits_ = iConfig.getParameter<uint32_t>("ChargedHadrCand_IsolAnnulus_minNhits");
70  Track_IsolAnnulus_minNhits_ = iConfig.getParameter<uint32_t>("Track_IsolAnnulus_minNhits");
71 
72  ElecPreIDLeadTkMatch_maxDR_ = iConfig.getParameter<double>("ElecPreIDLeadTkMatch_maxDR");
73  EcalStripSumE_minClusEnergy_ = iConfig.getParameter<double>("EcalStripSumE_minClusEnergy");
74  EcalStripSumE_deltaEta_ = iConfig.getParameter<double>("EcalStripSumE_deltaEta");
75  EcalStripSumE_deltaPhiOverQ_minValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_minValue");
76  EcalStripSumE_deltaPhiOverQ_maxValue_ = iConfig.getParameter<double>("EcalStripSumE_deltaPhiOverQ_maxValue");
77  maximumForElectrionPreIDOutput_ = iConfig.getParameter<double>("maximumForElectrionPreIDOutput");
78 
79  DataType_ = iConfig.getParameter<std::string>("DataType");
80 
81  //TFormula computation
82  myMatchingConeSizeTFormula = TauTagTools::computeConeSizeTFormula(MatchingConeSizeFormula_,"Matching cone size");
83  //Charged particles cones
84  myTrackerSignalConeSizeTFormula = TauTagTools::computeConeSizeTFormula(TrackerSignalConeSizeFormula_,"Tracker signal cone size");
85  myTrackerIsolConeSizeTFormula = TauTagTools::computeConeSizeTFormula(TrackerIsolConeSizeFormula_,"Tracker isolation cone size");
86  //Gamma candidates cones
87  myECALSignalConeSizeTFormula = TauTagTools::computeConeSizeTFormula(ECALSignalConeSizeFormula_,"ECAL signal cone size");
88  myECALIsolConeSizeTFormula = TauTagTools::computeConeSizeTFormula(ECALIsolConeSizeFormula_,"ECAL isolation cone size");
89  //Neutral hadrons cones
90  myHCALSignalConeSizeTFormula = TauTagTools::computeConeSizeTFormula(HCALSignalConeSizeFormula_,"HCAL signal cone size");
91  myHCALIsolConeSizeTFormula = TauTagTools::computeConeSizeTFormula(HCALIsolConeSizeFormula_,"HCAL isolation cone size");
92 }
93 
94 
95 PFTau PFRecoTauAlgorithm::buildPFTau(const PFTauTagInfoRef& myPFTauTagInfoRef, const Vertex& myPV)
96 {
97  PFJetRef myPFJet=(*myPFTauTagInfoRef).pfjetRef(); // catch a ref to the initial PFJet
98  PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(),myPFJet->p4()); // create the PFTau
99 
100  myPFTau.setpfTauTagInfoRef(myPFTauTagInfoRef);
101 
102  PFCandidateRefVector myPFCands=(*myPFTauTagInfoRef).PFCands();
103 
104  PFTauElementsOperators myPFTauElementsOperators(myPFTau);
105  double myMatchingConeSize=myPFTauElementsOperators.computeConeSize(myMatchingConeSizeTFormula,MatchingConeSize_min_,MatchingConeSize_max_);
106 
107  PFCandidateRef myleadPFChargedCand=myPFTauElementsOperators.leadPFChargedHadrCand(MatchingConeMetric_,myMatchingConeSize,PFTauAlgo_PFCand_minPt_);
108 
109  // These two quantities always taken from the signal cone
110  PFCandidateRef myleadPFNeutralCand;
111  PFCandidateRef myleadPFCand;
112 
113  bool myleadPFCand_rectkavailable = false;
114  double myleadPFCand_rectkDZ = 0.;
115 
116  // Determine the SIPT of the lead track
117  if(myleadPFChargedCand.isNonnull()) {
118  myPFTau.setleadPFChargedHadrCand(myleadPFChargedCand);
119  TrackRef myleadPFCand_rectk=(*myleadPFChargedCand).trackRef();
120  if(myleadPFCand_rectk.isNonnull()) {
121  myleadPFCand_rectkavailable=true;
122  myleadPFCand_rectkDZ=(*myleadPFCand_rectk).dz(myPV.position());
123  if(TransientTrackBuilder_!=0) {
124  const TransientTrack myleadPFCand_rectransienttk=TransientTrackBuilder_->build(&(*myleadPFCand_rectk));
125  GlobalVector myPFJetdir((*myPFJet).px(),(*myPFJet).py(),(*myPFJet).pz());
126  if(IPTools::signedTransverseImpactParameter(myleadPFCand_rectransienttk,myPFJetdir,myPV).first)
127  myPFTau.setleadPFChargedHadrCandsignedSipt(
128  IPTools::signedTransverseImpactParameter(myleadPFCand_rectransienttk,myPFJetdir,myPV).second.significance());
129  }
130  }
131  }
132 
133  //Building PF Components
134  if (myleadPFChargedCand.isNonnull())
135  {
136  math::XYZVector tauAxis = myleadPFChargedCand->momentum();
137  // Compute energy of the PFTau considering only inner constituents
138  // (inner == pfcandidates inside a cone which is equal to the maximum value of the signal cone)
139  // The axis is built about the lead charged hadron
140  PFCandidateRefVector myTmpPFCandsInSignalCone =
141  myPFTauElementsOperators.PFCandsInCone(tauAxis,TrackerSignalConeMetric_,TrackerSignalConeSize_max_,0.5);
142  math::XYZTLorentzVector tmpLorentzVect(0.,0.,0.,0.);
143 
144  double jetOpeningAngle = 0.0;
145  for (PFCandidateRefVector::const_iterator iCand = myTmpPFCandsInSignalCone.begin();
146  iCand != myTmpPFCandsInSignalCone.end(); iCand++)
147  {
148  //find the maximum opening angle of the jet (now a parameter in available TFormulas)
149  double deltaRToSeed = TauTagTools::computeDeltaR(tauAxis, (**iCand).momentum());
150  if (deltaRToSeed > jetOpeningAngle)
151  jetOpeningAngle = deltaRToSeed;
152 
153  tmpLorentzVect+=(**iCand).p4();
154  }
155 
156  //Setting the myPFTau four momentum as the one made from the signal cone constituents.
157  double energy = tmpLorentzVect.energy();
158  double transverseEnergy = tmpLorentzVect.pt();
159  myPFTau.setP4(tmpLorentzVect);
160 
161  // Compute the cone sizes
162  double myTrackerSignalConeSize = myPFTauElementsOperators.computeConeSize(
163  myTrackerSignalConeSizeTFormula, TrackerSignalConeSize_min_, TrackerSignalConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
164  double myTrackerIsolConeSize = myPFTauElementsOperators.computeConeSize(
165  myTrackerIsolConeSizeTFormula, TrackerIsolConeSize_min_, TrackerIsolConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
166  double myECALSignalConeSize = myPFTauElementsOperators.computeConeSize(
167  myECALSignalConeSizeTFormula, ECALSignalConeSize_min_, ECALSignalConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
168  double myECALIsolConeSize = myPFTauElementsOperators.computeConeSize(
169  myECALIsolConeSizeTFormula, ECALIsolConeSize_min_, ECALIsolConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
170  double myHCALSignalConeSize = myPFTauElementsOperators.computeConeSize(
171  myHCALSignalConeSizeTFormula, HCALSignalConeSize_min_, HCALSignalConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
172  double myHCALIsolConeSize = myPFTauElementsOperators.computeConeSize(
173  myHCALIsolConeSizeTFormula, HCALIsolConeSize_min_, HCALIsolConeSize_max_, transverseEnergy, energy, jetOpeningAngle);
174 
175  // Signal cone collections
176  PFCandidateRefVector mySignalPFChargedHadrCands, mySignalPFNeutrHadrCands, mySignalPFGammaCands, mySignalPFCands;
177 
178  if (UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_ && myleadPFCand_rectkavailable) {
179  mySignalPFChargedHadrCands=myPFTauElementsOperators.PFChargedHadrCandsInCone(tauAxis,
181  ChargedHadrCandLeadChargedHadrCand_tksmaxDZ_, myleadPFCand_rectkDZ, myPV);
182  }
183  else {
184  mySignalPFChargedHadrCands=myPFTauElementsOperators.PFChargedHadrCandsInCone(tauAxis,
186  }
187 
188  // Set the Charged hadronics that live in the signal cones
189  myPFTau.setsignalPFChargedHadrCands(mySignalPFChargedHadrCands);
190 
191  // Set the neurtral hadrons that live in the signal cone
192  mySignalPFNeutrHadrCands=myPFTauElementsOperators.PFNeutrHadrCandsInCone(tauAxis,
194 
195  myPFTau.setsignalPFNeutrHadrCands(mySignalPFNeutrHadrCands);
196 
197  // Compute the gammas that live in the signal cone
198  mySignalPFGammaCands=myPFTauElementsOperators.PFGammaCandsInCone(tauAxis,
200 
201  myPFTau.setsignalPFGammaCands(mySignalPFGammaCands);
202 
203  // Add charged objects to signal cone, and calculate charge
204  if(mySignalPFChargedHadrCands.size() != 0) {
205  int mySignalPFChargedHadrCands_qsum=0;
206  for(size_t i = 0; i < mySignalPFChargedHadrCands.size(); i++) {
207  mySignalPFChargedHadrCands_qsum += mySignalPFChargedHadrCands[i]->charge();
208  mySignalPFCands.push_back(mySignalPFChargedHadrCands[i]);
209  }
210  myPFTau.setCharge(mySignalPFChargedHadrCands_qsum);
211  }
212 
213  //Add neutral objects to signal cone
214  for(size_t i = 0; i < mySignalPFNeutrHadrCands.size(); i++) {
215  mySignalPFCands.push_back(mySignalPFNeutrHadrCands[i]);
216  }
217 
218  // For the signal gammas, keep track of the highest pt object
219  double maxSignalGammaPt = 0.;
220  for(size_t i = 0; i < mySignalPFGammaCands.size(); i++) {
221  if(mySignalPFGammaCands[i]->pt() > maxSignalGammaPt) {
222  myleadPFNeutralCand = mySignalPFGammaCands[i];
223  maxSignalGammaPt = mySignalPFGammaCands[i]->pt();
224  }
225  mySignalPFCands.push_back(mySignalPFGammaCands[i]);
226  }
227  myPFTau.setsignalPFCands(mySignalPFCands);
228  // Set leading gamma
229  myPFTau.setleadPFNeutralCand(myleadPFNeutralCand);
230 
231  // Logic to determine lead PFCand. If the lead charged object
232  // is above the threshold, take that. If the lead charged object is less
233  // than the threshold (but exists), AND there exists a gamma above the threshold
234  // take the gamma as the leadPFCand. Otherwise it is null.
235 
236  if(myleadPFChargedCand->pt() > LeadPFCand_minPt_) {
237  myPFTau.setleadPFCand(myleadPFChargedCand);
238  } else if (maxSignalGammaPt > LeadPFCand_minPt_) {
239  myPFTau.setleadPFCand(myleadPFNeutralCand);
240  }
241 
242  // Declare isolation collections
243  PFCandidateRefVector myUnfilteredIsolPFChargedHadrCands, myIsolPFNeutrHadrCands, myIsolPFGammaCands, myIsolPFCands;
244 
245  // Build unfiltered isolation collection
246  if(UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_ && myleadPFCand_rectkavailable) {
247  myUnfilteredIsolPFChargedHadrCands=myPFTauElementsOperators.PFChargedHadrCandsInAnnulus(
248  tauAxis,TrackerSignalConeMetric_,myTrackerSignalConeSize,TrackerIsolConeMetric_,myTrackerIsolConeSize,
250  } else {
251  myUnfilteredIsolPFChargedHadrCands=myPFTauElementsOperators.PFChargedHadrCandsInAnnulus(
252  tauAxis,TrackerSignalConeMetric_,myTrackerSignalConeSize,TrackerIsolConeMetric_,myTrackerIsolConeSize,
254  }
255 
256  // Filter isolation annulus charge dhadrons with additional nHits quality cut
257  // (note that other cuts [pt, chi2, are already cut on])
258  PFCandidateRefVector myIsolPFChargedHadrCands;
259  myIsolPFChargedHadrCands = TauTagTools::filteredPFChargedHadrCandsByNumTrkHits(
260  myUnfilteredIsolPFChargedHadrCands, ChargedHadrCand_IsolAnnulus_minNhits_);
261 
262  myPFTau.setisolationPFChargedHadrCands(myIsolPFChargedHadrCands);
263 
264  // Fill neutral hadrons
265  myIsolPFNeutrHadrCands = myPFTauElementsOperators.PFNeutrHadrCandsInAnnulus(
266  tauAxis, HCALSignalConeMetric_, myHCALSignalConeSize, HCALIsolConeMetric_,
267  myHCALIsolConeSize, PFTauAlgo_NeutrHadrCand_minPt_);
268  myPFTau.setisolationPFNeutrHadrCands(myIsolPFNeutrHadrCands);
269 
270  // Fill gamma candidates
271  myIsolPFGammaCands = myPFTauElementsOperators.PFGammaCandsInAnnulus(
272  tauAxis, ECALSignalConeMetric_, myECALSignalConeSize, ECALIsolConeMetric_,
273  myECALIsolConeSize, PFTauAlgo_GammaCand_minPt_);
274  myPFTau.setisolationPFGammaCands(myIsolPFGammaCands);
275 
276  //Incorporate converted gammas from isolation ellipse into signal ... ELLL
277  //Get pair with in/out elements using the isoPFGammaCandidates set by default
278  if(AddEllipseGammas_) {
279  double rPhi;
280  if(Rphi_ >= 1.)
281  rPhi = Rphi_*myECALSignalConeSize;
282  else
283  rPhi = Rphi_;
284 
285  std::pair<PFCandidateRefVector,PFCandidateRefVector> elementsInOutEllipse =
286  myPFTauElementsOperators.PFGammaCandsInOutEllipse(myIsolPFGammaCands, *myleadPFCand, rPhi, myECALSignalConeSize, MaxEtInEllipse_);
287 
288  PFCandidateRefVector elementsInEllipse = elementsInOutEllipse.first;
289  PFCandidateRefVector elementsOutEllipse = elementsInOutEllipse.second;
290  //add the inside elements to signal PFCandidates and reset signal PFCands
291  for(PFCandidateRefVector::const_iterator inEllipseIt = elementsInEllipse.begin(); inEllipseIt != elementsInEllipse.end(); inEllipseIt++){
292  mySignalPFCands.push_back(*inEllipseIt);
293  mySignalPFGammaCands.push_back(*inEllipseIt);
294  }
295  myPFTau.setsignalPFCands(mySignalPFCands);
296  //redefine isoPFGammaCandidates to be the outside elements
297  myIsolPFGammaCands=elementsOutEllipse;
298  myPFTau.setisolationPFGammaCands(myIsolPFGammaCands);
299  }
300 
301 
302  // Fill isolation collections, and calculate pt sum in isolation cone
303  float myIsolPFChargedHadrCands_Ptsum = 0.;
304  float myIsolPFGammaCands_Etsum = 0.;
305  for(size_t i = 0; i < myIsolPFChargedHadrCands.size(); i++) {
306  myIsolPFChargedHadrCands_Ptsum += myIsolPFChargedHadrCands[i]->pt();
307  myIsolPFCands.push_back(myIsolPFChargedHadrCands[i]);
308  }
309  myPFTau.setisolationPFChargedHadrCandsPtSum(myIsolPFChargedHadrCands_Ptsum);
310 
311  // Put neutral hadrons into collection
312  for(size_t i = 0; i < myIsolPFNeutrHadrCands.size(); i++) {
313  myIsolPFCands.push_back(myIsolPFNeutrHadrCands[i]);
314  }
315 
316  for(size_t i = 0; i < myIsolPFGammaCands.size(); i++) {
317  myIsolPFGammaCands_Etsum += myIsolPFGammaCands[i]->et();
318  myIsolPFCands.push_back(myIsolPFGammaCands[i]);
319  }
320  myPFTau.setisolationPFGammaCandsEtSum(myIsolPFGammaCands_Etsum);
321  myPFTau.setisolationPFCands(myIsolPFCands);
322 
323  //Making the alternateLorentzVector, i.e. direction with only signal components
324  math::XYZTLorentzVector alternatLorentzVect(0.,0.,0.,0.);
325  for (PFCandidateRefVector::const_iterator iGammaCand = mySignalPFGammaCands.begin();
326  iGammaCand != mySignalPFGammaCands.end(); iGammaCand++) {
327  alternatLorentzVect+=(**iGammaCand).p4();
328  }
329 
330  for (PFCandidateRefVector::const_iterator iChargedHadrCand = mySignalPFChargedHadrCands.begin();
331  iChargedHadrCand != mySignalPFChargedHadrCands.end(); iChargedHadrCand++) {
332  alternatLorentzVect+=(**iChargedHadrCand).p4();
333  }
334  // Alternate lorentz vector is always charged + gammas
335  myPFTau.setalternatLorentzVect(alternatLorentzVect);
336 
337  // Optionally add the neutral hadrons to the p4
339  for (PFCandidateRefVector::const_iterator iNeutralHadrCand = mySignalPFNeutrHadrCands.begin();
340  iNeutralHadrCand != mySignalPFNeutrHadrCands.end(); iNeutralHadrCand++) {
341  alternatLorentzVect+=(**iNeutralHadrCand).p4();
342  }
343  }
344  myPFTau.setP4(alternatLorentzVect);
345 
346  // Set tau vertex as PV vertex
347  myPFTau.setVertex(math::XYZPoint(myPV.x(), myPV.y(), myPV.z()));
348  }
349 
350  // set the leading, signal cone and isolation annulus Tracks (the initial list of Tracks was catched through a JetTracksAssociation
351  // object, not through the charged hadr. PFCandidates inside the PFJet ;
352  // the motivation for considering these objects is the need for checking that a selection by the
353  // charged hadr. PFCandidates is equivalent to a selection by the rec. Tracks.)
354  TrackRef myleadTk=myPFTauElementsOperators.leadTk(MatchingConeMetric_,myMatchingConeSize,LeadTrack_minPt_);
355  myPFTau.setleadTrack(myleadTk);
356  if(myleadTk.isNonnull()){
357  double myleadTkDZ = (*myleadTk).dz(myPV.position());
358  double myTrackerSignalConeSize=myPFTauElementsOperators.computeConeSize(myTrackerSignalConeSizeTFormula,TrackerSignalConeSize_min_,TrackerSignalConeSize_max_);
359  double myTrackerIsolConeSize=myPFTauElementsOperators.computeConeSize(myTrackerIsolConeSizeTFormula,TrackerIsolConeSize_min_,TrackerIsolConeSize_max_);
361  myPFTau.setsignalTracks(myPFTauElementsOperators.tracksInCone((*myleadTk).momentum(),TrackerSignalConeMetric_,myTrackerSignalConeSize,PFTauAlgo_Track_minPt_,TrackLeadTrack_maxDZ_,myleadTkDZ, myPV));
362 
363  TrackRefVector myUnfilteredTracks = myPFTauElementsOperators.tracksInAnnulus((*myleadTk).momentum(),TrackerSignalConeMetric_,myTrackerSignalConeSize,TrackerIsolConeMetric_,myTrackerIsolConeSize,PFTauAlgo_Track_minPt_,TrackLeadTrack_maxDZ_,myleadTkDZ, myPV);
365  myPFTau.setisolationTracks(myFilteredTracks);
366 
367  }else{
368  myPFTau.setsignalTracks(myPFTauElementsOperators.tracksInCone((*myleadTk).momentum(),TrackerSignalConeMetric_,myTrackerSignalConeSize,PFTauAlgo_Track_minPt_));
369 
370  TrackRefVector myUnfilteredTracks = myPFTauElementsOperators.tracksInAnnulus((*myleadTk).momentum(),TrackerSignalConeMetric_,myTrackerSignalConeSize,TrackerIsolConeMetric_,myTrackerIsolConeSize,PFTauAlgo_Track_minPt_);
372  myPFTau.setisolationTracks(myFilteredTracks);
373  }
374  }
375 
376 
377  /* For elecron rejection */
378  double myECALenergy = 0.;
379  double myHCALenergy = 0.;
380  double myHCALenergy3x3 = 0.;
381  double myMaximumHCALPFClusterE = 0.;
382  double myMaximumHCALPFClusterEt = 0.;
383  double myStripClusterE = 0.;
384  double myEmfrac = -1.;
385  double myElectronPreIDOutput = -1111.;
386  bool myElecPreid = false;
387  reco::TrackRef myElecTrk;
388 
389  typedef std::pair<reco::PFBlockRef, unsigned> ElementInBlock;
390  typedef std::vector< ElementInBlock > ElementsInBlocks;
391 
392  //Use the electron rejection only in case there is a charged leading pion
393  if(myleadPFChargedCand.isNonnull()){
394  myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi();
395 
396  math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance();
397  myElecTrk = myleadPFChargedCand->trackRef();//Electron candidate
398 
399  if(myElecTrk.isNonnull()) {
400  //FROM AOD
401  if(DataType_ == "AOD"){
402  // Corrected Cluster energies
403  for(int i=0;i<(int)myPFCands.size();i++){
404  myHCALenergy += myPFCands[i]->hcalEnergy();
405  myECALenergy += myPFCands[i]->ecalEnergy();
406 
407  math::XYZPointF candPos;
408  if (myPFCands[i]->particleId()==1 || myPFCands[i]->particleId()==2)//if charged hadron or electron
409  candPos = myPFCands[i]->positionAtECALEntrance();
410  else
411  candPos = math::XYZPointF(myPFCands[i]->px(),myPFCands[i]->py(),myPFCands[i]->pz());
412 
413  double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,candPos);
414  double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos);
415  double deltaEta = std::abs(myElecTrkEcalPos.eta()-candPos.eta());
416  double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
417 
418  if (myPFCands[i]->ecalEnergy() >= EcalStripSumE_minClusEnergy_ && deltaEta < EcalStripSumE_deltaEta_ &&
420  myStripClusterE += myPFCands[i]->ecalEnergy();
421  }
422  if (deltaR<0.184) {
423  myHCALenergy3x3 += myPFCands[i]->hcalEnergy();
424  }
425  if (myPFCands[i]->hcalEnergy()>myMaximumHCALPFClusterE) {
426  myMaximumHCALPFClusterE = myPFCands[i]->hcalEnergy();
427  }
428  if ((myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())))>myMaximumHCALPFClusterEt) {
429  myMaximumHCALPFClusterEt = (myPFCands[i]->hcalEnergy()*fabs(sin(candPos.Theta())));
430  }
431  }
432 
433  } else if(DataType_ == "RECO"){ //From RECO
434  // Against double counting of clusters
435  std::vector<math::XYZPoint> hcalPosV; hcalPosV.clear();
436  std::vector<math::XYZPoint> ecalPosV; ecalPosV.clear();
437  for(int i=0;i<(int)myPFCands.size();i++){
438  const ElementsInBlocks& elts = myPFCands[i]->elementsInBlocks();
439  for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) {
440  const reco::PFBlock& block = *(it->first);
441  unsigned indexOfElementInBlock = it->second;
443  assert(indexOfElementInBlock<elements.size());
444 
445  const reco::PFBlockElement& element = elements[indexOfElementInBlock];
446 
447  if(element.type()==reco::PFBlockElement::HCAL) {
448  math::XYZPoint clusPos = element.clusterRef()->position();
449  double en = (double)element.clusterRef()->energy();
450  double et = (double)element.clusterRef()->energy()*fabs(sin(clusPos.Theta()));
451  if (en>myMaximumHCALPFClusterE) {
452  myMaximumHCALPFClusterE = en;
453  }
454  if (et>myMaximumHCALPFClusterEt) {
455  myMaximumHCALPFClusterEt = et;
456  }
457  if (!checkPos(hcalPosV,clusPos)) {
458  hcalPosV.push_back(clusPos);
459  myHCALenergy += en;
460  double deltaR = ROOT::Math::VectorUtil::DeltaR(myElecTrkEcalPos,clusPos);
461  if (deltaR<0.184) {
462  myHCALenergy3x3 += en;
463  }
464  }
465  } else if(element.type()==reco::PFBlockElement::ECAL) {
466  double en = (double)element.clusterRef()->energy();
467  math::XYZPoint clusPos = element.clusterRef()->position();
468  if (!checkPos(ecalPosV,clusPos)) {
469  ecalPosV.push_back(clusPos);
470  myECALenergy += en;
471  double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
472  double deltaEta = std::abs(myElecTrkEcalPos.eta()-clusPos.eta());
473  double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
474  if (en >= EcalStripSumE_minClusEnergy_ && deltaEta<EcalStripSumE_deltaEta_ && deltaPhiOverQ > EcalStripSumE_deltaPhiOverQ_minValue_ && deltaPhiOverQ < EcalStripSumE_deltaPhiOverQ_maxValue_) {
475  myStripClusterE += en;
476  }
477  }
478  }
479  } //end elements in blocks
480  } //end loop over PFcands
481  } //end RECO case
482  } // end check for null electrk
483  } // end check for null pfChargedHadrCand
484 
485  if ((myHCALenergy+myECALenergy)>0.)
486  myEmfrac = myECALenergy/(myHCALenergy+myECALenergy);
487  myPFTau.setemFraction((float)myEmfrac);
488 
489  // scale the appropriate quantities by the momentum of the electron if it exists
490  if (myElecTrk.isNonnull())
491  {
492  float myElectronMomentum = (float)myElecTrk->p();
493  if (myElectronMomentum > 0.)
494  {
495  myHCALenergy /= myElectronMomentum;
496  myMaximumHCALPFClusterE /= myElectronMomentum;
497  myHCALenergy3x3 /= myElectronMomentum;
498  myStripClusterE /= myElectronMomentum;
499  }
500  }
501  myPFTau.sethcalTotOverPLead((float)myHCALenergy);
502  myPFTau.sethcalMaxOverPLead((float)myMaximumHCALPFClusterE);
503  myPFTau.sethcal3x3OverPLead((float)myHCALenergy3x3);
504  myPFTau.setecalStripSumEOverPLead((float)myStripClusterE);
505  myPFTau.setmaximumHCALPFClusterEt(myMaximumHCALPFClusterEt);
506  myPFTau.setelectronPreIDOutput(myElectronPreIDOutput);
507  if (myElecTrk.isNonnull())
508  myPFTau.setelectronPreIDTrack(myElecTrk);
509  if (myElectronPreIDOutput > maximumForElectrionPreIDOutput_)
510  myElecPreid = true;
511  myPFTau.setelectronPreIDDecision(myElecPreid);
512 
513  // These need to be filled!
514  //myPFTau.setbremsRecoveryEOverPLead(my...);
515 
516  /* End elecron rejection */
517 
518  return myPFTau;
519 }
520 
521 bool
522 PFRecoTauAlgorithm::checkPos(std::vector<math::XYZPoint> CalPos,math::XYZPoint CandPos) const{
523  bool flag = false;
524  for (unsigned int i=0;i<CalPos.size();i++) {
525  if (CalPos[i] == CandPos) {
526  flag = true;
527  break;
528  }
529  }
530  return flag;
531  //return false;
532 }
double computeConeSize(const TFormula &ConeSizeTFormula, double ConeSizeMin, double ConeSizeMax)
std::string ECALIsolConeSizeFormula_
T getParameter(std::string const &) const
Abstract base class for a PFBlock element (track, cluster...)
int i
Definition: DBlmapReader.cc:9
reco::TrackRefVector filteredTracksByNumTrkHits(reco::TrackRefVector theInitialTracks, int tkminTrackerHitsn)
Definition: TauTagTools.cc:68
long int flag
Definition: mlp_lapack.h:47
#define PFTauAlgo_ChargedHadrCand_minPt_
bool checkPos(std::vector< math::XYZPoint >, math::XYZPoint) const
std::string TrackerIsolConeSizeFormula_
double maximumForElectrionPreIDOutput_
std::string ECALSignalConeSizeFormula_
const reco::TrackRef leadTk(std::string matchingConeMetric, double matchingConeSize, double ptTrackMin) const
const TransientTrackBuilder * TransientTrackBuilder_
double y() const
y coordinate
Definition: Vertex.h:97
uint32_t ChargedHadrCand_IsolAnnulus_minNhits_
reco::PFCandidateRefVector PFCandsInCone(const reco::PFCandidateRefVector PFCands, const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
size_type size() const
Definition: OwnVector.h:247
#define PFTauAlgo_Track_minPt_
reco::TransientTrack build(const reco::Track *p) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string HCALSignalConeSizeFormula_
#define abs(x)
Definition: mlp_lapack.h:159
bool UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_
list elements
Definition: asciidump.py:414
const edm::OwnVector< reco::PFBlockElement > & elements() const
Definition: PFBlock.h:107
double EcalStripSumE_deltaPhiOverQ_minValue_
TFormula myHCALSignalConeSizeTFormula
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:11
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
reco::PFCandidateRefVector PFNeutrHadrCandsInCone(const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
const Point & position() const
position
Definition: Vertex.h:93
reco::PFCandidateRefVector PFGammaCandsInCone(const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
reco::PFCandidateRefVector PFChargedHadrCandsInAnnulus(const math::XYZVector myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
double ChargedHadrCandLeadChargedHadrCand_tksmaxDZ_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
std::pair< reco::PFCandidateRefVector, reco::PFCandidateRefVector > PFGammaCandsInOutEllipse(const reco::PFCandidateRefVector, const reco::PFCandidate, double rPhi, double rEta, double maxPt) const
#define PFTauAlgo_NeutrHadrCand_minPt_
const reco::TrackRefVector tracksInCone(const math::XYZVector &coneAxis, const std::string coneMetric, const double coneSize, const double ptTrackMin) const
TFormula myTrackerSignalConeSizeTFormula
std::string ECALSignalConeMetric_
reco::PFCandidateRefVector filteredPFChargedHadrCandsByNumTrkHits(reco::PFCandidateRefVector theInitialPFCands, int ChargedHadrCand_tkminTrackerHitsn)
Definition: TauTagTools.cc:104
double z() const
y coordinate
Definition: Vertex.h:99
TFormula myECALSignalConeSizeTFormula
double AreaMetric_recoElements_maxabsEta_
uint32_t Track_IsolAnnulus_minNhits_
block
Formating index page&#39;s pieces.
Definition: Association.py:232
TFormula computeConeSizeTFormula(const std::string &ConeSizeFormula, const char *errorMessage)
std::string ECALIsolConeMetric_
double computeDeltaR(const math::XYZVector &vec1, const math::XYZVector &vec2)
Definition: TauTagTools.cc:8
std::string TrackerSignalConeMetric_
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::string MatchingConeSizeFormula_
reco::PFTau buildPFTau(const reco::PFTauTagInfoRef &, const reco::Vertex &)
double x() const
x coordinate
Definition: Vertex.h:95
TFormula myMatchingConeSizeTFormula
double EcalStripSumE_deltaPhiOverQ_maxValue_
TFormula myHCALIsolConeSizeTFormula
void clear()
Clear the vector.
Definition: RefVector.h:133
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
reco::PFCandidateRefVector PFChargedHadrCandsInCone(const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
TFormula myTrackerIsolConeSizeTFormula
reco::PFCandidateRef leadPFChargedHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
std::string HCALIsolConeSizeFormula_
#define PFTauAlgo_GammaCand_minPt_
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
std::string MatchingConeMetric_
const reco::TrackRefVector tracksInAnnulus(const math::XYZVector &coneAxis, const std::string innerconeMetric, const double innerconeSize, const std::string outerconeMetric, const double outerconeSize, const double ptTrackMin) const
std::string TrackerIsolConeMetric_
std::string HCALSignalConeMetric_
std::string TrackerSignalConeSizeFormula_
reco::PFCandidateRefVector PFGammaCandsInAnnulus(const math::XYZVector myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
TFormula myECALIsolConeSizeTFormula
reco::PFCandidateRefVector PFNeutrHadrCandsInAnnulus(const math::XYZVector myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
#define PFTauAlgo_PFCand_minPt_
void setpfTauTagInfoRef(const PFTauTagInfoRef)
Definition: PFTau.cc:60
Block of elements.
Definition: PFBlock.h:30
std::string HCALIsolConeMetric_