|
| 1 | +// -*- C++ -*- |
| 2 | +// |
| 3 | +// Package: HGCalListValidCells |
| 4 | +// Class: HGCalListValidCells |
| 5 | +// |
| 6 | +/**\class HGCalListValidCells HGCalListValidCells.cc |
| 7 | + test/HGCalListValidCells.cc |
| 8 | +
|
| 9 | + Description: <one line class summary> |
| 10 | +
|
| 11 | + Implementation: |
| 12 | + <Notes on implementation> |
| 13 | +*/ |
| 14 | +// |
| 15 | +// Original Author: Sunanda Banerjee |
| 16 | +// Created: Mon 2025/05/02 |
| 17 | +// |
| 18 | +// |
| 19 | + |
| 20 | +// system include files |
| 21 | +#include <algorithm> |
| 22 | +#include <iostream> |
| 23 | +#include <memory> |
| 24 | +#include <string> |
| 25 | +#include <vector> |
| 26 | + |
| 27 | +// user include files |
| 28 | +#include "FWCore/Framework/interface/Frameworkfwd.h" |
| 29 | +#include "FWCore/Framework/interface/one/EDAnalyzer.h" |
| 30 | +#include "FWCore/Framework/interface/Event.h" |
| 31 | +#include "FWCore/Framework/interface/EventSetup.h" |
| 32 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 33 | +#include "FWCore/MessageLogger/interface/MessageLogger.h" |
| 34 | +#include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 35 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 36 | + |
| 37 | +#include "DataFormats/DetId/interface/DetId.h" |
| 38 | +#include "DataFormats/GeometryVector/interface/GlobalPoint.h" |
| 39 | +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" |
| 40 | +#include "Geometry/Records/interface/IdealGeometryRecord.h" |
| 41 | + |
| 42 | +class HGCalListValidCells : public edm::one::EDAnalyzer<> { |
| 43 | +public: |
| 44 | + explicit HGCalListValidCells(const edm::ParameterSet&); |
| 45 | + ~HGCalListValidCells() override = default; |
| 46 | + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); |
| 47 | + |
| 48 | + void beginJob() override {} |
| 49 | + void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; |
| 50 | + void endJob() override {} |
| 51 | + |
| 52 | +private: |
| 53 | + const std::string name_; |
| 54 | + const int partialType_, verbosity_; |
| 55 | + const edm::ESGetToken<HGCalGeometry, IdealGeometryRecord> geomToken_; |
| 56 | +}; |
| 57 | + |
| 58 | +HGCalListValidCells::HGCalListValidCells(const edm::ParameterSet& iC) |
| 59 | + : name_(iC.getParameter<std::string>("detector")), |
| 60 | + partialType_(iC.getParameter<int>("partialType")), |
| 61 | + verbosity_(iC.getParameter<int>("verbosity")), |
| 62 | + geomToken_(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag("", name_))) {} |
| 63 | + |
| 64 | +void HGCalListValidCells::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 65 | + edm::ParameterSetDescription desc; |
| 66 | + desc.add<std::string>("detector", "HGCalEESensitive"); |
| 67 | + desc.add<int>("partialType", 16); |
| 68 | + desc.add<int>("verbosity", 0); |
| 69 | + descriptions.add("hgcalListValidCellsEE", desc); |
| 70 | +} |
| 71 | + |
| 72 | +// ------------ method called to produce the data ------------ |
| 73 | +void HGCalListValidCells::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { |
| 74 | + const auto& geom = &iSetup.getData(geomToken_); |
| 75 | + DetId::Detector det = (name_ == "HGCalHESiliconSensitive") ? DetId::HGCalHSi : DetId::HGCalEE; |
| 76 | + edm::LogVerbatim("HGCalGeom") << "Perform test for " << name_ << " Detector " << det; |
| 77 | + |
| 78 | + std::string parts[26] = {"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2", |
| 79 | + "Five2", "????", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "????", |
| 80 | + "????", "????", "????", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive"}; |
| 81 | + const std::vector<DetId>& ids = geom->getValidDetIds(); |
| 82 | + edm::LogVerbatim("HGCalGeom") << "Find the list of valid DetIds of type " << partialType_ << ":" |
| 83 | + << parts[partialType_] << " among a list of " << ids.size() << " valid ids of " |
| 84 | + << geom->cellElement(); |
| 85 | + std::vector<HGCSiliconDetId> detIds; |
| 86 | + |
| 87 | + for (auto const& id : ids) { |
| 88 | + if ((id.det() == DetId::HGCalEE) || (id.det() == DetId::HGCalHSi)) { |
| 89 | + HGCSiliconDetId detId(id); |
| 90 | + HGCalParameters::waferInfo info = |
| 91 | + geom->topology().dddConstants().waferInfo(detId.layer(), detId.waferU(), detId.waferV()); |
| 92 | + if (info.part == partialType_) { |
| 93 | + if (std::find(detIds.begin(), detIds.end(), detId) == detIds.end()) |
| 94 | + detIds.emplace_back(detId); |
| 95 | + } |
| 96 | + } else { |
| 97 | + edm::LogVerbatim("HGCalGeom") << "Illegal Det " << id.det() << " in " << std::hex << id.rawId() << std::dec |
| 98 | + << " ERROR"; |
| 99 | + } |
| 100 | + } |
| 101 | + edm::LogVerbatim("HGCalGeom") << "There are " << detIds.size() << " valid Ids with partial type " << partialType_ |
| 102 | + << ":" << parts[partialType_]; |
| 103 | + if (verbosity_ > 0) { |
| 104 | + for (auto const detId : detIds) |
| 105 | + edm::LogVerbatim("HGCalGeom") << " " << detId; |
| 106 | + } |
| 107 | + |
| 108 | + if (detIds.size() > 0) { |
| 109 | + std::vector<int> cellPatterns; |
| 110 | + for (auto const& detId : detIds) { |
| 111 | + int iuv = (100 * detId.cellU() + detId.cellV()); |
| 112 | + if (std::find(cellPatterns.begin(), cellPatterns.end(), iuv) == cellPatterns.end()) |
| 113 | + cellPatterns.emplace_back(iuv); |
| 114 | + } |
| 115 | + std::sort(cellPatterns.begin(), cellPatterns.end()); |
| 116 | + edm::LogVerbatim("HGCalGeom") << "There are " << cellPatterns.size() << " different cell patterns:"; |
| 117 | + for (const auto& iuv : cellPatterns) { |
| 118 | + int u = ((iuv / 100) % 100); |
| 119 | + int v = (iuv % 100); |
| 120 | + edm::LogVerbatim("HGCalGeom") << "u = " << std::setw(3) << u << " v = " << std::setw(3) << v; |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | +// define this as a plug-in |
| 126 | +DEFINE_FWK_MODULE(HGCalListValidCells); |
0 commit comments