Skip to content

Commit

Permalink
Persist the HCAL bar's orientation (#1577)
Browse files Browse the repository at this point in the history
  • Loading branch information
tvami authored Feb 6, 2025
1 parent 2723bfb commit 8a3e0cf
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 17 deletions.
50 changes: 43 additions & 7 deletions Hcal/include/Hcal/Event/HcalHit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* @file HcalHit.h
* @brief Class that stores Stores reconstructed hit information from the HCAL
* @author Jeremy Mans, University of Minnesota
* @author Tamas Almos Vami, UCSB, added orientation members
*/

#ifndef HCAL_EVENT_HCALHIT_H_
Expand Down Expand Up @@ -111,6 +112,39 @@ class HcalHit : public ldmx::CalorimeterHit {
*/
int getAmplitudeNeg() const { return amplitudeNeg_; }

/**
* Get the position of the hit
* @return position
*/
double getPosition() const { return position_; }

/**
* Get if bar is oriented in X
* @return true if oriented in X
*/
bool isOrientationX_() const { return orientation_ == 0; }

/**
* Get if bar is oriented in Y
* @return true if oriented in Y
*/
bool isOrientationY_() const { return orientation_ == 1; }

/**
* Get if bar is oriented in Z
* @return true if oriented in Z
*/
bool isOrientationZ_() const { return orientation_ == 2; }

/**
* Get the time difference between the two ends
* Note: only applies for double ended readout
* @return timeDiff
*/
double getTimeDiff() const { return timeDiff_; }

// Now the setters

/**
* Set the number of photoelectrons estimated for this hit.
* @param pe Number of photoelectrons, including noise which affects the
Expand Down Expand Up @@ -188,14 +222,16 @@ class HcalHit : public ldmx::CalorimeterHit {
/**
* Set original position
*/
void setPositionUnchanged(double position, int isX) {
void setPositionUnchanged(double position, int orientation) {
position_ = position;
isX_ = isX;
orientation_ = orientation;
}

double getPosition() const { return position_; }
int getIsX() const { return isX_; }
double getTimeDiff() const { return timeDiff_; }
/**
* Set if the bar is orientied in X / Y / Z
* meanig 0 / 1 / 2, respectively
*/
void setOrientation(int orientation) { orientation_ = orientation; }

private:
/** The number of PE estimated for this hit. */
Expand All @@ -216,7 +252,7 @@ class HcalHit : public ldmx::CalorimeterHit {

double timeDiff_{-9999.};
double position_{-9999.};
double isX_{-9999.};
int orientation_{-9999};

double toaPos_{-9999.};
double toaNeg_{-9999.};
Expand All @@ -226,7 +262,7 @@ class HcalHit : public ldmx::CalorimeterHit {
/**
* The ROOT class definition.
*/
ClassDef(HcalHit, 4);
ClassDef(HcalHit, 5);
};
} // namespace ldmx

Expand Down
12 changes: 5 additions & 7 deletions Hcal/src/Hcal/HcalDoubleEndRecProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ void HcalDoubleEndRecProducer::produce(framework::Event& event) {
// get bar position from geometry
auto position = hcalGeometry.getStripCenterPosition(id);
const auto orientation{hcalGeometry.getScintillatorOrientation(id)};
int orientation_int = static_cast<int>(orientation);

// skip non-double-ended layers
if (id.section() != ldmx::HcalID::HcalSection::BACK) continue;
Expand Down Expand Up @@ -105,21 +106,18 @@ void HcalDoubleEndRecProducer::produce(framework::Event& event) {

int position_bar_sign = hitTimeDiff > 0 ? 1 : -1;
double position_unchanged = 0;
int isX = 0;
double position_bar = position_bar_sign * fabs(hitTimeDiff) * v / 2;
if (orientation ==
ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
position_unchanged = position.X();
isX = 1;
position.SetX(position_bar);
} else {
position_unchanged = position.Y();
isX = 0;
position.SetY(position_bar);
}
// std::cout << "position unchanged " << position_unchanged << " isx " <<
// isX << std::endl; std::cout << "newposition " << position.X() << " " <<
// position.Y() << " " << position.Z() << std::endl;
// std::cout << "position unchanged " << position_unchanged << " orientation
// " << orientation_int << std::endl; std::cout << "newposition " <<
// position.X() << " " << position.Y() << " " << position.Z() << std::endl;

// TODO: switch unique hit time for this pulse
[[maybe_unused]] double hitTime =
Expand Down Expand Up @@ -151,7 +149,7 @@ void HcalDoubleEndRecProducer::produce(framework::Event& event) {
recHit.setEnergy(reconstructed_energy);
recHit.setTime(hitTimeDiff);
recHit.setTimeDiff(hitPosEnd.getTime() - hitNegEnd.getTime());
recHit.setPositionUnchanged(position_unchanged, isX);
recHit.setPositionUnchanged(position_unchanged, orientation_int);
doubleHcalRecHits.push_back(recHit);
}

Expand Down
10 changes: 7 additions & 3 deletions Hcal/src/Hcal/HcalRecProducer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ void HcalRecProducer::produce(framework::Event& event) {
double amplT_posend(0.), amplTm1_posend(0.);
double amplT_negend(0.), amplTm1_negend(0.);

// Check if the bar is oriented in X or Y
const auto orientation{hcalGeometry.getScintillatorOrientation(id)};
int orientation_int = static_cast<int>(orientation);

// double readout
if (id.section() == ldmx::HcalID::HcalSection::BACK) {
auto digi_negend = hcalDigis.getDigi(iDigi + 1);
Expand Down Expand Up @@ -228,8 +232,8 @@ void HcalRecProducer::produce(framework::Event& event) {

// get x(y) coordinate from TOA measurement = (dt*v/2)
// if time_posend < time_negend: position is positive
double v =
299.792 / 1.6; // velocity of light in polystyrene, n = 1.6 = c/v
// velocity of light in polystyrene, n = 1.6 = c/v
double v = 299.792 / 1.6;
double position_bar =
position_bar_sign * fabs(TOA_posend - TOA_negend) * v / 2;

Expand All @@ -250,7 +254,6 @@ void HcalRecProducer::produce(framework::Event& event) {
// set amplitude as the average of both bars (reverse attenuated)
amplT = (amplT_posend / att_posend + amplT_negend / att_negend) / 2;

const auto orientation{hcalGeometry.getScintillatorOrientation(id)};
// set position along the bar
if (orientation ==
ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
Expand Down Expand Up @@ -358,6 +361,7 @@ void HcalRecProducer::produce(framework::Event& event) {
recHit.setAmplitude((amplT / voltage_per_mip_) * mip_energy_);
recHit.setEnergy(reconstructed_energy);
recHit.setTime(hitTime);
recHit.setOrientation(orientation_int);
hcalRecHits.push_back(recHit);
}

Expand Down

0 comments on commit 8a3e0cf

Please sign in to comment.