]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMagFMaps.cxx
To test the retrieval and storage of raw tag files, return in case of DCS problems...
[u/mrichter/AliRoot.git] / STEER / AliMagFMaps.cxx
index 921a641110d15b1b472f5302df6e16483518c2d9..c854dbb9973efc490ea7152bb05b565a4cea1587 100644 (file)
 // Author: Andreas Morsch <andreas.morsch@cern.ch>
 //------------------------------------------------------------------------
 
+#include <TClass.h>
 #include <TFile.h>
+#include <TMath.h>
 #include <TSystem.h>
-#include <TVector.h>
 
+#include "AliLog.h"
 #include "AliFieldMap.h"
 #include "AliMagFMaps.h"
 
 ClassImp(AliMagFMaps)
+    
 
 //_______________________________________________________________________
 AliMagFMaps::AliMagFMaps():
   fSolenoid(0),
   fSolenoidUser(0.),
-  fL3Option(0),
-  fFieldRead(0)
+  fL3Option(0)
 {
   //
   // Default constructor
   //
+  //
+  // Don't replicate field information in gAlice
   fFieldMap[0] = fFieldMap[1] = fFieldMap[2] = 0;
 }
 
@@ -51,8 +55,7 @@ AliMagFMaps::AliMagFMaps(const char *name, const char *title, Int_t integ,
   AliMagFC(name,title,integ,factor,fmax),
   fSolenoid(0),
   fSolenoidUser(0),
-  fL3Option(l3),
-  fFieldRead(0)
+  fL3Option(l3)
 {
   //
   // Standard constructor
@@ -62,7 +65,6 @@ AliMagFMaps::AliMagFMaps(const char *name, const char *title, Int_t integ,
   fMap          = map;
   fL3Option     = l3;
   ReadField();
-  fFieldRead = 1;
   //
   // Don't replicate field information in gAlice
   for (Int_t i = 0; i < 3; i++)  fFieldMap[i]->SetWriteEnable(0);
@@ -73,8 +75,8 @@ AliMagFMaps::AliMagFMaps(const char *name, const char *title, Int_t integ,
 AliMagFMaps::AliMagFMaps(const AliMagFMaps &magf):
   AliMagFC(magf),
   fSolenoid(0),
-  fL3Option(0),
-  fFieldRead(0)
+  fSolenoidUser(0),
+  fL3Option(0)
 {
   //
   // Copy constructor
@@ -100,10 +102,12 @@ void AliMagFMaps::ReadField()
   //
   //  don't read twice
   //
-  if (fFieldRead) return;
-  fFieldRead = 1;
+    if (!fReadField) return;
+    fReadField = kFALSE;
   //    
-  char* fname;
+   
+
+  char* fname = 0;
   TFile* file = 0;
   if (fMap == k2kG) {
       fSolenoid = 2.;
@@ -112,17 +116,19 @@ void AliMagFMaps::ReadField()
       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B02"));
       file->Close();
       delete file;
+      delete [] fname; // see documentation to expand filenam
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root");
       file = new TFile(fname);
       fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB02"));
       file->Close();
       delete file;;
-      
+      delete [] fname;
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root");
       file = new TFile(fname);
       fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB02"));
       file->Close();
       delete file;
+      delete [] fname;
   } else if (fMap == k4kG) {
       fSolenoid = 4.;
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root");
@@ -130,16 +136,19 @@ void AliMagFMaps::ReadField()
       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B04"));
       file->Close();
       delete file;
+      delete [] fname;
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root");
       file = new TFile(fname);
       fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB04"));
       file->Close();
+      delete [] fname;
       delete file;
       
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root");
       file = new TFile(fname);
       fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB04"));
       file->Close();
+      delete [] fname;
       delete file;
   } else if (fMap == k5kG) {
       fSolenoid = 5.;
@@ -147,18 +156,20 @@ void AliMagFMaps::ReadField()
       file = new TFile(fname);
       fFieldMap[0] = dynamic_cast<AliFieldMap*>(file->Get("L3B05"));
       file->Close();
-      delete file;
+      delete file;      
+      delete [] fname;
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root");
       file = new TFile(fname);
       fFieldMap[1] = dynamic_cast<AliFieldMap*>(file->Get("DipB05"));
       file->Close();
       delete file;
-      
+      delete [] fname;
       fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root");
       file = new TFile(fname);
       fFieldMap[2] = dynamic_cast<AliFieldMap*>(file->Get("ExtB05"));
       file->Close();
       delete file;
+      delete [] fname;
   }
 
   if (!fL3Option) fSolenoidUser = fSolenoid;
@@ -172,11 +183,11 @@ Float_t AliMagFMaps::SolenoidField() const
   // Returns max. L3 (solenoid) field strength 
   // according to field map setting 
   //
-  return fSolenoid;
+  return -Factor()*fSolenoid;
 }
 
 //_______________________________________________________________________
-void AliMagFMaps::Field(Float_t *x, Float_t *b)
+void AliMagFMaps::Field(Float_t *x, Float_t *b) const
 {
   //
   // Method to calculate the magnetic field
@@ -185,7 +196,7 @@ void AliMagFMaps::Field(Float_t *x, Float_t *b)
   
 
     
-    if (!fFieldRead) ReadField();
//    if (!fFieldRead) ReadField();
 
   //
   // Field Maps have been calculated for the coordinate system in which 
@@ -202,11 +213,13 @@ void AliMagFMaps::Field(Float_t *x, Float_t *b)
   AliFieldMap* map = 0;
   if (fFieldMap[0]->Inside(xm[0], xm[1], xm[2])) {
       map = fFieldMap[0];
-      if (!fL3Option && TMath::Abs(xm[2]) < 370.) {
+      Float_t r = TMath::Sqrt(xm[0] * xm[0] + xm[1] * xm[1]);
+      
+      if (!fL3Option && TMath::Abs(xm[2]) < 370. && r < 550.) {
       //
       //     Constant L3 field , if this option was selected
       //
-         b[2] = - fSolenoid;
+       b[2] = (- fSolenoid)*fFactor;
          return;
       } 
   } else if (fFieldMap[1]->Inside(xm[0], xm[1], xm[2])) {
@@ -239,7 +252,7 @@ void AliMagFMaps::Copy(TObject & /* magf */) const
   //
   // Copy *this onto magf -- Not implemented
   //
-  Fatal("Copy","Not implemented!\n");
+  AliFatal("Not implemented!");
 }
 
 //_______________________________________________________________________
@@ -247,9 +260,11 @@ void AliMagFMaps::Streamer(TBuffer &R__b)
 {
   // Stream an object of class AliMagFMaps.
   if (R__b.IsReading()) {
-    AliMagFMaps::Class()->ReadBuffer(R__b, this);
-    fFieldRead = 0;
+   R__b.ReadClassBuffer(AliMagFMaps::Class(), this);
+   // 
+   fReadField = kTRUE;
+   ReadField();
   } else {
-    AliMagFMaps::Class()->WriteBuffer(R__b, this);
+    R__b.WriteClassBuffer(AliMagFMaps::Class(), this);
   }
 }