Skip to content

Commit

Permalink
Deprecate ECal cellxy.txt and use EcalGeometry instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tvami committed Aug 31, 2024
1 parent d140fd3 commit c545a43
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 2,899 deletions.
24 changes: 24 additions & 0 deletions DetDescr/include/DetDescr/EcalGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @author Patterson, UCSB
* @author Tom Eichlersmith, University of Minnesota
* @author Hongyin Liu, UCSB
* @author Tamas Almos Vami, UCSB
*/

#ifndef DETDESCR_ECALGEOMETRY_H_
Expand Down Expand Up @@ -308,6 +309,29 @@ class EcalGeometry : public framework::ConditionsObject {
return new EcalGeometry(p);
}

/**
* Is the hit based on its x,y global position and layer numbers
* fiducial in the module?
*
* @param[in] x global x position [mm]
* @param[in] y global y position [mm]
* @param[in] layer_id integer ID of the layer the hit is in
* @return bool if fiducial
*/
bool isFiducialInModule(double x, double y, int layer_id) const;

/**
* Is the hit based on its x,y global position and layer/module numbers
* fiducial in the cell?
*
* @param[in] x global x position [mm]
* @param[in] y global y position [mm]
* @param[in] layer_id integer ID of the layer the hit is in
* @param[in] module_id integer ID of the module the hit is in
* @return bool if fiducial
*/
bool isFiducialInCell(double x, double y, int layer_id, int module_id) const;

private:
/**
* Class constructor, for use only by the provider
Expand Down
52 changes: 51 additions & 1 deletion DetDescr/src/DetDescr/EcalGeometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ EcalGeometry::EcalGeometry(const framework::config::Parameters& ps)
}

EcalID EcalGeometry::getID(double x, double y, double z) const {
static const double tolerance = 0.5; // thickness of Si
static const double tolerance = 0.3; // thickness of Si
int layer_id{-1};
for (const auto& [lid, layer_xyz] : layer_pos_xy_) {
if (abs(std::get<2>(layer_xyz) - z) < tolerance) {
Expand Down Expand Up @@ -629,4 +629,54 @@ bool EcalGeometry::isInside(double normX, double normY) const {
return (dotProd > 0.);
}

bool EcalGeometry::isFiducialInModule(double x, double y, int layer_id) const {
// now assume we know the layer
// shift to center of layer
// and convert to flower coordinates
double p{x - std::get<0>(layer_pos_xy_.at(layer_id))},
q{y - std::get<1>(layer_pos_xy_.at(layer_id))};

// deduce module ID
// there are only 7 modules so we just loop through them
// all and pick out the module ID that we are inside of

int module_id{-1};
for (auto const& [mid, module_xy] : module_pos_xy_) {
double probe_x{p - module_xy.first}, probe_y{q - module_xy.second};
if (cornersSideUp_) rotate(probe_x, probe_y);
if (isInside(probe_x / moduleR_, probe_y / moduleR_)) {
module_id = mid;
break;
}
}

if (module_id < 0) {
return false;
} else {
return true;
}
}

bool EcalGeometry::isFiducialInCell(double x, double y, int layer_id,
int module_id) const {
// now assume we know the layer and module
// shift to center of layer and then center of module
double p{x - std::get<0>(layer_pos_xy_.at(layer_id)) -
module_pos_xy_.at(module_id).first},
q{y - std::get<1>(layer_pos_xy_.at(layer_id)) -
module_pos_xy_.at(module_id).second};

// need to rotate
if (cornersSideUp_) rotate(p, q);

// deduce cell ID
int cell_id = cell_id_in_module_.FindBin(p, q) - 1;

if (cell_id < 0) {
return false;
} else {
return true;
}
}

} // namespace ldmx
Loading

0 comments on commit c545a43

Please sign in to comment.