CMS 3D CMS Logo

JetExtractor.cc
Go to the documentation of this file.
1 #include "JetExtractor.h"
2 
7 
12 
17 
19 
23 
25 
26 using namespace edm;
27 using namespace std;
28 using namespace reco;
29 using namespace muonisolation;
31 
32 JetExtractor::JetExtractor(const ParameterSet& par, edm::ConsumesCollector&& iC)
33  : theJetCollectionToken(iC.consumes<CaloJetCollection>(par.getParameter<edm::InputTag>("JetCollectionLabel"))),
34  thePropagatorName(par.getParameter<std::string>("PropagatorName")),
35  theThreshold(par.getParameter<double>("Threshold")),
36  theDR_Veto(par.getParameter<double>("DR_Veto")),
37  theDR_Max(par.getParameter<double>("DR_Max")),
38  theExcludeMuonVeto(par.getParameter<bool>("ExcludeMuonVeto")),
39  theService(nullptr),
40  theAssociator(nullptr),
41  thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport")) {
42  ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
43  theService = new MuonServiceProxy(serviceParameters);
44 
45  // theAssociatorParameters = new TrackAssociatorParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC_);
47  theAssociatorParameters->loadParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
49 }
50 
54  if (theService)
55  delete theService;
56  if (theAssociator)
57  delete theAssociator;
58 }
59 
61  // LogWarning("JetExtractor")
62  // <<"fillVetos does nothing now: IsoDeposit provides enough functionality\n"
63  // <<"to remove a deposit at/around given (eta, phi)";
64 }
65 
66 IsoDeposit JetExtractor::deposit(const Event& event, const EventSetup& eventSetup, const Track& muon) const {
67  theService->update(eventSetup);
69 
70  typedef IsoDeposit::Veto Veto;
71  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
72 
73  IsoDeposit depJet(muonDir);
74 
76  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
77 
78  reco::TransientTrack tMuon(muon, &*bField);
80  TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
81 
82  reco::isodeposit::Direction vetoDirection(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi());
83  depJet.setVeto(Veto(vetoDirection, theDR_Veto));
84 
86  event.getByToken(theJetCollectionToken, caloJetsH);
87 
88  //use calo towers
89  CaloJetCollection::const_iterator jetCI = caloJetsH->begin();
90  for (; jetCI != caloJetsH->end(); ++jetCI) {
91  double deltar0 = reco::deltaR(muon, *jetCI);
92  if (deltar0 > theDR_Max)
93  continue;
94  if (jetCI->et() < theThreshold)
95  continue;
96 
97  //should I make a separate config option for this?
98  std::vector<CaloTowerPtr> jetConstituents = jetCI->getCaloConstituents();
99 
100  std::vector<DetId>::const_iterator crossedCI = mInfo.crossedTowerIds.begin();
101  std::vector<CaloTowerPtr>::const_iterator jetTowCI = jetConstituents.begin();
102 
103  double sumEtExcluded = 0;
104  for (; jetTowCI != jetConstituents.end(); ++jetTowCI) {
105  bool isExcluded = false;
106  double deltaRLoc = reco::deltaR(vetoDirection, *jetCI);
107  if (deltaRLoc < theDR_Veto) {
108  isExcluded = true;
109  }
110  for (; !isExcluded && crossedCI != mInfo.crossedTowerIds.end(); ++crossedCI) {
111  if (crossedCI->rawId() == (*jetTowCI)->id().rawId()) {
112  isExcluded = true;
113  }
114  }
115  if (isExcluded)
116  sumEtExcluded += (*jetTowCI)->et();
117  }
118  if (theExcludeMuonVeto) {
119  if (jetCI->et() - sumEtExcluded < theThreshold)
120  continue;
121  }
122 
123  double depositEt = jetCI->et();
124  if (theExcludeMuonVeto)
125  depositEt = depositEt - sumEtExcluded;
126 
127  reco::isodeposit::Direction jetDir(jetCI->eta(), jetCI->phi());
128  depJet.addDeposit(jetDir, depositEt);
129  }
130 
131  std::vector<const CaloTower*>::const_iterator crossedCI = mInfo.crossedTowers.begin();
132  double muSumEt = 0;
133  for (; crossedCI != mInfo.crossedTowers.end(); ++crossedCI) {
134  muSumEt += (*crossedCI)->et();
135  }
136  depJet.addCandEnergy(muSumEt);
137 
138  return depJet;
139 }
T getParameter(std::string const &) const
std::vector< const CaloTower * > crossedTowers
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
Definition: JetExtractor.cc:66
std::vector< DetId > crossedTowerIds
#define nullptr
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
Definition: JetExtractor.cc:60
math::XYZPoint trkGlobPosAtHcal
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
void setPropagator(const Propagator *)
use a user configured propagator
edm::EDGetTokenT< reco::CaloJetCollection > theJetCollectionToken
Definition: JetExtractor.h:47
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
FreeTrajectoryState initialFreeState() const
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
Definition: JetExtractor.h:60
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
TrackAssociatorParameters * theAssociatorParameters
Definition: JetExtractor.h:62
TrackDetectorAssociator * theAssociator
Definition: JetExtractor.h:63
Definition: event.py:1
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects