Test for Coverity
[u/mrichter/AliRoot.git] / TPC / AliTPCMisAligner.cxx
CommitLineData
d02cfd55 1/**************************************************************************
2 * Copyright(c) 2007-2010, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//========================================================================
17//
18// This class generates misalignment for TPC. In particular it defines
19// the misalignment in the three canonical scenarios: "ideal", "residual"
20// and "full".
21// It is meant to be run standalone or from the steering macro
22// $ALICE_ROOT/macros/MakeAlignmentObjs.C
23// looping on the detectors.
24//
25//========================================================================
26
27#include "AliTPCMisAligner.h"
28#include "AliGeomManager.h"
29#include "TClonesArray.h"
30#include "TGeoManager.h"
31#include "TRandom.h"
32#include "AliAlignObjParams.h"
33#include "AliLog.h"
34
35ClassImp(AliTPCMisAligner)
36
37 //_______________________________________________________________________________________
38AliTPCMisAligner::AliTPCMisAligner() : AliMisAligner()
39{
40 //
41 // dummy constructor
42 //
43}
44
45//_______________________________________________________________________________________
46TClonesArray* AliTPCMisAligner::MakeAlObjsArray() {
47 // builds and returns the array of alignment objects
48 // according to the spcified misalignment scenario
49 // ("ideal", "residual" or "full").
50 //
51 if(!AliGeomManager::GetGeometry())
52 {
53 AliError("No geometry loaded into AliGeomManager! Returning null pointer!");
54 return 0;
55 }
56
57 TClonesArray *array = new TClonesArray("AliAlignObjParams",73);
58 TClonesArray &alobj = *array;
59
60 gRandom->SetSeed(4357);
61 Int_t j = 0;
62 // misalignment of the whole TPC according to survey
63 Double_t dx=-0.159, dy=-0.05, dz=0.034, dpsi=-0.00183, dtheta=0.01835, dphi=0.02865;
64 new(alobj[j++]) AliAlignObjParams("ALIC_1/TPC_M_1", 0, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
65 AliAlignObjParams* alObjTPC = (AliAlignObjParams*) array->UncheckedAt(0);
66 alObjTPC->ApplyToGeometry();
67
68 if(TString(GetMisalType())=="ideal")
69 {
70
71 dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
72 for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
73 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
74
75 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
76 const char *symname = AliGeomManager::SymName(volid);
77 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
78 }
79 }
80
81 }else if(TString(GetMisalType())=="residual" || TString(GetMisalType())=="full"){
82 // sigma translation = 0.1 mm
83 // sigma rotation = 0.1 mrad
84 // RS = local
85
86 Double_t sigmatr=0.01;
87 Double_t sigmarot = 0.006;
88
89 for (Int_t iLayer = AliGeomManager::kTPC1; iLayer <= AliGeomManager::kTPC2; iLayer++) {
90 for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
91
92 dx = gRandom->Gaus(0,sigmatr);
93 dy = gRandom->Gaus(0,sigmatr);
94 dz = gRandom->Gaus(0,sigmatr);
95 dpsi = gRandom->Gaus(0,sigmarot);
96 dtheta = gRandom->Gaus(0,sigmarot);
97 dphi = gRandom->Gaus(0,sigmarot);
98
99 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
100 const char *symname = AliGeomManager::SymName(volid);
101 new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
102 }
103 }
104 }else{
105 AliError(Form("\"%s\" is not a valid identifier for misalignment types. Exiting ...",GetMisalType()));
106 return 0;
107 }
108
109 return array;
110}
111
112//_______________________________________________________________________________________
113AliCDBMetaData* AliTPCMisAligner::GetCDBMetaData() const {
114 // Returns the comment and responsible for the
115 // AliCDBMetaData to be associated with the OCDB entry
116 // containing the TPC array of misalignment objects
117 //
118 AliCDBMetaData* md = new AliCDBMetaData();
119 md->SetResponsible("");
120
121 if(TString(GetMisalType())=="ideal")
122 md->SetComment("Alignment objects for TPC ideal misalignment");
123 if(TString(GetMisalType())=="residual")
124 md->SetComment("Alignment objects for TPC residual misalignment");
125 if(TString(GetMisalType())=="full")
126 md->SetComment("Alignment objects for TPC full misalignment");
127
128 return md;
129}