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
9 
11 
13 
17 
20 
23 
26 
28 
29 #include <string>
30 
31 using namespace edm;
32 using namespace std;
33 using namespace reco;
34 using namespace muonisolation;
35 
38  theConfig(par),
39  theMuonCollectionLabel(par.getParameter<InputTag>("inputMuonCollection")),
40  optOutputIsoDeposits(par.getParameter<bool>("OutputMuIsoDeposits")),
41  theExtractor(0),
42  theTrackPt_Min(-1)
43  {
44  LogDebug("RecoMuon|L3MuonIsolationProducer")<<" L3MuonIsolationProducer CTOR";
45 
46  theMuonCollectionToken = consumes<RecoChargedCandidateCollection>(theMuonCollectionLabel);
47 
48  if (optOutputIsoDeposits) produces<reco::IsoDepositMap>();
49  produces<edm::ValueMap<bool> >();
50 
51  //
52  // Extractor
53  //
54  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
56  theTrackPt_Min = theConfig.getParameter<double>("TrackPt_Min");
57  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
58  theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet, consumesCollector());
59  std::string depositType = extractorPSet.getUntrackedParameter<std::string>("DepositLabel");
60 
61  //
62  // Cuts
63  //
65  std::string cutsName = cutsPSet.getParameter<std::string>("ComponentName");
66  if (cutsName == "SimpleCuts") {
67  theCuts = Cuts(cutsPSet);
68  }
69  else if (
70 // (cutsName== "L3NominalEfficiencyCuts_PXLS" && depositType=="PXLS")
71 // || (cutsName== "L3NominalEfficiencyCuts_TRKS" && depositType=="TRKS")
73  (cutsName== "L3NominalEfficiencyCuts_PXLS" )
74  || (cutsName== "L3NominalEfficiencyCuts_TRKS") ) {
76  }
77  else {
78  LogError("L3MuonIsolationProducer::beginJob")
79  <<"cutsName: "<<cutsPSet<<" is not recognized:"
80  <<" theCuts not set!";
81  }
82  LogTrace("")<< theCuts.print();
83 
84  // (kludge) additional cut on the number of tracks
85  theMaxNTracks = cutsPSet.getParameter<int>("maxNTracks");
86  theApplyCutsORmaxNTracks = cutsPSet.getParameter<bool>("applyCutsORmaxNTracks");
87 }
88 
91  LogDebug("RecoMuon|L3MuonIsolationProducer")<<" L3MuonIsolationProducer DTOR";
92  if (theExtractor) delete theExtractor;
93 }
94 
96  std::string metname = "RecoMuon|L3MuonIsolationProducer";
97 
98  LogDebug(metname)<<" L3 Muon Isolation producing..."
99  <<" BEGINING OF EVENT " <<"================================";
100 
101  // Take the SA container
102  LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionLabel;
104  event.getByToken(theMuonCollectionToken,muons);
105 
106  std::auto_ptr<reco::IsoDepositMap> depMap( new reco::IsoDepositMap());
107  std::auto_ptr<edm::ValueMap<bool> > isoMap( new edm::ValueMap<bool> ());
108 
109 
110  //
111  // get Vetos and deposits
112  //
113  unsigned int nMuons = muons->size();
114 
115  IsoDeposit::Vetos vetos(nMuons);
116 
117  std::vector<IsoDeposit> deps(nMuons);
118  std::vector<bool> isos(nMuons, false);
119 
120  for (unsigned int i=0; i<nMuons; i++) {
121  TrackRef mu(muons,i);
122  deps[i] = theExtractor->deposit(event, eventSetup, *mu);
123  vetos[i] = deps[i].veto();
124  }
125 
126  //
127  // add here additional vetos
128  //
129  //.....
130 
131  //
132  // actual cut step
133  //
134  for(unsigned int iMu=0; iMu < nMuons; ++iMu){
135  const reco::Track* mu = &(*muons)[iMu];
136 
137  const IsoDeposit & deposit = deps[iMu];
138  LogTrace(metname)<< deposit.print();
139 
140  const Cuts::CutSpec & cut = theCuts( mu->eta());
141  std::pair<double, int> sumAndCount = deposit.depositAndCountWithin(cut.conesize, vetos, theTrackPt_Min);
142 
143  double value = sumAndCount.first;
144  int count = sumAndCount.second;
145 
146  bool result = (value < cut.threshold);
147  if (theApplyCutsORmaxNTracks ) result |= count <= theMaxNTracks;
148  LogTrace(metname)<<"deposit in cone: "<<value<<"with count "<<count<<" is isolated: "<<result;
149 
150  isos[iMu] = result;
151  }
152 
153  //
154  // store
155  //
157  reco::IsoDepositMap::Filler depFiller(*depMap);
158  depFiller.insert(muons, deps.begin(), deps.end());
159  depFiller.fill();
160  event.put(depMap);
161  }
162  edm::ValueMap<bool> ::Filler isoFiller(*isoMap);
163  isoFiller.insert(muons, isos.begin(), isos.end());
164  isoFiller.fill();
165  event.put(isoMap);
166 
167  LogTrace(metname) <<" END OF EVENT " <<"================================";
168 }
#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
virtual void produce(edm::Event &, const edm::EventSetup &)
Produce isolation maps.
const std::string metname
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
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:139
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > theMuonCollectionToken
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
tuple result
Definition: query.py:137
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 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 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