PandaRoot
BSEmcFwEndcapDetIdToAlveoleMap.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 #ifndef BSEMCFWENDCAPDETIDTOALVEOLEMAP_HH
14 #define BSEMCFWENDCAPDETIDTOALVEOLEMAP_HH
15 
16 #include <map>
17 #include <vector>
18 
19 #include "TString.h"
20 
22  public:
24  Int_t fX{0}, fY{0}, fCrystal{-1};
25  };
26 
29  void SetFileName(const TString &t_filename)
30  {
31  fFilename = t_filename;
32  LoadMap();
33  }
34  BSEmcFwEndcapCrystal_t GetAlveoleId(const Int_t t_detectorId) const { return fDetIdToAlveole.at(t_detectorId); }
35  std::vector<Int_t> GetAlveoleCrystals(const Int_t t_xindex, const Int_t t_yindex) const { return GetAlveoleCrystals(ConvertToKey(t_xindex, t_yindex)); };
36  std::vector<Int_t> GetAlveoleCrystals(const TString t_key) const { return fAlveoleDetIds.at(t_key); }
37  std::vector<Int_t> GetAlveoleCrystals(const Int_t t_detectorId) const;
38 
39  TString ConvertToKey(const Int_t t_xindex, const Int_t t_yindex) const { return "X" + TString{std::to_string(t_xindex)} + "Y" + TString{std::to_string(t_yindex)}; }
40 
41  private:
42  void LoadMap();
43  std::map<Int_t, BSEmcFwEndcapCrystal_t> fDetIdToAlveole{};
44  std::map<TString, std::vector<Int_t>> fAlveoleDetIds{};
45  TString fFilename{"FwEndcapDetIdToAlveoleMap.txt"};
46  ClassDef(BSEmcFwEndcapDetIdToAlveoleMap, 1);
47 };
48 
49 #endif /*BSEMCFWENDCAPDETIDTOALVEOLEMAP_HH*/
std::vector< Int_t > GetAlveoleCrystals(const TString t_key) const
TString ConvertToKey(const Int_t t_xindex, const Int_t t_yindex) const
BSEmcFwEndcapCrystal_t GetAlveoleId(const Int_t t_detectorId) const
void SetFileName(const TString &t_filename)
std::vector< Int_t > GetAlveoleCrystals(const Int_t t_xindex, const Int_t t_yindex) const