8 #define PFTauAlgo_NeutrHadrCand_minPt_ (0.0) 9 #define PFTauAlgo_GammaCand_minPt_ (0.0) 10 #define PFTauAlgo_PFCand_minPt_ (0.0) 11 #define PFTauAlgo_Track_minPt_ (0.0) 12 #define PFTauAlgo_ChargedHadrCand_minPt_ (0.0) 21 = iConfig.
getParameter<
bool>(
"UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint");
24 = iConfig.
getParameter<
double>(
"ChargedHadrCandLeadChargedHadrCand_tksmaxDZ");
60 iConfig.
getParameter<
bool>(
"putNeutralHadronsInP4") :
false;
97 JetBaseRef myPFJet=(*myPFTauTagInfoRef).pfjetRef();
98 PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(),myPFJet->p4());
102 std::vector<CandidatePtr> myPFCands=(*myPFTauTagInfoRef).PFCands();
113 bool myleadPFCand_rectkavailable =
false;
114 double myleadPFCand_rectkDZ = 0.;
118 myPFTau.setleadChargedHadrCand(myleadPFChargedCand);
120 if (pflch ==
nullptr)
121 throw cms::Exception(
"Type Mismatch") <<
"The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n";
124 myleadPFCand_rectkavailable=
true;
125 myleadPFCand_rectkDZ=(*myleadPFCand_rectk).dz(myPV.
position());
128 GlobalVector myPFJetdir((*myPFJet).px(),(*myPFJet).py(),(*myPFJet).pz());
130 myPFTau.setleadPFChargedHadrCandsignedSipt(
143 std::vector<CandidatePtr> myTmpPFCandsInSignalCone =
147 double jetOpeningAngle = 0.0;
148 for (std::vector<CandidatePtr>::const_iterator iCand = myTmpPFCandsInSignalCone.begin();
149 iCand != myTmpPFCandsInSignalCone.end(); iCand++)
153 if (deltaRToSeed > jetOpeningAngle)
154 jetOpeningAngle = deltaRToSeed;
156 tmpLorentzVect+=(**iCand).p4();
160 double energy = tmpLorentzVect.energy();
161 double transverseEnergy = tmpLorentzVect.pt();
162 myPFTau.setP4(tmpLorentzVect);
165 double myTrackerSignalConeSize = myPFTauElementsOperators.
computeConeSize(
167 double myTrackerIsolConeSize = myPFTauElementsOperators.
computeConeSize(
169 double myECALSignalConeSize = myPFTauElementsOperators.
computeConeSize(
173 double myHCALSignalConeSize = myPFTauElementsOperators.
computeConeSize(
179 std::vector<CandidatePtr> mySignalPFChargedHadrCands, mySignalPFNeutrHadrCands, mySignalPFGammaCands, mySignalPFCands;
192 myPFTau.setsignalChargedHadrCands(mySignalPFChargedHadrCands);
198 myPFTau.setsignalNeutrHadrCands(mySignalPFNeutrHadrCands);
204 myPFTau.setsignalGammaCands(mySignalPFGammaCands);
207 if(!mySignalPFChargedHadrCands.empty()) {
208 int mySignalPFChargedHadrCands_qsum=0;
209 for(
size_t i = 0;
i < mySignalPFChargedHadrCands.size();
i++) {
210 mySignalPFChargedHadrCands_qsum += mySignalPFChargedHadrCands[
i]->charge();
211 mySignalPFCands.push_back(mySignalPFChargedHadrCands[
i]);
213 myPFTau.setCharge(mySignalPFChargedHadrCands_qsum);
217 for(
size_t i = 0;
i < mySignalPFNeutrHadrCands.size();
i++) {
218 mySignalPFCands.push_back(mySignalPFNeutrHadrCands[
i]);
222 double maxSignalGammaPt = 0.;
223 for(
size_t i = 0;
i < mySignalPFGammaCands.size();
i++) {
224 if(mySignalPFGammaCands[
i]->
pt() > maxSignalGammaPt) {
225 myleadPFNeutralCand = mySignalPFGammaCands[
i];
226 maxSignalGammaPt = mySignalPFGammaCands[
i]->
pt();
228 mySignalPFCands.push_back(mySignalPFGammaCands[
i]);
230 myPFTau.setsignalCands(mySignalPFCands);
232 myPFTau.setleadNeutralCand(myleadPFNeutralCand);
240 myPFTau.setleadCand(myleadPFChargedCand);
242 myPFTau.setleadCand(myleadPFNeutralCand);
246 std::vector<CandidatePtr> myUnfilteredIsolPFChargedHadrCands, myIsolPFNeutrHadrCands, myIsolPFGammaCands, myIsolPFCands;
261 std::vector<CandidatePtr> myIsolPFChargedHadrCands;
265 myPFTau.setisolationChargedHadrCands(myIsolPFChargedHadrCands);
271 myPFTau.setisolationNeutrHadrCands(myIsolPFNeutrHadrCands);
277 myPFTau.setisolationGammaCands(myIsolPFGammaCands);
284 rPhi =
Rphi_*myECALSignalConeSize;
288 std::pair<std::vector<CandidatePtr>,std::vector<CandidatePtr>> elementsInOutEllipse =
291 std::vector<CandidatePtr> elementsInEllipse = elementsInOutEllipse.first;
292 std::vector<CandidatePtr> elementsOutEllipse = elementsInOutEllipse.second;
294 for(std::vector<CandidatePtr>::const_iterator inEllipseIt = elementsInEllipse.begin(); inEllipseIt != elementsInEllipse.end(); inEllipseIt++){
295 mySignalPFCands.push_back(*inEllipseIt);
296 mySignalPFGammaCands.push_back(*inEllipseIt);
298 myPFTau.setsignalCands(mySignalPFCands);
300 myIsolPFGammaCands=elementsOutEllipse;
301 myPFTau.setisolationGammaCands(myIsolPFGammaCands);
306 float myIsolPFChargedHadrCands_Ptsum = 0.;
307 float myIsolPFGammaCands_Etsum = 0.;
308 for(
size_t i = 0;
i < myIsolPFChargedHadrCands.size();
i++) {
309 myIsolPFChargedHadrCands_Ptsum += myIsolPFChargedHadrCands[
i]->pt();
310 myIsolPFCands.push_back(myIsolPFChargedHadrCands[
i]);
312 myPFTau.setisolationPFChargedHadrCandsPtSum(myIsolPFChargedHadrCands_Ptsum);
315 for(
size_t i = 0;
i < myIsolPFNeutrHadrCands.size();
i++) {
316 myIsolPFCands.push_back(myIsolPFNeutrHadrCands[
i]);
319 for(
size_t i = 0;
i < myIsolPFGammaCands.size();
i++) {
320 myIsolPFGammaCands_Etsum += myIsolPFGammaCands[
i]->et();
321 myIsolPFCands.push_back(myIsolPFGammaCands[
i]);
323 myPFTau.setisolationPFGammaCandsEtSum(myIsolPFGammaCands_Etsum);
324 myPFTau.setisolationCands(myIsolPFCands);
328 for (std::vector<CandidatePtr>::const_iterator iGammaCand = mySignalPFGammaCands.begin();
329 iGammaCand != mySignalPFGammaCands.end(); iGammaCand++) {
330 alternatLorentzVect+=(**iGammaCand).p4();
333 for (std::vector<CandidatePtr>::const_iterator iChargedHadrCand = mySignalPFChargedHadrCands.begin();
334 iChargedHadrCand != mySignalPFChargedHadrCands.end(); iChargedHadrCand++) {
335 alternatLorentzVect+=(**iChargedHadrCand).p4();
338 myPFTau.setalternatLorentzVect(alternatLorentzVect);
342 for (std::vector<CandidatePtr>::const_iterator iNeutralHadrCand = mySignalPFNeutrHadrCands.begin();
343 iNeutralHadrCand != mySignalPFNeutrHadrCands.end(); iNeutralHadrCand++) {
344 alternatLorentzVect+=(**iNeutralHadrCand).p4();
347 myPFTau.setP4(alternatLorentzVect);
358 myPFTau.setleadTrack(myleadTk);
360 double myleadTkDZ = (*myleadTk).dz(myPV.
position());
368 myPFTau.setisolationTracks(myFilteredTracks);
375 myPFTau.setisolationTracks(myFilteredTracks);
381 double myECALenergy = 0.;
382 double myHCALenergy = 0.;
383 double myHCALenergy3x3 = 0.;
384 double myMaximumHCALPFClusterE = 0.;
385 double myMaximumHCALPFClusterEt = 0.;
386 double myStripClusterE = 0.;
387 double myEmfrac = -1.;
388 double myElectronPreIDOutput = -1111.;
389 bool myElecPreid =
false;
398 if (pflch ==
nullptr)
399 throw cms::Exception(
"Type Mismatch") <<
"The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n";
400 myElectronPreIDOutput = pflch->
mva_e_pi();
409 for(
int i=0;
i<(
int)myPFCands.size();
i++){
411 if (myPFCand ==
nullptr)
412 throw cms::Exception(
"Type Mismatch") <<
"The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n";
425 double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
434 if (myPFCand->
hcalEnergy()>myMaximumHCALPFClusterE) {
435 myMaximumHCALPFClusterE = myPFCand->
hcalEnergy();
437 if ((myPFCand->
hcalEnergy()*fabs(
sin(candPos.Theta())))>myMaximumHCALPFClusterEt) {
438 myMaximumHCALPFClusterEt = (myPFCand->
hcalEnergy()*fabs(
sin(candPos.Theta())));
444 std::vector<math::XYZPoint> hcalPosV; hcalPosV.clear();
445 std::vector<math::XYZPoint> ecalPosV; ecalPosV.clear();
446 for(
int i=0;
i<(
int)myPFCands.size();
i++){
448 if (myPFCand ==
nullptr)
449 throw cms::Exception(
"Type Mismatch") <<
"The PFTau was not made from PFCandidates, and this outdated algorithm was not updated to cope with PFTaus made from other Candidates.\n";
451 for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) {
453 unsigned indexOfElementInBlock = it->second;
455 assert(indexOfElementInBlock<elements.
size());
461 double en = (double)element.clusterRef()->energy();
462 double et = (double)element.clusterRef()->energy()*fabs(
sin(clusPos.Theta()));
463 if (en>myMaximumHCALPFClusterE) {
464 myMaximumHCALPFClusterE = en;
466 if (et>myMaximumHCALPFClusterEt) {
467 myMaximumHCALPFClusterEt =
et;
470 hcalPosV.push_back(clusPos);
474 myHCALenergy3x3 += en;
478 double en = (double)element.clusterRef()->energy();
481 ecalPosV.push_back(clusPos);
485 double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
487 myStripClusterE += en;
497 if ((myHCALenergy+myECALenergy)>0.)
498 myEmfrac = myECALenergy/(myHCALenergy+myECALenergy);
499 myPFTau.setemFraction((
float)myEmfrac);
504 float myElectronMomentum = (
float)myElecTrk->p();
505 if (myElectronMomentum > 0.)
507 myHCALenergy /= myElectronMomentum;
508 myMaximumHCALPFClusterE /= myElectronMomentum;
509 myHCALenergy3x3 /= myElectronMomentum;
510 myStripClusterE /= myElectronMomentum;
513 myPFTau.sethcalTotOverPLead((
float)myHCALenergy);
514 myPFTau.sethcalMaxOverPLead((
float)myMaximumHCALPFClusterE);
515 myPFTau.sethcal3x3OverPLead((
float)myHCALenergy3x3);
516 myPFTau.setecalStripSumEOverPLead((
float)myStripClusterE);
517 myPFTau.setmaximumHCALPFClusterEt(myMaximumHCALPFClusterEt);
518 myPFTau.setelectronPreIDOutput(myElectronPreIDOutput);
520 myPFTau.setelectronPreIDTrack(myElecTrk);
523 myPFTau.setelectronPreIDDecision(myElecPreid);
536 for (
unsigned int i=0;
i<CalPos.size();
i++) {
537 if (CalPos[
i] == CandPos) {
std::vector< reco::CandidatePtr > PFGammaCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
double computeConeSize(const TFormula &ConeSizeTFormula, double ConeSizeMin, double ConeSizeMax)
std::string ECALIsolConeSizeFormula_
T getParameter(std::string const &) const
double ecalEnergy() const
return corrected Ecal energy
Abstract base class for a PFBlock element (track, cluster...)
bool isNonnull() const
Checks for non-null.
#define PFTauAlgo_ChargedHadrCand_minPt_
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
std::string TrackerIsolConeSizeFormula_
double maximumForElectrionPreIDOutput_
std::string ECALSignalConeSizeFormula_
reco::PFTau buildPFTau(const reco::PFTauTagInfoRef &, const reco::Vertex &) override
const reco::TrackRef leadTk(std::string matchingConeMetric, double matchingConeSize, double ptTrackMin) const
double HCALIsolConeSize_min_
const TransientTrackBuilder * TransientTrackBuilder_
double ECALSignalConeSize_max_
T const * get() const
Returns C++ pointer to the item.
double y() const
y coordinate
uint32_t ChargedHadrCand_IsolAnnulus_minNhits_
double px() const final
x coordinate of momentum vector
Sin< T >::type sin(const T &t)
#define PFTauAlgo_Track_minPt_
bool UseTrackLeadTrackDZconstraint_
reco::TransientTrack build(const reco::Track *p) const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::string HCALSignalConeSizeFormula_
bool UseChargedHadrCandLeadChargedHadrCand_tksDZconstraint_
const edm::OwnVector< reco::PFBlockElement > & elements() const
double EcalStripSumE_deltaPhiOverQ_minValue_
TFormula myHCALSignalConeSizeTFormula
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
double HCALSignalConeSize_max_
const Point & position() const
position
const math::XYZPointF & positionAtECALEntrance() const
static const double deltaEta
double ChargedHadrCandLeadChargedHadrCand_tksmaxDZ_
reco::TrackRef trackRef() const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
double ECALSignalConeSize_min_
double TrackerIsolConeSize_min_
#define PFTauAlgo_NeutrHadrCand_minPt_
const reco::TrackRefVector tracksInCone(const math::XYZVector &coneAxis, const std::string coneMetric, const double coneSize, const double ptTrackMin) const
double TrackerSignalConeSize_max_
double MatchingConeSize_min_
TFormula myTrackerSignalConeSizeTFormula
std::string ECALSignalConeMetric_
double pz() const final
z coordinate of momentum vector
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
Abs< T >::type abs(const T &t)
double z() const
z coordinate
TFormula myECALSignalConeSizeTFormula
double AreaMetric_recoElements_maxabsEta_
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
uint32_t Track_IsolAnnulus_minNhits_
double ECALIsolConeSize_max_
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
std::string ECALIsolConeMetric_
double TrackerIsolConeSize_max_
bool isNonnull() const
Checks for non-null.
std::string TrackerSignalConeMetric_
float mva_e_pi() const
mva for electron-pion discrimination
std::string MatchingConeSizeFormula_
double HCALSignalConeSize_min_
double x() const
x coordinate
std::vector< ElementInBlock > ElementsInBlocks
TFormula myMatchingConeSizeTFormula
double HCALIsolConeSize_max_
double EcalStripSumE_deltaPhiOverQ_maxValue_
TFormula myHCALIsolConeSizeTFormula
virtual double pt() const =0
transverse momentum
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
bool checkPos(const std::vector< math::XYZPoint > &, const math::XYZPoint &) const
TFormula myTrackerIsolConeSizeTFormula
double py() const final
y coordinate of momentum vector
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
std::string HCALIsolConeSizeFormula_
et
define resolution functions of each parameter
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
double MatchingConeSize_max_
virtual Vector momentum() const =0
spatial momentum vector
double EcalStripSumE_deltaEta_
Particle reconstructed by the particle flow algorithm.
#define PFTauAlgo_GammaCand_minPt_
double hcalEnergy() const
return corrected Hcal energy
double EcalStripSumE_minClusEnergy_
double ElecPreIDLeadTkMatch_maxDR_
bool putNeutralHadronsInP4_
std::string MatchingConeMetric_
virtual ParticleType particleId() const
double ECALIsolConeSize_min_
const reco::TrackRefVector tracksInAnnulus(const math::XYZVector &coneAxis, const std::string innerconeMetric, const double innerconeSize, const std::string outerconeMetric, const double outerconeSize, const double ptTrackMin) const
const ElementsInBlocks & elementsInBlocks() const
double TrackLeadTrack_maxDZ_
std::string TrackerIsolConeMetric_
std::string HCALSignalConeMetric_
std::string TrackerSignalConeSizeFormula_
TFormula myECALIsolConeSizeTFormula
#define PFTauAlgo_PFCand_minPt_
double TrackerSignalConeSize_min_
void setpfTauTagInfoRef(const PFTauTagInfoRef)
std::string HCALIsolConeMetric_
reco::CandidatePtr leadChargedHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const