CMS 3D CMS Logo

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 std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFCandsInCone(const std::vector<reco::PFCandidatePtr>& thePFCands,const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{
21  std::vector<reco::PFCandidatePtr> theFilteredPFCands;
22  for (std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
23  if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
24  }
25  std::vector<reco::PFCandidatePtr> 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 std::vector<reco::PFCandidatePtr>();
38  return theFilteredPFCandsInCone;
39 }
40 std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{
41  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(PFCands_,myVector,conemetric,conesize,minPt);
42  return theFilteredPFCandsInCone;
43 }
44 std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{
45  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(PFChargedHadrCands_,myVector,conemetric,conesize,minPt);
46  return theFilteredPFCandsInCone;
47 }
48 std::vector<reco::PFCandidatePtr> 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{
49  std::vector<reco::PFCandidatePtr> filteredPFChargedHadrCands;
50  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){
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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt);
56  return theFilteredPFCandsInCone;
57 }
58 std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFNeutrHadrCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{
59  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(PFNeutrHadrCands_,myVector,conemetric,conesize,minPt);
60  return theFilteredPFCandsInCone;
61 }
62  std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFGammaCandsInCone(const math::XYZVector& myVector,const string conemetric,const double conesize,const double minPt)const{
63  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(PFGammaCands_,myVector,conemetric,conesize,minPt);
64  return theFilteredPFCandsInCone;
65 }
66 
67 // Function to get elements inside ellipse here ... EELL
68 std::pair<std::vector<reco::PFCandidatePtr>, std::vector<reco::PFCandidatePtr>> PFTauElementsOperators::PFGammaCandsInOutEllipse(const std::vector<reco::PFCandidatePtr>& PFGammaCands_, const PFCandidate& leadCand_, double rPhi, double rEta, double maxPt) const{
69  std::pair<std::vector<reco::PFCandidatePtr>,std::vector<reco::PFCandidatePtr>> myPFGammaCandsInEllipse = PFCandidatesInEllipse_(leadCand_, rPhi, rEta, PFGammaCands_);
70  std::vector<reco::PFCandidatePtr> thePFGammaCandsInEllipse = myPFGammaCandsInEllipse.first;
71  std::vector<reco::PFCandidatePtr> thePFGammaCandsOutEllipse = myPFGammaCandsInEllipse.second;
72  std::vector<reco::PFCandidatePtr> theFilteredPFGammaCandsInEllipse;
73  for(std::vector<reco::PFCandidatePtr>::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<std::vector<reco::PFCandidatePtr>, std::vector<reco::PFCandidatePtr>> theFilteredPFGammaCandsInOutEllipse(theFilteredPFGammaCandsInEllipse, thePFGammaCandsOutEllipse);
78 
79  return theFilteredPFGammaCandsInOutEllipse;
80 }
81 // EELL
82 
83 
84  std::vector<reco::PFCandidatePtr> PFTauElementsOperators::PFCandsInAnnulus(const std::vector<reco::PFCandidatePtr>& 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  std::vector<reco::PFCandidatePtr> theFilteredPFCands;
86  for (std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
87  if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
88  }
89  std::vector<reco::PFCandidatePtr> 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 std::vector<reco::PFCandidatePtr>();
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 std::vector<reco::PFCandidatePtr>();
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 std::vector<reco::PFCandidatePtr>();
133  }
134  return theFilteredPFCandsInAnnulus;
135 }
136  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
138  return theFilteredPFCandsInAnnulus;
139 }
140  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFChargedHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
142  return theFilteredPFCandsInAnnulus;
143 }
144 std::vector<reco::PFCandidatePtr> 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{
145  std::vector<reco::PFCandidatePtr> filteredPFChargedHadrCands;
146  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){
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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
152  return theFilteredPFCandsInAnnulus;
153 }
154  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFNeutrHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
156  return theFilteredPFCandsInAnnulus;
157 }
158  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr> theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
160  return theFilteredPFCandsInAnnulus;
161 }
162 PFCandidatePtr PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
163  PFCandidatePtr myleadPFCand;
164  if (!PFJetRef_) return myleadPFCand;
165  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
166  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
167  double pt_cut=minPt;
168  if (theFilteredPFCandsInCone.size()>0.){
169  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
179  PFCandidatePtr myleadPFCand;
180  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
181  double pt_cut=minPt;
182  if (!theFilteredPFCandsInCone.empty()){
183  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
193  PFCandidatePtr myleadPFCand;
194  if (!PFJetRef_) return myleadPFCand;
195  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
196  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFChargedHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
197  double pt_cut=minPt;
198  if (theFilteredPFCandsInCone.size()>0.){
199  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
209  PFCandidatePtr myleadPFCand;
210  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
211  double pt_cut=minPt;
212  if (!theFilteredPFCandsInCone.empty()){
213  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
223  PFCandidatePtr myleadPFCand;
224  if (!PFJetRef_) return myleadPFCand;
225  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
226  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
227  double pt_cut=minPt;
228  if (theFilteredPFCandsInCone.size()>0.){
229  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
239  PFCandidatePtr myleadPFCand;
240  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
241  double pt_cut=minPt;
242  if (!theFilteredPFCandsInCone.empty()){
243  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
253  PFCandidatePtr myleadPFCand;
254  if (!PFJetRef_) return myleadPFCand;
255  math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
256  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFGammaCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
257  double pt_cut=minPt;
258  if (theFilteredPFCandsInCone.size()>0.){
259  for(std::vector<reco::PFCandidatePtr>::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 PFCandidatePtr PFTauElementsOperators::leadPFGammaCand(const math::XYZVector& myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
269  PFCandidatePtr myleadPFCand;
270  const std::vector<reco::PFCandidatePtr> theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
271  double pt_cut=minPt;
272  if (!theFilteredPFCandsInCone.empty()){
273  for(std::vector<reco::PFCandidatePtr>::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 std::vector<reco::PFCandidatePtr>& theInputCands, std::vector<reco::PFCandidatePtr>& theOutputCands, const double minPt)
285 {
286  for(std::vector<reco::PFCandidatePtr>::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
298 PFTauElementsOperators::computeInsideOutContents(const std::vector<reco::PFCandidatePtr>& theChargedCands, const std::vector<reco::PFCandidatePtr>& theGammaCands,
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  std::vector<reco::PFCandidatePtr>& signalChargedObjects, std::vector<reco::PFCandidatePtr>& outlierChargedObjects,
304  std::vector<reco::PFCandidatePtr>& signalGammaObjects, std::vector<reco::PFCandidatePtr>& outlierGammaObjects, bool useScanningAxis)
305 {
306  if (theChargedCands.empty() && theGammaCands.empty())
307  return;
308  //copy the vector of PFCands filtering by Pt
309  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr> 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  std::vector<reco::PFCandidatePtr>::const_iterator signalObjectCandidate = sortedCands.begin();
340  double totalEnergySoFar = (**signalObjectCandidate).energy();
341  double totalEtSoFar = (**signalObjectCandidate).et();
342  math::XYZVector axisVectorSoFar = leadTrackVector;
343  //advance to next object
344  ++signalObjectCandidate;
345  bool doneBuilding = false;
346  while (!doneBuilding && signalObjectCandidate != sortedCands.end())
347  {
348  //compute cutoff quanity
349  math::XYZVector testAxis = axisVectorSoFar;
350  if (useScanningAxis)
351  testAxis += (**signalObjectCandidate).momentum();
352  double currentDelToCenter = ptrToMetricFunction((**signalObjectCandidate).momentum(), testAxis);
353  double testEnergy = totalEnergySoFar + (**signalObjectCandidate).energy();
354  double testEt = totalEtSoFar + (**signalObjectCandidate).et();
355  bool isCharged = (**signalObjectCandidate).charge();
356  bool addThisObject = true;
357  if (currentDelToCenter > ((isCharged)?maxChargedSize:maxNeutralSize) ) {
358  //max conesize is reached
359  addThisObject = false;
360  }
361  else if (currentDelToCenter > ((isCharged)?minChargedSize:minNeutralSize) )
362  {
363  //only do calculation if we are in the region above the minimum size
364  double cutOffQuantity = coneSizeFormula.Eval(testEnergy, testEt);
365  if (currentDelToCenter > cutOffQuantity)
366  addThisObject = false;
367  else if (useScanningAxis)
368  {
369  //make sure we don't make the seed track kinematically inconsistent
370  //(stop growth if axis-lead track distance greater than computed opening angle
371  if (ptrToMetricFunction(testAxis, leadTrackVector) > cutOffQuantity)
372  addThisObject = false;
373  }
374  }
375  if (addThisObject)
376  {
377  axisVectorSoFar = testAxis;
378  totalEnergySoFar = testEnergy;
379  totalEtSoFar = testEt;
380  ++signalObjectCandidate; //signal object candidate now points to one past the
381  }
382  else
383  {
384  doneBuilding = true;
385  }
386  }
387  // split the collection into two collections
388  double largest3DOpeningAngleSignal = 0.; //used for area outlier collection cone
389  for (std::vector<reco::PFCandidatePtr>::const_iterator iterCand = sortedCands.begin();
390  iterCand != signalObjectCandidate;
391  ++iterCand)
392  {
393  double angleToAxis = TauTagTools::computeAngle((*iterCand)->momentum(), axisVectorSoFar);
394  if (angleToAxis > largest3DOpeningAngleSignal)
395  largest3DOpeningAngleSignal = angleToAxis;
396 
397  if ((*iterCand)->charge())
398  signalChargedObjects.push_back(*iterCand);
399  else
400  signalGammaObjects.push_back(*iterCand);
401  }
402 
403  //function pointer to outlier collection cutoff quantity
404  double (*outlierCollectionCalculator)(const math::XYZVector&, const math::XYZVector&) = TauTagTools::computeAngle;
405  double outlierCollectionComputedMaxSize = 0;
406 
407  if (!outlierCollectorConeMetric.compare("angle"))
408  {
409  outlierCollectionCalculator = TauTagTools::computeAngle;
410  outlierCollectionComputedMaxSize = outlierCollectionMaxSize;
411  } else if (!outlierCollectorConeMetric.compare("area"))
412  {
413  //determine opening angle (in 3D space of signal objects)
414 
415  outlierCollectionCalculator = TauTagTools::computeAngle; //the area cone outside angle is defined in 3D
416  FixedAreaIsolationCone theFixedAreaCone;
417  theFixedAreaCone.setAcceptanceLimit(2.5);
418  //calculate new iso cone size
419  int errorFlagForConeSizeCalc = 0;
420  outlierCollectionComputedMaxSize = theFixedAreaCone(axisVectorSoFar.theta(), axisVectorSoFar.phi(), largest3DOpeningAngleSignal, outlierCollectionMaxSize, errorFlagForConeSizeCalc);
421  if (errorFlagForConeSizeCalc != 0)
422  {
423  edm::LogError("PFRecoTauAlgorithm") << "Error: " << errorFlagForConeSizeCalc << " when calculated const area annulus. Taking all non-signal PFJet consituents!";
424  outlierCollectionComputedMaxSize = 1000.; //takes everything...
425  }
426  } else if (!outlierCollectorConeMetric.compare("DR"))
427  {
428  outlierCollectionCalculator = TauTagTools::computeDeltaR;
429  outlierCollectionComputedMaxSize = outlierCollectionMaxSize;
430  }
431  else //warn if metric choice for outlier collection is not consistent
432  {
433  edm::LogWarning("PFRecoTauAlgorithm") << "Error in computeInsideOutContents(...): Outlier (isolation) collector cone metric (" << outlierCollectorConeMetric
434  << ") is not recognized! All non-signal associated PFJet constituents will be included in the outliers!";
435  }
436 
437  for (std::vector<reco::PFCandidatePtr>::const_iterator iterCand = signalObjectCandidate;
438  iterCand != sortedCands.end();
439  ++iterCand)
440  {
441  //stop adding objects if we have reached the maximum outleir collector size
442  double outlierOpeningQuantity = outlierCollectionCalculator(axisVectorSoFar, (*iterCand)->momentum());
443  if (outlierOpeningQuantity > outlierCollectionComputedMaxSize) break;
444 
445  if ((*iterCand)->charge())
446  outlierChargedObjects.push_back(*iterCand);
447  else
448  outlierGammaObjects.push_back(*iterCand);
449  }
450  //done
451 }
452 
453 
454 // ***
456  double myDiscriminator=0.;
457  if ((int)IsolPFCands_.size()<=IsolPFCands_maxN) myDiscriminator=1;
458  return myDiscriminator;
459 }
460 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){
461  double myDiscriminator=0.;
462  PFCandidatePtr myleadPFCand;
463  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
464  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
465  if(!myleadPFCand)return myDiscriminator;
466  //if(signalcone_size>=isolcone_size) return 1.;
467  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
468  const std::vector<reco::PFCandidatePtr> isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
469  if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
470  return myDiscriminator;
471 }
472 double PFTauElementsOperators::discriminatorByIsolPFCandsN(const 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){
473  double myDiscriminator=0;
474  PFCandidatePtr myleadPFCand;
475  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
476  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
477  if(!myleadPFCand)return myDiscriminator;
478  //if(signalcone_size>=isolcone_size) return 1.;
479  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
480  const std::vector<reco::PFCandidatePtr> isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
481  if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
482  return myDiscriminator;
483 }
485  double myDiscriminator=0.;
486  if ((int)IsolPFChargedHadrCands_.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
487  return myDiscriminator;
488 }
489 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){
490  double myDiscriminator=0.;
491  PFCandidatePtr myleadPFCand;
492  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
493  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
494  if(!myleadPFCand)return myDiscriminator;
495  //if(signalcone_size>=isolcone_size) return 1.;
496  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
497  std::vector<reco::PFCandidatePtr> isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
498  if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
499  return myDiscriminator;
500 }
501 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(const 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){
502  double myDiscriminator=0;
503  PFCandidatePtr myleadPFCand;
504  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
505  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
506  if(!myleadPFCand)return myDiscriminator;
507  //if(signalcone_size>=isolcone_size) return 1.;
508  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
509  std::vector<reco::PFCandidatePtr> isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
510  if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
511  return myDiscriminator;
512 }
514  double myDiscriminator=0.;
515  if ((int)IsolPFNeutrHadrCands_.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
516  return myDiscriminator;
517 }
518 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){
519  double myDiscriminator=0.;
520  PFCandidatePtr myleadPFCand;
521  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
522  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
523  if(!myleadPFCand)return myDiscriminator;
524  //if(signalcone_size>=isolcone_size) return 1.;
525  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
526  std::vector<reco::PFCandidatePtr> isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
527  if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
528  return myDiscriminator;
529 }
530 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(const 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){
531  double myDiscriminator=0;
532  PFCandidatePtr myleadPFCand;
533  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
534  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
535  if(!myleadPFCand)return myDiscriminator;
536  //if(signalcone_size>=isolcone_size) return 1.;
537  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
538  std::vector<reco::PFCandidatePtr> isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
539  if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
540  return myDiscriminator;
541 }
543  double myDiscriminator=0.;
544  if ((int)IsolPFGammaCands_.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
545  return myDiscriminator;
546 }
547 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){
548  double myDiscriminator=0.;
549  PFCandidatePtr myleadPFCand;
550  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
551  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
552  if(!myleadPFCand)return myDiscriminator;
553  //if(signalcone_size>=isolcone_size) return 1.;
554  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
555  std::vector<reco::PFCandidatePtr> isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
556  if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
557  return myDiscriminator;
558 }
559 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(const 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){
560  double myDiscriminator=0;
561  PFCandidatePtr myleadPFCand;
562  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
563  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
564  if(!myleadPFCand)return myDiscriminator;
565  //if(signalcone_size>=isolcone_size) return 1.;
566  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
567  std::vector<reco::PFCandidatePtr> isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
568  if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
569  return myDiscriminator;
570 }
572  double myIsolPFCandsEtSum=0.;
573  double myDiscriminator=0.;
574  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=IsolPFCands_.begin();iPFCand!=IsolPFCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
575  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
576  return myDiscriminator;
577 }
578 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){
579  double myIsolPFCandsEtSum=0.;
580  double myDiscriminator=0.;
581  PFCandidatePtr myleadPFCand;
582  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
583  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
584  if(!myleadPFCand)return myDiscriminator;
585  //if(signalcone_size>=isolcone_size) return 1.;
586  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
587  std::vector<reco::PFCandidatePtr> isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
588  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
589  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
590  return myDiscriminator;
591 }
592 double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(const 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){
593  double myIsolPFCandsEtSum=0.;
594  double myDiscriminator=0;
595  PFCandidatePtr myleadPFCand;
596  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
597  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
598  if(!myleadPFCand)return myDiscriminator;
599  //if(signalcone_size>=isolcone_size) return 1.;
600  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
601  std::vector<reco::PFCandidatePtr> isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
602  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
603  if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
604  return myDiscriminator;
605 }
606 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(double IsolPFChargedHadrCands_maxEtSum){
607  double myIsolPFCandsEtSum=0.;
608  double myDiscriminator=0.;
609  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=IsolPFChargedHadrCands_.begin();iPFCand!=IsolPFChargedHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
610  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
611  return myDiscriminator;
612 }
613 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){
614  double myIsolPFCandsEtSum=0.;
615  double myDiscriminator=0.;
616  PFCandidatePtr myleadPFCand;
617  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
618  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
619  if(!myleadPFCand)return myDiscriminator;
620  //if(signalcone_size>=isolcone_size) return 1.;
621  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
622  std::vector<reco::PFCandidatePtr> isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
623  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
624  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
625  return myDiscriminator;
626 }
627 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(const 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){
628  double myIsolPFCandsEtSum=0.;
629  double myDiscriminator=0;
630  PFCandidatePtr myleadPFCand;
631  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
632  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
633  if(!myleadPFCand)return myDiscriminator;
634  //if(signalcone_size>=isolcone_size) return 1.;
635  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
636  std::vector<reco::PFCandidatePtr> isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
637  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
638  if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
639  return myDiscriminator;
640 }
641 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(double IsolPFNeutrHadrCands_maxEtSum){
642  double myIsolPFCandsEtSum=0.;
643  double myDiscriminator=0.;
644  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=IsolPFNeutrHadrCands_.begin();iPFCand!=IsolPFNeutrHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
645  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
646  return myDiscriminator;
647 }
648 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){
649  double myIsolPFCandsEtSum=0.;
650  double myDiscriminator=0.;
651  PFCandidatePtr myleadPFCand;
652  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
653  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
654  if(!myleadPFCand)return myDiscriminator;
655  //if(signalcone_size>=isolcone_size) return 1.;
656  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
657  std::vector<reco::PFCandidatePtr> isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
658  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
659  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
660  return myDiscriminator;
661 }
662 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(const 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){
663  double myIsolPFCandsEtSum=0.;
664  double myDiscriminator=0;
665  PFCandidatePtr myleadPFCand;
666  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
667  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
668  if(!myleadPFCand)return myDiscriminator;
669  //if(signalcone_size>=isolcone_size) return 1.;
670  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
671  std::vector<reco::PFCandidatePtr> isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
672  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
673  if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
674  return myDiscriminator;
675 }
676 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(double IsolPFGammaCands_maxEtSum){
677  double myIsolPFCandsEtSum=0.;
678  double myDiscriminator=0.;
679  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=IsolPFGammaCands_.begin();iPFCand!=IsolPFGammaCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
680  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
681  return myDiscriminator;
682 }
683 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){
684  double myIsolPFCandsEtSum=0.;
685  double myDiscriminator=0.;
686  PFCandidatePtr myleadPFCand;
687  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
688  else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);
689  if(!myleadPFCand)return myDiscriminator;
690  if(signalcone_size>=isolcone_size) return 1.;
691  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
692  std::vector<reco::PFCandidatePtr> isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
693  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
694  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
695  return myDiscriminator;
696 }
697 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(const 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){
698  double myIsolPFCandsEtSum=0.;
699  double myDiscriminator=0;
700  PFCandidatePtr myleadPFCand;
701  if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
702  else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);
703  if(!myleadPFCand)return myDiscriminator;
704  //if(signalcone_size>=isolcone_size) return 1.;
705  math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
706  std::vector<reco::PFCandidatePtr> isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);
707  for(std::vector<reco::PFCandidatePtr>::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
708  if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
709  return myDiscriminator;
710 }
std::vector< reco::PFCandidatePtr > PFCandsInCone(const std::vector< reco::PFCandidatePtr > &PFCands, const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
std::vector< reco::PFCandidatePtr > IsolPFChargedHadrCands_
std::vector< reco::PFCandidatePtr > IsolPFGammaCands_
const std::vector< reco::PFCandidatePtr > & isolationPFCands() const
PFCandidates in isolation region.
Definition: PFTau.cc:87
double computeAngle(const math::XYZVector &vec1, const math::XYZVector &vec2)
Definition: TauTagTools.cc:13
std::pair< std::vector< reco::PFCandidatePtr >, std::vector< reco::PFCandidatePtr > > PFGammaCandsInOutEllipse(const std::vector< reco::PFCandidatePtr > &, const reco::PFCandidate &, double rPhi, double rEta, double maxPt) const
double discriminatorByIsolPFGammaCandsN(int IsolPFCands_maxN=0)
std::vector< reco::PFCandidatePtr > PFGammaCands_
std::vector< reco::PFCandidatePtr > PFGammaCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
ElementsInAnnulus< math::XYZVector, Angle< math::XYZVector >, Angle< math::XYZVector >, reco::PFCandidate > PFCandsinAnnulus_innerAngleouterAnglemetrics_
Angle< math::XYZVector > metricAngle_
std::vector< reco::PFCandidatePtr > IsolPFNeutrHadrCands_
double discriminatorByIsolPFChargedHadrCandsN(int IsolPFCands_maxN=0)
ElementsInAnnulus< math::XYZVector, Angle< math::XYZVector >, DeltaR< math::XYZVector >, reco::PFCandidate > PFCandsinAnnulus_innerAngleouterDRmetrics_
std::vector< reco::PFCandidatePtr > PFNeutrHadrCands_
std::vector< reco::PFCandidatePtr > filteredPFChargedHadrCands(const std::vector< reco::PFCandidatePtr > &theInitialPFCands, double ChargedHadrCand_tkminPt, int ChargedHadrCand_tkminPixelHitsn, int ChargedHadrCand_tkminTrackerHitsn, double ChargedHadrCand_tkmaxipt, double ChargedHadrCand_tkmaxChi2, reco::Vertex pV)
Definition: TauTagTools.cc:119
void computeInsideOutContents(const std::vector< reco::PFCandidatePtr > &theChargedCands, const std::vector< reco::PFCandidatePtr > &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, std::vector< reco::PFCandidatePtr > &signalChargedObjects, std::vector< reco::PFCandidatePtr > &outlierChargedObjects, std::vector< reco::PFCandidatePtr > &signalGammaObjects, std::vector< reco::PFCandidatePtr > &outlierGammaObjects, bool useScanningAxis)
compute size of cone using the Inside-Out cone (Author Evan Friis, UC Davis)
const Point & position() const
position
Definition: Vertex.h:109
ElementsInAnnulus< math::XYZVector, DeltaR< math::XYZVector >, Angle< math::XYZVector >, reco::PFCandidate > PFCandsinAnnulus_innerDRouterAnglemetrics_
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
Gamma candidates in isolation region.
Definition: PFTau.cc:93
std::vector< reco::PFCandidatePtr > PFCands_
void copyCandRefsFilteredByPt(const std::vector< reco::PFCandidatePtr > &theInputCands, std::vector< reco::PFCandidatePtr > &theOutputCands, const double minPt)
append elements of theInputCands that pass Pt requirement to the end of theOutputCands ...
reco::PFCandidatePtr leadPFCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
double discriminatorByIsolPFCandsEtSum(double IsolPFCands_maxEtSum=0)
ElementsInEllipse< reco::PFCandidate, reco::PFCandidate > PFCandidatesInEllipse_
double discriminatorByIsolPFGammaCandsEtSum(double IsolPFCands_maxEtSum=0)
double discriminatorByIsolPFCandsN(int IsolPFCands_maxN=0)
reco::PFCandidatePtr leadPFNeutrHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
std::vector< reco::PFCandidatePtr > PFNeutrHadrCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
PFTauElementsOperators(reco::PFTau &thePFTau)
void setAcceptanceLimit(double etaMaxTrackingAcceptance)
std::vector< reco::PFCandidatePtr > IsolPFCands_
const std::vector< reco::PFCandidatePtr > & isolationPFNeutrHadrCands() const
Definition: PFTau.cc:91
double discriminatorByIsolPFNeutrHadrCandsN(int IsolPFCands_maxN=0)
ElementsInAnnulus< math::XYZVector, DeltaR< math::XYZVector >, DeltaR< math::XYZVector >, reco::PFCandidate > PFCandsinAnnulus_innerDRouterDRmetrics_
const std::vector< reco::PFCandidatePtr > & isolationPFChargedHadrCands() const
Charged candidates in isolation region.
Definition: PFTau.cc:89
reco::TrackRefVector Tracks_
ElementsInCone< math::XYZVector, Angle< math::XYZVector >, reco::PFCandidate > PFCandsinCone_Anglemetric_
double computeDeltaR(const math::XYZVector &vec1, const math::XYZVector &vec2)
Definition: TauTagTools.cc:8
const PFTauTagInfoRef & pfTauTagInfoRef() const
Definition: PFTau.cc:61
reco::PFCandidatePtr leadPFGammaCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
reco::PFCandidatePtr leadPFChargedHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
ElementsInCone< math::XYZVector, DeltaR< math::XYZVector >, reco::PFCandidate > PFCandsinCone_DRmetric_
std::vector< reco::PFCandidatePtr > 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
DeltaR< math::XYZVector > metricDR_
std::vector< reco::PFCandidatePtr > 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 setAreaMetricrecoElementsmaxabsEta(double x)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
std::vector< reco::PFCandidatePtr > PFCandsInAnnulus(const std::vector< reco::PFCandidatePtr > &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
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)
std::vector< reco::PFCandidatePtr > PFChargedHadrCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
std::vector< reco::PFCandidatePtr > 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
std::vector< reco::PFCandidatePtr > PFChargedHadrCands_