00001 #include "RecoMuon/MuonIdentification/plugins/InterestingEcalDetIdProducer.h" 00002 00003 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00004 #include "FWCore/Framework/interface/Event.h" 00005 #include "FWCore/Framework/interface/EventSetup.h" 00006 #include "FWCore/Framework/interface/ESHandle.h" 00007 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00008 00009 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" 00010 00011 #include "DataFormats/EcalDetId/interface/EBDetId.h" 00012 #include "DataFormats/EcalDetId/interface/EEDetId.h" 00013 00014 #include "DataFormats/DetId/interface/DetIdCollection.h" 00015 #include "DataFormats/EgammaReco/interface/BasicCluster.h" 00016 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h" 00017 00018 #include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" 00019 #include "Geometry/CaloTopology/interface/CaloTopology.h" 00020 #include "Geometry/CaloTopology/interface/CaloSubdetectorTopology.h" 00021 00022 #include "DataFormats/MuonReco/interface/Muon.h" 00023 #include "DataFormats/MuonReco/interface/MuonFwd.h" 00024 00025 InterestingEcalDetIdProducer::InterestingEcalDetIdProducer(const edm::ParameterSet& iConfig) 00026 { 00027 inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection"); 00028 produces< DetIdCollection >() ; 00029 } 00030 00031 00032 InterestingEcalDetIdProducer::~InterestingEcalDetIdProducer() 00033 {} 00034 00035 void InterestingEcalDetIdProducer::beginRun (const edm::Run & run, const edm::EventSetup & iSetup) 00036 { 00037 edm::ESHandle<CaloTopology> theCaloTopology; 00038 iSetup.get<CaloTopologyRecord>().get(theCaloTopology); 00039 caloTopology_ = &(*theCaloTopology); 00040 } 00041 00042 void 00043 InterestingEcalDetIdProducer::produce (edm::Event& iEvent, 00044 const edm::EventSetup& iSetup) 00045 { 00046 edm::Handle<reco::MuonCollection> muons; 00047 iEvent.getByLabel(inputCollection_,muons); 00048 00049 std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ; 00050 00051 for(reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon){ 00052 if (! muon->isEnergyValid() ) continue; 00053 if ( muon->calEnergy().ecal_id.rawId()==0 ) continue; 00054 const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(DetId::Ecal,muon->calEnergy().ecal_id.subdetId()); 00055 const std::vector<DetId>& ids = topology->getWindow(muon->calEnergy().ecal_id, 5, 5); 00056 for ( std::vector<DetId>::const_iterator id = ids.begin(); id != ids.end(); ++id ) 00057 if(std::find(interestingDetIdCollection->begin(), interestingDetIdCollection->end(), *id) 00058 == interestingDetIdCollection->end()) 00059 interestingDetIdCollection->push_back(*id); 00060 } 00061 iEvent.put(interestingDetIdCollection); 00062 }