FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
create_misalign_parameter.C
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 void create_misalign_parameter(Int_t nrOfDetLayers = 40)
9 {
10  Bool_t misalignX = kTRUE;
11  Bool_t misalignY = kTRUE;
12  Bool_t misalignZ = kFALSE;
13  Bool_t rotX = kFALSE;
14  Bool_t rotY = kFALSE;
15  Bool_t rotZ = kFALSE;
16 
17  Float_t* ShiftX = new Float_t[nrOfDetLayers];
18  Float_t* ShiftY = new Float_t[nrOfDetLayers];
19  Float_t* ShiftZ = new Float_t[nrOfDetLayers];
20  Float_t* RotX = new Float_t[nrOfDetLayers];
21  Float_t* RotY = new Float_t[nrOfDetLayers];
22  Float_t* RotZ = new Float_t[nrOfDetLayers];
23 
24  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
25  ShiftX[iLayer] = 0.;
26  ShiftY[iLayer] = 0.;
27  ShiftZ[iLayer] = 0.;
28  RotX[iLayer] = 0.;
29  RotY[iLayer] = 0.;
30  RotZ[iLayer] = 0.;
31  }
32 
33  Int_t lastEntry = nrOfDetLayers - 1;
34 
35  for (Int_t iLayer = 1; iLayer < lastEntry; ++iLayer) {
36 
37  Float_t shiftx = gRandom->Uniform(-1., 1.);
38  Float_t shifty = gRandom->Uniform(-1., 1.);
39  Float_t shiftz = gRandom->Uniform(-1., 1.);
40  Float_t rotx = gRandom->Uniform(-1., 1.);
41  Float_t roty = gRandom->Uniform(-1., 1.);
42  Float_t rotz = gRandom->Uniform(-1., 1.);
43 
44  if (misalignX)
45  ShiftX[iLayer] = shiftx;
46  if (misalignY)
47  ShiftY[iLayer] = shifty;
48  if (misalignZ)
49  ShiftZ[iLayer] = shiftz;
50  if (rotX)
51  RotX[iLayer] = rotx;
52  if (rotY)
53  RotY[iLayer] = roty;
54  if (rotZ)
55  RotZ[iLayer] = rotz;
56  }
57 
58  ofstream myfile;
59  myfile.open("example.par");
60 
61  myfile << "##############################################################################" << endl;
62  myfile << "# Class: FairTutorialDetMissallignPar" << endl;
63  myfile << "# Context: TestDefaultContext" << endl;
64  myfile << "##############################################################################" << endl;
65  myfile << "[FairTutorialDetMissallignPar]" << endl;
66  myfile << "//----------------------------------------------------------------------------" << endl;
67  myfile << "NrOfDetectors: Int_t " << nrOfDetLayers << endl;
68  myfile << "ShiftX: Double_t \\ " << endl;
69 
70  Int_t counter = 0;
71 
72  myfile << " ";
73  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
74  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
75  myfile << ShiftX[iLayer] << " \\" << endl;
76  myfile << " ";
77  counter = 0;
78  } else {
79  myfile << ShiftX[iLayer] << " ";
80  ++counter;
81  }
82  }
83  myfile << endl;
84 
85  myfile << "ShiftY: Double_t \\ " << endl;
86 
87  counter = 0;
88 
89  myfile << " ";
90  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
91  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
92  myfile << ShiftY[iLayer] << " \\" << endl;
93  myfile << " ";
94  counter = 0;
95  } else {
96  myfile << ShiftY[iLayer] << " ";
97  ++counter;
98  }
99  }
100  myfile << endl;
101 
102  myfile << "ShiftZ: Double_t \\ " << endl;
103 
104  counter = 0;
105 
106  myfile << " ";
107  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
108  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
109  myfile << ShiftZ[iLayer] << " \\" << endl;
110  myfile << " ";
111  counter = 0;
112  } else {
113  myfile << ShiftZ[iLayer] << " ";
114  ++counter;
115  }
116  }
117  myfile << endl;
118 
119  myfile << "RotationX: Double_t \\ " << endl;
120 
121  counter = 0;
122 
123  myfile << " ";
124  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
125  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
126  myfile << RotX[iLayer] << " \\" << endl;
127  myfile << " ";
128  counter = 0;
129  } else {
130  myfile << RotX[iLayer] << " ";
131  ++counter;
132  }
133  }
134  myfile << endl;
135 
136  myfile << "RotationY: Double_t \\ " << endl;
137 
138  counter = 0;
139 
140  myfile << " ";
141  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
142  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
143  myfile << RotY[iLayer] << " \\" << endl;
144  myfile << " ";
145  counter = 0;
146  } else {
147  myfile << RotY[iLayer] << " ";
148  ++counter;
149  }
150  }
151  myfile << endl;
152 
153  myfile << "RotationZ: Double_t \\ " << endl;
154 
155  counter = 0;
156 
157  myfile << " ";
158  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
159  if ((9 == counter) && (1 != nrOfDetLayers - iLayer)) {
160  myfile << RotZ[iLayer] << " \\" << endl;
161  myfile << " ";
162  counter = 0;
163  } else {
164  myfile << RotZ[iLayer] << " ";
165  ++counter;
166  }
167  }
168  myfile << endl;
169 
170  myfile << "##############################################################################" << endl;
171 
172  myfile.close();
173 
174  ofstream myfile;
175  myfile.open("shifts.txt");
176 
177  for (Int_t iLayer = 0; iLayer < nrOfDetLayers; ++iLayer) {
178  if (misalignX)
179  myfile << iLayer + 1 << " " << ShiftX[iLayer] << endl;
180  if (misalignY)
181  myfile << iLayer + 101 << " " << ShiftY[iLayer] << endl;
182  if (misalignZ)
183  myfile << iLayer + 201 << " " << ShiftZ[iLayer] << endl;
184  if (rotX)
185  myfile << iLayer + 301 << " " << RotX[iLayer] << endl;
186  if (rotY)
187  myfile << iLayer + 401 << " " << RotY[iLayer] << endl;
188  if (rotZ)
189  myfile << iLayer + 501 << " " << RotZ[iLayer] << endl;
190  }
191 
192  myfile.close();
193 }
void create_misalign_parameter(Int_t nrOfDetLayers=40)