CMS 3D CMS Logo

L2MuonIsolationProducer.cc
Go to the documentation of this file.
1 
6 // Framework
13 
16 
23 
27 
28 #include <string>
29 
30 using namespace edm;
31 using namespace std;
32 using namespace reco;
33 using namespace muonisolation;
34 
37  theSACollectionLabel(par.getParameter<edm::InputTag>("StandAloneCollectionLabel")),
38  theExtractor(nullptr),
39  theDepositIsolator(nullptr)
40 {
41  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")<<" L2MuonIsolationProducer constructor called";
42 
43  theSACollectionToken = consumes<RecoChargedCandidateCollection>(theSACollectionLabel);
44 
45  //
46  // Extractor
47  //
48  edm::ParameterSet extractorPSet = par.getParameter<edm::ParameterSet>("ExtractorPSet");
49  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
50  theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector());
51 
52 
53  edm::ParameterSet isolatorPSet = par.getParameter<edm::ParameterSet>("IsolatorPSet");
54  bool haveIsolator = !isolatorPSet.empty();
55  optOutputDecision = haveIsolator;
56  if (optOutputDecision){
57  std::string type = isolatorPSet.getParameter<std::string>("ComponentName");
58  theDepositIsolator = MuonIsolatorFactory::get()->create(type, isolatorPSet, consumesCollector());
59  }
60  if (optOutputDecision) produces<edm::ValueMap<bool> >();
61  produces<reco::IsoDepositMap>();
62 
63  optOutputIsolatorFloat = par.getParameter<bool>("WriteIsolatorFloat");
64  if (optOutputIsolatorFloat && haveIsolator){
65  produces<edm::ValueMap<float> >();
66  }
67 }
68 
71  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")<<" L2MuonIsolationProducer destructor called";
72  if (theExtractor) delete theExtractor;
73 }
74 
78  desc.add<edm::InputTag>("StandAloneCollectionLabel",edm::InputTag("hltL2MuonCandidates"));
79  edm::ParameterSetDescription extractorPSet;
80  {
81  extractorPSet.add<double>("DR_Veto_H",0.1);
82  extractorPSet.add<bool>("Vertex_Constraint_Z",false);
83  extractorPSet.add<double>("Threshold_H",0.5);
84  extractorPSet.add<std::string>("ComponentName","CaloExtractor");
85  extractorPSet.add<double>("Threshold_E",0.2);
86  extractorPSet.add<double>("DR_Max",1.0);
87  extractorPSet.add<double>("DR_Veto_E",0.07);
88  extractorPSet.add<double>("Weight_E",1.5);
89  extractorPSet.add<bool>("Vertex_Constraint_XY",false);
90  extractorPSet.addUntracked<std::string>("DepositLabel","EcalPlusHcal");
91  extractorPSet.add<edm::InputTag>("CaloTowerCollectionLabel",edm::InputTag("towerMaker"));
92  extractorPSet.add<double>("Weight_H",1.0);
93  }
94  desc.add<edm::ParameterSetDescription>("ExtractorPSet",extractorPSet);
95  edm::ParameterSetDescription isolatorPSet;
96  {
97  std::vector<double> temp;
98  isolatorPSet.add<std::vector<double> >("ConeSizesRel",std::vector<double>(1, 0.3));
99  isolatorPSet.add<double>("EffAreaSFEndcap",1.0);
100  isolatorPSet.add<bool>("CutAbsoluteIso",true);
101  isolatorPSet.add<bool>("AndOrCuts",true);
102  isolatorPSet.add<edm::InputTag>("RhoSrc",edm::InputTag("hltKT6CaloJetsForMuons","rho"));
103  isolatorPSet.add<std::vector<double> >("ConeSizes",std::vector<double>(1, 0.3));
104  isolatorPSet.add<std::string>("ComponentName","CutsIsolatorWithCorrection");
105  isolatorPSet.add<bool>("ReturnRelativeSum",false);
106  isolatorPSet.add<double>("RhoScaleBarrel",1.0);
107  isolatorPSet.add<double>("EffAreaSFBarrel",1.0);
108  isolatorPSet.add<bool>("CutRelativeIso",false);
109  isolatorPSet.add<std::vector<double> >("EtaBounds",std::vector<double>(1, 2.411));
110  isolatorPSet.add<std::vector<double> >("Thresholds",std::vector<double>(1, 9.9999999E7));
111  isolatorPSet.add<bool>("ReturnAbsoluteSum",true);
112  isolatorPSet.add<std::vector<double> >("EtaBoundsRel",std::vector<double>(1, 2.411));
113  isolatorPSet.add<std::vector<double> >("ThresholdsRel",std::vector<double>(1, 9.9999999E7));
114  isolatorPSet.add<double>("RhoScaleEndcap",1.0);
115  isolatorPSet.add<double>("RhoMax",9.9999999E7);
116  isolatorPSet.add<bool>("UseRhoCorrection",true);
117  }
118  desc.add<edm::ParameterSetDescription>("IsolatorPSet",isolatorPSet);
119  desc.add<bool>("WriteIsolatorFloat",false);
120  descriptions.add("hltL2MuonIsolations", desc);
121 }
122 
125  std::string metname = "Muon|RecoMuon|L2MuonIsolationProducer";
126 
127  LogDebug(metname)<<" L2 Muon Isolation producing...";
128 
129  // Take the SA container
130  LogDebug(metname)<<" Taking the StandAlone muons: "<<theSACollectionLabel;
132  event.getByToken(theSACollectionToken,muons);
133 
134  // Find deposits and load into event
135  LogDebug(metname)<<" Get energy around";
136  auto depMap = std::make_unique<reco::IsoDepositMap>();
137  auto isoMap = std::make_unique<edm::ValueMap<bool>>();
138  auto isoFloatMap = std::make_unique<edm::ValueMap<float>>();
139 
140  unsigned int nMuons = muons->size();
141  std::vector<IsoDeposit> deps(nMuons);
142  std::vector<bool> isos(nMuons, false);
143  std::vector<float> isoFloats(nMuons, 0);
144 
145  // fill track collection to use for vetos calculation
146  TrackCollection muonTracks;
147  for (unsigned int i=0; i<nMuons; i++) {
148  TrackRef tk = (*muons)[i].track();
149  muonTracks.push_back(*tk);
150  }
151 
152  theExtractor->fillVetos(event,eventSetup,muonTracks);
153 
154  for (unsigned int i=0; i<nMuons; i++) {
155  TrackRef tk = (*muons)[i].track();
156 
157  deps[i] = theExtractor->deposit(event, eventSetup, *tk);
158 
159  if (optOutputDecision){
161  muonisolation::MuIsoBaseIsolator::Result isoResult = theDepositIsolator->result( isoContainer, *tk, &event );
162  isos[i] = isoResult.valBool;
163  isoFloats[i] = isoResult.valFloat;
164  }
165  }
166 
167 
168 
170  reco::IsoDepositMap::Filler depFiller(*depMap);
171  depFiller.insert(muons, deps.begin(), deps.end());
172  depFiller.fill();
173  event.put(std::move(depMap));
174 
175  if (optOutputDecision){
176  edm::ValueMap<bool> ::Filler isoFiller(*isoMap);
177  isoFiller.insert(muons, isos.begin(), isos.end());
178  isoFiller.fill();
179  event.put(std::move(isoMap));
180 
182  edm::ValueMap<float> ::Filler isoFloatFiller(*isoFloatMap);
183  isoFloatFiller.insert(muons, isoFloats.begin(), isoFloats.end());
184  isoFloatFiller.fill();
185  event.put(std::move(isoFloatMap));
186  }
187  }
188 
189  LogDebug(metname) <<" Event loaded"
190  <<"================================";
191 }
#define LogDebug(id)
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:217
reco::isodeposit::IsoDepositExtractor * theExtractor
~L2MuonIsolationProducer() override
destructor
const std::string metname
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
#define nullptr
virtual void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)=0
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const =0
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > theSACollectionToken
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterSet descriptions.
std::vector< DepositAndVetos > DepositContainer
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
Produce isolation maps.
fixed size matrix
HLT enums.
virtual Result result(const DepositContainer &deposits, const edm::Event *=0) const =0
Compute and return the isolation variable.
muonisolation::MuIsoBaseIsolator * theDepositIsolator
L2MuonIsolationProducer(const edm::ParameterSet &)
constructor with config
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1