CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetExtractor.cc
Go to the documentation of this file.
1 #include "JetExtractor.h"
2 
7 
12 
17 
19 
23 
25 
26 
27 using namespace edm;
28 using namespace std;
29 using namespace reco;
30 using namespace muonisolation;
32 
33 JetExtractor::JetExtractor(const ParameterSet& par, edm::ConsumesCollector && iC) :
34  theJetCollectionToken(iC.consumes<CaloJetCollection>(par.getParameter<edm::InputTag>("JetCollectionLabel"))),
35  thePropagatorName(par.getParameter<std::string>("PropagatorName")),
36  theThreshold(par.getParameter<double>("Threshold")),
37  theDR_Veto(par.getParameter<double>("DR_Veto")),
38  theDR_Max(par.getParameter<double>("DR_Max")),
39  theExcludeMuonVeto(par.getParameter<bool>("ExcludeMuonVeto")),
40  theService(0),
41  theAssociator(0),
42  thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport"))
43 {
44  ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
45  theService = new MuonServiceProxy(serviceParameters);
46 
47  // theAssociatorParameters = new TrackAssociatorParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC_);
49  theAssociatorParameters->loadParameters(par.getParameter<edm::ParameterSet>("TrackAssociatorParameters"), iC);
51 }
52 
55  if (theService) delete theService;
56  if (theAssociator) delete theAssociator;
57 }
58 
60 {
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 
67 IsoDeposit JetExtractor::deposit( const Event & event, const EventSetup& eventSetup, const Track & muon) const
68 {
69 
70  theService->update(eventSetup);
72 
73  typedef IsoDeposit::Veto Veto;
74  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
75 
76  IsoDeposit depJet(muonDir);
77 
79  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
80 
81 
82  reco::TransientTrack tMuon(muon, &*bField);
84  TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
85 
86  reco::isodeposit::Direction vetoDirection(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi());
87  depJet.setVeto(Veto(vetoDirection, theDR_Veto));
88 
89 
91  event.getByToken(theJetCollectionToken, caloJetsH);
92 
93  //use calo towers
94  CaloJetCollection::const_iterator jetCI = caloJetsH->begin();
95  for (; jetCI != caloJetsH->end(); ++jetCI){
96  double deltar0 = reco::deltaR(muon,*jetCI);
97  if (deltar0>theDR_Max) continue;
98  if (jetCI->et() < theThreshold ) continue;
99 
100  //should I make a separate config option for this?
101  std::vector<CaloTowerPtr> jetConstituents = jetCI->getCaloConstituents();
102 
103  std::vector<DetId>::const_iterator crossedCI = mInfo.crossedTowerIds.begin();
104  std::vector<CaloTowerPtr>::const_iterator jetTowCI = jetConstituents.begin();
105 
106  double sumEtExcluded = 0;
107  for (;jetTowCI != jetConstituents.end(); ++ jetTowCI){
108  bool isExcluded = false;
109  double deltaRLoc = reco::deltaR(vetoDirection, *jetCI);
110  if (deltaRLoc < theDR_Veto){
111  isExcluded = true;
112  }
113  for(; ! isExcluded && crossedCI != mInfo.crossedTowerIds.end(); ++crossedCI){
114  if (crossedCI->rawId() == (*jetTowCI)->id().rawId()){
115  isExcluded = true;
116  }
117  }
118  if (isExcluded) sumEtExcluded += (*jetTowCI)->et();
119  }
120  if (theExcludeMuonVeto){
121  if (jetCI->et() - sumEtExcluded < theThreshold ) continue;
122  }
123 
124  double depositEt = jetCI->et();
125  if (theExcludeMuonVeto) depositEt = depositEt - sumEtExcluded;
126 
127  reco::isodeposit::Direction jetDir(jetCI->eta(), jetCI->phi());
128  depJet.addDeposit(jetDir, depositEt);
129 
130  }
131 
132  std::vector<const CaloTower*>::const_iterator crossedCI = mInfo.crossedTowers.begin();
133  double muSumEt = 0;
134  for (; crossedCI != mInfo.crossedTowers.end(); ++crossedCI){
135  muSumEt += (*crossedCI)->et();
136  }
137  depJet.addCandEnergy(muSumEt);
138 
139  return depJet;
140 
141 }
142 
T getParameter(std::string const &) const
std::vector< const CaloTower * > crossedTowers
std::vector< DetId > crossedTowerIds
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const
Definition: JetExtractor.cc:67
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:632
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
math::XYZPoint trkGlobPosAtHcal
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:638
void setPropagator(const Propagator *)
use a user configured propagator
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< reco::CaloJetCollection > theJetCollectionToken
Definition: JetExtractor.h:48
FreeTrajectoryState initialFreeState() const
const T & get() const
Definition: EventSetup.h:56
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
Definition: JetExtractor.h:61
tuple muons
Definition: patZpeak.py:38
virtual void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)
Definition: JetExtractor.cc:59
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
TrackAssociatorParameters * theAssociatorParameters
Definition: JetExtractor.h:63
TrackDetectorAssociator * theAssociator
Definition: JetExtractor.h:64
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects