|
| 1 | +#include "FWCore/Framework/interface/one/EDAnalyzer.h" |
| 2 | +#include "FWCore/Framework/interface/EventSetup.h" |
| 3 | +#include "FWCore/Framework/interface/MakerMacros.h" |
| 4 | +#include "FWCore/MessageLogger/interface/MessageLogger.h" |
| 5 | +#include "FWCore/ParameterSet/interface/ParameterSet.h" |
| 6 | +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" |
| 7 | +#include "Geometry/Records/interface/IdealGeometryRecord.h" |
| 8 | +#include "Geometry/HGCalGeometry/interface/HGCalGeometry.h" |
| 9 | +#include "Geometry/HGCalCommonData/interface/HGCalWaferIndex.h" |
| 10 | +#include "Geometry/HGCalCommonData/interface/HGCalWaferType.h" |
| 11 | +#include "DataFormats/ForwardDetId/interface/HFNoseDetId.h" |
| 12 | +#include "DataFormats/ForwardDetId/interface/HGCScintillatorDetId.h" |
| 13 | +#include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h" |
| 14 | +#include <iostream> |
| 15 | + |
| 16 | +class HGCalWaferSimWt : public edm::one::EDAnalyzer<> { |
| 17 | +public: |
| 18 | + explicit HGCalWaferSimWt(const edm::ParameterSet&); |
| 19 | + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); |
| 20 | + |
| 21 | + void beginJob() override {} |
| 22 | + void analyze(edm::Event const& iEvent, edm::EventSetup const&) override; |
| 23 | + void endJob() override {} |
| 24 | + |
| 25 | +private: |
| 26 | + const std::vector<std::string> names_; |
| 27 | + std::vector<edm::ESGetToken<HGCalGeometry, IdealGeometryRecord>> geomTokens_; |
| 28 | +}; |
| 29 | + |
| 30 | +HGCalWaferSimWt::HGCalWaferSimWt(const edm::ParameterSet& iC) |
| 31 | + : names_(iC.getParameter<std::vector<std::string>>("detectorNames")) { |
| 32 | + for (unsigned int k = 0; k < names_.size(); ++k) { |
| 33 | + edm::LogVerbatim("HGCalGeomX") << "Study detector [" << k << "] " << names_[k] << std::endl; |
| 34 | + geomTokens_.emplace_back(esConsumes<HGCalGeometry, IdealGeometryRecord>(edm::ESInputTag{"", names_[k]})); |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +void HGCalWaferSimWt::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { |
| 39 | + edm::ParameterSetDescription desc; |
| 40 | + std::vector<std::string> names = {"HGCalEESensitive", "HGCalHESiliconSensitive"}; |
| 41 | + desc.add<std::vector<std::string>>("detectorNames", names); |
| 42 | + descriptions.add("hgcalWaferSimWt", desc); |
| 43 | +} |
| 44 | + |
| 45 | +void HGCalWaferSimWt::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) { |
| 46 | + std::vector<std::string> parType = {"Full", "Five", "ChopTwo", "ChopTwoM", "Half", "Semi", "Semi2", "Three", "Half2", "Five2", "JK10", "LDTop", "LDBottom", "LDLeft", "LDRight", "LDFive", "LDThree", "JK17", "JK18", "JK19", "JK20", "HDTop", "HDBottom", "HDLeft", "HDRight", "HDFive"}; |
| 47 | + std::vector<std::string> detType = {"HD120", "LD200", "LD300", "HD200"}; |
| 48 | + for (unsigned int k = 0; k < names_.size(); ++k) { |
| 49 | + const auto& geomR = iSetup.getData(geomTokens_[k]); |
| 50 | + const HGCalGeometry* geom = &geomR; |
| 51 | + const std::vector<DetId>& ids = geom->getValidDetIds(); |
| 52 | + edm::LogVerbatim("HGCalGeomX") << ids.size() << " valid Ids for detector " << names_[k] << std::endl; |
| 53 | + int nall(0), ntypes(0); |
| 54 | + std::vector<int> idxs; |
| 55 | + for (auto id : ids) { |
| 56 | + ++nall; |
| 57 | + auto cell = geom->getGeometry(id); |
| 58 | + HGCSiliconDetId hid(id); |
| 59 | + int type = hid.type(); |
| 60 | + int part = geom->topology().dddConstants().partialWaferType(hid.layer(), hid.waferU(), hid.waferV()); |
| 61 | + int idx = part*10 + type; |
| 62 | + if (std::find(idxs.begin(), idxs.end(), idx) == idxs.end()) { |
| 63 | + ++ntypes; |
| 64 | + idxs.push_back(idx); |
| 65 | + double xpos = 10.0 * (cell->getPosition().x()); |
| 66 | + double ypos = 10.0 * (cell->getPosition().y()); |
| 67 | + int waferU, waferV, cellU, cellV, cellType; |
| 68 | + double wt; |
| 69 | + geom->topology().dddConstants().waferFromPosition(xpos, ypos, hid.zside(), hid.layer(), waferU, waferV, cellU, cellV, cellType, wt, false, true); |
| 70 | + std::string stype = (type >= 0 && type <= 3) ? detType[type] : ("JK" + std::to_string(type)); |
| 71 | + std::string spart = (part >= 0 && part <= 25) ? parType[part] : ("JK" + std::to_string(part)); |
| 72 | + int index = HGCalWaferIndex::waferIndex(hid.layer(), waferU, waferV); |
| 73 | + int celltypeX = HGCalWaferType::getType(index, geom->topology().dddConstants().getParameter()->waferInfoMap_); |
| 74 | + edm::LogVerbatim("HGCalGeomX") << "[" << ntypes << "] " << stype << " " << spart << " wt " << wt << " for " << hid << " at " << xpos << ":" << ypos << " Wafer " << waferU << ":" << waferV << " cell " << cellU << ":" << cellV << " Type " << cellType << ":" << celltypeX; |
| 75 | + } |
| 76 | + } |
| 77 | + edm::LogVerbatim("HGCalGeomX") << "\n\nFinds " << idxs.size() << " different wafer types among " << nall << " cells of the detector\n"; |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +DEFINE_FWK_MODULE(HGCalWaferSimWt); |
| 82 | + |
0 commit comments