Project
Loading...
Searching...
No Matches
MagFieldFact.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#include "Field/MagFieldFact.h"
13#include "FairField.h"
14#include <fairlogger/Logger.h>
15#include "FairRuntimeDb.h"
16#include "Field/MagFieldParam.h"
17#include "Field/MagneticField.h"
18
19#include <iostream>
20using std::cerr;
21using std::cout;
22using std::endl;
23
24using namespace o2::field;
25
27
28static MagFieldFact gMagFieldFact;
29
30MagFieldFact::MagFieldFact() : FairFieldFactory(), mFieldPar(nullptr) { fCreator = this; }
32
34{
35 auto RunDB = FairRuntimeDb::instance();
36 mFieldPar = (MagFieldParam*)RunDB->getContainer("MagFieldParam");
37}
38
40{
41 if (!mFieldPar) {
42 LOG(error) << "MagFieldFact::createFairField: No field parameters available";
43 return nullptr;
44 }
45 // since we have just 1 field class, we don't need to consider fFieldPar->GetType()
46 std::cerr << "creating the field as unmanaged pointer\n";
47 // we have to use naked "new" here since the FairRootAna or TGeoGlobalMagField expect
48 // bare pointer on the field which they eventually destroy
49 return new MagneticField(*mFieldPar);
50}
ClassImp(MagFieldFact)
Definition of the MagFieldFact: factory for ALIDE mag. field from MagFieldParam.
Definition of the MagFieldParam: container for ALICE mag. field parameters.
Definition of the MagF class.
FairField * createFairField() override
void SetParm() override
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"