Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:49:14

0001 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0002 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0008 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0009 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0010 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0011 #include "Geometry/CaloGeometry/interface/EZArrayFL.h"
0012 
0013 #include <iomanip>
0014 #include <iostream>
0015 #include <sstream>
0016 
0017 typedef EZArrayFL<GlobalPoint> CornersVec;
0018 
0019 class EcalBarrelCellParameterDump : public edm::one::EDAnalyzer<> {
0020 public:
0021   explicit EcalBarrelCellParameterDump(const edm::ParameterSet&);
0022 
0023   void beginJob() override {}
0024   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0025   void endJob() override {}
0026 
0027 private:
0028   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> tok_geom_;
0029 };
0030 
0031 EcalBarrelCellParameterDump::EcalBarrelCellParameterDump(const edm::ParameterSet&)
0032     : tok_geom_(esConsumes<CaloGeometry, CaloGeometryRecord>()) {}
0033 
0034 void EcalBarrelCellParameterDump::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
0035   const CaloGeometry* geo = &iSetup.getData(tok_geom_);
0036   const CaloSubdetectorGeometry* ecalGeom =
0037       static_cast<const CaloSubdetectorGeometry*>(geo->getSubdetectorGeometry(DetId::Ecal, EcalBarrel));
0038 
0039   edm::LogVerbatim("EcalGeom") << "\n\nStudy Detector = Ecal SubDetector = EB"
0040                                << "\n======================================\n";
0041   const std::vector<DetId>& ids = ecalGeom->getValidDetIds(DetId::Ecal, EcalBarrel);
0042   int nall(0);
0043   for (auto id : ids) {
0044     ++nall;
0045     std::shared_ptr<const CaloCellGeometry> geom = ecalGeom->getGeometry(id);
0046     EBDetId ebid(id.rawId());
0047 
0048     std::ostringstream st1;
0049     st1 << "IEta = " << ebid.ieta() << ";  IPhi = " << ebid.iphi() << " geom->getPosition " << std::setprecision(4)
0050         << geom->getPosition() << " BackPoint " << geom->getBackPoint() << " [rho,eta:etaSpan,phi:phiSpan] ("
0051         << geom->rhoPos() << ", " << geom->etaPos() << ":" << geom->etaSpan() << ", " << geom->phiPos() << ":"
0052         << geom->phiSpan() << ")";
0053 
0054     const CaloCellGeometry::CornersVec& corners(geom->getCorners());
0055 
0056     for (unsigned int ci(0); ci != corners.size(); ci++) {
0057       st1 << " Corner: " << ci << "  Location" << corners[ci] << " ; ";
0058     }
0059 
0060     edm::LogVerbatim("EcalGeom") << st1.str();
0061   }
0062   edm::LogVerbatim("EcalGeom") << "\n\nDumps a total of : " << nall << " cells of the detector\n";
0063 }
0064 
0065 DEFINE_FWK_MODULE(EcalBarrelCellParameterDump);