From: kharlov Date: Thu, 19 Apr 2007 15:47:20 +0000 (+0000) Subject: Add misalignment of strip units with AliPHOSSurvey class X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=3c759505f362cb280f68c4cb5c9566c65977b632;p=u%2Fmrichter%2FAliRoot.git Add misalignment of strip units with AliPHOSSurvey class --- diff --git a/PHOS/AliPHOSSurvey.cxx b/PHOS/AliPHOSSurvey.cxx new file mode 100644 index 00000000000..0e3c2aba885 --- /dev/null +++ b/PHOS/AliPHOSSurvey.cxx @@ -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 + +#include +#include +#include +#include + +#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 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 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 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 index 00000000000..8df69a4c371 --- /dev/null +++ b/PHOS/AliPHOSSurvey.h @@ -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 + +#include +#include + +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 fStripData; // Strip unit transformation data + + ClassDef(AliPHOSSurvey, 1) //Survey data reader +}; + +#endif diff --git a/PHOS/MakePHOSFullMisAlignment.C b/PHOS/MakePHOSFullMisAlignment.C index d1fd5c68011..e433b941f6f 100644 --- a/PHOS/MakePHOSFullMisAlignment.C +++ b/PHOS/MakePHOSFullMisAlignment.C @@ -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); } diff --git a/PHOS/MakePHOSResMisAlignment.C b/PHOS/MakePHOSResMisAlignment.C index f63b859fc91..16ecbdf24e8 100644 --- a/PHOS/MakePHOSResMisAlignment.C +++ b/PHOS/MakePHOSResMisAlignment.C @@ -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); } diff --git a/PHOS/MakePHOSZeroMisAlignment.C b/PHOS/MakePHOSZeroMisAlignment.C index 97102753fed..42d02fbea8d 100644 --- a/PHOS/MakePHOSZeroMisAlignment.C +++ b/PHOS/MakePHOSZeroMisAlignment.C @@ -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); } diff --git a/PHOS/PHOSLinkDef.h b/PHOS/PHOSLinkDef.h index 10128c77aec..8ea1eeeef4e 100644 --- a/PHOS/PHOSLinkDef.h +++ b/PHOS/PHOSLinkDef.h @@ -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 diff --git a/PHOS/PHOSbaseLinkDef.h b/PHOS/PHOSbaseLinkDef.h index e040b22258e..cc328c4a9f1 100644 --- a/PHOS/PHOSbaseLinkDef.h +++ b/PHOS/PHOSbaseLinkDef.h @@ -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