Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:11

0001 #include <iostream>
0002 #include <string>
0003 #include <vector>
0004 
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 
0013 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0014 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0015 #include "Geometry/HGCalGeometry/interface/HGCalMouseBite.h"
0016 #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
0017 #include "DataFormats/ForwardDetId/interface/HFNoseDetId.h"
0018 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0019 
0020 class HGCalGeometryMouseBiteTester : public edm::one::EDAnalyzer<> {
0021 public:
0022   explicit HGCalGeometryMouseBiteTester(const edm::ParameterSet&);
0023   ~HGCalGeometryMouseBiteTester() override = default;
0024 
0025   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0026 
0027 private:
0028   const std::string nameSense_, nameDetector_;
0029   const edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> dddToken_;
0030 };
0031 
0032 HGCalGeometryMouseBiteTester::HGCalGeometryMouseBiteTester(const edm::ParameterSet& iC)
0033     : nameSense_(iC.getParameter<std::string>("NameSense")),
0034       nameDetector_(iC.getParameter<std::string>("NameDevice")),
0035       dddToken_(esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
0036   edm::LogVerbatim("HGCalGeomX") << "Test mousebite for " << nameDetector_ << " using constants of " << nameSense_
0037                                  << std::endl;
0038 }
0039 
0040 void HGCalGeometryMouseBiteTester::analyze(const edm::Event&, const edm::EventSetup& iSetup) {
0041   const HGCalDDDConstants& hgdc = iSetup.getData(dddToken_);
0042   edm::LogVerbatim("HGCalGeomX") << nameDetector_ << " Layers = " << hgdc.layers(true)
0043                                  << " Sectors = " << hgdc.sectors();
0044 
0045   const auto bite = std::make_unique<HGCalMouseBite>(hgdc, false);
0046   ForwardSubdetector subdet(ForwardEmpty);
0047   DetId::Detector det;
0048   if (nameSense_ == "HGCalHESiliconSensitive") {
0049     det = DetId::HGCalHSi;
0050   } else if (nameSense_ == "HFNoseSensitive") {
0051     det = DetId::Forward;
0052     subdet = HFNose;
0053   } else {
0054     det = DetId::HGCalEE;
0055   }
0056   edm::LogVerbatim("HGCalGeomX") << "Perform test for " << nameSense_ << " Detector " << det << " SubDetector "
0057                                  << subdet;
0058 
0059   int zside(1), layer(1), waferU(1), waferV(1);
0060   int types[] = {0, 1};
0061   for (int type : types) {
0062     int ncell = (type == 0) ? HGCSiliconDetId::HGCalHighDensityN : HGCSiliconDetId::HGCalLowDensityN;
0063     edm::LogVerbatim("HGCalGeomX") << "zside " << zside << " layer " << layer << " wafer " << waferU << ":" << waferV
0064                                    << " type " << type << " cells " << ncell;
0065     for (int u = 0; u < 2 * ncell; ++u) {
0066       for (int v = 0; v < 2 * ncell; ++v) {
0067         if (((v - u) < ncell) && ((u - v) <= ncell)) {
0068           if (det == DetId::Forward) {
0069             HFNoseDetId id(zside, type, layer, waferU, waferV, u, v);
0070             edm::LogVerbatim("HGCalGeomX") << "ID: " << id << " with exclude flag " << bite->exclude(id);
0071           } else {
0072             HGCSiliconDetId id(det, zside, type, layer, waferU, waferV, u, v);
0073             edm::LogVerbatim("HGCalGeomX") << "ID: " << id << " with exclude flag " << bite->exclude(id);
0074           }
0075         }
0076       }
0077     }
0078   }
0079 }
0080 
0081 //define this as a plug-in
0082 DEFINE_FWK_MODULE(HGCalGeometryMouseBiteTester);