CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L2MuonIsolationProducer.cc
Go to the documentation of this file.
1 
6 // Framework
13 
16 
21 
25 
26 #include <string>
27 
28 using namespace edm;
29 using namespace std;
30 using namespace reco;
31 using namespace muonisolation;
32 
35  theSACollectionLabel(par.getParameter<edm::InputTag>("StandAloneCollectionLabel")),
36  theExtractor(0),
37  theDepositIsolator(0)
38 {
39  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")<<" L2MuonIsolationProducer constructor called";
40 
41 
42  //
43  // Extractor
44  //
45  edm::ParameterSet extractorPSet = par.getParameter<edm::ParameterSet>("ExtractorPSet");
46  std::string extractorName = extractorPSet.getParameter<std::string>("ComponentName");
47  theExtractor = IsoDepositExtractorFactory::get()->create( extractorName, extractorPSet);
48 
49 
50  edm::ParameterSet isolatorPSet = par.getParameter<edm::ParameterSet>("IsolatorPSet");
51  bool haveIsolator = !isolatorPSet.empty();
52  optOutputDecision = haveIsolator;
53  if (optOutputDecision){
54  std::string type = isolatorPSet.getParameter<std::string>("ComponentName");
55  theDepositIsolator = MuonIsolatorFactory::get()->create(type,isolatorPSet);
56  }
57  if (optOutputDecision) produces<edm::ValueMap<bool> >();
58  produces<reco::IsoDepositMap>();
59 
60  optOutputIsolatorFloat = par.getParameter<bool>("WriteIsolatorFloat");
61  if (optOutputIsolatorFloat && haveIsolator){
62  produces<edm::ValueMap<float> >();
63  }
64 }
65 
68  LogDebug("Muon|RecoMuon|L2MuonIsolationProducer")<<" L2MuonIsolationProducer destructor called";
69  if (theExtractor) delete theExtractor;
70 }
71 
74 
75 }
76 
79  std::string metname = "Muon|RecoMuon|L2MuonIsolationProducer";
80 
81  LogDebug(metname)<<" L2 Muon Isolation producing...";
82 
83  // Take the SA container
84  LogDebug(metname)<<" Taking the StandAlone muons: "<<theSACollectionLabel;
86  event.getByLabel(theSACollectionLabel,tracks);
87 
88  // Find deposits and load into event
89  LogDebug(metname)<<" Get energy around";
90  std::auto_ptr<reco::IsoDepositMap> depMap( new reco::IsoDepositMap());
91  std::auto_ptr<edm::ValueMap<bool> > isoMap( new edm::ValueMap<bool> ());
92  std::auto_ptr<edm::ValueMap<float> > isoFloatMap( new edm::ValueMap<float> ());
93 
94  theExtractor->fillVetos(event,eventSetup,*tracks);
95 
96  unsigned int nTracks = tracks->size();
97  std::vector<IsoDeposit> deps(nTracks);
98  std::vector<bool> isos(nTracks, false);
99  std::vector<float> isoFloats(nTracks, 0);
100 
101  for (unsigned int i=0; i<nTracks; i++) {
102  TrackRef tk(tracks,i);
103 
104  deps[i] = theExtractor->deposit(event, eventSetup, *tk);
105 
106  if (optOutputDecision){
108  muonisolation::MuIsoBaseIsolator::Result isoResult = theDepositIsolator->result( isoContainer, *tk, &event );
109  isos[i] = isoResult.valBool;
110  isoFloats[i] = isoResult.valFloat;
111  }
112  }
113 
114 
115 
117  reco::IsoDepositMap::Filler depFiller(*depMap);
118  depFiller.insert(tracks, deps.begin(), deps.end());
119  depFiller.fill();
120  event.put(depMap);
121 
122  if (optOutputDecision){
123  edm::ValueMap<bool> ::Filler isoFiller(*isoMap);
124  isoFiller.insert(tracks, isos.begin(), isos.end());
125  isoFiller.fill();
126  event.put(isoMap);
127 
129  edm::ValueMap<float> ::Filler isoFloatFiller(*isoFloatMap);
130  isoFloatFiller.insert(tracks, isoFloats.begin(), isoFloats.end());
131  isoFloatFiller.fill();
132  event.put(isoFloatMap);
133  }
134  }
135 
136  LogDebug(metname) <<" Event loaded"
137  <<"================================";
138 }
#define LogDebug(id)
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
bool empty() const
Definition: ParameterSet.h:219
reco::isodeposit::IsoDepositExtractor * theExtractor
int i
Definition: DBlmapReader.cc:9
const std::string metname
virtual Result result(const DepositContainer &deposits, const edm::Event *=0) const =0
Compute and return the isolation variable.
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:53
virtual void fillVetos(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::TrackCollection &tracks)=0
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
virtual ~L2MuonIsolationProducer()
destructor
std::vector< DepositAndVetos > DepositContainer
tuple tracks
Definition: testEve_cfg.py:39
virtual void produce(edm::Event &, const edm::EventSetup &)
Produce isolation maps.
virtual void beginJob()
setup the job
muonisolation::MuIsoBaseIsolator * theDepositIsolator
L2MuonIsolationProducer(const edm::ParameterSet &)
constructor with config
virtual reco::IsoDeposit deposit(const edm::Event &ev, const edm::EventSetup &evSetup, const reco::Track &track) const =0
T get(const Candidate &c)
Definition: component.h:56