CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/RecoTauTag/TauTagTools/src/PFTauElementsOperators.cc

Go to the documentation of this file.
00001 #include "RecoTauTag/TauTagTools/interface/PFTauElementsOperators.h"
00002 
00003 using namespace reco;
00004 using std::string;
00005 
00006  PFTauElementsOperators::PFTauElementsOperators(PFTau& thePFTau): TauElementsOperators(thePFTau),AreaMetric_recoElements_maxabsEta_(2.5){
00007    PFJetRef_=thePFTau.pfTauTagInfoRef()->pfjetRef();
00008    PFCands_=thePFTau.pfTauTagInfoRef()->PFCands();
00009    PFChargedHadrCands_=thePFTau.pfTauTagInfoRef()->PFChargedHadrCands();
00010    PFNeutrHadrCands_=thePFTau.pfTauTagInfoRef()->PFNeutrHadrCands();
00011    PFGammaCands_=thePFTau.pfTauTagInfoRef()->PFGammaCands();
00012    IsolPFCands_=thePFTau.isolationPFCands();
00013    IsolPFChargedHadrCands_=thePFTau.isolationPFChargedHadrCands();
00014    IsolPFNeutrHadrCands_=thePFTau.isolationPFNeutrHadrCands();
00015    IsolPFGammaCands_=thePFTau.isolationPFGammaCands();
00016    Tracks_=thePFTau.pfTauTagInfoRef()->Tracks();
00017 }
00018 void PFTauElementsOperators::setAreaMetricrecoElementsmaxabsEta( double x) {AreaMetric_recoElements_maxabsEta_=x;}
00019 
00020 PFCandidateRefVector PFTauElementsOperators::PFCandsInCone(const PFCandidateRefVector thePFCands,const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{     
00021   PFCandidateRefVector theFilteredPFCands;
00022   for (PFCandidateRefVector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
00023     if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
00024   }  
00025   PFCandidateRefVector theFilteredPFCandsInCone;
00026   if (conemetric=="DR"){
00027     theFilteredPFCandsInCone=PFCandsinCone_DRmetric_(myVector,metricDR_,conesize,theFilteredPFCands);
00028   }else if(conemetric=="angle"){
00029     theFilteredPFCandsInCone=PFCandsinCone_Anglemetric_(myVector,metricAngle_,conesize,theFilteredPFCands);
00030   }else if(conemetric=="area"){
00031     int errorFlag=0;
00032     FixedAreaIsolationCone theFixedAreaCone;
00033     theFixedAreaCone.setAcceptanceLimit(AreaMetric_recoElements_maxabsEta_);
00034     double coneangle=theFixedAreaCone(myVector.theta(),myVector.phi(),0,conesize,errorFlag); 
00035     if (errorFlag!=0)return theFilteredPFCandsInCone;   
00036     theFilteredPFCandsInCone=PFCandsinCone_Anglemetric_(myVector,metricAngle_,coneangle,theFilteredPFCands);
00037   }else return PFCandidateRefVector();
00038   return theFilteredPFCandsInCone;
00039 }
00040 PFCandidateRefVector PFTauElementsOperators::PFCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{     
00041   PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFCands_,myVector,conemetric,conesize,minPt);
00042   return theFilteredPFCandsInCone;
00043 }
00044 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{     
00045   PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFChargedHadrCands_,myVector,conemetric,conesize,minPt);
00046   return theFilteredPFCandsInCone;
00047 }
00048 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{     
00049   PFCandidateRefVector filteredPFChargedHadrCands;
00050   for(PFCandidateRefVector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){
00051     TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef();
00052     if (!PFChargedHadrCand_track)continue;
00053     if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand);
00054   }
00055   PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(filteredPFChargedHadrCands,myVector,conemetric,conesize,minPt);
00056   return theFilteredPFCandsInCone;
00057 }
00058 PFCandidateRefVector PFTauElementsOperators::PFNeutrHadrCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{     
00059   PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFNeutrHadrCands_,myVector,conemetric,conesize,minPt);
00060   return theFilteredPFCandsInCone;
00061 }
00062  PFCandidateRefVector PFTauElementsOperators::PFGammaCandsInCone(const math::XYZVector myVector,const string conemetric,const double conesize,const double minPt)const{     
00063   PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFGammaCands_,myVector,conemetric,conesize,minPt);
00064   return theFilteredPFCandsInCone;
00065 }
00066 
00067 // Function to get elements inside ellipse here ... EELL
00068 std::pair<PFCandidateRefVector, PFCandidateRefVector> PFTauElementsOperators::PFGammaCandsInOutEllipse(const PFCandidateRefVector PFGammaCands_, const PFCandidate leadCand_, double rPhi, double rEta, double maxPt) const{
00069   std::pair<PFCandidateRefVector,PFCandidateRefVector> myPFGammaCandsInEllipse = PFCandidatesInEllipse_(leadCand_, rPhi, rEta, PFGammaCands_);
00070   PFCandidateRefVector thePFGammaCandsInEllipse = myPFGammaCandsInEllipse.first;
00071   PFCandidateRefVector thePFGammaCandsOutEllipse = myPFGammaCandsInEllipse.second;
00072   PFCandidateRefVector theFilteredPFGammaCandsInEllipse;
00073   for(PFCandidateRefVector::const_iterator iPFGammaCand = thePFGammaCandsInEllipse.begin(); iPFGammaCand != thePFGammaCandsInEllipse.end(); ++iPFGammaCand){
00074     if((**iPFGammaCand).pt() <= maxPt) theFilteredPFGammaCandsInEllipse.push_back(*iPFGammaCand);
00075     else thePFGammaCandsOutEllipse.push_back(*iPFGammaCand);
00076   }
00077   std::pair<PFCandidateRefVector, PFCandidateRefVector> theFilteredPFGammaCandsInOutEllipse(theFilteredPFGammaCandsInEllipse, thePFGammaCandsOutEllipse);
00078   
00079   return theFilteredPFGammaCandsInOutEllipse;
00080 }
00081 // EELL
00082 
00083 
00084  PFCandidateRefVector PFTauElementsOperators::PFCandsInAnnulus(const PFCandidateRefVector thePFCands,const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{     
00085   PFCandidateRefVector theFilteredPFCands;
00086   for (PFCandidateRefVector::const_iterator iPFCand=thePFCands.begin();iPFCand!=thePFCands.end();++iPFCand) {
00087     if ((**iPFCand).pt()>minPt)theFilteredPFCands.push_back(*iPFCand);
00088   }  
00089   PFCandidateRefVector theFilteredPFCandsInAnnulus;
00090   if (outercone_metric=="DR"){
00091     if (innercone_metric=="DR"){
00092       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterDRmetrics_(myVector,metricDR_,innercone_size,metricDR_,outercone_size,theFilteredPFCands);
00093     }else if(innercone_metric=="angle"){
00094       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterDRmetrics_(myVector,metricAngle_,innercone_size,metricDR_,outercone_size,theFilteredPFCands);
00095     }else if(innercone_metric=="area"){
00096       int errorFlag=0;
00097       FixedAreaIsolationCone theFixedAreaSignalCone;
00098       theFixedAreaSignalCone.setAcceptanceLimit(AreaMetric_recoElements_maxabsEta_);
00099       double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);
00100       if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
00101       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterDRmetrics_(myVector,metricAngle_,innercone_angle,metricDR_,outercone_size,theFilteredPFCands);
00102     }else return PFCandidateRefVector();
00103   }else if(outercone_metric=="angle"){
00104     if (innercone_metric=="DR"){
00105       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerDRouterAnglemetrics_(myVector,metricDR_,innercone_size,metricAngle_,outercone_size,theFilteredPFCands);
00106     }else if(innercone_metric=="angle"){
00107       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_size,metricAngle_,outercone_size,theFilteredPFCands);
00108     }else if(innercone_metric=="area"){
00109       int errorFlag=0;
00110       FixedAreaIsolationCone theFixedAreaSignalCone;
00111       theFixedAreaSignalCone.setAcceptanceLimit(AreaMetric_recoElements_maxabsEta_);
00112       double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);
00113       if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
00114       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_size,theFilteredPFCands);
00115     }else return PFCandidateRefVector();
00116   }else if(outercone_metric=="area"){
00117     int errorFlag=0;
00118     FixedAreaIsolationCone theFixedAreaSignalCone;
00119     theFixedAreaSignalCone.setAcceptanceLimit(AreaMetric_recoElements_maxabsEta_);
00120     if (innercone_metric=="DR"){
00121       // not implemented yet
00122     }else if(innercone_metric=="angle"){
00123       double outercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),innercone_size,outercone_size,errorFlag);    
00124       if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
00125       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_size,metricAngle_,outercone_angle,theFilteredPFCands);
00126     }else if(innercone_metric=="area"){
00127       double innercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),0,innercone_size,errorFlag);    
00128       if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
00129       double outercone_angle=theFixedAreaSignalCone(myVector.theta(),myVector.phi(),innercone_angle,outercone_size,errorFlag);
00130       if (errorFlag!=0)return theFilteredPFCandsInAnnulus;
00131       theFilteredPFCandsInAnnulus=PFCandsinAnnulus_innerAngleouterAnglemetrics_(myVector,metricAngle_,innercone_angle,metricAngle_,outercone_angle,theFilteredPFCands);
00132     }else return PFCandidateRefVector();
00133   }
00134   return theFilteredPFCandsInAnnulus;
00135 }
00136  PFCandidateRefVector PFTauElementsOperators::PFCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{     
00137   PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
00138   return theFilteredPFCandsInAnnulus;
00139 }
00140  PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{     
00141   PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFChargedHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
00142   return theFilteredPFCandsInAnnulus;
00143 }
00144 PFCandidateRefVector PFTauElementsOperators::PFChargedHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt,const double PFChargedHadrCand_tracktorefpoint_maxDZ,const double refpoint_Z, const Vertex &myPV)const{     
00145   PFCandidateRefVector filteredPFChargedHadrCands;
00146   for(PFCandidateRefVector::const_iterator iPFCand=PFChargedHadrCands_.begin();iPFCand!=PFChargedHadrCands_.end();iPFCand++){
00147     TrackRef PFChargedHadrCand_track=(**iPFCand).trackRef();
00148     if (!PFChargedHadrCand_track)continue;
00149     if (fabs((*PFChargedHadrCand_track).dz(myPV.position())-refpoint_Z)<=PFChargedHadrCand_tracktorefpoint_maxDZ) filteredPFChargedHadrCands.push_back(*iPFCand);
00150   }
00151   PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(filteredPFChargedHadrCands,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
00152   return theFilteredPFCandsInAnnulus;
00153 }
00154  PFCandidateRefVector PFTauElementsOperators::PFNeutrHadrCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{     
00155   PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFNeutrHadrCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
00156   return theFilteredPFCandsInAnnulus;
00157 }
00158  PFCandidateRefVector PFTauElementsOperators::PFGammaCandsInAnnulus(const math::XYZVector myVector,const string innercone_metric,const double innercone_size,const string outercone_metric,const double outercone_size,const double minPt)const{     
00159   PFCandidateRefVector theFilteredPFCandsInAnnulus=PFCandsInAnnulus(PFGammaCands_,myVector,innercone_metric,innercone_size,outercone_metric,outercone_size,minPt);
00160   return theFilteredPFCandsInAnnulus;
00161 }
00162 PFCandidateRef PFTauElementsOperators::leadPFCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00163   PFCandidateRef myleadPFCand;
00164   if (!PFJetRef_) return myleadPFCand;
00165   math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
00166   const PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
00167   double pt_cut=minPt;
00168   if (theFilteredPFCandsInCone.size()>0.){
00169     for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00170       if((*iPFCand)->pt()>pt_cut) {
00171         myleadPFCand=*iPFCand;
00172         pt_cut=(**iPFCand).pt();
00173       }
00174     }
00175   }
00176   return myleadPFCand;
00177 }
00178 PFCandidateRef PFTauElementsOperators::leadPFCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00179   PFCandidateRef myleadPFCand;
00180   const PFCandidateRefVector theFilteredPFCandsInCone=PFCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
00181   double pt_cut=minPt;
00182   if (theFilteredPFCandsInCone.size()>0){
00183     for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00184       if((*iPFCand)->pt()>pt_cut) {
00185         myleadPFCand=*iPFCand;
00186         pt_cut=(**iPFCand).pt();
00187       }
00188     }
00189   }
00190   return myleadPFCand;
00191 }
00192 PFCandidateRef PFTauElementsOperators::leadPFChargedHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00193   PFCandidateRef myleadPFCand;
00194   if (!PFJetRef_) return myleadPFCand;
00195   math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
00196   const PFCandidateRefVector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
00197   double pt_cut=minPt;
00198   if (theFilteredPFCandsInCone.size()>0.){
00199     for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00200       if((*iPFCand)->pt()>pt_cut) {
00201         myleadPFCand=*iPFCand;
00202         pt_cut=(**iPFCand).pt();
00203       }
00204     }
00205   }
00206   return myleadPFCand;
00207 }
00208 PFCandidateRef PFTauElementsOperators::leadPFChargedHadrCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00209   PFCandidateRef myleadPFCand;
00210   const PFCandidateRefVector theFilteredPFCandsInCone=PFChargedHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
00211   double pt_cut=minPt;
00212   if (theFilteredPFCandsInCone.size()>0){
00213     for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00214       if((*iPFCand)->pt()>pt_cut) {
00215         myleadPFCand=*iPFCand;
00216         pt_cut=(**iPFCand).pt();
00217       }
00218     }
00219   }
00220   return myleadPFCand;
00221 }
00222 PFCandidateRef PFTauElementsOperators::leadPFNeutrHadrCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00223   PFCandidateRef myleadPFCand;
00224   if (!PFJetRef_) return myleadPFCand;
00225   math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
00226   const PFCandidateRefVector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
00227   double pt_cut=minPt;
00228   if (theFilteredPFCandsInCone.size()>0.){
00229     for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00230       if((*iPFCand)->pt()>pt_cut) {
00231         myleadPFCand=*iPFCand;
00232         pt_cut=(**iPFCand).pt();
00233       }
00234     }
00235   }
00236   return myleadPFCand;
00237 }
00238 PFCandidateRef PFTauElementsOperators::leadPFNeutrHadrCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00239   PFCandidateRef myleadPFCand;
00240   const PFCandidateRefVector theFilteredPFCandsInCone=PFNeutrHadrCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
00241   double pt_cut=minPt;
00242   if (theFilteredPFCandsInCone.size()>0){
00243     for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00244       if((*iPFCand)->pt()>pt_cut) {
00245         myleadPFCand=*iPFCand;
00246         pt_cut=(**iPFCand).pt();
00247       }
00248     }
00249   }
00250   return myleadPFCand;
00251 }
00252 PFCandidateRef PFTauElementsOperators::leadPFGammaCand(const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00253   PFCandidateRef myleadPFCand;
00254   if (!PFJetRef_) return myleadPFCand;
00255   math::XYZVector PFJet_XYZVector=(*PFJetRef_).momentum();
00256   const PFCandidateRefVector theFilteredPFCandsInCone=PFGammaCandsInCone(PFJet_XYZVector,matchingcone_metric,matchingcone_size,minPt);
00257   double pt_cut=minPt;
00258   if (theFilteredPFCandsInCone.size()>0.){
00259     for(PFCandidateRefVector::const_iterator iPFCand =theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00260       if((*iPFCand)->pt()>pt_cut) {
00261         myleadPFCand=*iPFCand;
00262         pt_cut=(**iPFCand).pt();
00263       }
00264     }
00265   }
00266   return myleadPFCand;
00267 }
00268 PFCandidateRef PFTauElementsOperators::leadPFGammaCand(const math::XYZVector myVector,const string matchingcone_metric,const double matchingcone_size,const double minPt)const{
00269   PFCandidateRef myleadPFCand;
00270   const PFCandidateRefVector theFilteredPFCandsInCone=PFGammaCandsInCone(myVector,matchingcone_metric,matchingcone_size,minPt);
00271   double pt_cut=minPt;
00272   if (theFilteredPFCandsInCone.size()>0){
00273     for(PFCandidateRefVector::const_iterator iPFCand=theFilteredPFCandsInCone.begin();iPFCand!=theFilteredPFCandsInCone.end();iPFCand++){
00274       if((*iPFCand)->pt()>pt_cut) {
00275         myleadPFCand=*iPFCand;
00276         pt_cut=(**iPFCand).pt();
00277       }
00278     }
00279   }
00280   return myleadPFCand;
00281 }
00282 
00283 void
00284 PFTauElementsOperators::copyCandRefsFilteredByPt(const PFCandidateRefVector& theInputCands, PFCandidateRefVector& theOutputCands, const double minPt)
00285 {
00286    for(PFCandidateRefVector::const_iterator iPFCand  = theInputCands.begin();
00287                                             iPFCand != theInputCands.end();
00288                                             ++iPFCand)
00289    {
00290       if ( (*iPFCand)->pt() > minPt )
00291          theOutputCands.push_back(*iPFCand);
00292    }
00293 }
00294 
00295 // Inside Out Signal contents determination algorithm
00296 // Determines tau signal content by building from seed track
00297 void
00298 PFTauElementsOperators::computeInsideOutContents(const PFCandidateRefVector& theChargedCands, const PFCandidateRefVector& theGammaCands,
00299        const math::XYZVector leadTrackVector, const TFormula& coneSizeFormula, double (*ptrToMetricFunction)(const math::XYZVector&, const math::XYZVector&),  
00300        const double minChargedSize, const double maxChargedSize, const double minNeutralSize, const double maxNeutralSize,
00301        const double minChargedPt, const double minNeutralPt,
00302        const string& outlierCollectorConeMetric, const double outlierCollectionMaxSize,
00303        PFCandidateRefVector& signalChargedObjects, PFCandidateRefVector& outlierChargedObjects,
00304        PFCandidateRefVector& signalGammaObjects, PFCandidateRefVector& outlierGammaObjects, bool useScanningAxis) 
00305 {
00306    if (theChargedCands.empty() && theGammaCands.empty()) 
00307       return;
00308    //copy the vector of PFCands filtering by Pt
00309    PFCandidateRefVector filteredCands;
00310    filteredCands.reserve(theChargedCands.size() + theGammaCands.size());
00311 
00312    copyCandRefsFilteredByPt(theChargedCands, filteredCands, minChargedPt);
00313    copyCandRefsFilteredByPt(theGammaCands, filteredCands, minNeutralPt);
00314 
00315    if (filteredCands.empty())
00316       return;
00317 
00318 
00319    //create vector of indexes as RefVectors can't use STL algos?
00320    unsigned int numberOfCandidates = filteredCands.size();
00321    std::vector<uint32_t> filteredCandIndexes(numberOfCandidates);
00322    for(uint32_t theIndex = 0; theIndex < numberOfCandidates; theIndex++)
00323       filteredCandIndexes[theIndex] = theIndex;
00324    
00325    TauTagTools::sortRefsByOpeningDistance myAngularSorter(leadTrackVector, ptrToMetricFunction, filteredCands);
00326 
00327    //sort the remaining candidates by angle to seed track
00328    sort(filteredCandIndexes.begin(), filteredCandIndexes.end(), myAngularSorter);
00329 
00330    PFCandidateRefVector sortedCands;
00331    for(std::vector<uint32_t>::const_iterator theSortedIndex = filteredCandIndexes.begin();
00332                                         theSortedIndex != filteredCandIndexes.end();
00333                                         ++theSortedIndex)
00334    {
00335       sortedCands.push_back(filteredCands.at(*theSortedIndex));
00336    }
00337 
00338    //get first candidate (seed trk by definition)
00339    PFCandidateRefVector::const_iterator signalObjectCandidate = sortedCands.begin();
00340    double totalEnergySoFar                                    = (**signalObjectCandidate).energy();
00341    double totalEtSoFar                                        = (**signalObjectCandidate).et();
00342    math::XYZVector axisVectorSoFar                            = leadTrackVector;
00343    double currentDelToCenter = ptrToMetricFunction(leadTrackVector, axisVectorSoFar);
00344    //advance to next object
00345    ++signalObjectCandidate;
00346    bool doneBuilding = false;
00347    while (!doneBuilding && signalObjectCandidate != sortedCands.end())
00348    {
00349       //compute cutoff quanity
00350       math::XYZVector testAxis       = axisVectorSoFar;
00351       if (useScanningAxis)
00352          testAxis           += (**signalObjectCandidate).momentum();
00353       currentDelToCenter    = ptrToMetricFunction((**signalObjectCandidate).momentum(), testAxis);
00354       double testEnergy     = totalEnergySoFar + (**signalObjectCandidate).energy();
00355       double testEt         = totalEtSoFar     + (**signalObjectCandidate).et();
00356       bool isCharged        = (**signalObjectCandidate).charge();
00357       bool addThisObject    = true;
00358       if (currentDelToCenter > ((isCharged)?maxChargedSize:maxNeutralSize) ) {
00359          //max conesize is reached
00360          addThisObject = false;
00361       }
00362       else if (currentDelToCenter > ((isCharged)?minChargedSize:minNeutralSize) )
00363       {
00364          //only do calculation if we are in the region above the minimum size
00365          double cutOffQuantity = coneSizeFormula.Eval(testEnergy, testEt);
00366          if (currentDelToCenter > cutOffQuantity)
00367             addThisObject = false;
00368          else if (useScanningAxis)
00369          {
00370             //make sure we don't make the seed track kinematically inconsistent  
00371             //(stop growth if axis-lead track distance greater than computed opening angle
00372             if (ptrToMetricFunction(testAxis, leadTrackVector) > cutOffQuantity)
00373                addThisObject = false;
00374          }
00375       }
00376       if (addThisObject)
00377       {
00378          axisVectorSoFar  = testAxis;
00379          totalEnergySoFar = testEnergy;
00380          totalEtSoFar     = testEt;
00381          ++signalObjectCandidate;  //signal object candidate now points to one past the
00382       }
00383       else
00384       {
00385          doneBuilding = true;
00386       }
00387    }
00388    // split the collection into two collections
00389    double largest3DOpeningAngleSignal = 0.;  //used for area outlier collection cone
00390    for (PFCandidateRefVector::const_iterator iterCand =  sortedCands.begin();
00391                                              iterCand != signalObjectCandidate;
00392                                              ++iterCand)
00393    {
00394       double angleToAxis = TauTagTools::computeAngle((*iterCand)->momentum(), axisVectorSoFar);
00395       if (angleToAxis > largest3DOpeningAngleSignal)
00396          largest3DOpeningAngleSignal = angleToAxis;
00397 
00398       if ((*iterCand)->charge())
00399          signalChargedObjects.push_back(*iterCand);
00400       else
00401          signalGammaObjects.push_back(*iterCand);
00402    }
00403 
00404    //function pointer to outlier collection cutoff quantity
00405    double (*outlierCollectionCalculator)(const math::XYZVector&, const math::XYZVector&) = TauTagTools::computeAngle;
00406    double outlierCollectionComputedMaxSize = 0;
00407 
00408    if (!outlierCollectorConeMetric.compare("angle"))
00409    {
00410       outlierCollectionCalculator       = TauTagTools::computeAngle;
00411       outlierCollectionComputedMaxSize  = outlierCollectionMaxSize;
00412    } else if (!outlierCollectorConeMetric.compare("area"))
00413    {
00414       //determine opening angle (in 3D space of signal objects)
00415       
00416       outlierCollectionCalculator       = TauTagTools::computeAngle;  //the area cone outside angle is defined in 3D
00417       FixedAreaIsolationCone theFixedAreaCone;
00418       theFixedAreaCone.setAcceptanceLimit(2.5);
00419       //calculate new iso cone size
00420       int errorFlagForConeSizeCalc = 0;
00421       outlierCollectionComputedMaxSize = theFixedAreaCone(axisVectorSoFar.theta(), axisVectorSoFar.phi(), largest3DOpeningAngleSignal, outlierCollectionMaxSize, errorFlagForConeSizeCalc);
00422       if (errorFlagForConeSizeCalc != 0)
00423       {
00424          edm::LogError("PFRecoTauAlgorithm") << "Error: " << errorFlagForConeSizeCalc << " when calculated const area annulus.  Taking all non-signal PFJet consituents!";
00425          outlierCollectionComputedMaxSize = 1000.;  //takes everything...
00426       }
00427    } else if (!outlierCollectorConeMetric.compare("DR"))
00428    {
00429       outlierCollectionCalculator       = TauTagTools::computeDeltaR;
00430       outlierCollectionComputedMaxSize  = outlierCollectionMaxSize;
00431    } 
00432    else //warn if metric choice for outlier collection is not consistent
00433    {
00434       edm::LogWarning("PFRecoTauAlgorithm") << "Error in computeInsideOutContents(...):  Outlier (isolation) collector cone metric (" << outlierCollectorConeMetric 
00435                                             << ") is not recognized! All non-signal associated PFJet constituents will be included in the outliers!";
00436    }
00437 
00438    for (PFCandidateRefVector::const_iterator iterCand =  signalObjectCandidate;
00439                                              iterCand != sortedCands.end();
00440                                              ++iterCand)
00441    {
00442       //stop adding objects if we have reached the maximum outleir collector size
00443       double outlierOpeningQuantity = outlierCollectionCalculator(axisVectorSoFar, (*iterCand)->momentum());
00444       if (outlierOpeningQuantity > outlierCollectionComputedMaxSize) break;
00445 
00446       if ((*iterCand)->charge())
00447          outlierChargedObjects.push_back(*iterCand);
00448       else
00449          outlierGammaObjects.push_back(*iterCand);
00450    }
00451    //done
00452 }
00453 
00454 
00455 // ***
00456 double PFTauElementsOperators::discriminatorByIsolPFCandsN(int IsolPFCands_maxN){
00457   double myDiscriminator=0.;
00458   if ((int)IsolPFCands_.size()<=IsolPFCands_maxN) myDiscriminator=1;
00459   return myDiscriminator;
00460 }
00461 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){
00462   double myDiscriminator=0.;
00463   PFCandidateRef myleadPFCand;
00464   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00465   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00466   if(!myleadPFCand)return myDiscriminator;
00467   //if(signalcone_size>=isolcone_size) return 1.;
00468   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00469   const PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00470   if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
00471   return myDiscriminator;
00472 }
00473 double PFTauElementsOperators::discriminatorByIsolPFCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFCands_maxN){
00474   double myDiscriminator=0;
00475   PFCandidateRef myleadPFCand;
00476   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00477   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00478   if(!myleadPFCand)return myDiscriminator;
00479   //if(signalcone_size>=isolcone_size) return 1.;
00480   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00481   const PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00482   if ((int)isolPFCands.size()<=IsolPFCands_maxN) myDiscriminator=1;
00483   return myDiscriminator;
00484 }
00485 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(int IsolPFChargedHadrCands_maxN){
00486   double myDiscriminator=0.;
00487   if ((int)IsolPFChargedHadrCands_.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
00488   return myDiscriminator;
00489 }
00490 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){
00491   double myDiscriminator=0.;
00492   PFCandidateRef myleadPFCand;
00493   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00494   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00495   if(!myleadPFCand)return myDiscriminator;
00496   //if(signalcone_size>=isolcone_size) return 1.;
00497   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00498   PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00499   if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
00500   return myDiscriminator;
00501 }
00502 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFChargedHadrCands_maxN){
00503   double myDiscriminator=0;
00504   PFCandidateRef myleadPFCand;
00505   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00506   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00507   if(!myleadPFCand)return myDiscriminator;
00508   //if(signalcone_size>=isolcone_size) return 1.;
00509   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00510    PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00511   if ((int)isolPFChargedHadrCands.size()<=IsolPFChargedHadrCands_maxN) myDiscriminator=1;
00512   return myDiscriminator;
00513 }
00514 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(int IsolPFNeutrHadrCands_maxN){
00515   double myDiscriminator=0.;
00516   if ((int)IsolPFNeutrHadrCands_.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
00517   return myDiscriminator;
00518 }
00519 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){
00520   double myDiscriminator=0.;
00521   PFCandidateRef myleadPFCand;
00522   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00523   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00524   if(!myleadPFCand)return myDiscriminator;
00525   //if(signalcone_size>=isolcone_size) return 1.;
00526   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00527    PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00528   if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
00529   return myDiscriminator;
00530 }
00531 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFNeutrHadrCands_maxN){
00532   double myDiscriminator=0;
00533   PFCandidateRef myleadPFCand;
00534   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00535   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00536   if(!myleadPFCand)return myDiscriminator;
00537   //if(signalcone_size>=isolcone_size) return 1.;
00538   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00539    PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00540   if ((int)isolPFNeutrHadrCands.size()<=IsolPFNeutrHadrCands_maxN) myDiscriminator=1;
00541   return myDiscriminator;
00542 }
00543 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(int IsolPFGammaCands_maxN){
00544   double myDiscriminator=0.;
00545   if ((int)IsolPFGammaCands_.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
00546   return myDiscriminator;
00547 }
00548 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){
00549   double myDiscriminator=0.;
00550   PFCandidateRef myleadPFCand;
00551   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00552   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00553   if(!myleadPFCand)return myDiscriminator;
00554   //if(signalcone_size>=isolcone_size) return 1.;
00555   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00556    PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00557   if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
00558   return myDiscriminator;
00559 }
00560 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsN(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,int IsolPFGammaCands_maxN){
00561   double myDiscriminator=0;
00562   PFCandidateRef myleadPFCand;
00563   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00564   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00565   if(!myleadPFCand)return myDiscriminator;
00566   //if(signalcone_size>=isolcone_size) return 1.;
00567   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00568    PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00569   if ((int)isolPFGammaCands.size()<=IsolPFGammaCands_maxN) myDiscriminator=1;
00570   return myDiscriminator;
00571 }
00572 double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(double IsolPFCands_maxEtSum){
00573   double myIsolPFCandsEtSum=0.;
00574   double myDiscriminator=0.;
00575   for(PFCandidateRefVector::const_iterator iPFCand=IsolPFCands_.begin();iPFCand!=IsolPFCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00576   if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
00577   return myDiscriminator;
00578 }
00579 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){
00580   double myIsolPFCandsEtSum=0.;
00581   double myDiscriminator=0.;
00582   PFCandidateRef myleadPFCand;
00583   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00584   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00585   if(!myleadPFCand)return myDiscriminator;
00586   //if(signalcone_size>=isolcone_size) return 1.;
00587   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00588    PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00589   for(PFCandidateRefVector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00590   if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
00591   return myDiscriminator;
00592 }
00593 double PFTauElementsOperators::discriminatorByIsolPFCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFCands_maxEtSum){
00594   double myIsolPFCandsEtSum=0.;
00595   double myDiscriminator=0;
00596   PFCandidateRef myleadPFCand;
00597   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00598   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00599   if(!myleadPFCand)return myDiscriminator;
00600   //if(signalcone_size>=isolcone_size) return 1.;
00601   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00602    PFCandidateRefVector isolPFCands=PFCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00603   for(PFCandidateRefVector::const_iterator iPFCand=isolPFCands.begin();iPFCand!=isolPFCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00604   if (myIsolPFCandsEtSum<=IsolPFCands_maxEtSum) myDiscriminator=1;
00605   return myDiscriminator;
00606 }
00607 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(double IsolPFChargedHadrCands_maxEtSum){
00608   double myIsolPFCandsEtSum=0.;
00609   double myDiscriminator=0.;
00610   for(PFCandidateRefVector::const_iterator iPFCand=IsolPFChargedHadrCands_.begin();iPFCand!=IsolPFChargedHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00611   if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
00612   return myDiscriminator;
00613 }
00614 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){
00615   double myIsolPFCandsEtSum=0.;
00616   double myDiscriminator=0.;
00617   PFCandidateRef myleadPFCand;
00618   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00619   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00620   if(!myleadPFCand)return myDiscriminator;
00621   //if(signalcone_size>=isolcone_size) return 1.;
00622   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00623    PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00624   for(PFCandidateRefVector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00625   if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
00626   return myDiscriminator;
00627 }
00628 double PFTauElementsOperators::discriminatorByIsolPFChargedHadrCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFChargedHadrCands_maxEtSum){
00629   double myIsolPFCandsEtSum=0.;
00630   double myDiscriminator=0;
00631   PFCandidateRef myleadPFCand;
00632   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00633   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00634   if(!myleadPFCand)return myDiscriminator;
00635   //if(signalcone_size>=isolcone_size) return 1.;
00636   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00637    PFCandidateRefVector isolPFChargedHadrCands=PFChargedHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00638   for(PFCandidateRefVector::const_iterator iPFCand=isolPFChargedHadrCands.begin();iPFCand!=isolPFChargedHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00639   if (myIsolPFCandsEtSum<=IsolPFChargedHadrCands_maxEtSum) myDiscriminator=1;
00640   return myDiscriminator;
00641 }
00642 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(double IsolPFNeutrHadrCands_maxEtSum){
00643   double myIsolPFCandsEtSum=0.;
00644   double myDiscriminator=0.;
00645   for(PFCandidateRefVector::const_iterator iPFCand=IsolPFNeutrHadrCands_.begin();iPFCand!=IsolPFNeutrHadrCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00646   if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
00647   return myDiscriminator;
00648 }
00649 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){
00650   double myIsolPFCandsEtSum=0.;
00651   double myDiscriminator=0.;
00652   PFCandidateRef myleadPFCand;
00653   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00654   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00655   if(!myleadPFCand)return myDiscriminator;
00656   //if(signalcone_size>=isolcone_size) return 1.;
00657   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00658    PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00659   for(PFCandidateRefVector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00660   if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
00661   return myDiscriminator;
00662 }
00663 double PFTauElementsOperators::discriminatorByIsolPFNeutrHadrCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFNeutrHadrCands_maxEtSum){
00664   double myIsolPFCandsEtSum=0.;
00665   double myDiscriminator=0;
00666   PFCandidateRef myleadPFCand;
00667   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00668   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00669   if(!myleadPFCand)return myDiscriminator;
00670   //if(signalcone_size>=isolcone_size) return 1.;
00671   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00672    PFCandidateRefVector isolPFNeutrHadrCands=PFNeutrHadrCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00673   for(PFCandidateRefVector::const_iterator iPFCand=isolPFNeutrHadrCands.begin();iPFCand!=isolPFNeutrHadrCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00674   if (myIsolPFCandsEtSum<=IsolPFNeutrHadrCands_maxEtSum) myDiscriminator=1;
00675   return myDiscriminator;
00676 }
00677 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(double IsolPFGammaCands_maxEtSum){
00678   double myIsolPFCandsEtSum=0.;
00679   double myDiscriminator=0.;
00680   for(PFCandidateRefVector::const_iterator iPFCand=IsolPFGammaCands_.begin();iPFCand!=IsolPFGammaCands_.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00681   if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
00682   return myDiscriminator;
00683 }
00684 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){
00685   double myIsolPFCandsEtSum=0.;
00686   double myDiscriminator=0.;
00687   PFCandidateRef myleadPFCand;
00688   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00689   else myleadPFCand=leadPFCand(matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00690   if(!myleadPFCand)return myDiscriminator;
00691   if(signalcone_size>=isolcone_size) return 1.;
00692   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00693    PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);   
00694   for(PFCandidateRefVector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00695   if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
00696   return myDiscriminator;
00697 }
00698 double PFTauElementsOperators::discriminatorByIsolPFGammaCandsEtSum(math::XYZVector myVector,string matchingcone_metric,double matchingcone_size,string signalcone_metric,double signalcone_size,string isolcone_metric,double isolcone_size,bool useOnlyChargedHadrforleadPFCand,double minPt_leadPFCand,double minPt_PFCand,double IsolPFGammaCands_maxEtSum){
00699   double myIsolPFCandsEtSum=0.;
00700   double myDiscriminator=0;
00701   PFCandidateRef myleadPFCand;
00702   if (useOnlyChargedHadrforleadPFCand) myleadPFCand=leadPFChargedHadrCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand);  
00703   else myleadPFCand=leadPFCand(myVector,matchingcone_metric,matchingcone_size,minPt_leadPFCand); 
00704   if(!myleadPFCand)return myDiscriminator;
00705   //if(signalcone_size>=isolcone_size) return 1.;
00706   math::XYZVector leadPFCand_XYZVector=(*myleadPFCand).momentum() ;
00707    PFCandidateRefVector isolPFGammaCands=PFGammaCandsInAnnulus(leadPFCand_XYZVector,signalcone_metric,signalcone_size,isolcone_metric,isolcone_size,minPt_PFCand);  
00708   for(PFCandidateRefVector::const_iterator iPFCand=isolPFGammaCands.begin();iPFCand!=isolPFGammaCands.end();iPFCand++) myIsolPFCandsEtSum+=(**iPFCand).et();
00709   if (myIsolPFCandsEtSum<=IsolPFGammaCands_maxEtSum) myDiscriminator=1;
00710   return myDiscriminator;
00711 }