CMS 3D CMS Logo

L3MuonIsolationProducer.cc
Go to the documentation of this file.
2 
3 // Framework
8 
10 
12 
16 
19 
22 
25 
27 
28 #include <string>
29 
30 using namespace edm;
31 using namespace std;
32 using namespace reco;
33 using namespace muonisolation;
34 
37  : theConfig(par),
38  theMuonCollectionLabel(par.getParameter<InputTag>("inputMuonCollection")),
39  optOutputIsoDeposits(par.getParameter<bool>("OutputMuIsoDeposits")),
40  theTrackPt_Min(-1) {
41  LogDebug("RecoMuon|L3MuonIsolationProducer") << " L3MuonIsolationProducer CTOR";
42 
43  theMuonCollectionToken = consumes<RecoChargedCandidateCollection>(theMuonCollectionLabel);
44 
46  produces<reco::IsoDepositMap>();
47  produces<edm::ValueMap<bool>>();
48 
49  //
50  // Extractor
51  //
52  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
54  theTrackPt_Min = theConfig.getParameter<double>("TrackPt_Min");
55  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
56  theExtractor = std::unique_ptr<reco::isodeposit::IsoDepositExtractor>{
57  IsoDepositExtractorFactory::get()->create(extractorName, extractorPSet, consumesCollector())};
58  std::string depositType = extractorPSet.getUntrackedParameter<std::string>("DepositLabel");
59 
60  //
61  // Cuts
62  //
64  std::string cutsName = cutsPSet.getParameter<std::string>("ComponentName");
65  if (cutsName == "SimpleCuts") {
66  theCuts = Cuts(cutsPSet);
67  } else if (
68  // (cutsName== "L3NominalEfficiencyCuts_PXLS" && depositType=="PXLS")
69  // || (cutsName== "L3NominalEfficiencyCuts_TRKS" && depositType=="TRKS")
71  (cutsName == "L3NominalEfficiencyCuts_PXLS") || (cutsName == "L3NominalEfficiencyCuts_TRKS")) {
73  } else {
74  LogError("L3MuonIsolationProducer::beginJob") << "cutsName: " << cutsPSet << " is not recognized:"
75  << " theCuts not set!";
76  }
77  LogTrace("") << theCuts.print();
78 
79  // (kludge) additional cut on the number of tracks
80  theMaxNTracks = cutsPSet.getParameter<int>("maxNTracks");
81  theApplyCutsORmaxNTracks = cutsPSet.getParameter<bool>("applyCutsORmaxNTracks");
82 }
83 
86  LogDebug("RecoMuon|L3MuonIsolationProducer") << " L3MuonIsolationProducer DTOR";
87 }
88 
90  std::string metname = "RecoMuon|L3MuonIsolationProducer";
91 
92  LogDebug(metname) << " L3 Muon Isolation producing..."
93  << " BEGINING OF EVENT "
94  << "================================";
95 
96  // Take the SA container
97  LogTrace(metname) << " Taking the muons: " << theMuonCollectionLabel;
99  event.getByToken(theMuonCollectionToken, muons);
100 
101  auto depMap = std::make_unique<reco::IsoDepositMap>();
102  auto isoMap = std::make_unique<edm::ValueMap<bool>>();
103 
104  //
105  // get Vetos and deposits
106  //
107  unsigned int nMuons = muons->size();
108 
110 
111  std::vector<IsoDeposit> deps(nMuons);
112  std::vector<bool> isos(nMuons, false);
113 
114  for (unsigned int i = 0; i < nMuons; i++) {
115  TrackRef mu(muons, i);
116  deps[i] = theExtractor->deposit(event, eventSetup, *mu);
117  vetos[i] = deps[i].veto();
118  }
119 
120  //
121  // add here additional vetos
122  //
123  //.....
124 
125  //
126  // actual cut step
127  //
128  for (unsigned int iMu = 0; iMu < nMuons; ++iMu) {
129  const reco::Track* mu = &(*muons)[iMu];
130 
131  const IsoDeposit& deposit = deps[iMu];
132  LogTrace(metname) << deposit.print();
133 
134  const Cuts::CutSpec& cut = theCuts(mu->eta());
135  std::pair<double, int> sumAndCount = deposit.depositAndCountWithin(cut.conesize, vetos, theTrackPt_Min);
136 
137  double value = sumAndCount.first;
138  int count = sumAndCount.second;
139 
140  bool result = (value < cut.threshold);
142  result |= count <= theMaxNTracks;
143  LogTrace(metname) << "deposit in cone: " << value << "with count " << count << " is isolated: " << result;
144 
145  isos[iMu] = result;
146  }
147 
148  //
149  // store
150  //
151  if (optOutputIsoDeposits) {
152  reco::IsoDepositMap::Filler depFiller(*depMap);
153  depFiller.insert(muons, deps.begin(), deps.end());
154  depFiller.fill();
155  event.put(std::move(depMap));
156  }
157  edm::ValueMap<bool>::Filler isoFiller(*isoMap);
158  isoFiller.insert(muons, isos.begin(), isos.end());
159  isoFiller.fill();
160  event.put(std::move(isoMap));
161 
162  LogTrace(metname) << " END OF EVENT "
163  << "================================";
164 }
Range.h
muonisolation::Cuts::print
std::string print() const
Definition: Cuts.cc:54
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::helper::Filler::insert
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
L3MuonIsolationProducer::theMuonCollectionLabel
edm::InputTag theMuonCollectionLabel
Definition: L3MuonIsolationProducer.h:39
TkAlMuonSelectors_cfi.cut
cut
Definition: TkAlMuonSelectors_cfi.py:5
ESHandle.h
custom_jme_cff.nMuons
nMuons
Definition: custom_jme_cff.py:141
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
edm
HLT enums.
Definition: AlignableModifier.h:19
AssociationMap.h
L3MuonIsolationProducer::theCuts
muonisolation::Cuts theCuts
Definition: L3MuonIsolationProducer.h:43
edm::helper::Filler::fill
void fill()
Definition: ValueMap.h:65
reco::IsoDeposit::depositAndCountWithin
std::pair< double, int > depositAndCountWithin(double coneSize, const Vetos &vetos=Vetos(), double threshold=-1e+36, bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:37
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
L3MuonIsolationProducer::optOutputIsoDeposits
double optOutputIsoDeposits
Definition: L3MuonIsolationProducer.h:46
edm::Handle
Definition: AssociativeIterator.h:50
IsoDepositDirection.h
edm::Ref< TrackCollection >
L3MuonIsolationProducer::~L3MuonIsolationProducer
~L3MuonIsolationProducer() override
destructor
Definition: L3MuonIsolationProducer.cc:85
L3NominalEfficiencyConfigurator.h
L3MuonIsolationProducer::theApplyCutsORmaxNTracks
bool theApplyCutsORmaxNTracks
apply or not the maxN cut on top of the sumPt (or nominall eff) < cuts
Definition: L3MuonIsolationProducer.h:60
L3NominalEfficiencyConfigurator
Definition: L3NominalEfficiencyConfigurator.h:9
Track.h
TrackFwd.h
reco::Track
Definition: Track.h:27
muonisolation::Cuts
Definition: Cuts.h:14
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
L3MuonIsolationProducer.h
IsoDeposit.h
L3MuonIsolationProducer::theMuonCollectionToken
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > theMuonCollectionToken
Definition: L3MuonIsolationProducer.h:40
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IsoDepositExtractor.h
L3NominalEfficiencyConfigurator::cuts
muonisolation::Cuts cuts() const
Definition: L3NominalEfficiencyConfigurator.cc:22
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
L3MuonIsolationProducer::theTrackPt_Min
double theTrackPt_Min
Definition: L3MuonIsolationProducer.h:53
L3MuonIsolationProducer::L3MuonIsolationProducer
L3MuonIsolationProducer(const edm::ParameterSet &)
constructor with config
Definition: L3MuonIsolationProducer.cc:36
Event.h
value
Definition: value.py:1
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
get
#define get
L3MuonIsolationProducer::theExtractor
std::unique_ptr< reco::isodeposit::IsoDepositExtractor > theExtractor
Definition: L3MuonIsolationProducer.h:49
muonisolation
Definition: CandViewExtractor.h:16
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
IsoDepositExtractorFactory.h
EventSetup.h
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
L3MuonIsolationProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Produce isolation maps.
Definition: L3MuonIsolationProducer.cc:89
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
IsoDepositFwd.h
edm::helper::Filler
Definition: ValueMap.h:22
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
symbols.deps
deps
Definition: symbols.py:55
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
L3MuonIsolationProducer::theConfig
edm::ParameterSet theConfig
Definition: L3MuonIsolationProducer.h:36
reco::IsoDeposit::Vetos
std::vector< Veto > Vetos
Definition: IsoDeposit.h:65
boostedElectronIsolation_cff.vetos
vetos
Definition: boostedElectronIsolation_cff.py:79
edm::InputTag
Definition: InputTag.h:15
reco::IsoDeposit::print
std::string print() const
Definition: IsoDeposit.cc:178
L3MuonIsolationProducer::theMaxNTracks
int theMaxNTracks
Definition: L3MuonIsolationProducer.h:57
metname
const std::string metname
Definition: MuonSeedOrcaPatternRecognition.cc:40