Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:52

0001 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
0002 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
0003 #include "RecoCaloTools/Selectors/interface/CaloDualConeSelector.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/EventSetup.h"
0006 #include "DataFormats/Common/interface/Handle.h"
0007 #include "FWCore/Framework/interface/ESHandle.h"
0008 #include "FWCore/Framework/interface/EDAnalyzer.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/Utilities/interface/InputTag.h"
0011 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0012 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0013 #include <iostream>
0014 
0015 class TestCaloSelectors : public edm::EDAnalyzer {
0016 public:
0017   TestCaloSelectors(const edm::ParameterSet& ps) : inputTag_(ps.getParameter<edm::InputTag>("inputTag")) {}
0018   virtual void analyze(const edm::Event& evt, const edm::EventSetup& es);
0019 
0020 private:
0021   edm::InputTag inputTag_;
0022 };
0023 
0024 void TestCaloSelectors::analyze(const edm::Event& evt, const edm::EventSetup& c) {
0025   edm::Handle<HBHERecHitCollection> hbhe;
0026   evt.getByLabel(inputTag_, hbhe);
0027   edm::ESHandle<CaloGeometry> pG;
0028   c.get<CaloGeometryRecord>().get(pG);
0029 
0030   const HBHERecHitCollection& mhbhe = *hbhe;
0031 
0032   double maxEt = -1;
0033   GlobalPoint pMax;
0034   for (HBHERecHitCollection::const_iterator i = mhbhe.begin(); i != mhbhe.end(); i++) {
0035     GlobalPoint p = pG->getPosition(i->detid());
0036     double et = i->energy() / cosh(p.eta());
0037     if (et > maxEt) {
0038       pMax = p;
0039       maxEt = et;
0040     }
0041   }
0042 
0043   CaloConeSelector<HBHERecHit> sel(0.3, pG.product(), DetId::Hcal);
0044   CaloDualConeSelector<HBHERecHit> sel2(0.3, 0.5, pG.product(), DetId::Hcal);
0045 
0046   std::cout << "Center at " << pMax.eta() << "," << pMax.phi() << " (ET=" << maxEt << ")" << std::endl;
0047 
0048   sel.selectCallback(
0049       pMax, mhbhe, [&](const HBHERecHit& i) { std::cout << HcalDetId(i.detid()) << " : " << i << std::endl; });
0050 
0051   std::cout << "Dual cone\n";
0052 
0053   sel2.selectCallback(
0054       pMax, mhbhe, [&](const HBHERecHit& i) { std::cout << HcalDetId(i.detid()) << " : " << i << std::endl; });
0055 
0056   std::cout << std::endl;
0057 }
0058 
0059 #include "FWCore/PluginManager/interface/ModuleDef.h"
0060 #include "FWCore/Framework/interface/MakerMacros.h"
0061 
0062 DEFINE_FWK_MODULE(TestCaloSelectors);