CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
InterestingEcalDetIdProducer.cc
Go to the documentation of this file.
2 
8 
10 
13 
17 
21 
22 
24 {
25  inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection");
26  produces< DetIdCollection >() ;
27  muonToken_ = consumes<reco::MuonCollection>(inputCollection_);
28 }
29 
30 
32 {}
33 
35 {
36  edm::ESHandle<CaloTopology> theCaloTopology;
37  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
38  caloTopology_ = &(*theCaloTopology);
39 }
40 
41 void
43  const edm::EventSetup& iSetup)
44 {
46  iEvent.getByToken(muonToken_,muons);
47 
48  std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
49 
50  for(reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++muon){
51  if (! muon->isEnergyValid() ) continue;
52  if ( muon->calEnergy().ecal_id.rawId()==0 ) continue;
53  const CaloSubdetectorTopology* topology = caloTopology_->getSubdetectorTopology(DetId::Ecal,muon->calEnergy().ecal_id.subdetId());
54  const std::vector<DetId>& ids = topology->getWindow(muon->calEnergy().ecal_id, 5, 5);
55  for ( std::vector<DetId>::const_iterator id = ids.begin(); id != ids.end(); ++id )
56  if(std::find(interestingDetIdCollection->begin(), interestingDetIdCollection->end(), *id)
57  == interestingDetIdCollection->end())
58  interestingDetIdCollection->push_back(*id);
59  }
60  iEvent.put(interestingDetIdCollection);
61 }
T getParameter(std::string const &) const
InterestingEcalDetIdProducer(const edm::ParameterSet &)
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
void produce(edm::Event &, const edm::EventSetup &) override
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
edm::EDGetTokenT< reco::MuonCollection > muonToken_
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
const T & get() const
Definition: EventSetup.h:55
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:26
void beginRun(const edm::Run &, const edm::EventSetup &) override
tuple muons
Definition: patZpeak.py:38
edm::EDCollection< DetId > DetIdCollection
Definition: Run.h:41