Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:20:40

0001 #include "HLTEcalPixelIsolTrackFilter.h"
0002 #include "DataFormats/Common/interface/Handle.h"
0003 #include "DataFormats/Common/interface/RefToBase.h"
0004 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
0005 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0009 
0010 HLTEcalPixelIsolTrackFilter::HLTEcalPixelIsolTrackFilter(const edm::ParameterSet& iConfig)
0011     : HLTFilter(iConfig),
0012       candTag_(iConfig.getParameter<edm::InputTag>("candTag")),
0013       maxEnergyInEB_(iConfig.getParameter<double>("MaxEnergyInEB")),
0014       maxEnergyInEE_(iConfig.getParameter<double>("MaxEnergyInEE")),
0015       maxEnergyOutEB_(iConfig.getParameter<double>("MaxEnergyOutEB")),
0016       maxEnergyOutEE_(iConfig.getParameter<double>("MaxEnergyOutEE")),
0017       nMaxTrackCandidates_(iConfig.getParameter<int>("NMaxTrackCandidates")),
0018       dropMultiL2Event_(iConfig.getParameter<bool>("DropMultiL2Event")) {
0019   candTok = consumes<reco::IsolatedPixelTrackCandidateCollection>(candTag_);
0020 }
0021 
0022 HLTEcalPixelIsolTrackFilter::~HLTEcalPixelIsolTrackFilter() = default;
0023 
0024 void HLTEcalPixelIsolTrackFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0025   edm::ParameterSetDescription desc;
0026   makeHLTFilterDescription(desc);
0027   desc.add<edm::InputTag>("candTag", edm::InputTag("hltIsolEcalPixelTrackProd"));
0028   desc.add<double>("MaxEnergyInEB", 2.0);
0029   desc.add<double>("MaxEnergyInEE", 4.0);
0030   desc.add<double>("MaxEnergyOutEB", 1.2);
0031   desc.add<double>("MaxEnergyOutEE", 2.0);
0032   desc.add<int>("NMaxTrackCandidates", 10);
0033   desc.add<bool>("DropMultiL2Event", false);
0034   descriptions.add("isolEcalPixelTrackFilter", desc);
0035 }
0036 
0037 bool HLTEcalPixelIsolTrackFilter::hltFilter(edm::Event& iEvent,
0038                                             const edm::EventSetup& iSetup,
0039                                             trigger::TriggerFilterObjectWithRefs& filterproduct) const {
0040   if (saveTags())
0041     filterproduct.addCollectionTag(candTag_);
0042 
0043   edm::Handle<reco::IsolatedPixelTrackCandidateCollection> recotrackcands;
0044   iEvent.getByToken(candTok, recotrackcands);
0045   if (!recotrackcands.isValid())
0046     return false;
0047 
0048   int n = 0;
0049   for (unsigned int i = 0; i < recotrackcands->size(); i++) {
0050     edm::Ref<reco::IsolatedPixelTrackCandidateCollection> candref =
0051         edm::Ref<reco::IsolatedPixelTrackCandidateCollection>(recotrackcands, i);
0052     LogDebug("IsoTrk") << "candref.isNull() " << candref.isNull() << "\n";
0053     if (candref.isNull())
0054       continue;
0055     LogDebug("IsoTrk") << "candref.track().isNull() " << candref->track().isNull() << "\n";
0056     if (candref->track().isNull())
0057       continue;
0058     // select on transverse momentum
0059     double etaAbs = std::abs(candref->track()->eta());
0060     double maxEnergyIn = (etaAbs < 1.479) ? maxEnergyInEB_ : maxEnergyInEE_;
0061     double maxEnergyOut = (etaAbs < 1.479) ? maxEnergyOutEB_ : maxEnergyOutEE_;
0062     LogDebug("IsoTrk") << "energyin/out: " << candref->energyIn() << "/" << candref->energyOut() << "\n";
0063     if (candref->energyIn() < maxEnergyIn && candref->energyOut() < maxEnergyOut) {
0064       filterproduct.addObject(trigger::TriggerTrack, candref);
0065       n++;
0066       LogDebug("IsoTrk") << "EcalIsol:Candidate[" << n << "] pt|eta|phi " << candref->pt() << "|" << candref->eta()
0067                          << "|" << candref->phi() << "\n";
0068     }
0069     if (!dropMultiL2Event_ && n >= nMaxTrackCandidates_)
0070       break;
0071   }
0072   bool accept(n > 0);
0073   if (dropMultiL2Event_ && n > nMaxTrackCandidates_)
0074     accept = false;
0075   return accept;
0076 }
0077 
0078 // declare this class as a framework plugin
0079 #include "FWCore/Framework/interface/MakerMacros.h"
0080 DEFINE_FWK_MODULE(HLTEcalPixelIsolTrackFilter);