]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSSurvey.cxx
Fixed memory leaks for #86360: High memory consumption in 2.76TeV p+p RAW reco jobs
[u/mrichter/AliRoot.git] / PHOS / AliPHOSSurvey.cxx
index de30aef04f580c0d69f3e797c5b45fc12cdc43b8..06a04833c4f5dac7c83bfe8606536ac26f54ea72 100644 (file)
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.6  2007/08/28 13:12:18  hristov
+ * AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
+ *
+ * Revision 1.5  2007/07/10 12:41:38  kharlov
+ * Added a new class AliPHOSSurvet1 which read survey data from EDMS files
+ *
+ * Revision 1.4  2007/05/17 17:34:54  kharlov
+ * Merging differences if v1.2 and 1.3
+ *
+ * Revision 1.3  2007/05/17 17:13:32  kharlov
+ * Coding convensions satisfied (T.Pocheptsov)
+ *
  * Revision 1.1  2007/04/19 15:47:20  kharlov
  * Add misalignment of strip units with AliPHOSSurvey class
  *
  */
 
 // Objects of this class read txt file with survey (photogrammetry) data
-// and convert the data into AliAlignObjAngles of alignable PHOS volumes.
+// and convert the data into AliAlignObjParams of alignable PHOS volumes.
 // It can be used as a base class, you need to override GetStripTransformation.
 // AliPHOSSurvey inherits TObject only to use AliLog "functions".
 // Author: Timur Pocheptsov (JINR)
 #include <TString.h>
 #include <TMath.h>
 
+#include "AliSurveyObj.h"
+
 #include "AliPHOSEMCAGeometry.h"
-#include "AliAlignObjAngles.h"
+#include "AliAlignObjParams.h"
 #include "AliPHOSGeometry.h"
 #include "AliPHOSSurvey.h"
 #include "AliLog.h"
@@ -83,29 +97,20 @@ AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
 
   AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
   fStrNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
-  const Float_t *strip = emcaGeom->GetStripHalfSize();
-  const Float_t *cell = emcaGeom->GetSteelCellHalfSize(); 
-
-  AliPHOSStripCoords *idealStrips = new AliPHOSStripCoords[fStrNum];//1
-  for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
-    for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
-      AliPHOSStripCoords &str = idealStrips[stripNumber++];
-      str.fX1 = ix * 2 * strip[0];
-      str.fX2 = str.fX1 + 14 * cell[0];
-      str.fZ1 = iz * 2 * strip[2];
-      str.fZ2 = str.fZ1 + 2 * cell[2];
-    }
-  }
 
   Int_t dummyInt = 0;
   Double_t dummyY = 0.;
   Double_t *xReal = new Double_t[fStrNum * 2];//2
   Double_t *zReal = new Double_t[fStrNum * 2];//3
 
+  for (Int_t i = 0; i < fStrNum * 2; ++i) {
+    xReal[i] = 0.;
+    zReal[i] = 0.;
+  }
+  
   for (Int_t i = 0; i < fStrNum * 2; ++i) {
     if (!inputFile) {
       AliError("Error while reading input file.");
-      delete [] idealStrips;
       delete [] xReal;
       delete [] zReal;
       return;
@@ -115,36 +120,10 @@ AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
     zReal[i] *= 0.1;
   }
 
-  AliPHOSStripCoords *realStrips = new AliPHOSStripCoords[fStrNum];//4
+  InitStripData(xReal, zReal);
 
-  for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
-    for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
-      AliPHOSStripCoords &str = realStrips[stripNumber++];
-      str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()];
-      str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()];
-      str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()];
-      str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()];
-    }
-  }
-
-  fStripData = new AliPHOSStripDelta[fStrNum];
-  
-  for (Int_t i = 0; i < fStrNum; ++i) {
-    const AliPHOSStripCoords &real = realStrips[i];
-    const AliPHOSStripCoords &ideal = idealStrips[i];
-    AliPHOSStripDelta &t = fStripData[i];
-    t.fTheta = TMath::ATan((real.fZ2 - real.fZ1)  / (real.fX2 - real.fX1)) - 
-               TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1));
-    t.fTheta *= TMath::RadToDeg();
-    t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2;
-    t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2;
-    t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.;
-  }
-  
-  delete [] realStrips;
   delete [] zReal;
   delete [] xReal;
-  delete [] idealStrips;
 }
 
 //____________________________________________________________________________
@@ -154,9 +133,9 @@ AliPHOSSurvey::~AliPHOSSurvey()
 }
 
 //____________________________________________________________________________
-void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
+void AliPHOSSurvey::CreateAliAlignObjParams(TClonesArray &array)
 {
-  //Create AliAlignObjAngles.
+  //Create AliAlignObjParams.
   const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
   if (!phosGeom) {
     AliError("Cannot obtain AliPHOSGeometry instance.");
@@ -171,8 +150,8 @@ void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
 
   AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
   Int_t arrayInd = array.GetEntries(), iIndex = 0;
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
 
   for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) {
     for (Int_t i = 0, stripNum = 0; i < emcaGeom->GetNStripX(); ++i) {
@@ -180,7 +159,7 @@ void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
         TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
         AliPHOSStripDelta t(GetStripTransformation(stripNum++, module));
         new(array[arrayInd])
-          AliAlignObjAngles(
+          AliAlignObjParams(
                             stripName.Data(), volid, 
                             t.fXShift, t.fYShift, t.fZShift, 
                             -t.fPsi, -t.fTheta, -t.fPhi, 
@@ -198,14 +177,14 @@ void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry
   //Create null shifts and rotations.
   const AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
   Int_t arrayInd = array.GetEntries(), iIndex = 0;
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
 
   for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module)
     for (Int_t i = 0; i < emcaGeom->GetNStripX(); ++i)
       for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
         TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
-        new(array[arrayInd]) AliAlignObjAngles(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., true);
+        new(array[arrayInd]) AliAlignObjParams(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., true);
         ++arrayInd;
       }
 }
@@ -219,3 +198,51 @@ AliPHOSSurvey::AliPHOSStripDelta AliPHOSSurvey::GetStripTransformation(Int_t str
     return t;
   return fStripData[stripIndex];
 }
+
+//____________________________________________________________________________
+void AliPHOSSurvey::InitStripData(const Double_t *xReal, const Double_t *zReal)
+{
+  const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
+  const Float_t *strip = emcaGeom->GetStripHalfSize();
+  const Float_t *cell  = emcaGeom->GetAirCellHalfSize(); 
+
+  AliPHOSStripCoords *idealStrips = new AliPHOSStripCoords[fStrNum];//1
+  for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
+    for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
+      AliPHOSStripCoords &str = idealStrips[stripNumber++];
+      str.fX1 = ix * 2 * strip[0];
+      str.fX2 = str.fX1 + 14 * cell[0];
+      str.fZ1 = iz * 2 * strip[2];
+      str.fZ2 = str.fZ1 + 2 * cell[2];
+    }
+  }
+
+  AliPHOSStripCoords *realStrips = new AliPHOSStripCoords[fStrNum];//4
+  for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
+    for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
+      AliPHOSStripCoords &str = realStrips[stripNumber++];
+      str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()];
+      str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()];
+      str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()];
+      str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()];
+    }
+  }
+
+  fStripData = new AliPHOSStripDelta[fStrNum];
+  
+  for (Int_t i = 0; i < fStrNum; ++i) {
+    const AliPHOSStripCoords &real = realStrips[i];
+    const AliPHOSStripCoords &ideal = idealStrips[i];
+    AliPHOSStripDelta &t = fStripData[i];
+    t.fTheta = TMath::ATan((real.fZ2 - real.fZ1)  / (real.fX2 - real.fX1)) - 
+               TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1));
+    t.fTheta *= TMath::RadToDeg();
+    t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2;
+    t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2;
+    t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.;
+  }
+
+  delete [] realStrips;
+  delete [] idealStrips;
+}