File indexing completed on 2023-10-25 09:49:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #include <fstream>
0022 #include <iostream>
0023 #include <memory>
0024 #include <string>
0025 #include <vector>
0026 #include <stdlib.h>
0027 #include <cmath>
0028
0029
0030
0031 #include "FWCore/Framework/interface/Frameworkfwd.h"
0032 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0033
0034 #include "FWCore/Framework/interface/Event.h"
0035 #include "FWCore/Framework/interface/EventSetup.h"
0036 #include "FWCore/Framework/interface/MakerMacros.h"
0037
0038 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0039 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0040 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0041 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0042 #include "Geometry/HGCalCommonData/interface/HGCalParameters.h"
0043 #include "Geometry/HGCalCommonData/interface/HGCalCellUV.h"
0044 #include "Geometry/HGCalCommonData/interface/HGCalCell.h"
0045 #include "Geometry/HGCalCommonData/interface/HGCalCellOffset.h"
0046 #include "Geometry/HGCalCommonData/interface/HGCalWaferMask.h"
0047
0048 class HGCalCellOffsetTester : public edm::one::EDAnalyzer<> {
0049 public:
0050 explicit HGCalCellOffsetTester(const edm::ParameterSet&);
0051 ~HGCalCellOffsetTester() override = default;
0052 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0053
0054 void beginJob() override {}
0055 void analyze(edm::Event const& iEvent, edm::EventSetup const&) override;
0056 void endJob() override {}
0057
0058 private:
0059 const double waferSize_;
0060 const int waferType_;
0061 const int placeIndex_;
0062 const double mouseBiteCut_;
0063 const double guardRingOffset_;
0064 };
0065
0066 HGCalCellOffsetTester::HGCalCellOffsetTester(const edm::ParameterSet& iC)
0067 : waferSize_(iC.getParameter<double>("waferSize")),
0068 waferType_(iC.getParameter<int>("waferType")),
0069 placeIndex_(iC.getParameter<int>("cellPlacementIndex")),
0070 mouseBiteCut_(iC.getParameter<double>("mouseBiteCut")),
0071 guardRingOffset_(iC.getParameter<double>("guardRingOffset")) {
0072 edm::LogVerbatim("HGCalGeom") << "Test positions for wafer of size " << waferSize_ << " Type " << waferType_
0073 << " Placement Index " << placeIndex_ << " GuardRing offset " << guardRingOffset_
0074 << " Mousebite cut " << mouseBiteCut_;
0075 }
0076
0077 void HGCalCellOffsetTester::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0078 edm::ParameterSetDescription desc;
0079 desc.add<double>("waferSize", 166.4408);
0080 desc.add<int>("waferType", 0);
0081 desc.add<int>("cellPlacementIndex", 3);
0082 desc.add<double>("mouseBiteCut", 0.0);
0083 desc.add<double>("guardRingOffset", 0.0);
0084 descriptions.add("hgcalCellOffsetTester", desc);
0085 }
0086
0087
0088 void HGCalCellOffsetTester::analyze(const edm::Event&, const edm::EventSetup&) {
0089 const int nFine(12), nCoarse(8);
0090 int nCells = (waferType_ == 0) ? nFine : nCoarse;
0091 HGCalCellUV wafer(waferSize_, 0.0, nFine, nCoarse);
0092 HGCalCell wafer2(waferSize_, nFine, nCoarse);
0093 HGCalCellOffset offset(waferSize_, nFine, nCoarse, guardRingOffset_, mouseBiteCut_);
0094 edm::LogVerbatim("HGCalGeom") << "\nHGCalPartialCellTester:: nCells " << nCells << " and placement index "
0095 << placeIndex_ << "\n\n";
0096 for (int ui = 0; ui < 2 * nCells; ui++) {
0097 for (int vi = 0; vi < 2 * nCells; vi++) {
0098 if ((ui < 2 * nCells) && (vi < 2 * nCells) && ((vi - ui) < nCells) && ((ui - vi) <= nCells)) {
0099
0100 std::pair<double, double> xy1 = wafer2.cellUV2XY2(ui, vi, placeIndex_, waferType_);
0101 std::pair<double, double> xyOffset = offset.cellOffsetUV2XY1(ui, vi, placeIndex_, waferType_);
0102 std::pair<int32_t, int32_t> uv1 =
0103 wafer.cellUVFromXY1(xy1.first, xy1.second, placeIndex_, waferType_, true, false);
0104 std::string comment =
0105 ((uv1.first != ui) || (uv1.second != vi)) ? " ***** ERROR (u, v) from the methods dosent match *****" : "";
0106 edm::LogVerbatim("HGCalGeom") << "u = " << ui << " v = " << vi << " type = " << waferType_
0107 << " placement index " << placeIndex_ << " u " << uv1.first << " v " << uv1.second
0108 << " x " << xy1.first << " ,y " << xy1.second << " xoff " << xyOffset.first
0109 << " ,yoff " << xyOffset.second << comment;
0110 }
0111 }
0112 }
0113 }
0114
0115
0116 DEFINE_FWK_MODULE(HGCalCellOffsetTester);