PandaRoot
BSEmcGeoNeighbouringRelationPar.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 BSEMCNEIGHBOURINGRELATIONPAR_HH
14 #define BSEMCNEIGHBOURINGRELATIONPAR_HH
15 #include <algorithm>
16 #include <map>
17 #include <memory>
18 #include <string>
19 #include <vector>
20 
21 #include "Rtypes.h"
22 #include "RtypesCore.h"
23 #include "TObjArray.h"
24 #include "TString.h"
25 
26 #include "FairParGenericSet.h"
27 #include "FairParamList.h"
28 #include "FairRun.h"
29 
30 class FairParamList;
31 class TBuffer;
32 class TClass;
33 class TMemberInspector;
34 
43 class BSEmcGeoNeighbouringRelationPar : public FairParGenericSet {
44  public:
45  static std::string fgParameterName;
46  BSEmcGeoNeighbouringRelationPar(const char *t_name = "EmcGeoNeighbouringRelationPar", const char *t_title = "Neighbouring relation of Emc crystals",
47  const char *t_context = "TestDefaultContext");
49 
50  void clear(void) /*override*/ {}
51  void putParams(FairParamList * /*unused*/) /*override*/;
52  Bool_t getParams(FairParamList * /*unused*/) /*override*/;
53 
54  void RegisterIdAndNeighbours(Int_t t_id, std::vector<Int_t> &t_neighbours);
55  void AddNeighbourToId(Int_t t_neighbourid, Int_t t_id);
56 
57  const std::vector<Int_t> &GetNeighbourIds(Int_t t_detectorid) const;
58  Bool_t AreNeighbours(Int_t t_a, Int_t t_b) const
59  {
60  const std::vector<Int_t> &ids = GetNeighbourIds(t_a);
61  return std::find(ids.begin(), ids.end(), t_b) != ids.end();
62  }
63  const TObjArray *GetRelations() const { return fRelations.get(); }
64 
67 
68  void InitFromTextFile(const TString &t_filename);
69  void FillMap();
70  void UpdateRelationArray();
71 
72  Bool_t IsSet() { return fRelations->GetEntriesFast() != 0; }
73  const std::map<Int_t, std::vector<Int_t>> &GetRelationMap() const { return fRelationMap; }
74 
75  private:
76  std::unique_ptr<TObjArray> fRelations{nullptr};
77  std::map<Int_t, std::vector<Int_t>> fRelationMap{};
78  Bool_t fFilledMap{kFALSE};
80 };
81 
82 #endif /*BSEMCNEIGHBOURINGRELATIONPAR_HH*/
BSEmcGeoNeighbouringRelationPar(const char *t_name="EmcGeoNeighbouringRelationPar", const char *t_title="Neighbouring relation of Emc crystals", const char *t_context="TestDefaultContext")
Bool_t AreNeighbours(Int_t t_a, Int_t t_b) const
void AddNeighbourToId(Int_t t_neighbourid, Int_t t_id)
Bool_t getParams(FairParamList *)
void RegisterIdAndNeighbours(Int_t t_id, std::vector< Int_t > &t_neighbours)
void InitFromTextFile(const TString &t_filename)
Neigbouring Relations based on a list of detectorIds.
const std::vector< Int_t > & GetNeighbourIds(Int_t t_detectorid) const
void putParams(FairParamList *)
BSEmcGeoNeighbouringRelationPar & operator=(const BSEmcGeoNeighbouringRelationPar &t_l)
const std::map< Int_t, std::vector< Int_t > > & GetRelationMap() const