Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:53:18

0001 #include "HLTPixelIsolTrackL1TFilter.h"
0002 
0003 #include "DataFormats/Common/interface/RefToBase.h"
0004 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0005 
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 
0011 HLTPixelIsolTrackL1TFilter::HLTPixelIsolTrackL1TFilter(const edm::ParameterSet& iConfig)
0012     : HLTFilter(iConfig),
0013       candTag_{iConfig.getParameter<edm::InputTag>("candTag")},
0014       candToken_{consumes(candTag_)},
0015       maxptnearby_{iConfig.getParameter<double>("MaxPtNearby")},
0016       minEnergy_{iConfig.getParameter<double>("MinEnergyTrack")},
0017       minpttrack_{iConfig.getParameter<double>("MinPtTrack")},
0018       maxetatrack_{iConfig.getParameter<double>("MaxEtaTrack")},
0019       minetatrack_{iConfig.getParameter<double>("MinEtaTrack")},
0020       filterE_{iConfig.getParameter<bool>("filterTrackEnergy")},
0021       nMaxTrackCandidates_{iConfig.getParameter<int>("NMaxTrackCandidates")},
0022       dropMultiL2Event_{iConfig.getParameter<bool>("DropMultiL2Event")} {}
0023 
0024 void HLTPixelIsolTrackL1TFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0025   edm::ParameterSetDescription desc;
0026   makeHLTFilterDescription(desc);
0027   desc.add<edm::InputTag>("candTag", edm::InputTag("hltIsolPixelTrackProd"));
0028   desc.add<double>("MaxPtNearby", 2.0);
0029   desc.add<double>("MinEnergyTrack", 12.0);
0030   desc.add<double>("MinPtTrack", 3.5);
0031   desc.add<double>("MaxEtaTrack", 1.15);
0032   desc.add<double>("MinEtaTrack", 0.0);
0033   desc.add<bool>("filterTrackEnergy", true);
0034   desc.add<int>("NMaxTrackCandidates", 10);
0035   desc.add<bool>("DropMultiL2Event", false);
0036   descriptions.addWithDefaultLabel(desc);
0037 }
0038 
0039 bool HLTPixelIsolTrackL1TFilter::hltFilter(edm::Event& iEvent,
0040                                            const edm::EventSetup& iSetup,
0041                                            trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0042   if (saveTags())
0043     filterproduct.addCollectionTag(candTag_);
0044 
0045   // Ref to Candidate object to be recorded in filter object
0046   edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candref;
0047 
0048   // get hold of filtered candidates
0049   auto const recotrackcands = iEvent.getHandle(candToken_);
0050 
0051   //Filtering
0052   int n = 0;
0053   for (unsigned int i = 0; i < recotrackcands->size(); i++) {
0054     candref = edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(recotrackcands, i);
0055 
0056     // select on transverse momentum
0057     if (!filterE_ && (candref->maxPtPxl() < maxptnearby_) && (candref->pt() > minpttrack_) &&
0058         fabs(candref->track()->eta()) < maxetatrack_ && fabs(candref->track()->eta()) > minetatrack_) {
0059       filterproduct.addObject(trigger::TriggerTrack, candref);
0060       n++;
0061 
0062       LogDebug("HcalIsoTrack") << "PixelIsolP:Candidate[" << n << "] pt|eta|phi " << candref->pt() << "|"
0063                                << candref->track()->pt() << "|" << candref->track()->eta() << "|"
0064                                << candref->track()->phi() << "\n";
0065     }
0066 
0067     // select on momentum
0068     if (filterE_) {
0069       if ((candref->maxPtPxl() < maxptnearby_) && ((candref->pt()) * cosh(candref->track()->eta()) > minEnergy_) &&
0070           fabs(candref->track()->eta()) < maxetatrack_ && fabs(candref->track()->eta()) > minetatrack_) {
0071         filterproduct.addObject(trigger::TriggerTrack, candref);
0072         n++;
0073 
0074         LogDebug("HcalIsoTrack") << "PixelIsolE:Candidate[" << n << "] pt|eta|phi " << candref->pt() << "|"
0075                                  << candref->track()->pt() << "|" << candref->track()->eta() << "|"
0076                                  << candref->track()->phi() << "\n";
0077       }
0078     }
0079 
0080     // stop looping over tracks if max number is reached
0081     if (!dropMultiL2Event_ && n >= nMaxTrackCandidates_)
0082       break;
0083 
0084   }  // loop over tracks
0085 
0086   bool accept(n > 0);
0087 
0088   if (dropMultiL2Event_ && n > nMaxTrackCandidates_)
0089     accept = false;
0090 
0091   LogDebug("HcalIsoTrack") << "PixelIsolL1Filter: Tracks " << n << " accept " << accept << "\n";
0092 
0093   return accept;
0094 }
0095 
0096 // declare this class as a framework plugin
0097 #include "FWCore/Framework/interface/MakerMacros.h"
0098 DEFINE_FWK_MODULE(HLTPixelIsolTrackL1TFilter);