Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-02 03:10:43

0001 // -*- C++ -*-
0002 //
0003 // Package:    HGCalValidHexTester
0004 // Class:      HGCalValidHexTester
0005 //
0006 /**\class HGCalValidHexTester HGCalValidHexTester.cc
0007  test/HGCalValidHexTester.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 2019/10/08
0017 //
0018 //
0019 
0020 // system include files
0021 #include <iostream>
0022 #include <string>
0023 #include <vector>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/MakerMacros.h"
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0034 
0035 #include "DataFormats/DetId/interface/DetId.h"
0036 #include "DataFormats/ForwardDetId/interface/HGCSiliconDetId.h"
0037 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0038 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0039 
0040 class HGCalValidHexTester : public edm::one::EDAnalyzer<> {
0041 public:
0042   explicit HGCalValidHexTester(const edm::ParameterSet&);
0043   ~HGCalValidHexTester() override {}
0044   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0045 
0046   void beginJob() override {}
0047   void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0048   void endJob() override {}
0049 
0050 private:
0051   const std::string nameDetector_, nameSense_;
0052   const std::vector<int> layers_, moduleU_, moduleV_, types_;
0053   edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> dddToken_;
0054 };
0055 
0056 HGCalValidHexTester::HGCalValidHexTester(const edm::ParameterSet& iC)
0057     : nameDetector_(iC.getParameter<std::string>("NameDevice")),
0058       nameSense_(iC.getParameter<std::string>("NameSense")),
0059       layers_(iC.getParameter<std::vector<int> >("Layers")),
0060       moduleU_(iC.getParameter<std::vector<int> >("ModuleU")),
0061       moduleV_(iC.getParameter<std::vector<int> >("ModuleV")),
0062       types_(iC.getParameter<std::vector<int> >("Types")) {
0063   dddToken_ = esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_});
0064 
0065   edm::LogVerbatim("HGCalGeom") << "Test valid cells for " << nameDetector_ << " using constants of " << nameSense_
0066                                 << " for " << layers_.size() << " modules";
0067   for (unsigned int k = 0; k < layers_.size(); ++k)
0068     edm::LogVerbatim("HGCalGeom") << "Wafer[" << k << "] Layer " << layers_[k] << " Type " << types_[k] << " U:V "
0069                                   << moduleU_[k] << ":" << moduleV_[k];
0070 }
0071 
0072 void HGCalValidHexTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0073   std::vector<int> layers = {21, 21, 22, 22};
0074   std::vector<int> modU = {3, -3, 3, -3};
0075   std::vector<int> modV = {6, -6, 6, -6};
0076   std::vector<int> types = {2, 2, 2, 2};
0077   edm::ParameterSetDescription desc;
0078   desc.add<std::string>("NameDevice", "HGCal HE Silicon");
0079   desc.add<std::string>("NameSense", "HGCalHESiliconSensitive");
0080   desc.add<std::vector<int> >("Layers", layers);
0081   desc.add<std::vector<int> >("ModuleU", modU);
0082   desc.add<std::vector<int> >("ModuleV", modV);
0083   desc.add<std::vector<int> >("Types", types);
0084   descriptions.add("hgcalValidHexTesterHEF", desc);
0085 }
0086 
0087 // ------------ method called to produce the data  ------------
0088 void HGCalValidHexTester::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0089   const DetId::Detector det = (nameSense_ == "HGCalEESensitive") ? DetId::HGCalEE : DetId::HGCalHSi;
0090   const HGCalDDDConstants& hgdc = iSetup.getData(dddToken_);
0091   edm::LogVerbatim("HGCalGeom") << nameDetector_ << " Layers = " << hgdc.layers(true) << " Sectors = " << hgdc.sectors()
0092                                 << "\n";
0093   for (unsigned int k = 0; k < layers_.size(); ++k) {
0094     int nCells = (types_[k] == 0) ? HGCSiliconDetId::HGCalFineN : HGCSiliconDetId::HGCalCoarseN;
0095     int ncell(0);
0096     for (int u = 0; u < 2 * nCells; ++u) {
0097       for (int v = 0; v < 2 * nCells; ++v) {
0098         if (((v - u) < nCells) && (u - v) <= nCells) {
0099           std::string state = hgdc.isValidHex8(layers_[k], moduleU_[k], moduleV_[k], u, v) ? "within" : "outside of";
0100           edm::LogVerbatim("HGCalGeom") << "Cell[" << k << "," << ncell << "] "
0101                                         << HGCSiliconDetId(
0102                                                det, 1, types_[k], layers_[k], moduleU_[k], moduleV_[k], u, v)
0103                                         << " is " << state << " fiducial volume";
0104           ++ncell;
0105         }
0106       }
0107     }
0108   }
0109 }
0110 
0111 // define this as a plug-in
0112 DEFINE_FWK_MODULE(HGCalValidHexTester);