Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-31 23:46:15

0001 // -*- C++ -*-
0002 //
0003 // Package:    HGCGeometryTester
0004 // Class:      HGCGeometryTester
0005 //
0006 /**\class HGCGeometryTester HGCGeometryTester.cc test/HGCGeometryTester.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Sunanda Banerjee
0015 //         Created:  Mon 2014/02/07
0016 // $Id: HGCGeometryTester.cc,v 1.0 2014/02/07 14:06:07 sunanda Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <fstream>
0022 #include <iostream>
0023 #include <memory>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/Framework/interface/MakerMacros.h"
0032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0033 
0034 #include "DetectorDescription/Core/interface/DDCompactView.h"
0035 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0036 #include "DetectorDescription/Core/interface/DDSolid.h"
0037 #include "DetectorDescription/Core/interface/DDSpecifics.h"
0038 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0039 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0040 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0041 
0042 class HGCGeometryTester : public edm::one::EDAnalyzer<> {
0043 public:
0044   explicit HGCGeometryTester(const edm::ParameterSet&);
0045   ~HGCGeometryTester() override = default;
0046   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0047 
0048   void beginJob() override {}
0049   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0050   void endJob() override {}
0051 
0052 private:
0053   const edm::ESGetToken<DDCompactView, IdealGeometryRecord> ddToken_;
0054   const bool square_;
0055 };
0056 
0057 HGCGeometryTester::HGCGeometryTester(const edm::ParameterSet& iC)
0058     : ddToken_{esConsumes<DDCompactView, IdealGeometryRecord>(edm::ESInputTag{})},
0059       square_(iC.getUntrackedParameter<bool>("SquareType", false)) {}
0060 
0061 void HGCGeometryTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0062   edm::ParameterSetDescription desc;
0063   desc.addUntracked<bool>("SquareType", false);
0064   descriptions.add("hgcGeometryTester", desc);
0065 }
0066 
0067 // ------------ method called to produce the data  ------------
0068 void HGCGeometryTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069   const auto& pDD = iSetup.getData(ddToken_);
0070 
0071   // parse the DD for sensitive volumes
0072   DDExpandedView eview(pDD);
0073   std::map<std::string, std::pair<double, double> > svPars;
0074   do {
0075     const DDLogicalPart& logPart = eview.logicalPart();
0076     const std::string& name = logPart.name().fullname();
0077 
0078     // only EE sensitive volumes for the moment
0079     if ((name.find("HGCal") != std::string::npos) && (name.find("Sensitive") != std::string::npos)) {
0080       size_t pos = name.find("Sensitive") + 9;
0081       int layer = atoi(name.substr(pos, name.size() - 1).c_str());
0082       if (svPars.find(name) == svPars.end()) {
0083         // print half height and widths for the trapezoid
0084         std::vector<double> solidPar = eview.logicalPart().solid().parameters();
0085         if (square_) {
0086           svPars[name] = std::pair<double, double>(solidPar[3], 0.5 * (solidPar[4] + solidPar[5]));
0087           edm::LogVerbatim("HGCalGeomX") << name << " Layer " << layer << " " << solidPar[3] << " " << solidPar[4]
0088                                          << " " << solidPar[5];
0089         } else {
0090           svPars[name] = std::pair<double, double>(solidPar[0], 0.5 * (solidPar[2] - solidPar[1]));
0091           edm::LogVerbatim("HGCalGeomX") << name << " Layer " << layer << " " << solidPar[0] << " " << solidPar[1]
0092                                          << " " << solidPar[2];
0093         }
0094       }
0095     }
0096   } while (eview.next());
0097 }
0098 
0099 // define this as a plug-in
0100 DEFINE_FWK_MODULE(HGCGeometryTester);