Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:49:38

0001 #include "ConeIsolationAlgorithm.h"
0002 using namespace std;
0003 using namespace reco;
0004 using namespace edm;
0005 
0006 ConeIsolationAlgorithm::ConeIsolationAlgorithm() = default;
0007 
0008 ConeIsolationAlgorithm::ConeIsolationAlgorithm(const ParameterSet& parameters) {
0009   //FIXME: use unsigned int where needed
0010   m_cutPixelHits = parameters.getParameter<int>("MinimumNumberOfPixelHits");  // not used
0011   m_cutTotalHits = parameters.getParameter<int>("MinimumNumberOfHits");
0012   m_cutMaxTIP = parameters.getParameter<double>("MaximumTransverseImpactParameter");
0013   m_cutMinPt = parameters.getParameter<double>("MinimumTransverseMomentum");
0014   m_cutMaxChiSquared = parameters.getParameter<double>("MaximumChiSquared");
0015   dZ_vertex = parameters.getParameter<double>("DeltaZetTrackVertex");  //  to be modified
0016   useVertexConstrain_ = parameters.getParameter<bool>("useVertex");
0017 
0018   matching_cone = parameters.getParameter<double>("MatchingCone");
0019   signal_cone = parameters.getParameter<double>("SignalCone");
0020   isolation_cone = parameters.getParameter<double>("IsolationCone");
0021   pt_min_isolation = parameters.getParameter<double>("MinimumTransverseMomentumInIsolationRing");
0022   pt_min_leadTrack = parameters.getParameter<double>("MinimumTransverseMomentumLeadingTrack");
0023   n_tracks_isolation_ring = parameters.getParameter<int>("MaximumNumberOfTracksIsolationRing");
0024 
0025   useFixedSizeCone = parameters.getParameter<bool>("UseFixedSizeCone");
0026   variableConeParameter = parameters.getParameter<double>("VariableConeParameter");
0027   variableMaxCone = parameters.getParameter<double>("VariableMaxCone");
0028   variableMinCone = parameters.getParameter<double>("VariableMinCone");
0029 }
0030 
0031 void ConeIsolationAlgorithm::fillDescription(edm::ParameterSetDescription& desc) {
0032   desc.add<int>("MinimumNumberOfPixelHits", 2);
0033   desc.add<int>("MinimumNumberOfHits", 8);
0034   desc.add<double>("MaximumTransverseImpactParameter", 0.03);
0035   desc.add<double>("MinimumTransverseMomentum", 1.0);
0036   desc.add<double>("MaximumChiSquared", 100.0);
0037   desc.add<double>("DeltaZetTrackVertex", 0.2);
0038   desc.add<bool>("useVertex", true);
0039   desc.add<double>("MatchingCone", 0.1);
0040   desc.add<double>("SignalCone", 0.07);
0041   desc.add<double>("IsolationCone", 0.45);
0042   desc.add<double>("MinimumTransverseMomentumInIsolationRing", 0.0);
0043   desc.add<double>("MinimumTransverseMomentumLeadingTrack", 6.0);
0044   desc.add<int>("MaximumNumberOfTracksIsolationRing", 0);
0045   desc.add<bool>("UseFixedSizeCone", true);
0046   desc.add<double>("VariableConeParameter", 3.5);
0047   desc.add<double>("VariableMaxCone", 0.17);
0048   desc.add<double>("VariableMinCone", 0.05);
0049 }
0050 
0051 pair<float, IsolatedTauTagInfo> ConeIsolationAlgorithm::tag(const JetTracksAssociationRef& jetTracks,
0052                                                             const Vertex& pv) {
0053   const edm::RefVector<reco::TrackCollection>& tracks = jetTracks->second;
0054   edm::RefVector<reco::TrackCollection> myTracks;
0055 
0056   // Selection of the Tracks
0057   float z_pv = pv.z();
0058   for (auto&& track : tracks) {
0059     if ((track)->pt() > m_cutMinPt && (track)->normalizedChi2() < m_cutMaxChiSquared &&
0060         fabs((track)->dxy(pv.position())) < m_cutMaxTIP && (track)->recHitsSize() >= (unsigned int)m_cutTotalHits &&
0061         (track)->hitPattern().numberOfValidPixelHits() >= m_cutPixelHits) {
0062       if (useVertexConstrain_ && z_pv > -500.) {
0063         if (fabs((track)->dz(pv.position())) < dZ_vertex)
0064           myTracks.push_back(track);
0065       } else
0066         myTracks.push_back(track);
0067     }
0068   }
0069   IsolatedTauTagInfo resultExtended(myTracks, jetTracks);
0070 
0071   double r_sigCone = signal_cone;
0072   double energyJet = jetTracks->first->energy();
0073   if (not useFixedSizeCone) {
0074     r_sigCone = std::min(variableMaxCone, variableConeParameter / energyJet);
0075     r_sigCone = std::max((double)r_sigCone, variableMinCone);
0076   }
0077 
0078   // now I can use it for the discriminator;
0079   math::XYZVector jetDir(jetTracks->first->px(), jetTracks->first->py(), jetTracks->first->pz());
0080   float discriminator = 0.;
0081   if (useVertexConstrain_) {
0082     // In this case all the selected tracks comes from the same vertex, so no need to pass the dZ_vertex requirement to the discriminator
0083     const TrackRef myLeadTk = resultExtended.leadingSignalTrack(matching_cone, pt_min_leadTrack);
0084     resultExtended.setLeadingTrack(myLeadTk);
0085     discriminator = resultExtended.discriminator(
0086         jetDir, matching_cone, r_sigCone, isolation_cone, pt_min_leadTrack, pt_min_isolation, n_tracks_isolation_ring);
0087     resultExtended.setDiscriminator(discriminator);
0088   } else {
0089     // In this case the dZ_vertex is used to associate the tracks to the Z_imp parameter of the Leading Track
0090     const TrackRef myLeadTk = resultExtended.leadingSignalTrack(matching_cone, pt_min_leadTrack);
0091     resultExtended.setLeadingTrack(myLeadTk);
0092     discriminator = resultExtended.discriminator(jetDir,
0093                                                  matching_cone,
0094                                                  r_sigCone,
0095                                                  isolation_cone,
0096                                                  pt_min_leadTrack,
0097                                                  pt_min_isolation,
0098                                                  n_tracks_isolation_ring,
0099                                                  dZ_vertex);
0100     resultExtended.setDiscriminator(discriminator);
0101   }
0102 
0103   return std::make_pair(discriminator, resultExtended);
0104 }