Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-05-07 01:49:53

0001 // -*- C++ -*-
0002 //
0003 // Package:    HGCalWaferInfo
0004 // Class:      HGCalWaferInfo
0005 //
0006 /**\class HGCalWaferInfo HGCalWaferInfo.cc
0007  test/HGCalWaferInfo.cc
0008 
0009  Description: <one line class summary>
0010 
0011  Implementation:
0012      <Notes on implementation>
0013 */
0014 //
0015 // Original Author:  Sunanda Banerjee
0016 //         Created:  Mon 2025/05/02
0017 //
0018 //
0019 
0020 // system include files
0021 #include <fstream>
0022 #include <iostream>
0023 #include <memory>
0024 #include <string>
0025 #include <vector>
0026 
0027 // user include files
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0030 #include "FWCore/Framework/interface/Event.h"
0031 #include "FWCore/Framework/interface/EventSetup.h"
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0036 
0037 #include "DataFormats/DetId/interface/DetId.h"
0038 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0039 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0040 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0041 
0042 class HGCalWaferInfo : public edm::one::EDAnalyzer<> {
0043 public:
0044   explicit HGCalWaferInfo(const edm::ParameterSet&);
0045   ~HGCalWaferInfo() 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 std::string name_;
0054   const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_;
0055 };
0056 
0057 HGCalWaferInfo::HGCalWaferInfo(const edm::ParameterSet& iC)
0058     : name_(iC.getParameter<std::string>("detector")),
0059       geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag("", name_))) {}
0060 
0061 void HGCalWaferInfo::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0062   edm::ParameterSetDescription desc;
0063   desc.add<std::string>("detector", "HGCalEESensitive");
0064   descriptions.add("hgcalWaferInfoEE", desc);
0065 }
0066 
0067 // ------------ method called to produce the data  ------------
0068 void HGCalWaferInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069   const auto& geom = &iSetup.getData(geomToken_);
0070   DetId::Detector det = (name_ == "HGCalHESiliconSensitive") ? DetId::HGCalHSi : DetId::HGCalEE;
0071   edm::LogVerbatim("HGCalGeom") << "Perform test for " << name_ << " Detector " << det;
0072 
0073   const std::vector<DetId>& ids = geom->getValidDetIds();
0074   edm::LogVerbatim("HGCalGeom") << "Use " << ids.size() << " valid ids for " << geom->cellElement();
0075   std::string parts[26] = {"Full",  "Five", "ChopTwo", "ChopTwoM", "Half",     "Semi",    "Semi2",   "Three",   "Half2",
0076                            "Five2", "????", "LDTop",   "LDBottom", "LDLeft",   "LDRight", "LDFive",  "LDThree", "????",
0077                            "????",  "????", "????",    "HDTop",    "HDBottom", "HDLeft",  "HDRight", "HDFive"};
0078   std::string types[4] = {"HD120", "LD200", "LD300", "HD200"};
0079 
0080   for (auto const& id : ids) {
0081     if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) {
0082       HGCSiliconDetId detId(id);
0083       HGCalParameters::waferInfo info =
0084           geom->topology().dddConstants().waferInfo(detId.layer(), detId.waferU(), detId.waferV());
0085       edm::LogVerbatim("HGCalGeom") << "ID: " << detId << " Type " << info.type << ":" << types[info.type] << " Part "
0086                                     << info.part << ":" << parts[info.part] << " Orient " << info.orient
0087                                     << " placement " << geom->topology().dddConstants().placementIndex(detId)
0088                                     << " Cassette " << info.cassette << " at " << geom->getPosition(id, true, false);
0089     } else {
0090       edm::LogVerbatim("HGCalGeom") << "Illegal Det " << id.det() << " in " << std::hex << id.rawId() << std::dec
0091                                     << " ERROR";
0092     }
0093   }
0094 }
0095 
0096 // define this as a plug-in
0097 DEFINE_FWK_MODULE(HGCalWaferInfo);