PandaRoot
BSEmcGeoNeighbouringRelationPar.h
Go to the documentation of this file.
1 #ifndef BSEMCNEIGHBOURINGRELATIONPAR_HH
2 #define BSEMCNEIGHBOURINGRELATIONPAR_HH
3 #include <algorithm>
4 #include <map>
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 #include "Rtypes.h"
10 #include "RtypesCore.h"
11 #include "TObjArray.h"
12 #include "TString.h"
13 
14 #include "FairParGenericSet.h"
15 #include "FairParamList.h"
16 #include "FairRun.h"
17 
18 class FairParamList;
19 class TBuffer;
20 class TClass;
21 class TMemberInspector;
22 
31 class BSEmcGeoNeighbouringRelationPar : public FairParGenericSet {
32  public:
33  static std::string fgParameterName;
34  BSEmcGeoNeighbouringRelationPar(const char *t_name = "EmcGeoNeighbouringRelationPar", const char *t_title = "Neighbouring relation of Emc crystals",
35  const char *t_context = "TestDefaultContext");
37 
38  void clear(void) /*override*/ {}
39  void putParams(FairParamList * /*unused*/) /*override*/;
40  Bool_t getParams(FairParamList * /*unused*/) /*override*/;
41 
42  void RegisterIdAndNeighbours(Int_t t_id, std::vector<Int_t> &t_neighbours);
43  void AddNeighbourToId(Int_t t_neighbourid, Int_t t_id);
44 
45  const std::vector<Int_t> &GetNeighbourIds(Int_t t_detectorid) const;
46  Bool_t AreNeighbours(Int_t t_a, Int_t t_b) const
47  {
48  const std::vector<Int_t> &ids = GetNeighbourIds(t_a);
49  return std::find(ids.begin(), ids.end(), t_b) != ids.end();
50  }
51  const TObjArray *GetRelations() const { return fRelations.get(); }
52 
55 
56  void InitFromTextFile(const TString &t_filename);
57  void FillMap();
58  void UpdateRelationArray();
59 
60  Bool_t IsSet() { return fRelations->GetEntriesFast() != 0; }
61  const std::map<Int_t, std::vector<Int_t>> &GetRelationMap() const { return fRelationMap; }
62 
63  private:
64  std::unique_ptr<TObjArray> fRelations{nullptr};
65  std::map<Int_t, std::vector<Int_t>> fRelationMap{};
66  Bool_t fFilledMap{kFALSE};
68 };
69 
70 #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