CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  theExtractor(0),
41  theTrackPt_Min(-1)
42  {
43  LogDebug("RecoMuon|L3MuonIsolationProducer")<<" L3MuonIsolationProducer CTOR";
44 
45  theMuonCollectionToken = consumes<RecoChargedCandidateCollection>(theMuonCollectionLabel);
46 
47  if (optOutputIsoDeposits) produces<reco::IsoDepositMap>();
48  produces<edm::ValueMap<bool> >();
49 
50  //
51  // Extractor
52  //
53  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
55  theTrackPt_Min = theConfig.getParameter<double>("TrackPt_Min");
56  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
57  theExtractor = 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  }
68  else if (
69 // (cutsName== "L3NominalEfficiencyCuts_PXLS" && depositType=="PXLS")
70 // || (cutsName== "L3NominalEfficiencyCuts_TRKS" && depositType=="TRKS")
72  (cutsName== "L3NominalEfficiencyCuts_PXLS" )
73  || (cutsName== "L3NominalEfficiencyCuts_TRKS") ) {
75  }
76  else {
77  LogError("L3MuonIsolationProducer::beginJob")
78  <<"cutsName: "<<cutsPSet<<" is not recognized:"
79  <<" theCuts not set!";
80  }
81  LogTrace("")<< theCuts.print();
82 
83  // (kludge) additional cut on the number of tracks
84  theMaxNTracks = cutsPSet.getParameter<int>("maxNTracks");
85  theApplyCutsORmaxNTracks = cutsPSet.getParameter<bool>("applyCutsORmaxNTracks");
86 }
87 
90  LogDebug("RecoMuon|L3MuonIsolationProducer")<<" L3MuonIsolationProducer DTOR";
91  if (theExtractor) delete theExtractor;
92 }
93 
95  std::string metname = "RecoMuon|L3MuonIsolationProducer";
96 
97  LogDebug(metname)<<" L3 Muon Isolation producing..."
98  <<" BEGINING OF EVENT " <<"================================";
99 
100  // Take the SA container
101  LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionLabel;
103  event.getByToken(theMuonCollectionToken,muons);
104 
105  std::auto_ptr<reco::IsoDepositMap> depMap( new reco::IsoDepositMap());
106  std::auto_ptr<edm::ValueMap<bool> > isoMap( new edm::ValueMap<bool> ());
107 
108 
109  //
110  // get Vetos and deposits
111  //
112  unsigned int nMuons = muons->size();
113 
114  IsoDeposit::Vetos vetos(nMuons);
115 
116  std::vector<IsoDeposit> deps(nMuons);
117  std::vector<bool> isos(nMuons, false);
118 
119  for (unsigned int i=0; i<nMuons; i++) {
120  TrackRef mu(muons,i);
121  deps[i] = theExtractor->deposit(event, eventSetup, *mu);
122  vetos[i] = deps[i].veto();
123  }
124 
125  //
126  // add here additional vetos
127  //
128  //.....
129 
130  //
131  // actual cut step
132  //
133  for(unsigned int iMu=0; iMu < nMuons; ++iMu){
134  const reco::Track* mu = &(*muons)[iMu];
135 
136  const IsoDeposit & deposit = deps[iMu];
137  LogTrace(metname)<< deposit.print();
138 
139  const Cuts::CutSpec & cut = theCuts( mu->eta());
140  std::pair<double, int> sumAndCount = deposit.depositAndCountWithin(cut.conesize, vetos, theTrackPt_Min);
141 
142  double value = sumAndCount.first;
143  int count = sumAndCount.second;
144 
145  bool result = (value < cut.threshold);
146  if (theApplyCutsORmaxNTracks ) result |= count <= theMaxNTracks;
147  LogTrace(metname)<<"deposit in cone: "<<value<<"with count "<<count<<" is isolated: "<<result;
148 
149  isos[iMu] = result;
150  }
151 
152  //
153  // store
154  //
156  reco::IsoDepositMap::Filler depFiller(*depMap);
157  depFiller.insert(muons, deps.begin(), deps.end());
158  depFiller.fill();
159  event.put(depMap);
160  }
161  edm::ValueMap<bool> ::Filler isoFiller(*isoMap);
162  isoFiller.insert(muons, isos.begin(), isos.end());
163  isoFiller.fill();
164  event.put(isoMap);
165 
166  LogTrace(metname) <<" END OF EVENT " <<"================================";
167 }
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const Veto & veto() const
Get veto area.
Definition: IsoDeposit.h:78
const std::string metname
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
tuple result
Definition: mps_fire.py:83
std::string print() const
Definition: Cuts.cc:55
bool theApplyCutsORmaxNTracks
apply or not the maxN cut on top of the sumPt (or nominall eff) &lt; cuts
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > theMuonCollectionToken
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
const int mu
Definition: Constants.h:22
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
L3MuonIsolationProducer(const edm::ParameterSet &)
constructor with config
#define LogTrace(id)
tuple deps
Definition: symbols.py:54
tuple muons
Definition: patZpeak.py:38
std::pair< double, int > depositAndCountWithin(double coneSize, const Vetos &vetos=Vetos(), double threshold=-1e+36, bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:44
std::string print() const
Definition: IsoDeposit.cc:181
virtual void produce(edm::Event &, const edm::EventSetup &) override
Produce isolation maps.
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const =0
virtual ~L3MuonIsolationProducer()
destructor
T get(const Candidate &c)
Definition: component.h:55
reco::isodeposit::IsoDepositExtractor * theExtractor