Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:55:18

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 layerMode==xy)
0019   std::vector<std::variant<std::string, double>> sameLayerDistXY = {1.0 * dd4hep::mm,
0020                                                                     1.0 * dd4hep::mm};
0021   // maximum distance of global (eta, phi) to be considered as neighbors at same layers (if layerMode==etaphi)
0022   std::vector<double> sameLayerDistEtaPhi = {0.01, 0.01};
0023   // maximum distance of global (t, z) to be considered as neighbors at same layers (if layerMode==tz)
0024   std::vector<double> sameLayerDistTZ = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0025   // maximum distance of global (x, y) to be considered as neighbors at different layers (if layerMode==xy)
0026   std::vector<std::variant<std::string, double>> diffLayerDistXY = {1.0 * dd4hep::mm,
0027                                                                     1.0 * dd4hep::mm};
0028   // maximum distance of global (eta, phi) to be considered as neighbors at different layers (if layerMode==etaphi)
0029   std::vector<double> diffLayerDistEtaPhi = {0.01, 0.01};
0030   // maximum distance of global (t, z) to be considered as neighbors at different layers (if layerMode==tz)
0031   std::vector<double> diffLayerDistTZ = {1.0 * dd4hep::mm, 1.0 * dd4hep::mm};
0032   // Layermodes
0033   enum class ELayerMode { etaphi = 0, xy = 1, tz = 2 };
0034   // determines how neighbors are determined for hits in same layers (using either eta and phi, or x and y)
0035   ELayerMode sameLayerMode = ELayerMode::xy; // for ldiff =0
0036   // determines how neighbors are determined for hits in different layers (using either eta and phi, or x and y)
0037   ELayerMode diffLayerMode = ELayerMode::xy; // for ldiff <= neighbourLayersRange
0038 
0039   // maximum global distance to be considered as neighbors in different sectors
0040   double sectorDist = 1.0 * dd4hep::cm;
0041 
0042   // minimum hit energy to participate clustering
0043   double minClusterHitEdep = 0.;
0044   // minimum cluster center energy (to be considered as a seed for cluster)
0045   double minClusterCenterEdep = 0.;
0046   // minimum cluster energy (to save this cluster)
0047   double minClusterEdep = 0.5 * dd4hep::MeV;
0048   // minimum number of hits (to save this cluster)
0049   std::size_t minClusterNhits = 10;
0050 };
0051 
0052 std::istream& operator>>(std::istream& in, ImagingTopoClusterConfig::ELayerMode& layerMode) {
0053   std::string s;
0054   in >> s;
0055   // stringifying the enums causes them to be converted to integers before conversion to strings
0056   if (s == "etaphi" or s == "0") {
0057     layerMode = ImagingTopoClusterConfig::ELayerMode::etaphi;
0058   } else if (s == "xy" or s == "1") {
0059     layerMode = ImagingTopoClusterConfig::ELayerMode::xy;
0060   } else if (s == "tz" or s == "2") {
0061     layerMode = ImagingTopoClusterConfig::ELayerMode::tz;
0062   } else {
0063     in.setstate(std::ios::failbit); // Set the fail bit if the input is not valid
0064   }
0065 
0066   return in;
0067 }
0068 std::ostream& operator<<(std::ostream& out, const ImagingTopoClusterConfig::ELayerMode& layerMode) {
0069   switch (layerMode) {
0070   case ImagingTopoClusterConfig::ELayerMode::etaphi:
0071     out << "etaphi";
0072     break;
0073   case ImagingTopoClusterConfig::ELayerMode::xy:
0074     out << "xy";
0075     break;
0076   case ImagingTopoClusterConfig::ELayerMode::tz:
0077     out << "tz";
0078     break;
0079   default:
0080     out.setstate(std::ios::failbit);
0081   }
0082   return out;
0083 }
0084 } // namespace eicrecon