CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
HGCalMouseBiteTester Class Reference

#include <HGCalMouseBiteTester.cc>

Inheritance diagram for HGCalMouseBiteTester:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &iEvent, edm::EventSetup const &) override
 
void beginJob () override
 
void endJob () override
 
 HGCalMouseBiteTester (const edm::ParameterSet &)
 
 ~HGCalMouseBiteTester () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecorddddToken_
 
const int layer_
 
const std::string nameSense_
 
const int nTrials_
 
std::ofstream outputFile
 
const int waferU_
 
const int waferV_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

plugins/HGCalMouseBiteTester.cc

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 53 of file HGCalMouseBiteTester.cc.

Constructor & Destructor Documentation

◆ HGCalMouseBiteTester()

HGCalMouseBiteTester::HGCalMouseBiteTester ( const edm::ParameterSet iC)
explicit

Definition at line 73 of file HGCalMouseBiteTester.cc.

References nameSense_.

74  : nameSense_(iC.getParameter<std::string>("nameSense")),
75  waferU_(iC.getParameter<int>("waferU")),
76  waferV_(iC.getParameter<int>("waferV")),
77  nTrials_(iC.getParameter<int>("numbberOfTrials")),
78  layer_(iC.getParameter<int>("layer")),
79  dddToken_(esConsumes<HGCalDDDConstants, IdealGeometryRecord>(edm::ESInputTag{"", nameSense_})) {
80  edm::LogVerbatim("HGCalGeom") << "Test Guard_Ring for wafer in layer" << layer_ << " U " << waferU_ << " V "
81  << waferV_ << " with " << nTrials_ << " trials";
82 
83  outputFile.open("full1.csv");
84  if (!outputFile.is_open()) {
85  edm::LogError("HGCalGeom") << "Could not open output file.";
86  } else {
87  outputFile << "x,y,u,v,\n";
88  }
89 }
Log< level::Info, true > LogVerbatim
const std::string nameSense_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > dddToken_
Log< level::Error, false > LogError

◆ ~HGCalMouseBiteTester()

HGCalMouseBiteTester::~HGCalMouseBiteTester ( )
overridedefault

Member Function Documentation

◆ analyze()

void HGCalMouseBiteTester::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 102 of file HGCalMouseBiteTester.cc.

References HGCalCell::cellPlacementIndex(), HGCalCell::cellUV2XY2(), HGCalCellUV::cellUVFromXY1(), HGCalCellUV::cellUVFromXY2(), submitPVResolutionJobs::count, gather_cfg::cout, dddToken_, HGCGuardRingPartial::exclude(), HGCMouseBite::exclude(), edm::EventSetup::getData(), HGCalWaferType::getOrient(), HGCalDDDConstants::getParameter(), HGCalWaferType::getPartial(), HGCalWaferType::getType(), mps_fire::i, layer_, HGCalTypes::layerFrontBack(), HGCalDDDConstants::layerType(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::nCells, submitPVValidationJobs::now, nTrials_, hgcalPerformanceValidation::orient, outputFile, point, diffTwoXMLs::r2, mathSSE::sqrt(), funct::tan(), HGCalDDDConstants::v17OrLess(), HGCalWaferIndex::waferIndex(), HGCalParameters::waferInfoMap_, HGCalDDDConstants::waferPosition(), HGCalDDDConstants::waferSize(), waferU_, waferV_, HGCalWaferMask::waferXY(), protons_cff::xi, geometryCSVtoXML::xy, and ecaldqm::zside().

102  {
103  const HGCalDDDConstants& hgcons_ = iSetup.getData(dddToken_);
104  double waferSize_(hgcons_.waferSize(false));
105  int zside(1);
106  int layertype = hgcons_.layerType(layer_);
107  int frontBack = HGCalTypes::layerFrontBack(layertype);
108  const std::vector<double> angle_{90.0, 30.0};
110  int partialType_ = 0;
112  int placeIndex_ = HGCalCell::cellPlacementIndex(zside, frontBack, orient);
113  int waferType_ = HGCalWaferType::getType(index, hgcons_.getParameter()->waferInfoMap_);
114  double mouseBiteCut_ = waferSize_ * tan(30.0 * CLHEP::deg) - 5.0;
115  bool v17OrLess = hgcons_.v17OrLess();
116  HGCGuardRing guardRing_(hgcons_);
117  HGCGuardRingPartial guardRingPartial_(hgcons_);
118  HGCMouseBite mouseBite_(hgcons_, angle_, mouseBiteCut_, true);
119  const int nFine(12), nCoarse(8);
120  double r2 = 0.5 * waferSize_;
121  double R2 = 2 * r2 / sqrt(3);
122  int nCells = (waferType_ == 0) ? nFine : nCoarse;
123  std::cout << "start" << std::endl;
124  HGCalCellUV wafer(waferSize_, 0.0, nFine, nCoarse);
125  HGCalCell wafer2(waferSize_, nFine, nCoarse);
126  std::pair<double, double> xy = hgcons_.waferPosition(layer_, waferU_, waferV_, false, false);
127  double x0 = (zside > 0) ? xy.first : -xy.first;
128  double y0 = xy.second;
129  std::ofstream guard_ring("Guard_ring.csv");
130  std::ofstream guard_ring_partial("Guard_ring_partial.csv");
131  std::ofstream mouse_bite("Mouse_bite.csv");
132  std::ofstream selected("Selected.csv");
133  edm::LogVerbatim("HGCalGeom") << "\nHGCalMouseBiteTester:: nCells " << nCells << " FrontBack " << frontBack
134  << " Wafer Size " << waferSize_ << " and placement index " << placeIndex_
135  << " WaferType " << waferType_ << " Partial " << partialType_ << " WaferX " << x0
136  << " WaferY " << y0 << "\n\n";
138 
139  for (int i = 0; i < nTrials_; i++) {
140  double xi = (2 * r2 * static_cast<double>(rand()) / RAND_MAX) - r2;
141  double yi = (2 * R2 * static_cast<double>(rand()) / RAND_MAX) - R2;
142  bool goodPoint = true;
143  int ug = 0;
144  int vg = 0;
145  if (partialType_ == 11 || partialType_ == 13 || partialType_ == 15 || partialType_ == 21 || partialType_ == 23 ||
146  partialType_ == 25 || partialType_ == 0) {
147  ug = 0;
148  vg = 0;
149  } else if (partialType_ == 12 || partialType_ == 14 || partialType_ == 16 || partialType_ == 22 ||
150  partialType_ == 24) {
151  ug = nCells + 1;
152  vg = 2 * (nCells - 1);
153  }
154  std::pair<double, double> xyg = wafer2.cellUV2XY2(ug, vg, placeIndex_, waferType_);
155  std::vector<std::pair<double, double> > wxy =
156  HGCalWaferMask::waferXY(0, placeIndex_, waferSize_, 0.0, 0.0, 0.0, v17OrLess);
157  for (unsigned int i = 0; i < (wxy.size() - 1); ++i) {
158  double xp1 = wxy[i].first;
159  double yp1 = wxy[i].second;
160  double xp2 = wxy[i + 1].first;
161  double yp2 = wxy[i + 1].second;
162  if ((((xi - xp1) / (xp2 - xp1)) - ((yi - yp1) / (yp2 - yp1))) *
163  (((xyg.first - xp1) / (xp2 - xp1)) - ((xyg.second - yp1) / (yp2 - yp1))) <=
164  0) {
165  goodPoint = false;
166  }
167  }
168  if (goodPoint) { //Only allowing (x, y) inside a partial wafer 11, placement index 2
169  partialType_ = HGCalWaferType::getPartial(index, hgcons_.getParameter()->waferInfoMap_);
170  G4ThreeVector point(xi, yi, 0.0);
171  std::pair<int32_t, int32_t> uv5;
172  if (hgcons_.v17OrLess()) {
173  uv5 = wafer.cellUVFromXY1(xi, yi, placeIndex_, waferType_, partialType_, true, false);
174  } else {
175  uv5 = wafer.cellUVFromXY2(xi, yi, placeIndex_, waferType_, partialType_, true, false);
176  }
177  if (guardRingPartial_.exclude(point, zside, frontBack, layer_, waferU_, waferV_)) {
178  guard_ring_partial << xi << "," << yi << std::endl;
179  } else if (mouseBite_.exclude(point, zside, layer_, waferU_, waferV_)) {
180  mouse_bite << xi << "," << yi << std::endl;
181  } else {
182  selected << xi << "," << yi << std::endl;
183  outputFile << xi << "," << yi << "," << uv5.first << "," << uv5.second << "," << std::endl;
184  }
185  }
186  }
187  guard_ring.close();
188  guard_ring_partial.close();
189  mouse_bite.close();
190  selected.close();
191  outputFile.close();
193  auto diff_t = end_t - start_t;
194  edm::LogVerbatim("HGCalGeom") << "Execution time for " << nTrials_
195  << " events = " << std::chrono::duration<double, std::milli>(diff_t).count() << " ms";
196 }
Log< level::Info, true > LogVerbatim
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
Definition: HGCalCell.cc:237
static int getType(int index, const HGCalParameters::waferInfo_map &wafers)
const HGCalParameters * getParameter() const
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > dddToken_
static int getPartial(int index, const HGCalParameters::waferInfo_map &wafers)
int zside(DetId const &)
static std::vector< std::pair< double, double > > waferXY(const int &part, const int &orient, const int &zside, const double &waferSize, const double &offset, const double &xpos, const double &ypos, const bool &v17)
bool v17OrLess() const
static int getOrient(int index, const HGCalParameters::waferInfo_map &wafers)
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
std::pair< double, double > waferPosition(int wafer, bool reco) const
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t * nCells
waferInfo_map waferInfoMap_
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double waferSize(bool reco) const
int layerType(int lay) const
static constexpr int32_t layerFrontBack(int32_t layerOrient)
Definition: HGCalTypes.h:137

◆ beginJob()

void HGCalMouseBiteTester::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 59 of file HGCalMouseBiteTester.cc.

59 {}

◆ endJob()

void HGCalMouseBiteTester::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 61 of file HGCalMouseBiteTester.cc.

61 {}

◆ fillDescriptions()

void HGCalMouseBiteTester::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 91 of file HGCalMouseBiteTester.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

91  {
93  desc.add<std::string>("nameSense", "HGCalEESensitive");
94  desc.add<int>("waferU", 1);
95  desc.add<int>("waferV", 9);
96  desc.add<int>("numbberOfTrials", 1000000);
97  desc.add<int>("layer", 1);
98  descriptions.add("hgcalMouseBiteTester", desc);
99 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ dddToken_

const edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> HGCalMouseBiteTester::dddToken_
private

Definition at line 69 of file HGCalMouseBiteTester.cc.

Referenced by analyze().

◆ layer_

const int HGCalMouseBiteTester::layer_
private

Definition at line 68 of file HGCalMouseBiteTester.cc.

Referenced by analyze().

◆ nameSense_

const std::string HGCalMouseBiteTester::nameSense_
private

Definition at line 64 of file HGCalMouseBiteTester.cc.

Referenced by HGCalMouseBiteTester().

◆ nTrials_

const int HGCalMouseBiteTester::nTrials_
private

Definition at line 67 of file HGCalMouseBiteTester.cc.

Referenced by analyze().

◆ outputFile

std::ofstream HGCalMouseBiteTester::outputFile
private

Definition at line 70 of file HGCalMouseBiteTester.cc.

Referenced by analyze().

◆ waferU_

const int HGCalMouseBiteTester::waferU_
private

Definition at line 65 of file HGCalMouseBiteTester.cc.

Referenced by analyze().

◆ waferV_

const int HGCalMouseBiteTester::waferV_
private

Definition at line 66 of file HGCalMouseBiteTester.cc.

Referenced by analyze().