CMS 3D CMS Logo

JetExtractor.cc
Go to the documentation of this file.
1 #include "JetExtractor.h"
2 
7 
12 
14 
18 
20 
21 using namespace edm;
22 using namespace std;
23 using namespace reco;
24 using namespace muonisolation;
26 
27 JetExtractor::JetExtractor() {}
28 
29 JetExtractor::JetExtractor(const ParameterSet& par, edm::ConsumesCollector&& iC)
30  : theJetCollectionToken(iC.consumes<CaloJetCollection>(par.getParameter<edm::InputTag>("JetCollectionLabel"))),
31  thePropagatorName(par.getParameter<std::string>("PropagatorName")),
32  theFieldToken(iC.esConsumes()),
33  theThreshold(par.getParameter<double>("Threshold")),
34  theDR_Veto(par.getParameter<double>("DR_Veto")),
35  theDR_Max(par.getParameter<double>("DR_Max")),
36  theExcludeMuonVeto(par.getParameter<bool>("ExcludeMuonVeto")),
37  theService(nullptr),
38  theAssociator(nullptr),
39  thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport")) {
40  ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
41  theService = std::make_unique<MuonServiceProxy>(serviceParameters, edm::ConsumesCollector(iC));
42 
43  // theAssociatorParameters = new TrackAssociatorParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC_);
44  theAssociatorParameters = std::make_unique<TrackAssociatorParameters>();
45  theAssociatorParameters->loadParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
46  theAssociator = std::make_unique<TrackDetectorAssociator>();
47 }
48 
50 
52  // LogWarning("JetExtractor")
53  // <<"fillVetos does nothing now: IsoDeposit provides enough functionality\n"
54  // <<"to remove a deposit at/around given (eta, phi)";
55 }
56 
57 IsoDeposit JetExtractor::deposit(const Event& event, const EventSetup& eventSetup, const Track& muon) const {
58  theService->update(eventSetup);
59  theAssociator->setPropagator(&*(theService->propagator(thePropagatorName)));
60 
61  typedef IsoDeposit::Veto Veto;
62  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
63 
64  IsoDeposit depJet(muonDir);
65 
66  auto const& bField = eventSetup.getData(theFieldToken);
67 
70  TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
71 
72  reco::isodeposit::Direction vetoDirection(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi());
73  depJet.setVeto(Veto(vetoDirection, theDR_Veto));
74 
76  event.getByToken(theJetCollectionToken, caloJetsH);
77 
78  //use calo towers
79  CaloJetCollection::const_iterator jetCI = caloJetsH->begin();
80  for (; jetCI != caloJetsH->end(); ++jetCI) {
81  double deltar0 = reco::deltaR(muon, *jetCI);
82  if (deltar0 > theDR_Max)
83  continue;
84  if (jetCI->et() < theThreshold)
85  continue;
86 
87  //should I make a separate config option for this?
88  std::vector<CaloTowerPtr> jetConstituents = jetCI->getCaloConstituents();
89 
90  std::vector<DetId>::const_iterator crossedCI = mInfo.crossedTowerIds.begin();
91  std::vector<CaloTowerPtr>::const_iterator jetTowCI = jetConstituents.begin();
92 
93  double sumEtExcluded = 0;
94  for (; jetTowCI != jetConstituents.end(); ++jetTowCI) {
95  bool isExcluded = false;
96  double deltaRLoc = reco::deltaR(vetoDirection, *jetCI);
97  if (deltaRLoc < theDR_Veto) {
98  isExcluded = true;
99  }
100  for (; !isExcluded && crossedCI != mInfo.crossedTowerIds.end(); ++crossedCI) {
101  if (crossedCI->rawId() == (*jetTowCI)->id().rawId()) {
102  isExcluded = true;
103  }
104  }
105  if (isExcluded)
106  sumEtExcluded += (*jetTowCI)->et();
107  }
108  if (theExcludeMuonVeto) {
109  if (jetCI->et() - sumEtExcluded < theThreshold)
110  continue;
111  }
112 
113  double depositEt = jetCI->et();
114  if (theExcludeMuonVeto)
115  depositEt = depositEt - sumEtExcluded;
116 
117  reco::isodeposit::Direction jetDir(jetCI->eta(), jetCI->phi());
118  depJet.addDeposit(jetDir, depositEt);
119  }
120 
121  std::vector<const CaloTower*>::const_iterator crossedCI = mInfo.crossedTowers.begin();
122  double muSumEt = 0;
123  for (; crossedCI != mInfo.crossedTowers.end(); ++crossedCI) {
124  muSumEt += (*crossedCI)->et();
125  }
126  depJet.addCandEnergy(muSumEt);
127 
128  return depJet;
129 }
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
muonisolation::JetExtractor::theDR_Max
double theDR_Max
Definition: JetExtractor.h:59
MessageLogger.h
muonisolation::JetExtractor::theAssociatorParameters
std::unique_ptr< TrackAssociatorParameters > theAssociatorParameters
Definition: JetExtractor.h:67
ESHandle.h
muon
Definition: MuonCocktails.h:17
TrackDetectorAssociator.h
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackDetMatchInfo::crossedTowers
std::vector< const CaloTower * > crossedTowers
Definition: TrackDetMatchInfo.h:62
HLT_FULL_cff.thePropagatorName
thePropagatorName
Definition: HLT_FULL_cff.py:113837
TrackDetMatchInfo::trkGlobPosAtHcal
math::XYZPoint trkGlobPosAtHcal
Definition: TrackDetMatchInfo.h:39
muonisolation::JetExtractor::theFieldToken
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theFieldToken
Definition: JetExtractor.h:54
reco::IsoDeposit::Veto
Definition: IsoDeposit.h:59
muonisolation::JetExtractor::theService
std::unique_ptr< MuonServiceProxy > theService
the event setup proxy, it takes care the services update
Definition: JetExtractor.h:65
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
TransientTrack.h
muonisolation::JetExtractor::theDR_Veto
double theDR_Veto
Definition: JetExtractor.h:58
muonisolation::JetExtractor::theThreshold
double theThreshold
Definition: JetExtractor.h:57
edm::Handle
Definition: AssociativeIterator.h:50
reco::TransientTrack::initialFreeState
FreeTrajectoryState initialFreeState() const
Definition: TransientTrack.h:82
muonisolation::JetExtractor::theAssociator
std::unique_ptr< TrackDetectorAssociator > theAssociator
Definition: JetExtractor.h:68
muonisolation::JetExtractor::fillVetos
void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks) override
Definition: JetExtractor.cc:51
TrackDetMatchInfo::crossedTowerIds
std::vector< DetId > crossedTowerIds
Definition: TrackDetMatchInfo.h:69
muonisolation::JetExtractor::theExcludeMuonVeto
bool theExcludeMuonVeto
Definition: JetExtractor.h:62
reco::Track
Definition: Track.h:27
JetExtractor.h
EcalSubdetector.h
muonisolation::JetExtractor::theJetCollectionToken
edm::EDGetTokenT< reco::CaloJetCollection > theJetCollectionToken
Definition: JetExtractor.h:50
edm::ParameterSet
Definition: ParameterSet.h:47
deltaR.h
reco::CaloJetCollection
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition: CaloJetCollection.h:15
edm::EventSetup
Definition: EventSetup.h:58
HcalSubdetector.h
muonisolation::JetExtractor::~JetExtractor
~JetExtractor() override
Definition: JetExtractor.cc:49
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
muonisolation
Definition: CandViewExtractor.h:16
CaloTowerCollection.h
muonisolation::JetExtractor::deposit
reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const override
Definition: JetExtractor.cc:57
muonisolation::JetExtractor::thePropagatorName
std::string thePropagatorName
Definition: JetExtractor.h:52
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:13
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
Calorimetry_cff.bField
bField
Definition: Calorimetry_cff.py:284
reco::isodeposit::Direction
Definition: IsoDepositDirection.h:19
CaloGeometry.h
MuonServiceProxy.h
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
TrackAssociatorParameters.h
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45