]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Add misalignment of strip units with AliPHOSSurvey class
authorkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Apr 2007 15:47:20 +0000 (15:47 +0000)
committerkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Apr 2007 15:47:20 +0000 (15:47 +0000)
PHOS/AliPHOSSurvey.cxx [new file with mode: 0644]
PHOS/AliPHOSSurvey.h [new file with mode: 0644]
PHOS/MakePHOSFullMisAlignment.C
PHOS/MakePHOSResMisAlignment.C
PHOS/MakePHOSZeroMisAlignment.C
PHOS/PHOSLinkDef.h
PHOS/PHOSbaseLinkDef.h

diff --git a/PHOS/AliPHOSSurvey.cxx b/PHOS/AliPHOSSurvey.cxx
new file mode 100644 (file)
index 0000000..0e3c2ab
--- /dev/null
@@ -0,0 +1,198 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/* $Id$ */
+
+/* History of cvs commits:
+ *
+ * $Log$
+ */
+
+// Objects of this class read txt file with survey (photogrammetry) data
+// and convert the data into AliAlignObjAngles 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 <fstream>
+
+#include <TClonesArray.h>
+#include <TGeoManager.h>
+#include <TString.h>
+#include <TMath.h>
+
+#include "AliPHOSEMCAGeometry.h"
+#include "AliAlignObjAngles.h"
+#include "AliPHOSGeometry.h"
+#include "AliPHOSSurvey.h"
+#include "AliLog.h"
+
+ClassImp(AliPHOSSurvey)
+
+//____________________________________________________________________________
+AliPHOSSurvey::AliPHOSSurvey()
+                : fStripData()
+{
+  //Default constructor.
+}
+
+namespace {
+
+  struct Strip_t {
+    Double_t fX1;
+    Double_t fZ1;
+    Double_t fX2;
+    Double_t fZ2;
+  };
+
+}
+
+//____________________________________________________________________________
+AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
+                : fStripData()
+{
+  //Read survey data from txt file.
+  const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  if (!phosGeom) {
+    AliError("Cannot obtain AliPHOSGeometry instance.");
+    return;
+  }
+
+  std::ifstream inputFile(txtFileName.Data());
+  if (!inputFile) {
+    AliError(("Cannot open the survey file " + txtFileName).Data());
+    return;
+  }
+
+  AliPHOSEMCAGeometry  * emcaGeom = phosGeom->GetEMCAGeometry();
+  const Int_t strNum   = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
+  const Float_t *strip = emcaGeom->GetStripHalfSize();
+  const Float_t *cell  = emcaGeom->GetSteelCellHalfSize(); 
+
+  std::vector<Strip_t> idealStrips(strNum);
+  for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
+    for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
+      Strip_t &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.;
+  std::vector<Double_t> xReal(strNum * 2), zReal(strNum * 2);
+  for (Int_t i = 0; i < strNum * 2; ++i) {
+    if (!inputFile) {
+      AliError("Error while reading input file.");
+      return;
+    }
+    inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i];
+    xReal[i] *= 0.1;
+    zReal[i] *= 0.1;
+  }
+
+  std::vector<Strip_t> realStrips(strNum);
+  for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
+    for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
+      Strip_t &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.resize(strNum);
+  for (Int_t i = 0; i < strNum; ++i) {
+    const Strip_t &real = realStrips[i];
+    const Strip_t &ideal = idealStrips[i];
+    Transformation_t &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.;
+  }
+}
+
+//____________________________________________________________________________
+void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
+{
+  //Create AliAlignObjAngles.
+  const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  if (!phosGeom) {
+    AliError("Cannot obtain AliPHOSGeometry instance.");
+    return;
+  }
+
+  if (!gGeoManager) {
+    AliWarning("Cannot create local transformations for strip units - gGeoManager does not exist.");
+    AliInfo("Null shifts and rotations will be created instead.");
+    return CreateNullObjects(array, phosGeom);
+  }
+
+  AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
+  Int_t arrayInd = array.GetEntries(), iIndex = 0;
+  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
+  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+
+  for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) {
+    for (Int_t i = 0, stripNum = 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));
+        Transformation_t t(GetStripTransformation(stripNum++, module));
+        new(array[arrayInd])
+          AliAlignObjAngles(
+                            stripName.Data(), volid, 
+                            t.fXShift, t.fYShift, t.fZShift, 
+                            -t.fPsi, -t.fTheta, -t.fPhi, 
+                            kFALSE
+                           );
+        ++arrayInd;
+      }
+    }
+  }
+}
+
+//____________________________________________________________________________
+void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const
+{
+  //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);
+
+  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., kTRUE);
+        ++arrayInd;
+      }
+}
+
+//____________________________________________________________________________
+AliPHOSSurvey::Transformation_t AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const
+{
+  //Strip 'stripIndex' transformation.
+  const Transformation_t t = {0., 0., 0., 0., 0., 0.};
+  if (module != 3 || !fStripData.size())
+    return t;
+  return fStripData[stripIndex];
+}
diff --git a/PHOS/AliPHOSSurvey.h b/PHOS/AliPHOSSurvey.h
new file mode 100644 (file)
index 0000000..8df69a4
--- /dev/null
@@ -0,0 +1,64 @@
+#ifndef ALIPHOSSURVEY_H
+#define ALIPHOSSURVEY_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+/* History of cvs commits:
+ *
+ * $Log$
+ */
+
+#include <vector>
+
+#include <TObject.h>
+#include <Rtypes.h>
+
+class TClonesArray;
+class TString;
+
+class AliPHOSGeometry;
+
+/*
+  Objects of this class read txt file with survey (photogrammetry) data
+  and convert the data into AliAlignObjAngles 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".
+*/
+
+class AliPHOSSurvey : public TObject {
+public:
+  AliPHOSSurvey();
+  AliPHOSSurvey(const TString &txtFileName);
+
+  //Create AliAlignObjAngles for strips.
+  void CreateAliAlignObjAngles(TClonesArray &array);
+  //Create AliAlignObjAngles with null shifts and rotations.
+  void CreateNullObjects(TClonesArray &, const AliPHOSGeometry *)const;
+
+protected:
+  struct Transformation_t {
+    Float_t fXShift;
+    Float_t fYShift;
+    Float_t fZShift;
+    Float_t fPsi;
+    Float_t fTheta;
+    Float_t fPhi;
+  };
+
+private:
+  //Calculate shifts and rotations for strip number stripIndex in a module moduleIndex.
+  virtual Transformation_t GetStripTransformation(Int_t stripIndex, Int_t moduleIndex)const;
+
+  AliPHOSSurvey(const AliPHOSSurvey &);
+  AliPHOSSurvey &operator = (const AliPHOSSurvey &);
+
+private:
+  std::vector<Transformation_t> fStripData; // Strip unit transformation data
+
+  ClassDef(AliPHOSSurvey, 1) //Survey data reader
+};
+
+#endif
index d1fd5c680111c0c7a1a64ba054752b01c3e5d0c0..e433b941f6fece965888ab64cd9d34f3185d1de0 100644 (file)
@@ -1,18 +1,22 @@
 void MakePHOSFullMisAlignment(){
   // Create TClonesArray of full misalignment objects for PHOS
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",11);
+  const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  if (!phosGeom) {
+    Error("MakePHOSFullMisAlignment", "Cannot obtain AliPHOSGeometry singleton\n");
+    return;
+  }
+
+  AliPHOSEMCAGeometry *emca = phosGeom->GetEMCAGeometry();
+  TClonesArray *array = new TClonesArray("AliAlignObjAngles", 16 + phosGeom->GetNModules() * 
+                                         emca->GetNStripX() * emca->GetNStripZ());
   TClonesArray &alobj = *array;
    
-  AliAlignObjAngles a;
-
   Double_t dpsi=0., dtheta=0., dphi=0.;
   Double_t displacement = 10;
-
   Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
   AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
   UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
-
   Int_t i=0 ;
 
   // Alignment for 5 PHOS modules
@@ -56,9 +60,12 @@ void MakePHOSFullMisAlignment(){
   new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel3",
          volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
 
+  AliPHOSSurvey geodesicData("phos_mod3_survey.txt");
+  geodesicData.CreateAliAlignObjAngles(alobj);
+
   // *************************    2nd step    ***************
 
-  if(!gSystem->Getenv("$TOCDB")){
+  if(!gSystem->Getenv("TOCDB")){
     // save on file
     TFile f("PHOSfullMisalignment.root","RECREATE");
     if(!f) cerr<<"cannot open file for output\n";
@@ -67,13 +74,13 @@ void MakePHOSFullMisAlignment(){
     f.Close();
   }else{
     // save in CDB storage
-    const char* Storage = gSystem->Getenv("$STORAGE");
+    const char* Storage = gSystem->Getenv("STORAGE");
     AliCDBManager *CDB = AliCDBManager::Instance();
     AliCDBStorage* storage = CDB->GetStorage(Storage);
     AliCDBMetaData *md= new AliCDBMetaData();
     md->SetResponsible("Yuri Kharlov");
     md->SetComment("Alignment objects for fully misaligned geometry");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
     AliCDBId id("PHOS/Align/Data",0,9999999);
     storage->Put(array,id, md);
   }
index f63b859fc91e601848b610eed5fcf44e1da4bbbf..16ecbdf24e8599e53ccac50205d6b9391ea16702 100644 (file)
@@ -1,14 +1,19 @@
 void MakePHOSResMisAlignment(){
   // Create TClonesArray of residual misalignment objects for PHOS
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",11);
+  const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  if (!phosGeom) {
+    Error("MakePHOSFullMisAlignment", "Cannot obtain AliPHOSGeometry singleton\n");
+    return;
+  }
+
+  AliPHOSEMCAGeometry *emca = phosGeom->GetEMCAGeometry();
+  TClonesArray *array = new TClonesArray("AliAlignObjAngles", 16 + phosGeom->GetNModules() * 
+                                         emca->GetNStripX() * emca->GetNStripZ());
   TClonesArray &alobj = *array;
    
-  AliAlignObjAngles a;
-
   Double_t dpsi=0., dtheta=0., dphi=0.;
   Double_t displacement = 0.2;
-
   Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
   AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
   UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
@@ -56,8 +61,10 @@ void MakePHOSResMisAlignment(){
   new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel3",
        volid, 0., 0., +displacement, dpsi, dtheta, dphi, kTRUE);
 
+  AliPHOSSurvey geodesicData("phos_mod3_survey.txt");
+  geodesicData.CreateAliAlignObjAngles(alobj);
 
-  if(!gSystem->Getenv("$TOCDB")){
+  if(!gSystem->Getenv("TOCDB")){
     // save on file
     TFile f("PHOSresidualMisalignment.root","RECREATE");
     if(!f) cerr<<"cannot open file for output\n";
@@ -66,13 +73,13 @@ void MakePHOSResMisAlignment(){
     f.Close();
   }else{
     // save in CDB storage
-    const char* Storage = gSystem->Getenv("$STORAGE");
+    const char* Storage = gSystem->Getenv("STORAGE");
     AliCDBManager *CDB = AliCDBManager::Instance();
     AliCDBStorage* storage = CDB->GetStorage(Storage);
     AliCDBMetaData *md= new AliCDBMetaData();
     md->SetResponsible("Yuri Kharlov");
     md->SetComment("Alignment objects for slightly misaligned geometry (residual misalignment");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
     AliCDBId id("PHOS/Align/Data",0,9999999);
     storage->Put(array,id, md);
   }
index 97102753fed420983687b6ddb2c5c5005bf9a814..42d02fbea8d83e496fd390bd959e4f01e72c5db0 100644 (file)
@@ -1,13 +1,18 @@
 void MakePHOSZeroMisAlignment(){
   // Create TClonesArray of zero misalignment objects for PHOS
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",11);
+  const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
+  if (!phosGeom) {
+    Error("MakePHOSFullMisAlignment", "Cannot obtain AliPHOSGeometry singleton\n");
+    return;
+  }
+
+  AliPHOSEMCAGeometry *emca = phosGeom->GetEMCAGeometry();
+  TClonesArray *array = new TClonesArray("AliAlignObjAngles", 16 + phosGeom->GetNModules() * 
+                                         emca->GetNStripX() * emca->GetNStripZ());
   TClonesArray &alobj = *array;
    
-  AliAlignObjAngles a;
-
   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
-
   Int_t iIndex=0; // let all modules have index=0 in a layer with no LUT
   AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
   UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
@@ -54,8 +59,10 @@ void MakePHOSZeroMisAlignment(){
   new(alobj[i++]) AliAlignObjAngles("PHOS/Wheel3",
        volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
 
+  AliPHOSSurvey geodesicData;
+  geodesicData.CreateNullObjects(alobj, phosGeom);
 
-  if(!gSystem->Getenv("$TOCDB")){
+  if(!gSystem->Getenv("TOCDB")){
     // save on file
     TFile f("PHOSzeroMisalignment.root","RECREATE");
     if(!f) cerr<<"cannot open file for output\n";
@@ -64,13 +71,13 @@ void MakePHOSZeroMisAlignment(){
     f.Close();
   }else{
     // save in CDB storage
-    const char* Storage = gSystem->Getenv("$STORAGE");
+    const char* Storage = gSystem->Getenv("STORAGE");
     AliCDBManager *CDB = AliCDBManager::Instance();
     AliCDBStorage* storage = CDB->GetStorage(Storage);
     AliCDBMetaData *md= new AliCDBMetaData();
     md->SetResponsible("Yuri Kharlov");
     md->SetComment("Zero misalignment objects");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
     AliCDBId id("PHOS/Align/Data",0,9999999);
     storage->Put(array,id, md);
   }
index 10128c77aec1516c44fbc69c1cc43abefee366e0..8ea1eeeef4e7b519d79c2e7b87fe2bc5925795ab 100644 (file)
@@ -63,5 +63,6 @@
 #pragma link C++ class AliPHOSGetterLight+;
 #pragma link C++ class AliPHOSTracker+;
 #pragma link C++ class AliPHOSCalibData+;
+#pragma link C++ class AliPHOSSurvey+;
 
 #endif
index e040b22258ee8f6bfed69609fd0b1c084f2fb25a..cc328c4a9f1d79f7c4ceab38939d79d050403ed6 100644 (file)
@@ -30,5 +30,6 @@
 #pragma link C++ class AliPHOSRawDecoder+;
 #pragma link C++ class AliPHOSRawDigiProducer+;
 #pragma link C++ class AliPHOSEmcBadChannelsMap+;
+#pragma link C++ class AliPHOSSurvey+;
 
 #endif