1 #ifndef BSEMCPARAMETERLOADINGPROCESS_HH 2 #define BSEMCPARAMETERLOADINGPROCESS_HH 4 #include "TObjString.h" 24 template <
class DataStruct>
27 BSEmcParameterLoadingProcess(
const TString &t_neighbouringFilename =
"EmcCrystalsNeighbouringRelations.txt",
const TString &t_positionparFilename =
"")
28 :
PndProcess<DataStruct>(
"BSEmcParameterLoadingProcess"), fNeighbouringFilename(t_neighbouringFilename), fPositionParFilename(t_positionparFilename){};
57 SetupPositionParameters(t_parameter);
58 SetupNeighbouringParameters(t_parameter);
62 TString fNeighbouringFilename{
"EmcCrystalsNeighbouringRelations.txt"};
63 TString fPositionParFilename{
""};
65 void GetPositionParameterFromCrystals(
BSEmcCrystalPositionPar *t_par, Int_t t_lowerDetectorId, Int_t t_upperDetectorId)
71 Int_t
id = crystal.first;
73 if (t_lowerDetectorId <=
id &&
id < t_upperDetectorId) {
82 LOG(debug) <<
"BSEmcParameterLoadingProcess::ReadPositionParParameter(" << fPositionParFilename <<
").";
85 std::ifstream txtfile(fPositionParFilename.Data());
86 if (txtfile.is_open()) {
87 while (std::getline(txtfile, line)) {
90 std::unique_ptr<TObjArray> tokens{entry.Tokenize(
":")};
92 TVector3 vectorvalues[4];
93 if (tokens->GetEntriesFast() > 1) {
94 tmpstr = (
dynamic_cast<TObjString *
>(tokens->At(0)))->GetString();
95 crystalId = tmpstr.Atoi();
96 if (t_lowerDetectorId <= crystalId && crystalId < t_upperDetectorId) {
97 Int_t counter = 0, veccounter = 0;
98 for (Int_t tokenId = 1; tokenId < tokens->GetEntriesFast(); ++tokenId) {
99 tmpstr = (
dynamic_cast<TObjString *
>(tokens->At(tokenId)))->GetString();
100 vectorvalues[veccounter][counter] = tmpstr.Atof();
101 counter = (counter + 1) % 3;
112 LOG(error) <<
"BSEmcParameterLoadingProcess::ReadPositionParParameter(" << fPositionParFilename <<
") - Unable to open file!";
116 void FillPositionParameter(
BSEmcCrystalPositionPar *t_posPar, Int_t t_inputVersion, Int_t t_lowerDetectorId, Int_t t_upperDetectorId)
118 if (fPositionParFilename.Length() != 0) {
119 ReadPositionParParameter(t_posPar, t_lowerDetectorId, t_upperDetectorId);
121 GetPositionParameterFromCrystals(t_posPar, t_lowerDetectorId, t_upperDetectorId);
124 t_posPar->setChanged(kTRUE);
125 t_posPar->setInputVersion(t_inputVersion, 1);
152 FairRun *run = FairRun::Instance();
153 if (run ==
nullptr) {
154 Fatal(
"SetParContainers",
"No analysis run");
156 FillPositionParameter(barrelPar, run->GetRunId(), 100000000, 300000000);
157 FillPositionParameter(fwecPar, run->GetRunId(), 300000000, 400000000);
158 FillPositionParameter(bwecPar, run->GetRunId(), 400000000, 500000000);
159 FillPositionParameter(shashlikPar, run->GetRunId(), 500000000, 600000000);
162 SetupPositionParameter(barrelPar, barrelDigiPar);
163 SetupPositionParameter(fwecPar, fwecDigiPar);
164 SetupPositionParameter(bwecPar, bwecDigiPar);
165 SetupPositionParameter(shashlikPar, shashlikDigiPar);
170 LOG(debug) <<
"BSEmcParameterLoadingProcess::ReadNeighbouringParameter(" << fNeighbouringFilename <<
").";
173 std::ifstream txtfile(fNeighbouringFilename.Data());
174 if (txtfile.is_open()) {
175 while (std::getline(txtfile, line)) {
178 TObjArray *tokens = entry.Tokenize(
":");
180 std::vector<Int_t> neighbourIds;
181 if (tokens->GetEntriesFast() > 1) {
182 tmpstr = (
dynamic_cast<TObjString *
>(tokens->At(0)))->GetString();
183 crystalId = tmpstr.Atoi();
184 for (Int_t tokenId = 1; tokenId < tokens->GetEntriesFast(); ++tokenId) {
185 tmpstr = (
dynamic_cast<TObjString *
>(tokens->At(tokenId)))->GetString();
186 neighbourIds.push_back(tmpstr.Atoi());
188 if (t_lowerId <= crystalId && crystalId < t_upperId) {
195 LOG(error) <<
"BSEmcParameterLoadingProcess::ReadNeighbouringParameter(" << fNeighbouringFilename <<
") - Unable to open file!";
202 ReadNeighbouringParameter(t_par, t_lowerId, t_upperId);
203 t_par->setChanged(kTRUE);
204 t_par->setInputVersion(t_version, 1);
218 if (!barrelPar->
IsSet() || !fwEndcapPar->
IsSet() || !bwEndcapPar->
IsSet() || !shashlikPar->
IsSet()) {
219 FairRun *run = FairRun::Instance();
220 if (run ==
nullptr) {
221 Fatal(TString{
"BSEmcParameterLoadingProcess::SetupNeighbouringParameters(" + fNeighbouringFilename +
")"},
"No analysis run");
223 LoadNeighbouringParameter(barrelPar, run->GetRunId(), 100000000, 300000000);
224 LoadNeighbouringParameter(fwEndcapPar, run->GetRunId(), 300000000, 400000000);
225 LoadNeighbouringParameter(bwEndcapPar, run->GetRunId(), 400000000, 500000000);
226 LoadNeighbouringParameter(shashlikPar, run->GetRunId(), 500000000, 600000000);
void SetDetectorName(const std::string &t_detectorName)
Set the Detector name. Important, as most EmcParameter need to know for which detector they need to b...
FairParSet * GetParameter(const std::string &t_name) const
Access the parameter via the name.
Double_t GetDigiPositionDepth() const
virtual void Process()
The actual data transformation (digitizing, clustering, etc.) should be defined here.
static const std::string fgParameterName
void SetupParameters(const PndParameterRegister *t_parameter)
Fetch all parameters from the PndParameterRegister.
void UpdatePositionArray()
void SetPositionMethod(const TString &t_positionMethod)
void SetPositionDepth(Double_t t_depth)
void SetPositionParFilename(const TString &t_positionFilename)
void SetNeighbouringFilename(const TString &t_neighbouringFilename)
const TVector3 & GetCentre() const
void SetPositionDataForCrystal(Int_t t_id, const BSEmcCrystalPositionData &t_position)
static BSEmcStructure * Instance()
static std::string fgParameterName
Struct containing crystal position data.
void CreateDetIdXtalMap()
void RegisterIdAndNeighbours(Int_t t_id, std::vector< Int_t > &t_neighbours)
Parameter for crystal positions.
represents coordinates of one crystal
void UpdateRelationArray()
const TVector3 & GetNormalToFrontFace() const
const Text_t * GetDigiPositionMethod() const
static std::string fgParameterName
BSEmcParameterLoadingProcess(const TString &t_neighbouringFilename="EmcCrystalsNeighbouringRelations.txt", const TString &t_positionparFilename="")
const TVector3 & GetAxisVector() const
const TVector3 & GetFrontCentre() const
std::string fDetectorName
Set Detector name this PndProcess transforms data for. Required for example by EMC Processes to fetch...
std::vector< std::string > fParameterList
Parameter names required by this PndProcess. Needs to be populated in derived class.
Helper class to indirect the Parameter fetching via the FairRuntimeDb.
Neigbouring Relations based on a list of detectorIds.
virtual void SetData(DataStruct *)
Pass the data container ptrs to the process, and store pointers in class members. ...
Mini parameter set to contain position relevant parameter.
virtual ~BSEmcParameterLoadingProcess()
Process to load neighbouring and position parameters from txtfiles or position values via BSEmcStruct...