Skip to content
Snippets Groups Projects
Select Git revision
  • c2c404b4748901e8aad8fb86d1a8ad39e8034af9
  • master default protected
  • nightly_master
  • online_much_readconf_cleanup protected
  • online_mvd_readconf_cleanup protected
  • jul25_patches
  • cleanup_rich_v25a
  • jul24_patches
  • nov23_patches
  • DC_2404
  • nighly_master
  • DC_Jan24
  • DC_Nov23
  • DC_Oct23
  • feb23_patches
  • L1Algo-dev9
  • dec21_patches protected
  • apr21_patches protected
  • dev_2025_48
  • dev_2025_47
  • RC2_jul25
  • dev_2025_46
  • dev_2025_45
  • dev_2025_44
  • dev_2025_43
  • dev_2025_42
  • dev_2025_41
  • dev_2025_40
  • dev_2025_39
  • dev_2025_38
  • dev_2025_37
  • dev_2025_36
  • dev_2025_35
  • dev_2025_34
  • dev_2025_33
  • dev_2025_32
  • dev_2025_31
  • dev_2025_30
38 results

CbmFieldPar.cxx

Blame
  • Florian Uhlig's avatar
    Administrator authored
    Unify user names in the license header authors list.
    Remove duplicate users in the authors list.
    Cleanupo of some other inor issues.
    131d9ce2
    History
    CbmFieldPar.cxx 7.09 KiB
    /* Copyright (C) 2006-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
       SPDX-License-Identifier: GPL-3.0-only
       Authors: Volker Friese, Denis Bertini [committer], Florian Uhlig, Elena Lebedeva */
    
    // -------------------------------------------------------------------------
    // -----                      CbmFieldPar source file                  -----
    // -----                   Created 20/02/06  by V. Friese              -----
    // -------------------------------------------------------------------------
    #include "CbmFieldPar.h"
    
    #include "CbmFieldConst.h"         // for CbmFieldConst
    #include "CbmFieldMap.h"           // for CbmFieldMap
    #include "CbmFieldMapDistorted.h"  // for CbmFieldMapDistorted
    
    #include <FairField.h>          // for FairField
    #include <FairParGenericSet.h>  // for FairParGenericSet
    #include <FairParamList.h>      // for FairParamList
    
    #include <iostream>  // for operator<<, basic_ostream, endl, cerr
    
    using std::cerr;
    using std::cout;
    using std::endl;
    
    const int kMaxLen = 2048;
    
    // ------   Constructor   --------------------------------------------------
    CbmFieldPar::CbmFieldPar(const char* name, const char* title, const char* context)
      : FairParGenericSet(name, title, context)
      , fType(-1)
      , fXmin(0.)
      , fXmax(0.)
      , fYmin(0.)
      , fYmax(0.)
      , fZmin(0.)
      , fZmax(0.)
      , fBx(0.)
      , fBy(0.)
      , fBz(0.)
      , fMapName("")
      , fPosX(0.)
      , fPosY(0.)
      , fPosZ(0.)
      , fScale(0.)
      , fDistortionFilename("")
      , fParentName("")
      , fTypeOfParent(0)
    {
    }
    // -------------------------------------------------------------------------
    
    CbmFieldPar::CbmFieldPar()
      : FairParGenericSet()
      , fType(-1)
      , fXmin(0.)
      , fXmax(0.)
      , fYmin(0.)
      , fYmax(0.)
      , fZmin(0.)
      , fZmax(0.)
      , fBx(0.)
      , fBy(0.)
      , fBz(0.)
      , fMapName("")
      , fPosX(0.)
      , fPosY(0.)
      , fPosZ(0.)
      , fScale(0.)
      , fDistortionFilename("")
      , fParentName("")
      , fTypeOfParent(0)
    {
    }
    // -------------------------------------------------------------------------
    
    // ------   Destructor   ---------------------------------------------------
    CbmFieldPar::~CbmFieldPar() {}
    // -------------------------------------------------------------------------
    
    
    // ------   Put parameters   -----------------------------------------------
    void CbmFieldPar::putParams(FairParamList* list)
    {
    
      if (!list) return;
    
      list->add("Field Type", fType);
    
      if (fType == 0) {  // constant field
        list->add("Field min x", fXmin);
        list->add("Field max x", fXmax);
        list->add("Field min y", fYmin);
        list->add("Field max y", fYmax);
        list->add("Field min z", fZmin);
        list->add("Field max z", fZmax);
        list->add("Field Bx", fBx);
        list->add("Field By", fBy);
        list->add("Field Bz", fBz);
      }
    
      else if (fType >= 1 && fType <= kMaxFieldMapType) {  // field map
        list->add("Field map name", fMapName);
        list->add("Field x position", fPosX);
        list->add("Field y position", fPosY);
        list->add("Field z position", fPosZ);
        list->add("Field scaling factor", fScale);
    
        if (fType == kTypeDistorted) {  // CbmFieldMapDistorted case
          list->add("Field map distortion filename", fDistortionFilename.Data());
          list->add("Field name of parent field", fParentName.Data());
          list->add("Field type of parent field", fTypeOfParent);
        }
      }
    }
    // -------------------------------------------------------------------------
    
    
    // --------   Get parameters   ---------------------------------------------
    Bool_t CbmFieldPar::getParams(FairParamList* list)
    {
    
      if (!list) return kFALSE;
    
      if (!list->fill("Field Type", &fType)) return kFALSE;
    
      if (fType == 0) {  // constant field
        if (!list->fill("Field min x", &fXmin)) return kFALSE;
        if (!list->fill("Field max x", &fXmax)) return kFALSE;
        if (!list->fill("Field min y", &fYmin)) return kFALSE;
        if (!list->fill("Field max y", &fYmax)) return kFALSE;
        if (!list->fill("Field min z", &fZmin)) return kFALSE;
        if (!list->fill("Field max z", &fZmax)) return kFALSE;
        if (!list->fill("Field Bx", &fBx)) return kFALSE;
        if (!list->fill("Field By", &fBy)) return kFALSE;
        if (!list->fill("Field Bz", &fBz)) return kFALSE;
      }
    
      else if (fType >= 1 && fType <= kMaxFieldMapType) {  // field map
        Text_t mapName[80];
        if (!list->fill("Field map name", mapName, 80)) return kFALSE;
        fMapName = mapName;
        if (!list->fill("Field x position", &fPosX)) return kFALSE;
        if (!list->fill("Field y position", &fPosY)) return kFALSE;
        if (!list->fill("Field z position", &fPosZ)) return kFALSE;
        if (!list->fill("Field scaling factor", &fScale)) return kFALSE;
    
        if (fType == kTypeDistorted) {  // CbmFieldMapDistorted case
          Text_t tmp[kMaxLen];
          fDistortionFilename = "";
          if (!list->fill("Field map distortion filename", tmp, kMaxLen)) return kFALSE;
          fDistortionFilename = tmp;
          fParentName         = "";
          if (!list->fill("Field name of parent field", tmp, kMaxLen)) return kFALSE;
          fParentName = tmp;
          if (!list->fill("Field type of parent field", &fTypeOfParent)) return kFALSE;
        }
      }
    
      return kTRUE;
    }
    // -------------------------------------------------------------------------
    
    
    // ---------   Set parameters from CbmField   ------------------------------
    void CbmFieldPar::SetParameters(FairField* field)
    {
    
      if (!field) {
        cerr << "-W- CbmFieldPar::SetParameters: Empty field pointer!" << endl;
        return;
      }
    
      fType = field->GetType();
    
      if (fType == 0) {  // constant field
        CbmFieldConst* fieldConst = (CbmFieldConst*) field;
        fBx                       = fieldConst->GetBx();
        fBy                       = fieldConst->GetBy();
        fBz                       = fieldConst->GetBz();
        fXmin                     = fieldConst->GetXmin();
        fXmax                     = fieldConst->GetXmax();
        fYmin                     = fieldConst->GetYmin();
        fYmax                     = fieldConst->GetYmax();
        fZmin                     = fieldConst->GetZmin();
        fZmax                     = fieldConst->GetZmax();
        fMapName                  = "";
        fPosX = fPosY = fPosZ = fScale = 0.;
      }
    
      else if (fType >= 1 && fType <= kMaxFieldMapType) {  // field map
        CbmFieldMap* fieldMap = (CbmFieldMap*) field;
        fBx = fBy = fBz = 0.;
        fXmin = fXmax = fYmin = fYmax = fZmin = fZmax = 0.;
    
        fMapName = field->GetName();
        fPosX    = fieldMap->GetPositionX();
        fPosY    = fieldMap->GetPositionY();
        fPosZ    = fieldMap->GetPositionZ();
        fScale   = fieldMap->GetScale();
    
        if (fieldMap->GetType() == kTypeDistorted) {  // CbmFieldMapDistorted case
          fDistortionFilename = ((CbmFieldMapDistorted*) fieldMap)->GetDistortionFilename();
          fParentName         = ((CbmFieldMapDistorted*) fieldMap)->GetParent()->GetName();
          fTypeOfParent       = ((CbmFieldMapDistorted*) fieldMap)->GetParent()->GetType();
        }
      }
    
      else {
        cerr << "-W- CbmFieldPar::SetParameters: Unknown field type " << fType << "!" << endl;
        fBx = fBy = fBz = 0.;
        fXmin = fXmax = fYmin = fYmax = fZmin = fZmax = 0.;
        fMapName                                      = "";
        fPosX = fPosY = fPosZ = fScale = 0.;
      }
    
      return;
    }
    // -------------------------------------------------------------------------
    
    
    ClassImp(CbmFieldPar)