Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-05 09:09:56

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Chao Peng, Sylvester Joosten, Whitney Armstrong
0003 
0004 #pragma once
0005 
0006 #include <string>
0007 #include <variant>
0008 #include <iostream>
0009 
0010 #include <DD4hep/DD4hepUnits.h>
0011 
0012 namespace eicrecon {
0013 
0014 struct ImagingTopoClusterConfig {
0015 
0016   // maximum difference in layer numbers that can be considered as neighbours
0017   int neighbourLayersRange = 1;
0018   // maximum distance of global (x, y) to be considered as neighbors at same layers (if sameLayerMode==xy)
0019   std::vector<std::variant<std::string, double>> sameLayerDistXY = {1.0 * dd4hep::mm,
0020                                                                     1.0 * dd4hep::mm};
0021   // maximum distance of local (x, y,z) to be considered as neighbors at same layers (if sameLayerMode==xyz)
0022   std::vector<std::variant<std::string, double>> sameLayerDistXYZ = {
0023       1.0 * dd4hep::mm, 1.0 * dd4hep::mm, 20.0 * dd4hep::mm};
0024   // maximum distance of global (eta, phi) to be considered as neighbors at same layers (if sameLayerMode==etaphi)
0025   std::vector<double> sameLayerDistEtaPhi = {0.01, 0.01};
0026   // maximum distance of global (t, z) to be considered as neighbors at same layers (if sameLayerMode==tz)
0027   std::vector<double> sameLayerDistTZ = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0028   // maximum distance of global (x, y) to be considered as neighbors at different layers (if diffLayerMode==xy)
0029   std::vector<std::variant<std::string, double>> diffLayerDistXY = {1.0 * dd4hep::mm,
0030                                                                     1.0 * dd4hep::mm};
0031   // maximum distance of global (x, y, z) to be considered as neighbors at different layers (if diffLayerMode==xyz)
0032   std::vector<std::variant<std::string, double>> diffLayerDistXYZ = {
0033       1.0 * dd4hep::mm, 1.0 * dd4hep::mm, 20.0 * dd4hep::mm};
0034   // maximum distance of global (eta, phi) to be considered as neighbors at different layers (if diffLayerMode==etaphi)
0035   std::vector<double> diffLayerDistEtaPhi = {0.01, 0.01};
0036   // maximum distance of global (t, z) to be considered as neighbors at different layers (if diffLayerMode==tz)
0037   std::vector<double> diffLayerDistTZ = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0038   // Layermodes
0039   enum class ELayerMode { etaphi = 0, xy = 1, tz = 2, xyz = 3 };
0040   // determines how neighbors are determined for hits in same layers (using either eta and phi, or x and y)
0041   ELayerMode sameLayerMode = ELayerMode::xy; // for ldiff =0
0042   // determines how neighbors are determined for hits in different layers (using either eta and phi, or x and y)
0043   ELayerMode diffLayerMode = ELayerMode::xy; // for ldiff <= neighbourLayersRange
0044 
0045   // maximum global distance to be considered as neighbors in different sectors
0046   double sectorDist = 1.0 * dd4hep::cm;
0047 
0048   // minimum hit energy to participate clustering
0049   double minClusterHitEdep = 0.;
0050   // minimum cluster center energy (to be considered as a seed for cluster)
0051   double minClusterCenterEdep = 0.;
0052   // minimum cluster energy (to save this cluster)
0053   double minClusterEdep = 0.5 * dd4hep::MeV;
0054   // minimum number of hits (to save this cluster)
0055   std::size_t minClusterNhits = 10;
0056 };
0057 
0058 std::istream& operator>>(std::istream& in, ImagingTopoClusterConfig::ELayerMode& layerMode) {
0059   std::string s;
0060   in >> s;
0061   // stringifying the enums causes them to be converted to integers before conversion to strings
0062   if (s == "etaphi" or s == "0") {
0063     layerMode = ImagingTopoClusterConfig::ELayerMode::etaphi;
0064   } else if (s == "xy" or s == "1") {
0065     layerMode = ImagingTopoClusterConfig::ELayerMode::xy;
0066   } else if (s == "tz" or s == "2") {
0067     layerMode = ImagingTopoClusterConfig::ELayerMode::tz;
0068   } else if (s == "xyz" or s == "3") {
0069     layerMode = ImagingTopoClusterConfig::ELayerMode::xyz;
0070   } else {
0071     in.setstate(std::ios::failbit); // Set the fail bit if the input is not valid
0072   }
0073 
0074   return in;
0075 }
0076 std::ostream& operator<<(std::ostream& out, const ImagingTopoClusterConfig::ELayerMode& layerMode) {
0077   switch (layerMode) {
0078   case ImagingTopoClusterConfig::ELayerMode::etaphi:
0079     out << "etaphi";
0080     break;
0081   case ImagingTopoClusterConfig::ELayerMode::xy:
0082     out << "xy";
0083     break;
0084   case ImagingTopoClusterConfig::ELayerMode::xyz:
0085     out << "xyz";
0086     break;
0087   case ImagingTopoClusterConfig::ELayerMode::tz:
0088     out << "tz";
0089     break;
0090   default:
0091     out.setstate(std::ios::failbit);
0092   }
0093   return out;
0094 }
0095 } // namespace eicrecon