FairRoot/PandaRoot
PndFieldCreator.cxx
Go to the documentation of this file.
1 
2 #include "PndFieldCreator.h"
3 
4 #include "PndFieldMap.h"
5 #include "PndConstField.h"
6 #include "PndSolenoidMap.h"
7 #include "PndDipoleMap.h"
8 #include "PndTransMap.h"
9 #include "PndMultiField.h"
10 #include "PndMultiFieldPar.h"
11 #include "PndConstPar.h"
12 #include "PndDipoleMap.h"
13 #include "PndSolenoidMap.h"
14 #include "PndDipolePar.h"
15 #include "PndSolenoidPar.h"
16 #include "PndTransPar.h"
17 #include "PndTransMap.h"
18 #include "PndMapPar.h"
19 #include "FairBaseParSet.h"
20 #include "FairRunAna.h"
21 #include "FairRuntimeDb.h"
22 
23 #include "TObjArray.h"
24 
25 using std::cout;
26 using std::endl;
27 
29 
30 
32  :FairFieldFactory(),
33  fFieldPar(0),
34  fSPar(0),
35  fDPar(0),
36  fTPar(0),
37  fCPar(0),
38  fMPar(0)
39 
40 {
41  fCreator=this;
42 
43 }
44 
46  :FairFieldFactory(),
47  fFieldPar(L.fFieldPar),
48  fSPar(L.fSPar),
49  fDPar(L.fDPar),
50  fTPar(L.fTPar),
51  fCPar(L.fCPar),
52  fMPar(L.fMPar)
53 
54 {
55  fCreator = L.fCreator;
56 }
57 
59 {
60 }
62 {
63 
64 // cout << "PndFieldCreator::SetParm()" <<endl;
65  FairRun *Run = FairRun::Instance();
66  FairRuntimeDb *RunDB = Run->GetRuntimeDb();
67 
68  FairBaseParSet* par=(FairBaseParSet*)(RunDB->getContainer("FairBaseParSet"));
69 
70  TObjArray *contList= par->GetContList();
71  TObject *obj=0;
72  if (contList) {
73  obj=contList->FindObject("PndMultiFieldPar");
74  }
75 
76  cout << "PndFieldCreator::SetParm() " << obj <<endl;
77 
78 
79  if (obj) {
80  fMPar = (PndMultiFieldPar*)RunDB->getContainer("PndMultiFieldPar");
81  }else if (contList->FindObject("PndFieldPar")) {
82  fFieldPar = (PndFieldPar*) RunDB->getContainer("PndFieldPar");
83  }else if (contList->FindObject("PndSolenoidPar")) {
84  fSPar = (PndSolenoidPar*) RunDB->getContainer("PndSolenoidPar");
85  }else if (contList->FindObject("PndDipolePar")) {
86  fDPar = (PndDipolePar*) RunDB->getContainer("PndDipolePar");
87  }else if (contList->FindObject("PndTransPar")) {
88  fTPar = (PndTransPar*) RunDB->getContainer("PndTransPar");
89  }else if (contList->FindObject("PndConstPar")) {
90  fCPar = (PndConstPar*) RunDB->getContainer("PndConstPar");
91  }
92 
93 
94 }
95 
97 {
98  //cout << "PndFieldCreator::createFairField()" <<endl;
99  FairField *fMagneticField=0;
100  PndMultiField *MField=0;
101  Int_t Type=-1;
102  Bool_t multi=kFALSE;
103  if (fMPar) {
104  MField = new PndMultiField(fMPar);
105  Type= fMPar->GetType();
106  }
107  if (Type==-1) {delete MField; MField=0;}
108 
109  if(MField) {
110  multi=kTRUE;
111  TObjArray *fParArray=fMPar->GetParArray();
112  TIterator *Iter=fParArray->MakeIterator();
113  Iter->Reset();
114  PndMapPar* fPar = NULL;
115  while( (fPar = (PndMapPar*)Iter->Next() ) ) {
116  fPar->Print();
117  if (fPar->GetType()==0){
118  FairField *fField1 = new PndConstField((PndConstPar*)fPar);
119  MField->AddField(fField1);
120  }
121  if (fPar->GetType()==1){
122  FairField *fField2 = new PndFieldMap((PndFieldPar*)fPar);
123  MField->AddField(fField2);
124  }
125  if (fPar->GetType()==2){
126  FairField *fField3 = new PndSolenoidMap((PndSolenoidPar*)fPar);
127  MField->AddField(fField3);
128  }
129  if (fPar->GetType()==3){
130  FairField *fField4 = new PndDipoleMap((PndDipolePar*)fPar);
131  MField->AddField(fField4);
132  }
133  if (fPar->GetType()==4){
134  FairField *fField5 = new PndTransMap((PndTransPar*)fPar);
135  MField->AddField(fField5);
136  }
137  }
138  }
139 
140  if (fCPar) {
141  FairField *fField1 = new PndConstField(fCPar);
142  Type= fCPar->GetType();
143  if (Type==-1) {delete fField1; fField1=0;}
144  if(fField1)fMagneticField=fField1;
145  }
146  if(fFieldPar){
147  FairField *fField2 = new PndFieldMap(fFieldPar);
148  Type= fFieldPar->GetType();
149  if (Type==-1){delete fField2; fField2=0;}
150  if(fField2)fMagneticField=fField2;
151  }
152  if(fSPar){
153  FairField *fField3 = new PndSolenoidMap(fSPar);
154  Type= fSPar->GetType();
155  if (Type==-1) {delete fField3; fField3=0;}
156  if(fField3)fMagneticField=fField3;
157  }
158  if(fDPar){
159  FairField *fField4 = new PndDipoleMap(fDPar);
160  Type= fDPar->GetType();
161  if (Type==-1) {delete fField4; fField4=0;}
162  if(fField4)fMagneticField=fField4;
163  }
164  if(fTPar){
165  FairField *fField5 = new PndTransMap(fTPar);
166  Type= fTPar->GetType();
167  if (Type==-1){delete fField5; fField5=0;}
168  if(fField5)fMagneticField=fField5;
169  }
170 
171  if (multi) {
172  MField->Init();
173  return MField;
174  }else{
175  if(fMagneticField){
176  fMagneticField->Init();
177  }
178  return fMagneticField;
179  }
180 }
181 
182 
184 
185 
186 
Int_t GetType() const
Definition: PndFieldPar.h:37
Double_t par[3]
TObjArray * GetParArray()
virtual FairField * createFairField()
virtual ~PndFieldCreator()
PndConstPar * fCPar
static PndFieldCreator gPndFieldCreator
PndSolenoidPar * fSPar
PndFieldPar * fFieldPar
fRun Run(0, nEvents)
PndMultiFieldPar * fMPar
PndTransPar * fTPar
ClassImp(PndAnaContFact)
void AddField(FairField *field)
PndAnaPidSelector *& obj
Int_t GetType() const
Definition: PndMapPar.h:51
virtual void SetParm()
PndDipolePar * fDPar