CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFTauElementsOperators.cc
Go to the documentation of this file.
2 
3 using namespace reco;
4 using std::string;
5 
6  PFTauElementsOperators::PFTauElementsOperators(PFTau& thePFTau): TauElementsOperators(thePFTau),AreaMetric_recoElements_maxabsEta_(2.5){
7  PFJetRef_=thePFTau.pfTauTagInfoRef()->pfjetRef();
8  PFCands_=thePFTau.pfTauTagInfoRef()->PFCands();
9  PFChargedHadrCands_=thePFTau.pfTauTagInfoRef()->PFChargedHadrCands();
10  PFNeutrHadrCands_=thePFTau.pfTauTagInfoRef()->PFNeutrHadrCands();
11  PFGammaCands_=thePFTau.pfTauTagInfoRef()->PFGammaCands();
12  IsolPFCands_=thePFTau.isolationPFCands();
16  Tracks_=thePFTau.pfTauTagInfoRef()->Tracks();
17 }
19 
20 PFCandidateRefVector PFTauElementsOperators::PFCandsInCone(const PFCandidateRefVector thePFCands,const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{
21  PFCandidateRefVector theFilteredPFCands;
22  for (PFCandidateRefVector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
23  if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
24  }
25  PFCandidateRefVector theFilteredPFCandsInCone;
26  if (conemetric=="DR"){
27  theFilteredPFCandsInCone=PFCandsinCone_DRmetric_(myVector,metricDR_,conesize,theFilteredPFCands);
28  }else if(conemetric=="angle"){
29  theFilteredPFCandsInCone=PFCandsinCone_Anglemetric_(myVector,metricAngle_,conesize,theFilteredPFCands);
30  }else if(conemetric=="area"){
31  int errorFlag=0;
32  FixedAreaIsolationCone theFixedAreaCone;
34  double coneangle=theFixedAreaCone(myVector.theta(),myVector.phi(),0,conesize,errorFlag);
35  if (errorFlag!=0)return theFilteredPFCandsInCone;
36  theFilteredPFCandsInCone=PFCandsinCone_Anglemetric_(myVector,metricAngle_,coneangle,theFilteredPFCands);
37  }else return PFCandidateRefVector();
38  return theFilteredPFCandsInCone;
39 }
40 PFCandidateRefVector PFTauElementsOperators::PFCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{
41  PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFCands_,myVector,conemetric,conesize,minPt);
42  return theFilteredPFCandsInCone;
43 }
44 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{
45  PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFChargedHadrCands_,myVector,conemetric,conesize,minPt);
46  return theFilteredPFCandsInCone;
47 }
48 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{
51  TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef();
52  if (!PFChargedHadrCand_track)continue;
53  if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand);
54  }
55  PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt);
56  return theFilteredPFCandsInCone;
57 }
58 PFCandidateRefVector PFTauElementsOperators::PFNeutrHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{
59  PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFNeutrHadrCands_,myVector,conemetric,conesize,minPt);
60  return theFilteredPFCandsInCone;
61 }
62  PFCandidateRefVector PFTauElementsOperators::PFGammaCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{
63  PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFGammaCands_,myVector,conemetric,conesize,minPt);
64  return theFilteredPFCandsInCone;
65 }
66 
67 // Function to get elements inside ellipse here ... EELL
68 std::pair<PFCandidateRefVector, PFCandidateRefVector> PFTauElementsOperators::PFGammaCandsInOutEllipse(const PFCandidateRefVector PFGammaCands_, const PFCandidate leadCand_, double rPhi, double rEta, double maxPt) const{
69  std::pair<PFCandidateRefVector,PFCandidateRefVector> myPFGammaCandsInEllipse = PFCandidatesInEllipse_(leadCand_, rPhi, rEta, PFGammaCands_);
70  PFCandidateRefVector thePFGammaCandsInEllipse = myPFGammaCandsInEllipse.first;
71  PFCandidateRefVector thePFGammaCandsOutEllipse = myPFGammaCandsInEllipse.second;
72  PFCandidateRefVector theFilteredPFGammaCandsInEllipse;
73  for(PFCandidateRefVector::const_iterator iPFGammaCand = thePFGammaCandsInEllipse.begin(); iPFGammaCand != thePFGammaCandsInEllipse.end(); ++iPFGammaCand){
74  if((**iPFGammaCand).pt() <= maxPt) theFilteredPFGammaCandsInEllipse.push_back(*iPFGammaCand);
75  else thePFGammaCandsOutEllipse.push_back(*iPFGammaCand);
76  }
77  std::pair<PFCandidateRefVector, PFCandidateRefVector> theFilteredPFGammaCandsInOutEllipse(theFilteredPFGammaCandsInEllipse, thePFGammaCandsOutEllipse);
78 
79  return theFilteredPFGammaCandsInOutEllipse;
80 }
81 // EELL
82 
83 
84  PFCandidateRefVector PFTauElementsOperators::PFCandsInAnnulus(const PFCandidateRefVector thePFCands,const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{
85  PFCandidateRefVector theFilteredPFCands;
86  for (PFCandidateRefVector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
87  if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
88  }
89  PFCandidateRefVector theFilteredPFCandsInAnnulus;
90  if (outercone_metric=="DR"){
91  if (innercone_metric=="DR"){
92  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterDRmetrics_(myVector,metricDR_,innercone_size,metricDR_,outercone_size,theFilteredPFCands);
93  }else if(innercone_metric=="angle"){
94  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterDRmetrics_(myVector,metricAngle_,innercone_size,metricDR_,outercone_size,theFilteredPFCands);
95  }else if(innercone_metric=="area"){
96  int errorFlag=0;
97  FixedAreaIsolationCone theFixedAreaSignalCone;
99  double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);
100  if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
101  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterDRmetrics_(myVector,metricAngle_,innercone_angle,metricDR_,outercone_size,theFilteredPFCands);
102  }else return PFCandidateRefVector();
103  }else if(outercone_metric=="angle"){
104  if (innercone_metric=="DR"){
105  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterAnglemetrics_(myVector,metricDR_,innercone_size,metricAngle_,outercone_size,theFilteredPFCands);
106  }else if(innercone_metric=="angle"){
107  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_size,metricAngle_,outercone_size,theFilteredPFCands);
108  }else if(innercone_metric=="area"){
109  int errorFlag=0;
110  FixedAreaIsolationCone theFixedAreaSignalCone;
112  double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);
113  if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
114  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_size,theFilteredPFCands);
115  }else return PFCandidateRefVector();
116  }else if(outercone_metric=="area"){
117  int errorFlag=0;
118  FixedAreaIsolationCone theFixedAreaSignalCone;
120  if (innercone_metric=="DR"){
121  // not implemented yet
122  }else if(innercone_metric=="angle"){
123  double outercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),innercone_size,outercone_size,errorFlag);
124  if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
125  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_size,metricAngle_,outercone_angle,theFilteredPFCands);
126  }else if(innercone_metric=="area"){
127  double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);
128  if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
129  double outercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),innercone_angle,outercone_size,errorFlag);
130  if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
131  theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_angle,theFilteredPFCands);
132  }else return PFCandidateRefVector();
133  }
134  return theFilteredPFCandsInAnnulus;
135 }
136  PFCandidateRefVector PFTauElementsOperators::PFCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{
137  PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
138  return theFilteredPFCandsInAnnulus;
139 }
140  PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{
141  PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFChargedHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
142  return theFilteredPFCandsInAnnulus;
143 }
144 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{
147  TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef();
148  if (!PFChargedHadrCand_track)continue;
149  if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand);
150  }
151  PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
152  return theFilteredPFCandsInAnnulus;
153 }
154  PFCandidateRefVector PFTauElementsOperators::PFNeutrHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{
155  PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFNeutrHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
156  return theFilteredPFCandsInAnnulus;
157 }
158  PFCandidateRefVector PFTauElementsOperators::PFGammaCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{
159  PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
160  return theFilteredPFCandsInAnnulus;
161 }
162 PFCandidateRef PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
163  PFCandidateRef myleadPFCand;
164  if (!PFJetRef_) return myleadPFCand;
165  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
166  const PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
167  double pt_cut=minPt;
168  if (theFilteredPFCandsInCone.size()>0.){
169  for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
170  if((*iPFCand)->pt()>pt_cut) {
171  myleadPFCand=*iPFCand;
172  pt_cut=(**iPFCand).pt();
173  }
174  }
175  }
176  return myleadPFCand;
177 }
178 PFCandidateRef PFTauElementsOperators::leadPFCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
179  PFCandidateRef myleadPFCand;
180  const PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
181  double pt_cut=minPt;
182  if (theFilteredPFCandsInCone.size()>0){
183  for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
184  if((*iPFCand)->pt()>pt_cut) {
185  myleadPFCand=*iPFCand;
186  pt_cut=(**iPFCand).pt();
187  }
188  }
189  }
190  return myleadPFCand;
191 }
192 PFCandidateRef PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
193  PFCandidateRef myleadPFCand;
194  if (!PFJetRef_) return myleadPFCand;
195  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
196  const PFCandidateRefVector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
197  double pt_cut=minPt;
198  if (theFilteredPFCandsInCone.size()>0.){
199  for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
200  if((*iPFCand)->pt()>pt_cut) {
201  myleadPFCand=*iPFCand;
202  pt_cut=(**iPFCand).pt();
203  }
204  }
205  }
206  return myleadPFCand;
207 }
208 PFCandidateRef PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
209  PFCandidateRef myleadPFCand;
210  const PFCandidateRefVector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
211  double pt_cut=minPt;
212  if (theFilteredPFCandsInCone.size()>0){
213  for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
214  if((*iPFCand)->pt()>pt_cut) {
215  myleadPFCand=*iPFCand;
216  pt_cut=(**iPFCand).pt();
217  }
218  }
219  }
220  return myleadPFCand;
221 }
222 PFCandidateRef PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
223  PFCandidateRef myleadPFCand;
224  if (!PFJetRef_) return myleadPFCand;
225  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
226  const PFCandidateRefVector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
227  double pt_cut=minPt;
228  if (theFilteredPFCandsInCone.size()>0.){
229  for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
230  if((*iPFCand)->pt()>pt_cut) {
231  myleadPFCand=*iPFCand;
232  pt_cut=(**iPFCand).pt();
233  }
234  }
235  }
236  return myleadPFCand;
237 }
238 PFCandidateRef PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
239  PFCandidateRef myleadPFCand;
240  const PFCandidateRefVector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
241  double pt_cut=minPt;
242  if (theFilteredPFCandsInCone.size()>0){
243  for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
244  if((*iPFCand)->pt()>pt_cut) {
245  myleadPFCand=*iPFCand;
246  pt_cut=(**iPFCand).pt();
247  }
248  }
249  }
250  return myleadPFCand;
251 }
252 PFCandidateRef PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
253  PFCandidateRef myleadPFCand;
254  if (!PFJetRef_) return myleadPFCand;
255  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
256  const PFCandidateRefVector theFilteredPFCandsInCone=PFGammaCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
257  double pt_cut=minPt;
258  if (theFilteredPFCandsInCone.size()>0.){
259  for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
260  if((*iPFCand)->pt()>pt_cut) {
261  myleadPFCand=*iPFCand;
262  pt_cut=(**iPFCand).pt();
263  }
264  }
265  }
266  return myleadPFCand;
267 }
268 PFCandidateRef PFTauElementsOperators::leadPFGammaCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
269  PFCandidateRef myleadPFCand;
270  const PFCandidateRefVector theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
271  double pt_cut=minPt;
272  if (theFilteredPFCandsInCone.size()>0){
273  for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
274  if((*iPFCand)->pt()>pt_cut) {
275  myleadPFCand=*iPFCand;
276  pt_cut=(**iPFCand).pt();
277  }
278  }
279  }
280  return myleadPFCand;
281 }
282 
283 void
284 PFTauElementsOperators::copyCandRefsFilteredByPt(const PFCandidateRefVector& theInputCands, PFCandidateRefVector& theOutputCands, const double minPt)
285 {
286  for(PFCandidateRefVector::const_iterator iPFCand = theInputCands.begin();
287  iPFCand != theInputCands.end();
288  ++iPFCand)
289  {
290  if ( (*iPFCand)->pt() > minPt )
291  theOutputCands.push_back(*iPFCand);
292  }
293 }
294 
295 // Inside Out Signal contents determination algorithm
296 // Determines tau signal content by building from seed track
297 void
299  const math::XYZVector leadTrackVector, const TFormula& coneSizeFormula, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&),
300  const double minChargedSize, const double maxChargedSize, const double minNeutralSize, const double maxNeutralSize,
301  const double minChargedPt, const double minNeutralPt,
302  const string& outlierCollectorConeMetric, const double outlierCollectionMaxSize,
303  PFCandidateRefVector& signalChargedObjects, PFCandidateRefVector& outlierChargedObjects,
304  PFCandidateRefVector& signalGammaObjects, PFCandidateRefVector& outlierGammaObjects, bool useScanningAxis)
305 {
306  if (theChargedCands.empty() && theGammaCands.empty())
307  return;
308  //copy the vector of PFCands filtering by Pt
309  PFCandidateRefVector filteredCands;
310  filteredCands.reserve(theChargedCands.size() + theGammaCands.size());
311 
312  copyCandRefsFilteredByPt(theChargedCands, filteredCands, minChargedPt);
313  copyCandRefsFilteredByPt(theGammaCands, filteredCands, minNeutralPt);
314 
315  if (filteredCands.empty())
316  return;
317 
318 
319  //create vector of indexes as RefVectors can't use STL algos?
320  unsigned int numberOfCandidates = filteredCands.size();
321  std::vector<uint32_t> filteredCandIndexes(numberOfCandidates);
322  for(uint32_t theIndex = 0; theIndex < numberOfCandidates; theIndex++)
323  filteredCandIndexes[theIndex] = theIndex;
324 
325  TauTagTools::sortRefsByOpeningDistance myAngularSorter(leadTrackVector, ptrToMetricFunction, filteredCands);
326 
327  //sort the remaining candidates by angle to seed track
328  sort(filteredCandIndexes.begin(), filteredCandIndexes.end(), myAngularSorter);
329 
330  PFCandidateRefVector sortedCands;
331  for(std::vector<uint32_t>::const_iterator theSortedIndex = filteredCandIndexes.begin();
332  theSortedIndex != filteredCandIndexes.end();
333  ++theSortedIndex)
334  {
335  sortedCands.push_back(filteredCands.at(*theSortedIndex));
336  }
337 
338  //get first candidate (seed trk by definition)
339  PFCandidateRefVector::const_iterator signalObjectCandidate = sortedCands.begin();
340  double totalEnergySoFar = (**signalObjectCandidate).energy();
341  double totalEtSoFar = (**signalObjectCandidate).et();
342  math::XYZVector axisVectorSoFar = leadTrackVector;
343  double currentDelToCenter = ptrToMetricFunction(leadTrackVector, axisVectorSoFar);
344  //advance to next object
345  ++signalObjectCandidate;
346  bool doneBuilding = false;
347  while (!doneBuilding && signalObjectCandidate != sortedCands.end())
348  {
349  //compute cutoff quanity
350  math::XYZVector testAxis = axisVectorSoFar;
351  if (useScanningAxis)
352  testAxis += (**signalObjectCandidate).momentum();
353  currentDelToCenter = ptrToMetricFunction((**signalObjectCandidate).momentum(), testAxis);
354  double testEnergy = totalEnergySoFar + (**signalObjectCandidate).energy();
355  double testEt = totalEtSoFar + (**signalObjectCandidate).et();
356  bool isCharged = (**signalObjectCandidate).charge();
357  bool addThisObject = true;
358  if (currentDelToCenter > ((isCharged)?maxChargedSize:maxNeutralSize) ) {
359  //max conesize is reached
360  addThisObject = false;
361  }
362  else if (currentDelToCenter > ((isCharged)?minChargedSize:minNeutralSize) )
363  {
364  //only do calculation if we are in the region above the minimum size
365  double cutOffQuantity = coneSizeFormula.Eval(testEnergy, testEt);
366  if (currentDelToCenter > cutOffQuantity)
367  addThisObject = false;
368  else if (useScanningAxis)
369  {
370  //make sure we don't make the seed track kinematically inconsistent
371  //(stop growth if axis-lead track distance greater than computed opening angle
372  if (ptrToMetricFunction(testAxis, leadTrackVector) > cutOffQuantity)
373  addThisObject = false;
374  }
375  }
376  if (addThisObject)
377  {
378  axisVectorSoFar = testAxis;
379  totalEnergySoFar = testEnergy;
380  totalEtSoFar = testEt;
381  ++signalObjectCandidate; //signal object candidate now points to one past the
382  }
383  else
384  {
385  doneBuilding = true;
386  }
387  }
388  // split the collection into two collections
389  double largest3DOpeningAngleSignal = 0.; //used for area outlier collection cone
390  for (PFCandidateRefVector::const_iterator iterCand = sortedCands.begin();
391  iterCand != signalObjectCandidate;
392  ++iterCand)
393  {
394  double angleToAxis = TauTagTools::computeAngle((*iterCand)->momentum(), axisVectorSoFar);
395  if (angleToAxis > largest3DOpeningAngleSignal)
396  largest3DOpeningAngleSignal = angleToAxis;
397 
398  if ((*iterCand)->charge())
399  signalChargedObjects.push_back(*iterCand);
400  else
401  signalGammaObjects.push_back(*iterCand);
402  }
403 
404  //function pointer to outlier collection cutoff quantity
405  double (*outlierCollectionCalculator)(const math::XYZVector&, const math::XYZVector&) = TauTagTools::computeAngle;
406  double outlierCollectionComputedMaxSize = 0;
407 
408  if (!outlierCollectorConeMetric.compare("angle"))
409  {
410  outlierCollectionCalculator = TauTagTools::computeAngle;
411  outlierCollectionComputedMaxSize = outlierCollectionMaxSize;
412  } else if (!outlierCollectorConeMetric.compare("area"))
413  {
414  //determine opening angle (in 3D space of signal objects)
415 
416  outlierCollectionCalculator = TauTagTools::computeAngle; //the area cone outside angle is defined in 3D
417  FixedAreaIsolationCone theFixedAreaCone;
418  theFixedAreaCone.setAcceptanceLimit(2.5);
419  //calculate new iso cone size
420  int errorFlagForConeSizeCalc = 0;
421  outlierCollectionComputedMaxSize = theFixedAreaCone(axisVectorSoFar.theta(), axisVectorSoFar.phi(), largest3DOpeningAngleSignal, outlierCollectionMaxSize, errorFlagForConeSizeCalc);
422  if (errorFlagForConeSizeCalc != 0)
423  {
424  edm::LogError("PFRecoTauAlgorithm") << "Error: " << errorFlagForConeSizeCalc << " when calculated const area annulus. Taking all non-signal PFJet consituents!";
425  outlierCollectionComputedMaxSize = 1000.; //takes everything...
426  }
427  } else if (!outlierCollectorConeMetric.compare("DR"))
428  {
429  outlierCollectionCalculator = TauTagTools::computeDeltaR;
430  outlierCollectionComputedMaxSize = outlierCollectionMaxSize;
431  }
432  else //warn if metric choice for outlier collection is not consistent
433  {
434  edm::LogWarning("PFRecoTauAlgorithm") << "Error in computeInsideOutContents(...): Outlier (isolation) collector cone metric (" << outlierCollectorConeMetric
435  << ") is not recognized! All non-signal associated PFJet constituents will be included in the outliers!";
436  }
437 
438  for (PFCandidateRefVector::const_iterator iterCand = signalObjectCandidate;
439  iterCand != sortedCands.end();
440  ++iterCand)
441  {
442  //stop adding objects if we have reached the maximum outleir collector size
443  double outlierOpeningQuantity = outlierCollectionCalculator(axisVectorSoFar, (*iterCand)->momentum());
444  if (outlierOpeningQuantity > outlierCollectionComputedMaxSize) break;
445 
446  if ((*iterCand)->charge())
447  outlierChargedObjects.push_back(*iterCand);
448  else
449  outlierGammaObjects.push_back(*iterCand);
450  }
451  //done
452 }
453 
454 
455 // ***
457  double myDiscriminator=0.;
458  if ((int)IsolPFCands_.size()<=IsolPFCands_maxN) myDiscriminator=1;
459  return myDiscriminator;
460 }
461 double PFTauElementsOperators::discriminatorByIsolPFCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){
462  double myDiscriminator=0.;
463  PFCandidateRef myleadPFCand;
464  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
465  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
466  if(!myleadPFCand)return myDiscriminator;
467  //if(signalcone_size>=isolcone_size) return 1.;
468  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
469  const PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
470  if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
471  return myDiscriminator;
472 }
473 double PFTauElementsOperators::discriminatorByIsolPFCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){
474  double myDiscriminator=0;
475  PFCandidateRef myleadPFCand;
476  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
477  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
478  if(!myleadPFCand)return myDiscriminator;
479  //if(signalcone_size>=isolcone_size) return 1.;
480  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
481  const PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
482  if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
483  return myDiscriminator;
484 }
486  double myDiscriminator=0.;
487  if ((int)IsolPFChargedHadrCands_.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
488  return myDiscriminator;
489 }
490 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){
491  double myDiscriminator=0.;
492  PFCandidateRef myleadPFCand;
493  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
494  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
495  if(!myleadPFCand)return myDiscriminator;
496  //if(signalcone_size>=isolcone_size) return 1.;
497  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
498  PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
499  if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
500  return myDiscriminator;
501 }
502 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){
503  double myDiscriminator=0;
504  PFCandidateRef myleadPFCand;
505  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
506  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
507  if(!myleadPFCand)return myDiscriminator;
508  //if(signalcone_size>=isolcone_size) return 1.;
509  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
510  PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
511  if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
512  return myDiscriminator;
513 }
515  double myDiscriminator=0.;
516  if ((int)IsolPFNeutrHadrCands_.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
517  return myDiscriminator;
518 }
519 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){
520  double myDiscriminator=0.;
521  PFCandidateRef myleadPFCand;
522  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
523  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
524  if(!myleadPFCand)return myDiscriminator;
525  //if(signalcone_size>=isolcone_size) return 1.;
526  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
527  PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
528  if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
529  return myDiscriminator;
530 }
531 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){
532  double myDiscriminator=0;
533  PFCandidateRef myleadPFCand;
534  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
535  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
536  if(!myleadPFCand)return myDiscriminator;
537  //if(signalcone_size>=isolcone_size) return 1.;
538  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
539  PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
540  if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
541  return myDiscriminator;
542 }
544  double myDiscriminator=0.;
545  if ((int)IsolPFGammaCands_.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
546  return myDiscriminator;
547 }
548 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){
549  double myDiscriminator=0.;
550  PFCandidateRef myleadPFCand;
551  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
552  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
553  if(!myleadPFCand)return myDiscriminator;
554  //if(signalcone_size>=isolcone_size) return 1.;
555  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
556  PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
557  if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
558  return myDiscriminator;
559 }
560 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){
561  double myDiscriminator=0;
562  PFCandidateRef myleadPFCand;
563  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
564  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
565  if(!myleadPFCand)return myDiscriminator;
566  //if(signalcone_size>=isolcone_size) return 1.;
567  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
568  PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
569  if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
570  return myDiscriminator;
571 }
573  double myIsolPFCandsEtSum=0.;
574  double myDiscriminator=0.;
575  for(PFCandidateRefVector::const_iterator iPFCand=IsolPFCands_.begin();iPFCand!=IsolPFCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
576  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
577  return myDiscriminator;
578 }
579 double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum){
580  double myIsolPFCandsEtSum=0.;
581  double myDiscriminator=0.;
582  PFCandidateRef myleadPFCand;
583  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
584  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
585  if(!myleadPFCand)return myDiscriminator;
586  //if(signalcone_size>=isolcone_size) return 1.;
587  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
588  PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
589  for(PFCandidateRefVector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
590  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
591  return myDiscriminator;
592 }
593 double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum){
594  double myIsolPFCandsEtSum=0.;
595  double myDiscriminator=0;
596  PFCandidateRef myleadPFCand;
597  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
598  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
599  if(!myleadPFCand)return myDiscriminator;
600  //if(signalcone_size>=isolcone_size) return 1.;
601  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
602  PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
603  for(PFCandidateRefVector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
604  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
605  return myDiscriminator;
606 }
607 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(double IsolPFChargedHadrCands_maxEtSum){
608  double myIsolPFCandsEtSum=0.;
609  double myDiscriminator=0.;
610  for(PFCandidateRefVector::const_iterator iPFCand=IsolPFChargedHadrCands_.begin();iPFCand!=IsolPFChargedHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
611  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
612  return myDiscriminator;
613 }
614 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFChargedHadrCands_maxEtSum){
615  double myIsolPFCandsEtSum=0.;
616  double myDiscriminator=0.;
617  PFCandidateRef myleadPFCand;
618  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
619  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
620  if(!myleadPFCand)return myDiscriminator;
621  //if(signalcone_size>=isolcone_size) return 1.;
622  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
623  PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
624  for(PFCandidateRefVector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
625  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
626  return myDiscriminator;
627 }
628 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFChargedHadrCands_maxEtSum){
629  double myIsolPFCandsEtSum=0.;
630  double myDiscriminator=0;
631  PFCandidateRef myleadPFCand;
632  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
633  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
634  if(!myleadPFCand)return myDiscriminator;
635  //if(signalcone_size>=isolcone_size) return 1.;
636  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
637  PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
638  for(PFCandidateRefVector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
639  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
640  return myDiscriminator;
641 }
642 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(double IsolPFNeutrHadrCands_maxEtSum){
643  double myIsolPFCandsEtSum=0.;
644  double myDiscriminator=0.;
645  for(PFCandidateRefVector::const_iterator iPFCand=IsolPFNeutrHadrCands_.begin();iPFCand!=IsolPFNeutrHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
646  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
647  return myDiscriminator;
648 }
649 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFNeutrHadrCands_maxEtSum){
650  double myIsolPFCandsEtSum=0.;
651  double myDiscriminator=0.;
652  PFCandidateRef myleadPFCand;
653  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
654  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
655  if(!myleadPFCand)return myDiscriminator;
656  //if(signalcone_size>=isolcone_size) return 1.;
657  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
658  PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
659  for(PFCandidateRefVector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
660  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
661  return myDiscriminator;
662 }
663 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFNeutrHadrCands_maxEtSum){
664  double myIsolPFCandsEtSum=0.;
665  double myDiscriminator=0;
666  PFCandidateRef myleadPFCand;
667  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
668  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
669  if(!myleadPFCand)return myDiscriminator;
670  //if(signalcone_size>=isolcone_size) return 1.;
671  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
672  PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
673  for(PFCandidateRefVector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
674  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
675  return myDiscriminator;
676 }
677 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(double IsolPFGammaCands_maxEtSum){
678  double myIsolPFCandsEtSum=0.;
679  double myDiscriminator=0.;
680  for(PFCandidateRefVector::const_iterator iPFCand=IsolPFGammaCands_.begin();iPFCand!=IsolPFGammaCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
681  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
682  return myDiscriminator;
683 }
684 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFGammaCands_maxEtSum){
685  double myIsolPFCandsEtSum=0.;
686  double myDiscriminator=0.;
687  PFCandidateRef myleadPFCand;
688  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
689  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
690  if(!myleadPFCand)return myDiscriminator;
691  if(signalcone_size>=isolcone_size) return 1.;
692  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
693  PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
694  for(PFCandidateRefVector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
695  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
696  return myDiscriminator;
697 }
698 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFGammaCands_maxEtSum){
699  double myIsolPFCandsEtSum=0.;
700  double myDiscriminator=0;
701  PFCandidateRef myleadPFCand;
702  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
703  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
704  if(!myleadPFCand)return myDiscriminator;
705  //if(signalcone_size>=isolcone_size) return 1.;
706  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
707  PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
708  for(PFCandidateRefVector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
709  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
710  return myDiscriminator;
711 }
ElementsInEllipse< reco::PFCandidate, reco::PFCandidateCollection > PFCandidatesInEllipse_
const PFCandidateRefVector & isolationPFCands() const
PFCandidates in isolation region.
Definition: PFTau.cc:82
reco::PFCandidateRefVector PFGammaCands_
double computeAngle(const math::XYZVector &vec1, const math::XYZVector &vec2)
Definition: TauTagTools.cc:13
reco::PFCandidateRefVector PFNeutrHadrCands_
ElementsInCone< math::XYZVector, Angle< math::XYZVector >, reco::PFCandidateCollection > PFCandsinCone_Anglemetric_
reco::PFCandidateRefVector IsolPFChargedHadrCands_
double discriminatorByIsolPFGammaCandsN(int IsolPFCands_maxN=0)
reco::PFCandidateRefVector PFCands_
reco::PFCandidateRefVector PFCandsInCone(const reco::PFCandidateRefVector PFCands, const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
Angle< math::XYZVector > metricAngle_
ElementsInAnnulus< math::XYZVector, Angle< math::XYZVector >, DeltaR< math::XYZVector >, reco::PFCandidateCollection > PFCandsinAnnulus_innerAngleouterDRmetrics_
reco::PFCandidateRefVector PFChargedHadrCands_
double discriminatorByIsolPFChargedHadrCandsN(int IsolPFCands_maxN=0)
ElementsInCone< math::XYZVector, DeltaR< math::XYZVector >, reco::PFCandidateCollection > PFCandsinCone_DRmetric_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
bool empty() const
Is the RefVector empty.
Definition: RefVector.h:86
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
reco::PFCandidateRefVector IsolPFCands_
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
void computeInsideOutContents(const reco::PFCandidateRefVector &theChargedCands, const reco::PFCandidateRefVector &theGammaCands, const math::XYZVector leadTrackVector, const TFormula &coneSizeFormula, double(*ptrToMetricFunction)(const math::XYZVector &, const math::XYZVector &), const double minChargedSize, const double maxChargedSize, const double minNeutralSize, const double maxNeutralSize, const double minChargedPt, const double minNeutralPt, const std::string &outlierCollectorConeMetric, const double outlierCollectorConeSize, reco::PFCandidateRefVector &signalChargedObjects, reco::PFCandidateRefVector &outlierChargedObjects, reco::PFCandidateRefVector &signalGammaObjects, reco::PFCandidateRefVector &outlierGammaObjects, bool useScanningAxis)
compute size of cone using the Inside-Out cone (Author Evan Friis, UC Davis)
ElementsInAnnulus< math::XYZVector, Angle< math::XYZVector >, Angle< math::XYZVector >, reco::PFCandidateCollection > PFCandsinAnnulus_innerAngleouterAnglemetrics_
std::pair< reco::PFCandidateRefVector, reco::PFCandidateRefVector > PFGammaCandsInOutEllipse(const reco::PFCandidateRefVector, const reco::PFCandidate, double rPhi, double rEta, double maxPt) const
ElementsInAnnulus< math::XYZVector, DeltaR< math::XYZVector >, Angle< math::XYZVector >, reco::PFCandidateCollection > PFCandsinAnnulus_innerDRouterAnglemetrics_
double discriminatorByIsolPFCandsEtSum(double IsolPFCands_maxEtSum=0)
double discriminatorByIsolPFGammaCandsEtSum(double IsolPFCands_maxEtSum=0)
const PFCandidateRefVector & isolationPFGammaCands() const
Gamma candidates in isolation region.
Definition: PFTau.cc:88
double discriminatorByIsolPFCandsN(int IsolPFCands_maxN=0)
reco::PFCandidateRefVector IsolPFGammaCands_
PFTauElementsOperators(reco::PFTau &thePFTau)
void setAcceptanceLimit(double etaMaxTrackingAcceptance)
double discriminatorByIsolPFNeutrHadrCandsN(int IsolPFCands_maxN=0)
void reserve(size_type n)
Reserve space for RefVector.
Definition: RefVector.h:95
reco::TrackRefVector Tracks_
double computeDeltaR(const math::XYZVector &vec1, const math::XYZVector &vec2)
Definition: TauTagTools.cc:8
const PFTauTagInfoRef & pfTauTagInfoRef() const
Definition: PFTau.cc:53
reco::PFCandidateRefVector filteredPFChargedHadrCands(reco::PFCandidateRefVector theInitialPFCands, double ChargedHadrCand_tkminPt, int ChargedHadrCand_tkminPixelHitsn, int ChargedHadrCand_tkminTrackerHitsn, double ChargedHadrCand_tkmaxipt, double ChargedHadrCand_tkmaxChi2, reco::Vertex pV)
Definition: TauTagTools.cc:119
reco::PFCandidateRef leadPFNeutrHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
edm::RefVector< PFCandidateCollection > PFCandidateRefVector
vector of reference to GenParticleCandidate in the same collection
reco::PFCandidateRefVector PFChargedHadrCandsInCone(const math::XYZVector myVector, const std::string conemetric, const double conesize, const double minPt) const
reco::PFCandidateRefVector PFCandsInAnnulus(const reco::PFCandidateRefVector PFCands, 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
reco::PFCandidateRef leadPFChargedHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
DeltaR< math::XYZVector > metricDR_
void setAreaMetricrecoElementsmaxabsEta(double x)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
value_type const at(size_type idx) const
Retrieve an element of the RefVector.
Definition: RefVector.h:76
reco::PFCandidateRef leadPFCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
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
double discriminatorByIsolPFChargedHadrCandsEtSum(std::string matchingcone_metric, double matchingcone_size, std::string signalcone_metric, double signalcone_size, std::string isolcone_metric, double isolcone_size, bool useOnlyChargedHadrforleadPFCand, double minPt_leadPFCand, double minPt_PFCand, double IsolPFCands_maxEtSum=0)
double discriminatorByIsolPFNeutrHadrCandsEtSum(double IsolPFCands_maxEtSum=0)
ElementsInAnnulus< math::XYZVector, DeltaR< math::XYZVector >, DeltaR< math::XYZVector >, reco::PFCandidateCollection > PFCandsinAnnulus_innerDRouterDRmetrics_
x
Definition: VDTMath.h:216
void copyCandRefsFilteredByPt(const reco::PFCandidateRefVector &theInputCands, reco::PFCandidateRefVector &theOutputCands, const double minPt)
append elements of theInputCands that pass Pt requirement to the end of theOutputCands ...
reco::PFCandidateRef leadPFGammaCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
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
const PFCandidateRefVector & isolationPFNeutrHadrCands() const
Definition: PFTau.cc:86
reco::PFCandidateRefVector IsolPFNeutrHadrCands_
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
const PFCandidateRefVector & isolationPFChargedHadrCands() const
Charged candidates in isolation region.
Definition: PFTau.cc:84