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