Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:50

0001 #include "RecoBTag/TrackProbability/interface/TrackClassFilter.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include <iostream>
0004 
0005 using namespace std;
0006 
0007 bool TrackClassFilter::operator()(const first_argument_type& input, const second_argument_type& category) const {
0008   const reco::Track& track = input.track;
0009   //const reco::Jet & jet     = input.jet;
0010   //const reco::Vertex & pv   = input.vertex;
0011   const bool usequality = input.useQuality;
0012 
0013   const TrackProbabilityCategoryData& d = category.category;
0014   //Track Data
0015   double p = track.p();
0016   double eta = track.eta();
0017   double nhit = track.numberOfValidHits();
0018   double npix = track.hitPattern().numberOfValidPixelHits();
0019   bool firstPixel = track.hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1);
0020   double chi = track.normalizedChi2();
0021 
0022   //Chi^2 cut  if used
0023   bool chicut = (chi >= d.chiMin && chi < d.chiMax);
0024   if (d.chiMin <= 0.01 && d.chiMax <= 0.01)
0025     chicut = true;
0026 
0027   //First Pixel Hit cut 1=there should be an hit in first layer, -1=there should not be an hit, 0 = I do not care
0028   bool fisrtPixelCut =
0029       ((firstPixel && d.withFirstPixel == 1) || (!firstPixel && d.withFirstPixel == -1) || d.withFirstPixel == 0);
0030 
0031   //Track Quality:
0032   reco::TrackBase::TrackQuality trackQualityUndef = reco::TrackBase::qualityByName("undefQuality");
0033   reco::TrackBase::TrackQuality trackQualityLoose = reco::TrackBase::qualityByName("loose");
0034   reco::TrackBase::TrackQuality trackQualityTight = reco::TrackBase::qualityByName("tight");
0035   reco::TrackBase::TrackQuality trackQualityhighPur = reco::TrackBase::qualityByName("highPurity");
0036   reco::TrackBase::TrackQuality trackQualityConfirmed = reco::TrackBase::qualityByName("confirmed");
0037   reco::TrackBase::TrackQuality trackQualityGoodIterative = reco::TrackBase::qualityByName("goodIterative");
0038 
0039   signed short trakQuality = -1;
0040   if (track.quality(trackQualityUndef))
0041     trakQuality = 5;
0042   if (track.quality(trackQualityLoose))
0043     trakQuality = 0;
0044   if (track.quality(trackQualityTight))
0045     trakQuality = 1;
0046   if (track.quality(trackQualityhighPur))
0047     trakQuality = 2;
0048   if (track.quality(trackQualityConfirmed))
0049     trakQuality = 3;
0050   if (track.quality(trackQualityGoodIterative))
0051     trakQuality = 4;
0052 
0053   bool result = (p > d.pMin && p < d.pMax && fabs(eta) > d.etaMin && fabs(eta) < d.etaMax && nhit >= d.nHitsMin &&
0054                  nhit <= d.nHitsMax && npix >= d.nPixelHitsMin && npix <= d.nPixelHitsMax && chicut && fisrtPixelCut &&
0055                  ((trakQuality == d.trackQuality && usequality == 1) || usequality == 0));
0056 
0057   //std::cout << "result = " << result << std::endl;
0058   //std::cout << "usequality = " << usequality << std::endl;
0059   //  dump();
0060   //  cout << "TRACK: p " << " eta " <<   eta << " #hit " << nhit << " #pix " << npix << " chi " << chi << "                         matched ?";
0061   //  cout << result << endl;
0062   return result;
0063 }
0064 
0065 /*
0066 void TrackClassFilter::dump() const {
0067 
0068  LogTrace    ("TrackFilterDump") << "TrackClassFilter: "<<endl
0069   << pMin      <<" < P(GeV) < "                 <<pMax        <<endl
0070   << etaMin    <<" < |eta| < "                  <<etaMax      <<endl
0071   << nPixelHitsMin<<" =< number of Pixel Hits =< " << nPixelHitsMax <<endl
0072   << nHitsMin     <<" =< total number of hits  =< "<< nHitsMax      <<endl
0073   << chiMin       <<" =< chiSquare /dof  < "<< chiMax      <<endl
0074   << " First pixel hit  < "<< withFirstPixel   <<endl;
0075 }
0076 */