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 
10 
16 
21 
23 
27 
29 
30 
31 using namespace edm;
32 using namespace std;
33 using namespace reco;
34 using namespace muonisolation;
36 
37 JetExtractor::JetExtractor(const ParameterSet& par) :
38  theJetCollectionLabel(par.getParameter<edm::InputTag>("JetCollectionLabel")),
39  thePropagatorName(par.getParameter<std::string>("PropagatorName")),
40  theThreshold(par.getParameter<double>("Threshold")),
41  theDR_Veto(par.getParameter<double>("DR_Veto")),
42  theDR_Max(par.getParameter<double>("DR_Max")),
43  theExcludeMuonVeto(par.getParameter<bool>("ExcludeMuonVeto")),
44  theService(0),
45  theAssociator(0),
46  thePrintTimeReport(par.getUntrackedParameter<bool>("PrintTimeReport"))
47 {
48  ParameterSet serviceParameters = par.getParameter<ParameterSet>("ServiceParameters");
49  theService = new MuonServiceProxy(serviceParameters);
50 
53 }
54 
58  if (theService) delete theService;
59  if (theAssociator) delete theAssociator;
60 }
61 
63 {
64 // LogWarning("JetExtractor")
65 // <<"fillVetos does nothing now: IsoDeposit provides enough functionality\n"
66 // <<"to remove a deposit at/around given (eta, phi)";
67 
68 }
69 
70 IsoDeposit JetExtractor::deposit( const Event & event, const EventSetup& eventSetup, const Track & muon) const
71 {
72 
73  theService->update(eventSetup);
75 
76  typedef IsoDeposit::Veto Veto;
77  IsoDeposit::Direction muonDir(muon.eta(), muon.phi());
78 
79  IsoDeposit depJet(muonDir);
80 
82  eventSetup.get<IdealMagneticFieldRecord>().get(bField);
83 
84 
85  reco::TransientTrack tMuon(muon, &*bField);
87  TrackDetMatchInfo mInfo = theAssociator->associate(event, eventSetup, iFTS, *theAssociatorParameters);
88 
89  reco::isodeposit::Direction vetoDirection(mInfo.trkGlobPosAtHcal.eta(), mInfo.trkGlobPosAtHcal.phi());
90  depJet.setVeto(Veto(vetoDirection, theDR_Veto));
91 
92 
94  event.getByLabel(theJetCollectionLabel, caloJetsH);
95 
96  //use calo towers
97  CaloJetCollection::const_iterator jetCI = caloJetsH->begin();
98  for (; jetCI != caloJetsH->end(); ++jetCI){
99  double deltar0 = reco::deltaR(muon,*jetCI);
100  if (deltar0>theDR_Max) continue;
101  if (jetCI->et() < theThreshold ) continue;
102 
103  //should I make a separate config option for this?
104  std::vector<CaloTowerPtr> jetConstituents = jetCI->getCaloConstituents();
105 
106  std::vector<DetId>::const_iterator crossedCI = mInfo.crossedTowerIds.begin();
107  std::vector<CaloTowerPtr>::const_iterator jetTowCI = jetConstituents.begin();
108 
109  double sumEtExcluded = 0;
110  for (;jetTowCI != jetConstituents.end(); ++ jetTowCI){
111  bool isExcluded = false;
112  double deltaRLoc = reco::deltaR(vetoDirection, *jetCI);
113  if (deltaRLoc < theDR_Veto){
114  isExcluded = true;
115  }
116  for(; ! isExcluded && crossedCI != mInfo.crossedTowerIds.end(); ++crossedCI){
117  if (crossedCI->rawId() == (*jetTowCI)->id().rawId()){
118  isExcluded = true;
119  }
120  }
121  if (isExcluded) sumEtExcluded += (*jetTowCI)->et();
122  }
123  if (theExcludeMuonVeto){
124  if (jetCI->et() - sumEtExcluded < theThreshold ) continue;
125  }
126 
127  double depositEt = jetCI->et();
128  if (theExcludeMuonVeto) depositEt = depositEt - sumEtExcluded;
129 
130  reco::isodeposit::Direction jetDir(jetCI->eta(), jetCI->phi());
131  depJet.addDeposit(jetDir, depositEt);
132 
133  }
134 
135  std::vector<const CaloTower*>::const_iterator crossedCI = mInfo.crossedTowers.begin();
136  double muSumEt = 0;
137  for (; crossedCI != mInfo.crossedTowers.end(); ++crossedCI){
138  muSumEt += (*crossedCI)->et();
139  }
140  depJet.addCandEnergy(muSumEt);
141 
142  return depJet;
143 
144 }
145 
T getParameter(std::string const &) const
edm::InputTag theJetCollectionLabel
Definition: JetExtractor.h:50
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:70
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
math::XYZPoint trkGlobPosAtHcal
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
tuple TrackAssociatorParameters
Definition: example_cfg.py:32
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
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
FreeTrajectoryState initialFreeState() const
static TimingReport * current()
Definition: TimingReport.cc:21
const T & get() const
Definition: EventSetup.h:55
MuonServiceProxy * theService
the event setup proxy, it takes care the services update
Definition: JetExtractor.h:63
tuple muons
Definition: patZpeak.py:38
virtual void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)
Definition: JetExtractor.cc:62
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
TrackAssociatorParameters * theAssociatorParameters
Definition: JetExtractor.h:65
TrackDetectorAssociator * theAssociator
Definition: JetExtractor.h:66
tuple cout
Definition: gather_cfg.py:121
void dump(std::ostream &co, bool active=false)
Definition: TimingReport.cc:50