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 PFJetRef myPFJet=(*myPFTauTagInfoRef).pfjetRef();
98 PFTau myPFTau(std::numeric_limits<int>::quiet_NaN(),myPFJet->p4());
102 std::vector<PFCandidatePtr> myPFCands=(*myPFTauTagInfoRef).PFCands();
113 bool myleadPFCand_rectkavailable =
false;
114 double myleadPFCand_rectkDZ = 0.;
118 myPFTau.setleadPFChargedHadrCand(myleadPFChargedCand);
119 TrackRef myleadPFCand_rectk=(*myleadPFChargedCand).trackRef();
121 myleadPFCand_rectkavailable=
true;
122 myleadPFCand_rectkDZ=(*myleadPFCand_rectk).dz(myPV.
position());
125 GlobalVector myPFJetdir((*myPFJet).px(),(*myPFJet).py(),(*myPFJet).pz());
127 myPFTau.setleadPFChargedHadrCandsignedSipt(
140 std::vector<PFCandidatePtr> myTmpPFCandsInSignalCone =
144 double jetOpeningAngle = 0.0;
145 for (std::vector<PFCandidatePtr>::const_iterator iCand = myTmpPFCandsInSignalCone.begin();
146 iCand != myTmpPFCandsInSignalCone.end(); iCand++)
150 if (deltaRToSeed > jetOpeningAngle)
151 jetOpeningAngle = deltaRToSeed;
153 tmpLorentzVect+=(**iCand).p4();
157 double energy = tmpLorentzVect.energy();
158 double transverseEnergy = tmpLorentzVect.pt();
159 myPFTau.setP4(tmpLorentzVect);
162 double myTrackerSignalConeSize = myPFTauElementsOperators.
computeConeSize(
164 double myTrackerIsolConeSize = myPFTauElementsOperators.
computeConeSize(
166 double myECALSignalConeSize = myPFTauElementsOperators.
computeConeSize(
170 double myHCALSignalConeSize = myPFTauElementsOperators.
computeConeSize(
176 std::vector<PFCandidatePtr> mySignalPFChargedHadrCands, mySignalPFNeutrHadrCands, mySignalPFGammaCands, mySignalPFCands;
189 myPFTau.setsignalPFChargedHadrCands(mySignalPFChargedHadrCands);
195 myPFTau.setsignalPFNeutrHadrCands(mySignalPFNeutrHadrCands);
201 myPFTau.setsignalPFGammaCands(mySignalPFGammaCands);
204 if(mySignalPFChargedHadrCands.size() != 0) {
205 int mySignalPFChargedHadrCands_qsum=0;
206 for(
size_t i = 0;
i < mySignalPFChargedHadrCands.size();
i++) {
207 mySignalPFChargedHadrCands_qsum += mySignalPFChargedHadrCands[
i]->charge();
208 mySignalPFCands.push_back(mySignalPFChargedHadrCands[
i]);
210 myPFTau.setCharge(mySignalPFChargedHadrCands_qsum);
214 for(
size_t i = 0;
i < mySignalPFNeutrHadrCands.size();
i++) {
215 mySignalPFCands.push_back(mySignalPFNeutrHadrCands[
i]);
219 double maxSignalGammaPt = 0.;
220 for(
size_t i = 0;
i < mySignalPFGammaCands.size();
i++) {
221 if(mySignalPFGammaCands[
i]->
pt() > maxSignalGammaPt) {
222 myleadPFNeutralCand = mySignalPFGammaCands[
i];
223 maxSignalGammaPt = mySignalPFGammaCands[
i]->pt();
225 mySignalPFCands.push_back(mySignalPFGammaCands[
i]);
227 myPFTau.setsignalPFCands(mySignalPFCands);
229 myPFTau.setleadPFNeutralCand(myleadPFNeutralCand);
237 myPFTau.setleadPFCand(myleadPFChargedCand);
239 myPFTau.setleadPFCand(myleadPFNeutralCand);
243 std::vector<PFCandidatePtr> myUnfilteredIsolPFChargedHadrCands, myIsolPFNeutrHadrCands, myIsolPFGammaCands, myIsolPFCands;
258 std::vector<PFCandidatePtr> myIsolPFChargedHadrCands;
262 myPFTau.setisolationPFChargedHadrCands(myIsolPFChargedHadrCands);
268 myPFTau.setisolationPFNeutrHadrCands(myIsolPFNeutrHadrCands);
274 myPFTau.setisolationPFGammaCands(myIsolPFGammaCands);
281 rPhi =
Rphi_*myECALSignalConeSize;
285 std::pair<std::vector<PFCandidatePtr>,std::vector<PFCandidatePtr>> elementsInOutEllipse =
288 std::vector<PFCandidatePtr> elementsInEllipse = elementsInOutEllipse.first;
289 std::vector<PFCandidatePtr> elementsOutEllipse = elementsInOutEllipse.second;
291 for(std::vector<PFCandidatePtr>::const_iterator inEllipseIt = elementsInEllipse.begin(); inEllipseIt != elementsInEllipse.end(); inEllipseIt++){
292 mySignalPFCands.push_back(*inEllipseIt);
293 mySignalPFGammaCands.push_back(*inEllipseIt);
295 myPFTau.setsignalPFCands(mySignalPFCands);
297 myIsolPFGammaCands=elementsOutEllipse;
298 myPFTau.setisolationPFGammaCands(myIsolPFGammaCands);
303 float myIsolPFChargedHadrCands_Ptsum = 0.;
304 float myIsolPFGammaCands_Etsum = 0.;
305 for(
size_t i = 0;
i < myIsolPFChargedHadrCands.size();
i++) {
306 myIsolPFChargedHadrCands_Ptsum += myIsolPFChargedHadrCands[
i]->pt();
307 myIsolPFCands.push_back(myIsolPFChargedHadrCands[
i]);
309 myPFTau.setisolationPFChargedHadrCandsPtSum(myIsolPFChargedHadrCands_Ptsum);
312 for(
size_t i = 0;
i < myIsolPFNeutrHadrCands.size();
i++) {
313 myIsolPFCands.push_back(myIsolPFNeutrHadrCands[
i]);
316 for(
size_t i = 0;
i < myIsolPFGammaCands.size();
i++) {
317 myIsolPFGammaCands_Etsum += myIsolPFGammaCands[
i]->et();
318 myIsolPFCands.push_back(myIsolPFGammaCands[
i]);
320 myPFTau.setisolationPFGammaCandsEtSum(myIsolPFGammaCands_Etsum);
321 myPFTau.setisolationPFCands(myIsolPFCands);
325 for (std::vector<PFCandidatePtr>::const_iterator iGammaCand = mySignalPFGammaCands.begin();
326 iGammaCand != mySignalPFGammaCands.end(); iGammaCand++) {
327 alternatLorentzVect+=(**iGammaCand).p4();
330 for (std::vector<PFCandidatePtr>::const_iterator iChargedHadrCand = mySignalPFChargedHadrCands.begin();
331 iChargedHadrCand != mySignalPFChargedHadrCands.end(); iChargedHadrCand++) {
332 alternatLorentzVect+=(**iChargedHadrCand).p4();
335 myPFTau.setalternatLorentzVect(alternatLorentzVect);
339 for (std::vector<PFCandidatePtr>::const_iterator iNeutralHadrCand = mySignalPFNeutrHadrCands.begin();
340 iNeutralHadrCand != mySignalPFNeutrHadrCands.end(); iNeutralHadrCand++) {
341 alternatLorentzVect+=(**iNeutralHadrCand).p4();
344 myPFTau.setP4(alternatLorentzVect);
355 myPFTau.setleadTrack(myleadTk);
357 double myleadTkDZ = (*myleadTk).dz(myPV.
position());
365 myPFTau.setisolationTracks(myFilteredTracks);
372 myPFTau.setisolationTracks(myFilteredTracks);
378 double myECALenergy = 0.;
379 double myHCALenergy = 0.;
380 double myHCALenergy3x3 = 0.;
381 double myMaximumHCALPFClusterE = 0.;
382 double myMaximumHCALPFClusterEt = 0.;
383 double myStripClusterE = 0.;
384 double myEmfrac = -1.;
385 double myElectronPreIDOutput = -1111.;
386 bool myElecPreid =
false;
394 myElectronPreIDOutput = myleadPFChargedCand->mva_e_pi();
396 math::XYZPointF myElecTrkEcalPos = myleadPFChargedCand->positionAtECALEntrance();
397 myElecTrk = myleadPFChargedCand->trackRef();
403 for(
int i=0;
i<(int)myPFCands.size();
i++){
404 myHCALenergy += myPFCands[
i]->hcalEnergy();
405 myECALenergy += myPFCands[
i]->ecalEnergy();
408 if (myPFCands[
i]->particleId()==1 || myPFCands[
i]->particleId()==2)
409 candPos = myPFCands[
i]->positionAtECALEntrance();
414 double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,candPos);
416 double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
420 myStripClusterE += myPFCands[
i]->ecalEnergy();
423 myHCALenergy3x3 += myPFCands[
i]->hcalEnergy();
425 if (myPFCands[
i]->hcalEnergy()>myMaximumHCALPFClusterE) {
426 myMaximumHCALPFClusterE = myPFCands[
i]->hcalEnergy();
428 if ((myPFCands[
i]->hcalEnergy()*fabs(
sin(candPos.Theta())))>myMaximumHCALPFClusterEt) {
429 myMaximumHCALPFClusterEt = (myPFCands[
i]->hcalEnergy()*fabs(
sin(candPos.Theta())));
435 std::vector<math::XYZPoint> hcalPosV; hcalPosV.clear();
436 std::vector<math::XYZPoint> ecalPosV; ecalPosV.clear();
437 for(
int i=0;
i<(int)myPFCands.size();
i++){
438 const ElementsInBlocks& elts = myPFCands[
i]->elementsInBlocks();
439 for(ElementsInBlocks::const_iterator it=elts.begin(); it!=elts.end(); ++it) {
441 unsigned indexOfElementInBlock = it->second;
443 assert(indexOfElementInBlock<elements.
size());
449 double en = (double)element.clusterRef()->energy();
450 double et = (double)element.clusterRef()->energy()*fabs(
sin(clusPos.Theta()));
451 if (en>myMaximumHCALPFClusterE) {
452 myMaximumHCALPFClusterE = en;
454 if (et>myMaximumHCALPFClusterEt) {
455 myMaximumHCALPFClusterEt = et;
458 hcalPosV.push_back(clusPos);
462 myHCALenergy3x3 += en;
466 double en = (double)element.clusterRef()->energy();
469 ecalPosV.push_back(clusPos);
471 double deltaPhi = ROOT::Math::VectorUtil::DeltaPhi(myElecTrkEcalPos,clusPos);
473 double deltaPhiOverQ = deltaPhi/(double)myElecTrk->charge();
475 myStripClusterE += en;
485 if ((myHCALenergy+myECALenergy)>0.)
486 myEmfrac = myECALenergy/(myHCALenergy+myECALenergy);
487 myPFTau.setemFraction((
float)myEmfrac);
492 float myElectronMomentum = (float)myElecTrk->p();
493 if (myElectronMomentum > 0.)
495 myHCALenergy /= myElectronMomentum;
496 myMaximumHCALPFClusterE /= myElectronMomentum;
497 myHCALenergy3x3 /= myElectronMomentum;
498 myStripClusterE /= myElectronMomentum;
501 myPFTau.sethcalTotOverPLead((
float)myHCALenergy);
502 myPFTau.sethcalMaxOverPLead((
float)myMaximumHCALPFClusterE);
503 myPFTau.sethcal3x3OverPLead((
float)myHCALenergy3x3);
504 myPFTau.setecalStripSumEOverPLead((
float)myStripClusterE);
505 myPFTau.setmaximumHCALPFClusterEt(myMaximumHCALPFClusterEt);
506 myPFTau.setelectronPreIDOutput(myElectronPreIDOutput);
508 myPFTau.setelectronPreIDTrack(myElecTrk);
511 myPFTau.setelectronPreIDDecision(myElecPreid);
524 for (
unsigned int i=0;
i<CalPos.size();
i++) {
525 if (CalPos[
i] == CandPos) {
double computeConeSize(const TFormula &ConeSizeTFormula, double ConeSizeMin, double ConeSizeMax)
std::string ECALIsolConeSizeFormula_
T getParameter(std::string const &) const
std::vector< reco::PFCandidatePtr > PFCandsInCone(const std::vector< reco::PFCandidatePtr > &PFCands, const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
Abstract base class for a PFBlock element (track, cluster...)
bool isNonnull() const
Checks for non-null.
#define PFTauAlgo_ChargedHadrCand_minPt_
std::string TrackerIsolConeSizeFormula_
double maximumForElectrionPreIDOutput_
std::pair< std::vector< reco::PFCandidatePtr >, std::vector< reco::PFCandidatePtr > > PFGammaCandsInOutEllipse(const std::vector< reco::PFCandidatePtr > &, const reco::PFCandidate &, double rPhi, double rEta, double maxPt) const
std::string ECALSignalConeSizeFormula_
const reco::TrackRef leadTk(std::string matchingConeMetric, double matchingConeSize, double ptTrackMin) const
double HCALIsolConeSize_min_
const TransientTrackBuilder * TransientTrackBuilder_
double ECALSignalConeSize_max_
double y() const
y coordinate
uint32_t ChargedHadrCand_IsolAnnulus_minNhits_
std::vector< reco::PFCandidatePtr > PFGammaCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
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
double ChargedHadrCandLeadChargedHadrCand_tksmaxDZ_
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_
std::vector< reco::PFCandidatePtr > 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
y coordinate
TFormula myECALSignalConeSizeTFormula
double AreaMetric_recoElements_maxabsEta_
uint32_t Track_IsolAnnulus_minNhits_
double ECALIsolConeSize_max_
std::string ECALIsolConeMetric_
double TrackerIsolConeSize_max_
bool isNonnull() const
Checks for non-null.
std::string TrackerSignalConeMetric_
double deltaR(double eta1, double eta2, double phi1, double phi2)
std::string MatchingConeSizeFormula_
reco::PFTau buildPFTau(const reco::PFTauTagInfoRef &, const reco::Vertex &)
double HCALSignalConeSize_min_
double x() const
x coordinate
std::vector< ElementInBlock > ElementsInBlocks
TFormula myMatchingConeSizeTFormula
double HCALIsolConeSize_max_
double EcalStripSumE_deltaPhiOverQ_maxValue_
TFormula myHCALIsolConeSizeTFormula
reco::PFCandidatePtr leadPFChargedHadrCand(const std::string matchingcone_metric, const double matchingcone_size, const double minPt) const
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
std::vector< reco::PFCandidatePtr > PFGammaCandsInAnnulus(const math::XYZVector &myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
TFormula myTrackerIsolConeSizeTFormula
std::pair< reco::PFBlockRef, unsigned > ElementInBlock
std::string HCALIsolConeSizeFormula_
std::vector< reco::PFCandidatePtr > PFChargedHadrCandsInAnnulus(const math::XYZVector &myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
double MatchingConeSize_max_
double EcalStripSumE_deltaEta_
#define PFTauAlgo_GammaCand_minPt_
double EcalStripSumE_minClusEnergy_
double ElecPreIDLeadTkMatch_maxDR_
bool putNeutralHadronsInP4_
std::string MatchingConeMetric_
std::vector< reco::PFCandidatePtr > PFChargedHadrCandsInCone(const math::XYZVector &myVector, const std::string conemetric, const double conesize, const double minPt) const
std::vector< reco::PFCandidatePtr > PFNeutrHadrCandsInAnnulus(const math::XYZVector &myVector, const std::string innercone_metric, const double innercone_size, const std::string outercone_metric, const double outercone_size, const double minPt) const
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
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_