CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CosmicsMuonIdProducer.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 
9 
16 
18 
20 public:
22  inputMuonCollection_(iConfig.getParameter<edm::InputTag>("muonCollection")),
23  inputTrackCollections_(iConfig.getParameter<std::vector<edm::InputTag> >("trackCollections")),
24  compatibilityFiller_(iConfig.getParameter<edm::ParameterSet>("CosmicCompFillerParameters"))
25  {
26  produces<edm::ValueMap<unsigned int> >().setBranchAlias("cosmicsVeto");
27  produces<edm::ValueMap<reco::MuonCosmicCompatibility> >().setBranchAlias("cosmicCompatibility");
28  }
30 
31 private:
32  virtual void produce(edm::Event&, const edm::EventSetup&);
34  std::vector<edm::InputTag> inputTrackCollections_;
36 };
37 
38 void
40 {
42  iEvent.getByLabel(inputMuonCollection_, muons);
43  // reserve some space
44  std::vector<unsigned int> values;
45  values.reserve(muons->size());
46 
47  std::vector<reco::MuonCosmicCompatibility> compValues;
48  compValues.reserve(muons->size());
49 
50  for(reco::MuonCollection::const_iterator muon = muons->begin();
51  muon != muons->end(); ++muon)
52  {
53  unsigned int foundPartner(0);
54  if ( muon->innerTrack().isNonnull() ){
55  for ( unsigned int i=0; i<inputTrackCollections_.size(); ++i )
56  {
59  if ( muonid::findOppositeTrack(tracks,*muon->innerTrack()).isNonnull() ){
60  foundPartner = i+1;
61  break;
62  }
63  }
64  }
65  values.push_back(foundPartner);
66 
67  compValues.push_back(compatibilityFiller_.fillCompatibility(*muon, iEvent, iSetup));
68  }
69 
70  // create and fill value map
71  std::auto_ptr<edm::ValueMap<unsigned int> > out(new edm::ValueMap<unsigned int>());
73  filler.insert(muons, values.begin(), values.end());
74  filler.fill();
75 
76 
77  std::auto_ptr<edm::ValueMap<reco::MuonCosmicCompatibility> > outC(new edm::ValueMap<reco::MuonCosmicCompatibility>());
79  fillerC.insert(muons, compValues.begin(), compValues.end());
80  fillerC.fill();
81 
82  // put value map into event
83  iEvent.put(out);
84  iEvent.put(outC);
85 }
virtual void produce(edm::Event &, const edm::EventSetup &)
int i
Definition: DBlmapReader.cc:9
reco::TrackRef findOppositeTrack(const edm::Handle< reco::TrackCollection > &collection, const reco::Track &muon, double angleMatch=0.01, double momentumMatch=0.05)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void insert(const H &h, I begin, I end)
Definition: ValueMap.h:52
std::vector< edm::InputTag > inputTrackCollections_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
reco::MuonCosmicCompatibility fillCompatibility(const reco::Muon &muon, edm::Event &, const edm::EventSetup &)
fill cosmic compatibility variables
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
tuple out
Definition: dbtoconf.py:99
tuple tracks
Definition: testEve_cfg.py:39
MuonCosmicCompatibilityFiller compatibilityFiller_
CosmicsMuonIdProducer(const edm::ParameterSet &iConfig)