From: morsch Date: Fri, 22 Feb 2002 14:00:20 +0000 (+0000) Subject: Protection against replication of fieldmap data in gAlice. X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=7b6cddfa0032215933b9781ae6df2abd7a7c8907 Protection against replication of fieldmap data in gAlice. --- diff --git a/STEER/AliFieldMap.cxx b/STEER/AliFieldMap.cxx index 0e54c4a8105..b3b6d45deb8 100644 --- a/STEER/AliFieldMap.cxx +++ b/STEER/AliFieldMap.cxx @@ -15,6 +15,10 @@ /* $Log$ +Revision 1.1 2002/02/14 11:41:28 morsch +Magnetic field map for ALICE for L3+muon spectrometer stored in 3 seperate +root files. + */ // @@ -34,6 +38,7 @@ AliFieldMap::AliFieldMap() // Standard constructor // fB = 0; + SetWriteEnable(); } AliFieldMap::AliFieldMap(const char *name, const char *title) @@ -44,6 +49,7 @@ AliFieldMap::AliFieldMap(const char *name, const char *title) // fB = 0; ReadField(); + SetWriteEnable(); } AliFieldMap::~AliFieldMap() @@ -70,8 +76,8 @@ void AliFieldMap::ReadField() // Method to read the magnetic field map from file // FILE* magfile; - FILE* endf = fopen("end.table", "r"); - FILE* out = fopen("out", "w"); +// FILE* endf = fopen("end.table", "r"); +// FILE* out = fopen("out", "w"); Int_t ix, iy, iz, ipx, ipy, ipz; Float_t bx, by, bz; @@ -106,13 +112,14 @@ void AliFieldMap::ReadField() for (iz = 0; iz < fZn; iz++) { ipz=ipy+iz*3; - if (iz == -1) - fscanf(endf,"%f %f %f", &bx,&by,&bz); - else if (iz > -1) + if (iz == -1) { +// fscanf(endf,"%f %f %f", &bx,&by,&bz); + } else if (iz > -1) { fscanf(magfile," %f %f %f", &bx, &by, &bz); - else + } else { continue; - + } + // fscanf(magfile,"%f %f %f %f %f %f %f ", // &x, &y, &z, &bx,&by,&bz, &b); // fprintf(out, "%15.8e %15.8e %15.8e \n", bx, by, bz); @@ -220,3 +227,17 @@ AliFieldMap & AliFieldMap::operator =(const AliFieldMap &magf) magf.Copy(*this); return *this; } + +void AliFieldMap::Streamer(TBuffer &R__b) +{ + // Stream an object of class AliFieldMap. + if (R__b.IsReading()) { + AliFieldMap::Class()->ReadBuffer(R__b, this); + } else { + if (!fWriteEnable) { + delete fB; + fB = 0; + } + AliFieldMap::Class()->WriteBuffer(R__b, this); + } +} diff --git a/STEER/AliFieldMap.h b/STEER/AliFieldMap.h index 757c6ac7d3e..bfe0563f571 100644 --- a/STEER/AliFieldMap.h +++ b/STEER/AliFieldMap.h @@ -10,6 +10,7 @@ // #include #include +#include class AliFieldMap : public TNamed { @@ -59,28 +60,30 @@ public: fXbeg = xmin; fXend = xmax; fYbeg = ymin; fYend = ymax; fZbeg = zmin; fZend = zmax; } + void SetWriteEnable(Int_t flag = 1) {fWriteEnable = flag;} private: void ReadField(); protected: - - Float_t fXbeg; // Start of mesh in x - Float_t fYbeg; // Start of mesh in y - Float_t fZbeg; // Start of mesh in z - Float_t fXend; // End of mesh in x - Float_t fYend; // End of mesh in y - Float_t fZend; // End of mesh in z - Float_t fXdel; // Mesh step in x - Float_t fYdel; // Mesh step in y - Float_t fZdel; // Mesh step in z - Double_t fXdeli; // Inverse of Mesh step in x - Double_t fYdeli; // Inverse of Mesh step in y - Double_t fZdeli; // Inverse of Mesh step in z - Int_t fXn; // Number of mesh points in x - Int_t fYn; // Number of mesh points in y - Int_t fZn; // Number of mesh points in z - TVector* fB; //!Field map - ClassDef(AliFieldMap,2) //Class for Field Map + Float_t fXbeg; // Start of mesh in x + Float_t fYbeg; // Start of mesh in y + Float_t fZbeg; // Start of mesh in z + Float_t fXend; // End of mesh in x + Float_t fYend; // End of mesh in y + Float_t fZend; // End of mesh in z + Float_t fXdel; // Mesh step in x + Float_t fYdel; // Mesh step in y + Float_t fZdel; // Mesh step in z + Double_t fXdeli; // Inverse of Mesh step in x + Double_t fYdeli; // Inverse of Mesh step in y + Double_t fZdeli; // Inverse of Mesh step in z + Int_t fXn; // Number of mesh points in x + Int_t fYn; // Number of mesh points in y + Int_t fZn; // Number of mesh points in z + Int_t fWriteEnable; // Enable flag for writing of field data. + TVector* fB; // Field map + + ClassDef(AliFieldMap,3) //Class for Field Map }; #endif diff --git a/STEER/AliMagFMaps.cxx b/STEER/AliMagFMaps.cxx index 2a972536a0f..99eafbd166e 100644 --- a/STEER/AliMagFMaps.cxx +++ b/STEER/AliMagFMaps.cxx @@ -15,6 +15,9 @@ /* $Log$ +Revision 1.3 2002/02/21 09:23:41 morsch +Create dummy field map for L3 in case no detailed map is needed. + Revision 1.2 2002/02/19 16:14:35 morsch Reading of 0.2 T solenoid field map enabled. @@ -51,70 +54,82 @@ AliMagFMaps::AliMagFMaps(const char *name, const char *title, const Int_t integ, fMap = map; TFile* file = 0; if (fMap == k2kG) { - if (fL3Option) { - fFieldMap[0] = new AliFieldMap(); - fFieldMap[0]->SetLimits(-800., 800., -800., 800., -700., 700.); - } else { + if (integ) { fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B02.root"); file = new TFile(fname); fFieldMap[0] = (AliFieldMap*) file->Get("L3B02"); file->Close(); delete file; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root"); + } + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB02.root"); + file = new TFile(fname); + fFieldMap[1] = (AliFieldMap*) file->Get("DipB02"); + file->Close(); + delete file;; + + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root"); + file = new TFile(fname); + fFieldMap[2] = (AliFieldMap*) file->Get("ExtB02"); + file->Close(); + delete file; + fSolenoid = 2.; + } else if (fMap == k4kG) { + if (integ) { + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root"); file = new TFile(fname); - fFieldMap[1] = (AliFieldMap*) file->Get("DipB02"); + fFieldMap[0] = (AliFieldMap*) file->Get("L3B04"); file->Close(); - delete file;; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB02.root"); + delete file; + } + + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root"); + file = new TFile(fname); + fFieldMap[1] = (AliFieldMap*) file->Get("DipB04"); + file->Close(); + delete file;; + + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root"); + file = new TFile(fname); + fFieldMap[2] = (AliFieldMap*) file->Get("ExtB04"); + file->Close(); + delete file; + fSolenoid = 4.; + } else if (fMap == k5kG) { + if (integ) { + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root"); file = new TFile(fname); - fFieldMap[2] = (AliFieldMap*) file->Get("ExtB02"); + fFieldMap[0] = (AliFieldMap*) file->Get("L3B05"); file->Close(); delete file; } - fSolenoid = 2.; - } else if (fMap == k4kG) { - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B04.root"); - file = new TFile(fname); - fFieldMap[0] = (AliFieldMap*) file->Get("L3B04"); - file->Close(); - delete file; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB04.root"); - file = new TFile(fname); - fFieldMap[1] = (AliFieldMap*) file->Get("DipB04"); - file->Close(); - delete file;; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB04.root"); - file = new TFile(fname); - fFieldMap[2] = (AliFieldMap*) file->Get("ExtB04"); - file->Close(); - delete file; - fSolenoid = 4.; - } else if (fMap == k5kG) { - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/L3B05.root"); - file = new TFile(fname); - fFieldMap[0] = (AliFieldMap*) file->Get("L3B05"); - file->Close(); - delete file; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root"); - file = new TFile(fname); - fFieldMap[1] = (AliFieldMap*) file->Get("DipB05"); - file->Close(); - delete file;; - - fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root"); - file = new TFile(fname); - fFieldMap[2] = (AliFieldMap*) file->Get("ExtB05"); - file->Close(); - delete file; - - fSolenoid = 5.; - } - SetL3ConstField(0); + + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/DipB05.root"); + file = new TFile(fname); + fFieldMap[1] = (AliFieldMap*) file->Get("DipB05"); + file->Close(); + delete file;; + + fname = gSystem->ExpandPathName("$(ALICE_ROOT)/data/maps/ExtB05.root"); + file = new TFile(fname); + fFieldMap[2] = (AliFieldMap*) file->Get("ExtB05"); + file->Close(); + delete file; + + fSolenoid = 5.; + } + + if (!integ) { +// +// Dummy L3 map + fFieldMap[0] = new AliFieldMap(); + fFieldMap[0] -> SetLimits(-800., 800., -800., 800., -700., 700.); + } + +// +// Don't replicate field information in gAlice + for (Int_t i = 0; i < 3; i++) fFieldMap[i]->SetWriteEnable(0); +// + SetL3ConstField(0); } //________________________________________ @@ -154,12 +169,10 @@ void AliMagFMaps::Field(Float_t *x, Float_t *b) // // Method to calculate the magnetic field // - const Double_t kone=1; // --- find the position in the grid --- b[0]=b[1]=b[2]=0; AliFieldMap* map = 0; - if (fFieldMap[0]->Inside(x[0], x[1], x[2])) { map = fFieldMap[0]; if (fL3Option) {