Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:53:32

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