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