Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:46

0001 // -*- C++ -*-
0002 //
0003 // Package:    testEcalClusterLazyTools
0004 // Class:      testEcalClusterLazyTools
0005 //
0006 /**\class testEcalClusterLazyTools testEcalClusterLazyTools.cc
0007 
0008 Description: <one line class summary>
0009 
0010 Implementation:
0011 <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  "Federico Ferri federi
0015 //         Created:  Mon Apr  7 14:11:00 CEST 2008
0016 //
0017 //
0018 
0019 #include "FWCore/Framework/interface/Frameworkfwd.h"
0020 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0024 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0025 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
0028 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0029 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0030 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0031 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0032 
0033 #include <memory>
0034 
0035 class testEcalClusterLazyTools : public edm::one::EDAnalyzer<> {
0036 public:
0037   explicit testEcalClusterLazyTools(const edm::ParameterSet&);
0038 
0039 private:
0040   virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
0041 
0042   using LazyTools = noZS::EcalClusterLazyTools;  // alternatively just EcalClusterLazyTools
0043 
0044   const edm::EDGetTokenT<reco::BasicClusterCollection> barrelClusterToken_;
0045   const edm::EDGetTokenT<reco::BasicClusterCollection> endcapClusterToken_;
0046   const edm::EDGetTokenT<EcalRecHitCollection> barrelRecHitToken_;
0047   const edm::EDGetTokenT<EcalRecHitCollection> endcapRecHitToken_;
0048 
0049   LazyTools::ESGetTokens esGetTokens_;
0050 };
0051 
0052 testEcalClusterLazyTools::testEcalClusterLazyTools(const edm::ParameterSet& ps)
0053     : barrelClusterToken_(consumes(ps.getParameter<edm::InputTag>("barrelClusterCollection"))),
0054       endcapClusterToken_(consumes(ps.getParameter<edm::InputTag>("endcapClusterCollection"))),
0055       barrelRecHitToken_(consumes(ps.getParameter<edm::InputTag>("barrelRecHitCollection"))),
0056       endcapRecHitToken_(consumes(ps.getParameter<edm::InputTag>("endcapRecHitCollection"))),
0057       esGetTokens_{consumesCollector()} {}
0058 
0059 void testEcalClusterLazyTools::analyze(const edm::Event& ev, const edm::EventSetup& es) {
0060   edm::Handle<reco::BasicClusterCollection> pEBClusters;
0061   ev.getByToken(barrelClusterToken_, pEBClusters);
0062   const reco::BasicClusterCollection* ebClusters = pEBClusters.product();
0063 
0064   edm::Handle<reco::BasicClusterCollection> pEEClusters;
0065   ev.getByToken(endcapClusterToken_, pEEClusters);
0066   const reco::BasicClusterCollection* eeClusters = pEEClusters.product();
0067 
0068   LazyTools lazyTools(ev, esGetTokens_.get(es), barrelRecHitToken_, endcapRecHitToken_);
0069 
0070   std::cout << "========== BARREL ==========" << std::endl;
0071   for (auto const& clus : *ebClusters) {
0072     std::cout << "----- new cluster -----" << std::endl;
0073     std::cout << "----------------- size: " << (clus).size() << " energy: " << (clus).energy() << std::endl;
0074 
0075     std::cout << "e1x3..................... " << lazyTools.e1x3(clus) << std::endl;
0076     std::cout << "e3x1..................... " << lazyTools.e3x1(clus) << std::endl;
0077     std::cout << "e1x5..................... " << lazyTools.e1x5(clus) << std::endl;
0078     std::cout << "e5x1..................... " << lazyTools.e5x1(clus) << std::endl;
0079     std::cout << "e2x2..................... " << lazyTools.e2x2(clus) << std::endl;
0080     std::cout << "e3x3..................... " << lazyTools.e3x3(clus) << std::endl;
0081     std::cout << "e4x4..................... " << lazyTools.e4x4(clus) << std::endl;
0082     std::cout << "e5x5..................... " << lazyTools.e5x5(clus) << std::endl;
0083     std::cout << "n5x5..................... " << lazyTools.n5x5(clus) << std::endl;
0084     std::cout << "e2x5Right................ " << lazyTools.e2x5Right(clus) << std::endl;
0085     std::cout << "e2x5Left................. " << lazyTools.e2x5Left(clus) << std::endl;
0086     std::cout << "e2x5Top.................. " << lazyTools.e2x5Top(clus) << std::endl;
0087     std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom(clus) << std::endl;
0088     std::cout << "e2x5Max.................. " << lazyTools.e2x5Max(clus) << std::endl;
0089     std::cout << "eMax..................... " << lazyTools.eMax(clus) << std::endl;
0090     std::cout << "e2nd..................... " << lazyTools.e2nd(clus) << std::endl;
0091     std::vector<float> vEta = lazyTools.energyBasketFractionEta(clus);
0092     std::cout << "energyBasketFractionEta..";
0093     for (size_t i = 0; i < vEta.size(); ++i) {
0094       std::cout << " " << vEta[i];
0095     }
0096     std::cout << std::endl;
0097     std::vector<float> vPhi = lazyTools.energyBasketFractionPhi(clus);
0098     std::cout << "energyBasketFractionPhi..";
0099     for (size_t i = 0; i < vPhi.size(); ++i) {
0100       std::cout << " " << vPhi[i];
0101     }
0102     std::cout << std::endl;
0103     std::vector<float> vLat = lazyTools.lat(clus);
0104     std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl;
0105     const auto& vCov = lazyTools.covariances(clus);
0106     std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl;
0107     const auto& vLocCov = lazyTools.localCovariances(clus);
0108     std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl;
0109     std::cout << "zernike20................ " << lazyTools.zernike20(clus) << std::endl;
0110     std::cout << "zernike42................ " << lazyTools.zernike42(clus) << std::endl;
0111   }
0112 
0113   std::cout << "========== ENDCAPS ==========" << std::endl;
0114   for (auto const& clus : *eeClusters) {
0115     std::cout << "----- new cluster -----" << std::endl;
0116     std::cout << "----------------- size: " << (clus).size() << " energy: " << (clus).energy() << std::endl;
0117 
0118     std::cout << "e1x3..................... " << lazyTools.e1x3(clus) << std::endl;
0119     std::cout << "e3x1..................... " << lazyTools.e3x1(clus) << std::endl;
0120     std::cout << "e1x5..................... " << lazyTools.e1x5(clus) << std::endl;
0121     std::cout << "e5x1..................... " << lazyTools.e5x1(clus) << std::endl;
0122     std::cout << "e2x2..................... " << lazyTools.e2x2(clus) << std::endl;
0123     std::cout << "e3x3..................... " << lazyTools.e3x3(clus) << std::endl;
0124     std::cout << "e4x4..................... " << lazyTools.e4x4(clus) << std::endl;
0125     std::cout << "e5x5..................... " << lazyTools.e5x5(clus) << std::endl;
0126     std::cout << "n5x5..................... " << lazyTools.n5x5(clus) << std::endl;
0127     std::cout << "e2x5Right................ " << lazyTools.e2x5Right(clus) << std::endl;
0128     std::cout << "e2x5Left................. " << lazyTools.e2x5Left(clus) << std::endl;
0129     std::cout << "e2x5Top.................. " << lazyTools.e2x5Top(clus) << std::endl;
0130     std::cout << "e2x5Bottom............... " << lazyTools.e2x5Bottom(clus) << std::endl;
0131     std::cout << "eMax..................... " << lazyTools.eMax(clus) << std::endl;
0132     std::cout << "e2nd..................... " << lazyTools.e2nd(clus) << std::endl;
0133     std::vector<float> vLat = lazyTools.lat(clus);
0134     std::cout << "lat...................... " << vLat[0] << " " << vLat[1] << " " << vLat[2] << std::endl;
0135     const auto& vCov = lazyTools.covariances(clus);
0136     std::cout << "covariances.............. " << vCov[0] << " " << vCov[1] << " " << vCov[2] << std::endl;
0137     const auto& vLocCov = lazyTools.localCovariances(clus);
0138     std::cout << "local covariances........ " << vLocCov[0] << " " << vLocCov[1] << " " << vLocCov[2] << std::endl;
0139     std::cout << "zernike20................ " << lazyTools.zernike20(clus) << std::endl;
0140     std::cout << "zernike42................ " << lazyTools.zernike42(clus) << std::endl;
0141   }
0142 }
0143 
0144 //define this as a plug-in
0145 DEFINE_FWK_MODULE(testEcalClusterLazyTools);