Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZDC: LYSO + SiPM-on-tile #1221

Merged
merged 134 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 123 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
0460774
Added digitization for SiPM-on-tile ZDC hits
bschmookler Nov 14, 2023
2ebd588
Merge branch 'main' into sipmzdc
bschmookler Nov 20, 2023
7f24d2a
Merge branch 'main' into sipmzdc
bschmookler Nov 22, 2023
dd5b9cc
added HEXPLIT and LogWeightReco algorithms and implemented them for t…
sebouh137 Dec 6, 2023
94d040e
added files that I had missed earlier
sebouh137 Dec 6, 2023
f56be11
Resolved merge conflict
bschmookler Dec 7, 2023
90d7dda
Merge branch 'sipmzdc' of github.com:eic/EICrecon into sipmzdc
bschmookler Dec 7, 2023
f7c1ec7
updated HEXPLIT algorithm code after testing and debugging. Also add…
sebouh137 Dec 8, 2023
724282b
renamed the clusters made from the HEXPLIT subcell hits
sebouh137 Dec 8, 2023
04f7881
fixed sloppy-copied comments in one of the files
sebouh137 Dec 11, 2023
15243e1
Merge branch 'main' into sipmzdc
bschmookler Dec 11, 2023
7e22a50
Updated default collections
bschmookler Dec 11, 2023
89f2d65
made LogWeightReco take in protoclusters collection instead of calori…
sebouh137 Dec 14, 2023
a677cd1
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Dec 14, 2023
20f6436
Weibin's changes
sebouh137 Dec 16, 2023
dd86f03
removed factoryT.h for HEXPLIT and LogWeightReco, and only using fact…
sebouh137 Dec 18, 2023
eb38d1b
Merge remote-tracking branch 'origin/main' into sipmzdc
sebouh137 Jan 12, 2024
ade3733
Update ZDC.cc
sebouh137 Jan 12, 2024
c81e140
Update ZDC.cc
sebouh137 Jan 12, 2024
f8275eb
Update ZDC.cc
sebouh137 Jan 12, 2024
74618e3
Update JEventProcessorPODIO.cc
sebouh137 Jan 12, 2024
387ac3d
Update JEventProcessorPODIO.cc
sebouh137 Jan 12, 2024
084df26
Update ZDC.cc
sebouh137 Jan 12, 2024
c602b11
Update ZDC.cc
sebouh137 Jan 12, 2024
98a603d
Update JEventProcessorPODIO.cc
sebouh137 Jan 12, 2024
c4701fe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 12, 2024
8b93eb9
Update HEXPLIT.cc
sebouh137 Jan 13, 2024
680392e
Update HEXPLITConfig.h
sebouh137 Jan 13, 2024
f6263c7
Update HEXPLIT_factory.h
sebouh137 Jan 13, 2024
f133402
Update ZDC.cc
sebouh137 Jan 13, 2024
d71845f
Update HEXPLIT.cc
sebouh137 Jan 13, 2024
22dfc61
get the global positions of hits using the volume manager
sebouh137 Jan 13, 2024
072bbfa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2024
0ccf939
avoid using large arrays such as x[], y[], z[]
sebouh137 Jan 13, 2024
03c069a
merge
sebouh137 Jan 13, 2024
125559e
use iteration over the hits, instead of using nhits
sebouh137 Jan 13, 2024
955934d
for(const auto& hit: hits)
sebouh137 Jan 13, 2024
9eea2e6
fixed an issue with units regarding Emin
sebouh137 Jan 13, 2024
0a4c529
removed commented code
sebouh137 Jan 13, 2024
1b5f8f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2024
331f6c3
use vector constructor for Eneighbors
sebouh137 Jan 13, 2024
5e158e3
merge
sebouh137 Jan 13, 2024
b907230
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2024
cfc5e9a
use typeid for this instead of hit-by-hit string comparisons
sebouh137 Jan 13, 2024
7674cc9
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 13, 2024
b32dcb1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 13, 2024
75a6703
removed side_length and layer_spacing from configuration in HEXPLIT
sebouh137 Jan 15, 2024
941f81d
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 15, 2024
83e0a79
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 15, 2024
83ac9e7
Merge branch 'main' into sipmzdc
sebouh137 Jan 15, 2024
1e935e5
removed LogWeightReco, instead using CalorimeterClusterRecoCoG with e…
sebouh137 Jan 15, 2024
2e02850
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 15, 2024
72211f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 15, 2024
911c11f
removed broken include statement from previous commit
sebouh137 Jan 15, 2024
0227709
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 15, 2024
adf6307
removed the files for the LogWeightReco
sebouh137 Jan 15, 2024
d65db8c
Merge branch 'main' into sipmzdc
sebouh137 Jan 15, 2024
ae7fbae
made the arrays in HEXPLIT.h constant, and moved them to HEXPLIT.cc
sebouh137 Jan 15, 2024
841fd25
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 15, 2024
60010f2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 15, 2024
f15e476
removed include for Eigen in HEXPLIT
sebouh137 Jan 16, 2024
18bd2ea
Update ZDC.cc
sebouh137 Jan 16, 2024
0a6ef4e
Update HEXPLIT.cc
sebouh137 Jan 16, 2024
3d47079
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 16, 2024
a94b716
Update JEventProcessorPODIO.cc
sebouh137 Jan 16, 2024
39d5c0a
use the correct units for converting the local to global position in …
sebouh137 Jan 17, 2024
bfbd563
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 17, 2024
74bcf80
fixed input and output list for CoG recon in ZDC.cc
sebouh137 Jan 17, 2024
9c685e0
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 17, 2024
d7993a4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 17, 2024
acafa2f
fixed a bug involving the 'tol' value.
sebouh137 Jan 17, 2024
3eeda0b
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 17, 2024
40acbc2
reverted an earlier commit taht was causing problems at runtime invol…
sebouh137 Jan 17, 2024
331ceed
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 17, 2024
ca7bea1
Merge branch 'main' into sipmzdc
sebouh137 Jan 17, 2024
3751e66
explicitly cast to float (avoids compiler errors)
sebouh137 Jan 17, 2024
c678353
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 17, 2024
e038edc
static_cast to float (avoids compiler errors)
sebouh137 Jan 17, 2024
656220e
fiksed a mispelled werd in teh coments in the HEXPLIT.cc code
sebouh137 Jan 17, 2024
803d405
fixed parenthesis problem from previous commit
sebouh137 Jan 17, 2024
d90afcc
Update CalorimeterHitReco.cc
sebouh137 Jan 18, 2024
423a26a
Update src/algorithms/calorimetry/HEXPLITConfig.h
sebouh137 Jan 18, 2024
9001a26
Update src/algorithms/calorimetry/HEXPLIT.cc
sebouh137 Jan 18, 2024
26ea571
Update src/factories/calorimetry/HEXPLIT_factory.h
sebouh137 Jan 18, 2024
5c0c0e0
Update src/algorithms/calorimetry/CalorimeterHitReco.cc
sebouh137 Jan 18, 2024
b323bc6
Update src/algorithms/calorimetry/HEXPLIT.cc
sebouh137 Jan 18, 2024
208c17e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 18, 2024
9a97d85
Update src/algorithms/calorimetry/HEXPLIT.h
sebouh137 Jan 18, 2024
e5f6617
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 18, 2024
d20a4f2
Update src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc
sebouh137 Jan 18, 2024
1707f0b
Update src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h
sebouh137 Jan 18, 2024
518044b
Update src/factories/calorimetry/CalorimeterClusterRecoCoG_factory.h
sebouh137 Jan 18, 2024
b8c3e7c
Update src/algorithms/calorimetry/HEXPLIT.h
sebouh137 Jan 18, 2024
f4b22a9
removed parameter variableLogWeightBase from ZDC.cc
sebouh137 Jan 18, 2024
e0dece1
use the correct 'algorithm' interface
sebouh137 Jan 18, 2024
9104f46
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 18, 2024
4f3b900
Update src/algorithms/calorimetry/HEXPLIT.h
sebouh137 Jan 18, 2024
2e4e7da
undo earlier commit that did not compile correctly
sebouh137 Jan 18, 2024
7404c50
added a test for the HEXPLIT algorithm. Doesn't work yet, adding it …
sebouh137 Jan 19, 2024
5cc0ff5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 19, 2024
c85ed35
working on writing the test for the HEXPLIT algorithm. Doesn't work …
sebouh137 Jan 19, 2024
bab5b0c
merge
sebouh137 Jan 19, 2024
e092105
created a working test for HEXPLIT
sebouh137 Jan 21, 2024
5e36910
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2024
2a62af3
cleaned up the code for the test for the HEXPLIT algorithm; removed c…
sebouh137 Jan 21, 2024
a669fe3
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 21, 2024
f6948f1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2024
3d3b21b
Merge branch 'main' into sipmzdc
sebouh137 Jan 21, 2024
a7340dc
test if commenting out some of the unused factories will cause it to …
sebouh137 Jan 21, 2024
1ffb055
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 21, 2024
d84b9ce
test if commenting out some of the unused factories will cause it to …
sebouh137 Jan 21, 2024
a5d741f
test if commenting out some of the unused factories will cause it to …
sebouh137 Jan 21, 2024
5c1a296
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 21, 2024
7e6b62e
test if commenting out some of the unused factories will cause it to …
sebouh137 Jan 22, 2024
233a890
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 22, 2024
ea2fc2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
1988de2
fix the top of the the HEXPLIT test codefile. correct the copyright …
sebouh137 Jan 22, 2024
2cb2c52
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 22, 2024
b736270
test if reducing sampling fraction fixes issue in CoG factory for ZDC
sebouh137 Jan 22, 2024
d71719d
fix naming conflict among banks in ZDC plugin
sebouh137 Jan 22, 2024
0005f07
try to appease the iwyu
sebouh137 Jan 22, 2024
7c156ab
try to appease iwyu
sebouh137 Jan 22, 2024
8b5daeb
undo previous commit.
sebouh137 Jan 22, 2024
752aad4
use constants for the number of subcells per cell, the number of posi…
sebouh137 Jan 22, 2024
3e207c9
fixed the naming conventions for the ZDC
sebouh137 Jan 22, 2024
225ba85
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
4b3eca1
fixed the naming conventions for the ZDC
sebouh137 Jan 22, 2024
89e23fd
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 22, 2024
e51ced0
fixed the order of the bank names
sebouh137 Jan 22, 2024
9dc9ff1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 22, 2024
8c03d5a
fixed a missing end quote
sebouh137 Jan 23, 2024
bf382b6
Merge branch 'sipmzdc' of https://github.com/eic/EICrecon into sipmzdc
sebouh137 Jan 23, 2024
87d906d
use lambdas to set the values in the neighbor and subcell offsets in …
sebouh137 Jan 23, 2024
baebf9f
simplified the parameters list for CalorimeterClusterRecoCoG
sebouh137 Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/algorithms/calorimetry/CalorimeterClusterRecoCoG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,18 @@ std::optional<edm4eic::Cluster> CalorimeterClusterRecoCoG::reconstruct(const edm
// center of gravity with logarithmic weighting
float tw = 0.;
auto v = cl.getPosition();

double logWeightBase=m_cfg.logWeightBase;
if ((m_cfg.logWeightBase_lin != 0) || (m_cfg.logWeightBase_quad != 0)){
double l=log(cl.getEnergy()/m_cfg.logWeightBase_Eref);
logWeightBase+=m_cfg.logWeightBase_lin*l+m_cfg.logWeightBase_quad*l*l;
}

for (unsigned i = 0; i < pcl.getHits().size(); ++i) {
const auto& hit = pcl.getHits()[i];
const auto weight = pcl.getWeights()[i];
// _DBG_<<" -- weight = " << weight << " E=" << hit.getEnergy() << " totalE=" <<totalE << " log(E/totalE)=" << std::log(hit.getEnergy()/totalE) << std::endl;
float w = weightFunc(hit.getEnergy() * weight, totalE, m_cfg.logWeightBase, 0);
float w = weightFunc(hit.getEnergy() * weight, totalE, logWeightBase, 0);
tw += w;
v = v + (hit.getPosition() * w);
}
Expand Down
7 changes: 7 additions & 0 deletions src/algorithms/calorimetry/CalorimeterClusterRecoCoGConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ namespace eicrecon {
double sampFrac = 1.;
double logWeightBase = 3.6;

//optional: have the log weight base depend on the energy
// logWeightBase+logWeightBase_lin*l+logWeightBase_quad*l*l
// where l = log(cl.getEnergy()/logWeightBase_Eref)
double logWeightBase_lin=0;
double logWeightBase_quad=0;
double logWeightBase_Eref=50;

sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
// Constrain the cluster position eta to be within
// the eta of the contributing hits. This is useful to avoid edge effects
// for endcaps.
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/calorimetry/CalorimeterHitReco.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void CalorimeterHitReco::process(
std::vector<double> cdim;
// get segmentation dimensions
auto segmentation_type = m_converter->findReadout(local).segmentation().type();
if (segmentation_type == "CartesianGridXY") {
if (segmentation_type == "CartesianGridXY" || segmentation_type == "HexGridXY") {
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
auto cell_dim = m_converter->cellDimensions(cellID);
cdim.resize(3);
cdim[0] = cell_dim[0];
Expand Down
153 changes: 153 additions & 0 deletions src/algorithms/calorimetry/HEXPLIT.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Copyright (C) 2023 Sebouh Paul
// SPDX-License-Identifier: LGPL-3.0-or-later

// References:
// https://arxiv.org/abs/2308.06939

#include <DD4hep/Alignments.h>
#include <DD4hep/DetElement.h>
#include <DD4hep/Objects.h>
#include <DD4hep/VolumeManager.h>
#include <Evaluator/DD4hepUnits.h>
#include <Math/GenVector/Cartesian3D.h>
#include <Math/GenVector/DisplacementVector3D.h>
#include <edm4hep/Vector3f.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <gsl/pointers> // for not_null
#include <vector>
#include "HEXPLIT.h"
#include "algorithms/calorimetry/HEXPLITConfig.h"

namespace eicrecon {

const double HEXPLIT::neighbor_offsets_x[12]={1.5*cos(0), 1.5*cos(M_PI/3), 1.5*cos(2*M_PI/3),1.5*cos(3*M_PI/3), 1.5*cos(4*M_PI/3), 1.5*cos(5*M_PI/3),
-sqrt(3)/2.*sin(0),-sqrt(3)/2.*sin(M_PI/3),-sqrt(3)/2.*sin(2*M_PI/3),-sqrt(3)/2.*sin(3*M_PI/3),-sqrt(3)/2.*sin(4*M_PI/3),-sqrt(3)/2.*sin(5*M_PI/3)};
const double HEXPLIT::neighbor_offsets_y[12]={1.5*sin(0), 1.5*sin(M_PI/3), 1.5*sin(2*M_PI/3),1.5*sin(3*M_PI/3), 1.5*sin(4*M_PI/3), 1.5*sin(5*M_PI/3),
sqrt(3)/2.*cos(0), sqrt(3)/2.*cos(M_PI/3), sqrt(3)/2.*cos(2*M_PI/3), sqrt(3)/2.*cos(3*M_PI/3), sqrt(3)/2.*cos(4*M_PI/3), sqrt(3)/2.*cos(5*M_PI/3)};

//indices of the neighboring cells which overlap to produce a given subcell
const int HEXPLIT::neighbor_indices[12][3]={{0, 11,10}, {1, 6, 11},{2, 7, 6}, {3,8,7}, {4,9,8}, {5,10,9},
{6, 11, 7}, {7, 6, 8}, {8, 7, 9}, {9,8,10},{10,9,11},{11,10,6}};

//positions of the centers of subcells
const double HEXPLIT::subcell_offsets_x[12]={0.75*cos(0), 0.75*cos(M_PI/3), 0.75*cos(2*M_PI/3), 0.75*cos(3*M_PI/3), 0.75*cos(4*M_PI/3), 0.75*cos(5*M_PI/3),
-sqrt(3)/4*sin(0),-sqrt(3)/4*sin(M_PI/3),-sqrt(3)/4*sin(2*M_PI/3),-sqrt(3)/4*sin(3*M_PI/3),-sqrt(3)/4*sin(4*M_PI/3),-sqrt(3)/4*sin(5*M_PI/3)};
const double HEXPLIT::subcell_offsets_y[12]={0.75*sin(0), 0.75*sin(M_PI/3), 0.75*sin(2*M_PI/3), 0.75*sin(3*M_PI/3), 0.75*sin(4*M_PI/3), 0.75*sin(5*M_PI/3),
sqrt(3)/4*cos(0), sqrt(3)/4*cos(M_PI/3), sqrt(3)/4*cos(2*M_PI/3), sqrt(3)/4*cos(3*M_PI/3), sqrt(3)/4*cos(4*M_PI/3), sqrt(3)/4*cos(5*M_PI/3)};

void HEXPLIT::init(const dd4hep::Detector* detector, std::shared_ptr<spdlog::logger>& logger) {
m_log = logger;
m_detector = detector;

}

void HEXPLIT::process(const HEXPLIT::Input& input,
const HEXPLIT::Output& output) const {

const auto [hits] = input;
auto [subcellHits] = output;

double MIP=m_cfg.MIP/dd4hep::GeV;
double Emin=m_cfg.Emin_in_MIPs*MIP;
double tmax=m_cfg.tmax/dd4hep::ns;

auto volman = m_detector->volumeManager();

for(const auto& hit : *hits){
//skip hits that do not pass E and t cuts
if (hit.getEnergy()<Emin || hit.getTime()>tmax)
continue;

//keep track of the energy in each neighboring cell
std::vector<double> Eneighbors(SUBCELLS, 0.0);

double sl = hit.getDimension().x/2.;
for (const auto& other_hit : *hits){
// maximum distance between where the neighboring cell is and where it should be
// based on an ideal geometry using the staggered tessellation pattern.
// Deviations could arise from rounding errors or from detector misalignment.
double tol=0.1; // in units of side lengths.

//only look at hits nearby within two layers of the current layer
int dz=abs(hit.getLayer()-other_hit.getLayer());
if (dz>2 || dz==0)
continue;
if (other_hit.getEnergy()<Emin || other_hit.getTime()>tmax)
continue;
//difference in transverse position (in units of side lengths)
double dx=(other_hit.getLocal().x-hit.getLocal().x)/sl;
double dy=(other_hit.getLocal().y-hit.getLocal().y)/sl;
if (abs(dx)>2 || abs(dy)>sqrt(3))
continue;

//loop over locations of the neighboring cells
//and check if the jth hit matches this location
for(int k=0;k<SUBCELLS;k++){
if(abs(dx-neighbor_offsets_x[k])<tol && abs(dy-neighbor_offsets_y[k])<tol){
Eneighbors[k]+=other_hit.getEnergy();
break;
}
}
}
double weights[SUBCELLS];
for(int k=0; k<SUBCELLS; k++){
Eneighbors[k]=std::max(Eneighbors[k],MIP);
}
double sum_weights=0;
for(int k=0; k<SUBCELLS; k++){
weights[k]=Eneighbors[neighbor_indices[k][0]]*Eneighbors[neighbor_indices[k][1]]*Eneighbors[neighbor_indices[k][2]];
sum_weights+=weights[k];
}
for(int k=0; k<SUBCELLS;k++){

//create the subcell hits. First determine their positions in local coordinates.
const decltype(edm4eic::CalorimeterHitData::local) local(hit.getLocal().x+subcell_offsets_x[k]*sl, hit.getLocal().y+subcell_offsets_y[k]*sl, hit.getLocal().z);

//convert this to a position object so that the global position can be determined
dd4hep::Position local_position;
local_position.SetX(local.x*dd4hep::mm);
local_position.SetY(local.y*dd4hep::mm);
local_position.SetZ(local.z*dd4hep::mm);

dd4hep::Position global_position;
try {

//also convert this to the detector's global coordinates. To do: check if this is correct
auto alignment = volman.lookupDetElement(hit.getCellID()).nominal();

global_position = alignment.localToWorld(local_position);

}
catch (...){
// do this to prevent errors when running the test on the mock detector
m_log->warn("Cannot find transformation from local to global coordinates.");
global_position = local_position;
}

//convert this from position object to a vector object
const decltype(edm4eic::CalorimeterHitData::position) position = {static_cast<float>(global_position.X()/dd4hep::mm), static_cast<float>(global_position.Y()/dd4hep::mm), static_cast<float>(global_position.Z()/dd4hep::mm)};

//bounding box dimensions depend on the orientation of the rhombus
int orientation = k%3==0;
const decltype(edm4eic::CalorimeterHitData::dimension) dimension(sl*(orientation?1:1.5), sl*sqrt(3)/2.*(orientation?2:1),
hit.getDimension()[2]);

subcellHits->create(
hit.getCellID(),
hit.getEnergy()*weights[k]/sum_weights,
0,
hit.getTime(),
0,
position,
dimension,
hit.getSector(),
hit.getLayer(),
local);
}
}
}


} // namespace eicrecon
64 changes: 64 additions & 0 deletions src/algorithms/calorimetry/HEXPLIT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2023 Sebouh Paul

// An algorithm for splitting calorimeter hits in overlapping cells into "subhits" based on the relative
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
// energies of hits on neighboring layers
//
// Author: Sebouh Paul
// Date: 12/04/2023

#pragma once

#include <algorithms/algorithm.h>
#include <DD4hep/Detector.h>
#include <edm4eic/CalorimeterHitCollection.h>
#include <spdlog/logger.h>
#include <memory>
#include <string> // for basic_string
#include <string_view> // for string_view
#include "HEXPLITConfig.h"
#include "algorithms/interfaces/WithPodConfig.h"

namespace eicrecon {

using HEXPLITAlgorithm = algorithms::Algorithm<
algorithms::Input<
const edm4eic::CalorimeterHitCollection
>,
algorithms::Output<
edm4eic::CalorimeterHitCollection
>
>;

class HEXPLIT
: public HEXPLITAlgorithm,
public WithPodConfig<HEXPLITConfig> {

public:
HEXPLIT(std::string_view name)
: HEXPLITAlgorithm{name,
{"inputHits"},
{"outputSubcellHits"},
"Split hits into subcell hits"} {}

void init(const dd4hep::Detector* detector, std::shared_ptr<spdlog::logger>& logger);
void process(const Input&, const Output&) const final;

private:
const int SUBCELLS=12;
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
//positions where the overlapping cells are relative to a given cell (in units of hexagon side length)
static const double neighbor_offsets_x[12];
static const double neighbor_offsets_y[12];
//indices of the neighboring cells which overlap to produce a given subcell
static const int neighbor_indices[12][3];
//positions of the centers of subcells
static const double subcell_offsets_x[12];
static const double subcell_offsets_y[12];

private:
const dd4hep::Detector* m_detector;
std::shared_ptr<spdlog::logger> m_log;

};

} // namespace eicrecon
14 changes: 14 additions & 0 deletions src/algorithms/calorimetry/HEXPLITConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2023 Sebouh Paul

#pragma once

namespace eicrecon {

struct HEXPLITConfig {
double MIP{472.*dd4hep::keV};
double Emin_in_MIPs{0.1};
sebouh137 marked this conversation as resolved.
Show resolved Hide resolved
double tmax{325*dd4hep::ns};
};

} // eicrecon
Loading
Loading