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  if (optOutputIsoDeposits) produces<reco::IsoDepositMap>();
46  produces<edm::ValueMap<bool> >();
47 }
48 
51  LogDebug("RecoMuon|L3MuonIsolationProducer")<<" L3MuonIsolationProducer DTOR";
52  if (theExtractor) delete theExtractor;
53 }
54 
56 {
57 
58  //
59  // Extractor
60  //
61  edm::ParameterSet extractorPSet = theConfig.getParameter<edm::ParameterSet>("ExtractorPSet");
63  theTrackPt_Min = theConfig.getParameter<double>("TrackPt_Min");
64  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
65  theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet);
66  std::string depositType = extractorPSet.getUntrackedParameter<std::string>("DepositLabel");
67 
68  //
69  // Cuts
70  //
72  std::string cutsName = cutsPSet.getParameter<std::string>("ComponentName");
73  if (cutsName == "SimpleCuts") {
74  theCuts = Cuts(cutsPSet);
75  }
76  else if (
77 // (cutsName== "L3NominalEfficiencyCuts_PXLS" && depositType=="PXLS")
78 // || (cutsName== "L3NominalEfficiencyCuts_TRKS" && depositType=="TRKS")
80  (cutsName== "L3NominalEfficiencyCuts_PXLS" )
81  || (cutsName== "L3NominalEfficiencyCuts_TRKS") ) {
83  }
84  else {
85  LogError("L3MuonIsolationProducer::beginJob")
86  <<"cutsName: "<<cutsPSet<<" is not recognized:"
87  <<" theCuts not set!";
88  }
89  LogTrace("")<< theCuts.print();
90 
91  // (kludge) additional cut on the number of tracks
92  theMaxNTracks = cutsPSet.getParameter<int>("maxNTracks");
93  theApplyCutsORmaxNTracks = cutsPSet.getParameter<bool>("applyCutsORmaxNTracks");
94 }
95 
97  std::string metname = "RecoMuon|L3MuonIsolationProducer";
98 
99  LogDebug(metname)<<" L3 Muon Isolation producing..."
100  <<" BEGINING OF EVENT " <<"================================";
101 
102  // Take the SA container
103  LogTrace(metname)<<" Taking the muons: "<<theMuonCollectionLabel;
105  event.getByLabel(theMuonCollectionLabel,muons);
106 
107  std::auto_ptr<reco::IsoDepositMap> depMap( new reco::IsoDepositMap());
108  std::auto_ptr<edm::ValueMap<bool> > isoMap( new edm::ValueMap<bool> ());
109 
110 
111  //
112  // get Vetos and deposits
113  //
114  unsigned int nMuons = muons->size();
115 
116  IsoDeposit::Vetos vetos(nMuons);
117 
118  std::vector<IsoDeposit> deps(nMuons);
119  std::vector<bool> isos(nMuons, false);
120 
121  for (unsigned int i=0; i<nMuons; i++) {
122  TrackRef mu(muons,i);
123  deps[i] = theExtractor->deposit(event, eventSetup, *mu);
124  vetos[i] = deps[i].veto();
125  }
126 
127  //
128  // add here additional vetos
129  //
130  //.....
131 
132  //
133  // actual cut step
134  //
135  for(unsigned int iMu=0; iMu < nMuons; ++iMu){
136  const reco::Track* mu = &(*muons)[iMu];
137 
138  const IsoDeposit & deposit = deps[iMu];
139  LogTrace(metname)<< deposit.print();
140 
141  const Cuts::CutSpec & cut = theCuts( mu->eta());
142  std::pair<double, int> sumAndCount = deposit.depositAndCountWithin(cut.conesize, vetos, theTrackPt_Min);
143 
144  double value = sumAndCount.first;
145  int count = sumAndCount.second;
146 
147  bool result = (value < cut.threshold);
148  if (theApplyCutsORmaxNTracks ) result |= count <= theMaxNTracks;
149  LogTrace(metname)<<"deposit in cone: "<<value<<"with count "<<count<<" is isolated: "<<result;
150 
151  isos[iMu] = result;
152  }
153 
154  //
155  // store
156  //
158  reco::IsoDepositMap::Filler depFiller(*depMap);
159  depFiller.insert(muons, deps.begin(), deps.end());
160  depFiller.fill();
161  event.put(depMap);
162  }
163  edm::ValueMap<bool> ::Filler isoFiller(*isoMap);
164  isoFiller.insert(muons, isos.begin(), isos.end());
165  isoFiller.fill();
166  event.put(isoMap);
167 
168  LogTrace(metname) <<" END OF EVENT " <<"================================";
169 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const Veto & veto() const
Get veto area.
Definition: IsoDeposit.h:73
virtual void beginJob()
initialisation
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:53
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:141
tuple result
Definition: query.py:137
const int mu
Definition: Constants.h:23
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:56
reco::isodeposit::IsoDepositExtractor * theExtractor