PandaRoot
BSEmcCrystalPositionPar.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 BSEMCCRYSTALPOSITIONPAR_HH
14 #define BSEMCCRYSTALPOSITIONPAR_HH
15 #include <functional>
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 #include "TVector3.h"
26 
27 #include "FairParGenericSet.h"
28 #include "FairParamList.h"
29 #include "FairRun.h"
30 
31 class FairParamList;
32 class TBuffer;
33 class TClass;
34 class TMemberInspector;
35 
45  TVector3 Center{0, 0, 0};
46  TVector3 FrontCenter{0, 0, 0};
47  TVector3 FrontFaceNormal{0, 0, 0};
48  TVector3 Axis{0, 0, 0};
49  BSEmcCrystalPositionData() = default;
50  BSEmcCrystalPositionData(const TVector3 &center, const TVector3 &fcenter, const TVector3 &frontfacenormal, const TVector3 &axis)
51  : Center(center), FrontCenter(fcenter), FrontFaceNormal(frontfacenormal), Axis(axis)
52  {
53  }
54  const TVector3 &GetCentre() const { return Center; }
55  const TVector3 &GetFrontCentre() const { return FrontCenter; }
56  const TVector3 &GetNormalToFrontFace() const { return FrontFaceNormal; }
57  const TVector3 &GetAxisVector() const { return Axis; }
58 };
59 
68 class BSEmcCrystalPositionPar : public FairParGenericSet {
69  public:
70  static std::string fgParameterName;
71  BSEmcCrystalPositionPar(const char *t_name = "BSEmcCrystalPositionPar", const char *t_title = "Center front face position of BSEmc crystals",
72  const char *t_context = "TestDefaultContext");
74 
75  void clear(void) /*override*/ {}
76  void putParams(FairParamList * /*unused*/) /*override*/;
77  Bool_t getParams(FairParamList * /*unused*/) /*override*/;
78 
79  void SetPositionDataForCrystal(Int_t t_id, const BSEmcCrystalPositionData &t_position);
80  const BSEmcCrystalPositionData &GetPositionData(Int_t t_detectorid) const;
81  TObjArray *GetPositions() const { return fPositions.get(); }
82 
83  void SetPositionMethod(const TString &t_positionMethod);
84  void SetPositionDepth(Double_t t_depth) { fCrystalPositionDepth = t_depth; }
85  void SetRescaleFactor(Double_t t_factor) { fRescaleFactor = t_factor; }
86  Double_t GetRescaleFactor() const { return fRescaleFactor; }
87  TVector3 GetPosition(Int_t t_detectorId) const;
88 
90  BSEmcCrystalPositionPar &operator=(const BSEmcCrystalPositionPar &t_posPar);
91 
92  void InitFromTextFile(const TString &t_filename);
93  void WriteToTextFile(const TString &t_filename) const;
94  void FillMap();
95  void UpdatePositionArray();
96 
97  Bool_t IsSet() { return fPositions->GetEntriesFast() != 0; }
98 
99  private:
100  std::unique_ptr<TObjArray> fPositions{nullptr};
101  std::map<Int_t, BSEmcCrystalPositionData> fPositionMap{};
102  Double_t fRescaleFactor{-1};
103  Double_t fCrystalPositionDepth{-1};
104  std::function<TVector3(const BSEmcCrystalPositionData &, Double_t)> fDigiPosMethod{};
105  Bool_t fDigiPosMethodIsSet{kFALSE};
106 
107  ClassDef(BSEmcCrystalPositionPar, 2)
108 };
109 
110 #endif /*BSEMCCRYSTALPOSITIONPAR_HH*/
TObjArray * GetPositions() const
const TVector3 & GetAxisVector() const
void SetPositionDepth(Double_t t_depth)
const TVector3 & GetFrontCentre() const
void SetRescaleFactor(Double_t t_factor)
static std::string fgParameterName
Struct containing crystal position data.
const TVector3 & GetNormalToFrontFace() const
Parameter for crystal positions.
axis
BSEmcCrystalPositionData(const TVector3 &center, const TVector3 &fcenter, const TVector3 &frontfacenormal, const TVector3 &axis)
const TVector3 & GetCentre() const
BSEmcCrystalPositionData()=default