34 #include <CLHEP/Vector/ThreeVector.h> 51 #include "G4ThreeVector.hh" 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")),
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);
104 double waferSize_(hgcons_.
waferSize(
false));
108 const std::vector<double> angle_{90.0, 30.0};
110 int partialType_ = 0;
114 double mouseBiteCut_ = waferSize_ *
tan(30.0 * CLHEP::deg) - 5.0;
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;
124 HGCalCellUV wafer(waferSize_, 0.0, nFine, nCoarse);
125 HGCalCell wafer2(waferSize_, nFine, nCoarse);
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";
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;
145 if (partialType_ == 11 || partialType_ == 13 || partialType_ == 15 || partialType_ == 21 || partialType_ == 23 ||
146 partialType_ == 25 || partialType_ == 0) {
149 }
else if (partialType_ == 12 || partialType_ == 14 || partialType_ == 16 || partialType_ == 22 ||
150 partialType_ == 24) {
154 std::pair<double, double> xyg = wafer2.
cellUV2XY2(ug, vg, placeIndex_, waferType_);
155 std::vector<std::pair<double, double> > wxy =
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))) <=
170 G4ThreeVector
point(
xi, yi, 0.0);
171 std::pair<int32_t, int32_t> uv5;
173 uv5 = wafer.
cellUVFromXY1(
xi, yi, placeIndex_, waferType_, partialType_,
true,
false);
175 uv5 = wafer.
cellUVFromXY2(
xi, yi, placeIndex_, waferType_, partialType_,
true,
false);
178 guard_ring_partial <<
xi <<
"," << yi << std::endl;
180 mouse_bite <<
xi <<
"," << yi << std::endl;
182 selected <<
xi <<
"," << yi << std::endl;
183 outputFile <<
xi <<
"," << yi <<
"," << uv5.first <<
"," << uv5.second <<
"," << std::endl;
188 guard_ring_partial.close();
193 auto diff_t = end_t - start_t;
195 <<
" events = " << std::chrono::duration<double, std::milli>(diff_t).
count() <<
" ms";
Log< level::Info, true > LogVerbatim
const std::string nameSense_
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
static const char layer_[]
static int getType(int index, const HGCalParameters::waferInfo_map &wafers)
bool exclude(G4ThreeVector &point, int zside, int layer, int waferU, int waferV)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const HGCalParameters * getParameter() const
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > dddToken_
std::pair< int32_t, int32_t > cellUVFromXY1(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
static int getPartial(int index, const HGCalParameters::waferInfo_map &wafers)
Log< level::Error, false > LogError
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)
static int getOrient(int index, const HGCalParameters::waferInfo_map &wafers)
void analyze(edm::Event const &iEvent, edm::EventSetup const &) override
HGCalMouseBiteTester(const edm::ParameterSet &)
Tan< T >::type tan(const T &t)
#define DEFINE_FWK_MODULE(type)
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
~HGCalMouseBiteTester() override=default
std::pair< double, double > waferPosition(int wafer, bool reco) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< double, double > cellUV2XY2(int32_t u, int32_t v, int32_t placementIndex, int32_t type)
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t * nCells
waferInfo_map waferInfoMap_
bool exclude(G4ThreeVector &point, int zside, int frontBack, int layer, int waferU, int waferV)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
*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
double waferSize(bool reco) const
int layerType(int lay) const
std::pair< int32_t, int32_t > cellUVFromXY2(double xloc, double yloc, int32_t placement, int32_t type, bool extend, bool debug) const
static constexpr int32_t layerFrontBack(int32_t layerOrient)