]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add static functions to read magnetic field value from a file.
authorjchudoba <jchudoba@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2003 15:36:41 +0000 (15:36 +0000)
committerjchudoba <jchudoba@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Mar 2003 15:36:41 +0000 (15:36 +0000)
STEER/AliTracker.cxx
STEER/AliTracker.h

index 9fd6119b6550f4a7de067df30fc10eb91bc9d949..280155dd2b48d6d6acbd556af7bdac02e5fcd4d0 100644 (file)
 #include "AliTracker.h"
 #include "AliCluster.h"
 #include "AliKalmanTrack.h"
+#include "AliRun.h"
+#include "AliMagF.h"
+
+#include "TFile.h"
+#include "Riostream.h"
+
+
+extern AliRun* gAlice;
 
 ClassImp(AliTracker)
 
@@ -86,4 +94,44 @@ void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
   }
 }
 
+////////////////////////////////////////////////////////////////////////
+Int_t AliTracker::SetFieldFactor() {
+//
+// Utility class to set the value of the magnetic field in the barrel
+// It supposes that the correct object gAlice is in the memory
+//
+   AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
+   cout<<"Magnetic field in kGauss: "<<gAlice->Field()->SolenoidField()<<endl;
+   return 0;
+}
+////////////////////////////////////////////////////////////////////////
+Int_t AliTracker::SetFieldFactor(TFile *file, Bool_t deletegAlice) {
+//
+// Utility class to set the value of the magnetic field in the barrel
+// gAlice object is read from the file, and optionally deleted
+// 
+  if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
+    cerr<<"gAlice has not been found in file "<<file->GetName();
+    return 1;
+  }   
+  Int_t rc = SetFieldFactor();
+  if (deletegAlice) {
+    delete gAlice;  
+    gAlice = 0;
+  }
+  return rc;
+}
+////////////////////////////////////////////////////////////////////////
+Int_t AliTracker::SetFieldFactor(Char_t* fileName, Bool_t closeFile) {
+//
+// Utility class to set the value of the magnetic field in the barrel
+// gAlice object is read from the file, the file is optionally closed
+// 
+   TFile *file=TFile::Open(fileName);
+   if (!file->IsOpen()) {cerr<<"Cannnot open "<<fileName<<" !\n"; return 1;}
+   Int_t rc = SetFieldFactor(file, closeFile) ;
+   if (closeFile) file->Close();
+   return rc;
+}
+////////////////////////////////////////////////////////////////////////
 
index 2ed13b04f1ed816f9069bb509fc721ce3dbe9d70..3f01f55d5e763f2a234f0714e81e33c6a5e31393 100644 (file)
@@ -7,7 +7,7 @@
 
 //-------------------------------------------------------------------------
 //                          class AliTracker
-//
+//   that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker
 //       Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch 
 //-------------------------------------------------------------------------
 #include <Rtypes.h>
@@ -34,6 +34,10 @@ public:
   Double_t GetZ() const {return fZ;}
   Int_t GetEventNumber() const {return fEventN;}
 
+  static Int_t SetFieldFactor(Char_t* fileName, Bool_t closeFile = kTRUE);
+  static Int_t SetFieldFactor(TFile* file, Bool_t deletegAlice = kTRUE);
+  static Int_t SetFieldFactor();
+  
 private:
   Int_t fEventN;//event number