CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/HLTrigger/btau/src/ConeIsolationAlgorithm.cc

Go to the documentation of this file.
00001 #include "HLTrigger/btau/src/ConeIsolationAlgorithm.h"
00002 using namespace std;
00003 using namespace reco;
00004 using namespace edm;
00005 
00006 ConeIsolationAlgorithm::ConeIsolationAlgorithm(void)
00007 { }
00008 
00009 ConeIsolationAlgorithm::ConeIsolationAlgorithm(const ParameterSet & parameters)
00010 {
00011   //FIXME: use unsigned int where needed
00012   m_cutPixelHits     = parameters.getParameter<int>("MinimumNumberOfPixelHits");    // not used
00013   m_cutTotalHits     = parameters.getParameter<int>("MinimumNumberOfHits");
00014   m_cutMaxTIP        = parameters.getParameter<double>("MaximumTransverseImpactParameter");
00015   m_cutMinPt         = parameters.getParameter<double>("MinimumTransverseMomentum");
00016   m_cutMaxChiSquared = parameters.getParameter<double>("MaximumChiSquared");
00017   dZ_vertex          = parameters.getParameter<double>("DeltaZetTrackVertex");      //  to be modified
00018   useVertexConstrain_ = parameters.getParameter<bool>("useVertex");
00019 
00020   matching_cone      = parameters.getParameter<double>("MatchingCone");
00021   signal_cone        = parameters.getParameter<double>("SignalCone");
00022   isolation_cone     = parameters.getParameter<double>("IsolationCone"); 
00023   pt_min_isolation   = parameters.getParameter<double>("MinimumTransverseMomentumInIsolationRing"); 
00024   pt_min_leadTrack   = parameters.getParameter<double>("MinimumTransverseMomentumLeadingTrack"); 
00025   n_tracks_isolation_ring = parameters.getParameter<int>("MaximumNumberOfTracksIsolationRing"); 
00026   
00027   useFixedSizeCone = parameters.getParameter<bool>("UseFixedSizeCone"); 
00028   variableConeParameter = parameters.getParameter<double>("VariableConeParameter");
00029   variableMaxCone = parameters.getParameter<double>("VariableMaxCone");
00030   variableMinCone = parameters.getParameter<double>("VariableMinCone");
00031 }
00032 
00033 pair<float,IsolatedTauTagInfo> ConeIsolationAlgorithm::tag(const JetTracksAssociationRef & jetTracks, const Vertex & pv) 
00034 {
00035   const edm::RefVector<reco::TrackCollection> & tracks = jetTracks->second;
00036   edm::RefVector<reco::TrackCollection> myTracks;
00037 
00038   // Selection of the Tracks
00039   float z_pv = pv.z();
00040   for(edm::RefVector<reco::TrackCollection>::const_iterator it = tracks.begin(); it!= tracks.end(); ++it)
00041   {
00042     if ( (*it)->pt()                                  >  m_cutMinPt                     &&
00043          (*it)->normalizedChi2()                      <  m_cutMaxChiSquared             &&
00044          fabs((*it)->dxy(pv.position()))                            <  m_cutMaxTIP                    &&
00045          (*it)->recHitsSize()                         >= (unsigned int) m_cutTotalHits  &&
00046          (*it)->hitPattern().numberOfValidPixelHits() >= m_cutPixelHits ) 
00047     {
00048       if (useVertexConstrain_ && z_pv > -500.) {
00049         if (fabs((*it)->dz(pv.position())) < dZ_vertex)
00050           myTracks.push_back(*it);
00051       } else
00052         myTracks.push_back(*it);
00053     }
00054   }
00055   IsolatedTauTagInfo resultExtended(myTracks,jetTracks);
00056 
00057   double r_sigCone = signal_cone;
00058   double energyJet = jetTracks->first->energy();
00059   if (not useFixedSizeCone) {
00060     r_sigCone = std::min(variableMaxCone, variableConeParameter / energyJet);
00061     r_sigCone = std::max((double)r_sigCone, variableMinCone);
00062   }
00063 
00064   // now I can use it for the discriminator;
00065   math::XYZVector jetDir(jetTracks->first->px(), jetTracks->first->py(), jetTracks->first->pz());   
00066   float discriminator = 0.;
00067   if (useVertexConstrain_) {
00068     // In this case all the selected tracks comes from the same vertex, so no need to pass the dZ_vertex requirement to the discriminator 
00069    const TrackRef myLeadTk = resultExtended.leadingSignalTrack( matching_cone, pt_min_leadTrack);
00070       resultExtended.setLeadingTrack(myLeadTk);
00071     discriminator = resultExtended.discriminator(jetDir, matching_cone, r_sigCone, isolation_cone, pt_min_leadTrack, pt_min_isolation,  n_tracks_isolation_ring); 
00072     resultExtended.setDiscriminator(discriminator);
00073   } else {
00074     // In this case the dZ_vertex is used to associate the tracks to the Z_imp parameter of the Leading Track
00075  const TrackRef myLeadTk = resultExtended.leadingSignalTrack( matching_cone, pt_min_leadTrack);
00076    resultExtended.setLeadingTrack(myLeadTk);    
00077     discriminator = resultExtended.discriminator(jetDir, matching_cone, r_sigCone, isolation_cone, pt_min_leadTrack, pt_min_isolation,  n_tracks_isolation_ring, dZ_vertex); 
00078     resultExtended.setDiscriminator(discriminator);
00079   }
00080 
00081   return std::make_pair(discriminator, resultExtended); 
00082 }