]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALShishKebabModule.cxx
- added the PHOS library to the autotools configuration
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALShishKebabModule.cxx
CommitLineData
1963b290 1/**************************************************************************
25ab8a31 2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
1963b290 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/* $Id$ */
17
25ab8a31 18//_________________________________________________________________________
19// Main class for "twist" geometry of Shish-Kebab case.
20// Author: Aleksei Pavlinov(WSU).
21// Sep 20004.
22// See web page with description of Shish-Kebab geometries:
23// http://pdsfweb01.nersc.gov/~pavlinov/ALICE/SHISHKEBAB/RES/shishkebabALICE.html
24//_________________________________________________________________________
25
1963b290 26#include "AliEMCALShishKebabModule.h"
27#include "AliEMCALGeometry.h"
1963b290 28#include <TGraph.h>
25ab8a31 29#include <TMath.h>
1963b290 30
31ClassImp(AliEMCALShishKebabModule)
32
33 AliEMCALGeometry *AliEMCALShishKebabModule::fgGeometry=0;
34 Double_t AliEMCALShishKebabModule::fga=0.;
35 Double_t AliEMCALShishKebabModule::fgb=0.;
36 Double_t AliEMCALShishKebabModule::fgr=0.;
37
0a4cb131 38//_________________________________________________________________________
25ab8a31 39AliEMCALShishKebabModule::AliEMCALShishKebabModule() : TNamed()
40{
41 // theta in radians ; first object shold be with theta=pi/2.
1963b290 42 if(fgGeometry==0) {
25ab8a31 43 fTheta = TMath::PiOver2();
1963b290 44 if(GetParameters()) {
45 DefineFirstModule();
25ab8a31 46 DefineName(fTheta);
1963b290 47 }
25ab8a31 48 } else {
49 Warning("AliEMCALShishKebabModule(theta)","You should call this constractor just once !!");
50 }
1963b290 51}
52
0a4cb131 53//_________________________________________________________________________
1963b290 54AliEMCALShishKebabModule::AliEMCALShishKebabModule(AliEMCALShishKebabModule &leftNeighbor) : TNamed()
25ab8a31 55{
56 // 22-sep-04
1963b290 57 TObject::SetUniqueID(leftNeighbor.GetUniqueID()+1);
58 Init(leftNeighbor.GetA(),leftNeighbor.GetB());
59}
60
0a4cb131 61//_________________________________________________________________________
62AliEMCALShishKebabModule::AliEMCALShishKebabModule(const AliEMCALShishKebabModule& mod) : TNamed(mod.GetName(),mod.GetTitle())
63{
64 //copy ctor
65 fOK = mod.fOK;
66 fA = mod.fA;
67 fB = mod.fB;
68 fTheta = mod.fTheta;
69
70}
71
72//_________________________________________________________________________
25ab8a31 73void AliEMCALShishKebabModule::Init(Double_t A, Double_t B)
1963b290 74{
25ab8a31 75 //
76 // Initialisation method
77 //
1963b290 78 Double_t thetaMin, thetaMax, par[4];
79 Int_t npar=0;
80 if(A<0){
81 // DefineSecondModuleFirstAssumption();
82 thetaMax = TMath::ATan2(fgr, 1.4*fga);
83 thetaMin = TMath::ATan2(fgr, 1.6*fga);
84 fTheta = Solve(AliEMCALShishKebabModule::Y2, thetaMin,thetaMax,npar,par);
85 } else{
86 npar = 4;
87 par[0] = fga;
88 par[1] = fgr;
89 par[2] = A;
90 par[3] = B;
91 Double_t x = fgr/A;
92 thetaMax = TMath::ATan2(fgr,x + 0.5*fga);
93 thetaMin = TMath::ATan2(fgr,x + 1.5*fga);
94 fTheta = Solve(AliEMCALShishKebabModule::YALL, thetaMin,thetaMax,npar,par);
95 }
96
97 Double_t rOK = fgr / TMath::Sin(fTheta) + (fga/2.)/TMath::Tan(fTheta) + fgb/2.;
98 fOK.SetMagPhi(rOK, fTheta);
99 // have to define A and B
100 fA = TMath::Tan(fTheta);
101 fB = -fga/(2.*TMath::Cos(fTheta));
102 DefineName(fTheta);
103}
104
0a4cb131 105//_________________________________________________________________________
1963b290 106void AliEMCALShishKebabModule::DefineFirstModule()
107{
25ab8a31 108 // Define first module
1963b290 109 fOK.Set(fga/2., fgr + fgb/2.); // position the center of module vs o
110
111 fB = fga/2.; // z=fB
112 fA = -999.; // fA=infinite in this case
113 TObject::SetUniqueID(1); //
114}
115
0a4cb131 116//_________________________________________________________________________
1963b290 117void AliEMCALShishKebabModule::DefineSecondModuleFirstAssumption()
118{ // Keep for testing and checking
119 // cos(theta) << 1, theta ~ pi/2.; a/r = 11.4/462.54 = 0.0246465 << 1;
120 // theta=1.53382 from this case; theta=1.533869 from TGraph::Zero
121 Double_t x = (3.*fga)/(2.*fgr);
122 fTheta = TMath::ACos(x);
123 /*
124 Double_t rOK = fgr / TMath::Sin(fTheta) + (fga/2.)/TMath::Tan(fTheta) + fgb/2.;
125 fOK.SetMagPhi(rOK, fTheta);
126 // have to define A and B
127 fA = TMath::Tan(fTheta);
128 fB = -fga/(2.*TMath::Cos(fTheta));
129 DefineName(fTheta);
130 */
131}
132
0a4cb131 133//_________________________________________________________________________
1963b290 134Double_t AliEMCALShishKebabModule::Solve(Double_t (*fcn)(Double_t*,Double_t*),
135Double_t xmin, Double_t xmax, Int_t npar, Double_t *par, Double_t eps, Int_t maxIter)
136{
25ab8a31 137 // Find out "zero" using TGraph method
1963b290 138 if(npar); // unused now
139 TGraph gr;
25ab8a31 140 Double_t x,y;
1963b290 141 Int_t k = 0;
25ab8a31 142 gr.Zero(k, xmin,xmax, eps, x,y, maxIter); // remember initial interval
1963b290 143 while(k!=2) {
25ab8a31 144 y = fcn(&x, par);
145 gr.Zero(k, xmin,xmax, eps, x,y, maxIter);
1963b290 146 }
25ab8a31 147 return x;
1963b290 148}
149
0a4cb131 150//_________________________________________________________________________
25ab8a31 151Double_t AliEMCALShishKebabModule::Y2(Double_t *x, Double_t *par)
152{
153 // For position calulation of second module
1963b290 154 if(par);
155 Double_t theta = x[0];
156 Double_t cos = TMath::Cos(theta);
157 Double_t sin = TMath::Sin(theta);
158 Double_t y1 = fgr*cos/sin + fga/(2.*sin) - fga*sin;
159 Double_t y2 = fga, y = y1-y2;;
160 // printf(" theta %f Y %12.5e \n", theta, y);
161 return y;
162}
163
0a4cb131 164//_________________________________________________________________________
25ab8a31 165Double_t AliEMCALShishKebabModule::YALL(Double_t *x, Double_t *par)
166{
167 // For position calulation of 3th, 4th to 30th modules
168 Double_t a=par[0], r=par[1], aa=par[2], bb=par[3];
1963b290 169 Double_t theta = x[0];
170 Double_t cos = TMath::Cos(theta);
171 Double_t sin = TMath::Sin(theta);
172
173 Double_t y1 = r + a*cos;
25ab8a31 174 Double_t y2 = aa*(r*cos/sin + a/(2.*sin) - a*sin) + bb;
1963b290 175 Double_t y = y1-y2;
176 // printf(" theta %f Y %12.5e \n", theta, y);
177 return y;
178}
179
0a4cb131 180//_________________________________________________________________________
25ab8a31 181void AliEMCALShishKebabModule::DefineName(Double_t theta)
1963b290 182{
25ab8a31 183 // Define name of object
184 SetName(Form("%2i(%5.2f)", TObject::GetUniqueID(), theta*TMath::RadToDeg()));
1963b290 185}
186
0a4cb131 187//_________________________________________________________________________
1963b290 188Bool_t AliEMCALShishKebabModule::GetParameters()
189{
25ab8a31 190 // Get needing module parameters from EMCAL geometry
1963b290 191 fgGeometry = AliEMCALGeometry::GetInstance();
1963b290 192 if(!fgGeometry) {
193 Warning("GetParameters()"," No geometry ");
194 return kFALSE;
195 }
196
197 fga = (Double_t)fgGeometry->GetPhiModuleSize();
198 fgb = (Double_t)fgGeometry->GetLongModuleSize();
199 fgr = (Double_t)(fgGeometry->GetIPDistance() + fgGeometry->GetSteelFrontThickness());
c63c3c5d 200 PrintShish(0);
1963b290 201 return kTRUE;
202}
203
0a4cb131 204//_________________________________________________________________________
25ab8a31 205void AliEMCALShishKebabModule::PrintShish(Int_t pri) const
1963b290 206{
25ab8a31 207 // service method
1963b290 208 if(pri>=0) {
c63c3c5d 209 Info("PrintShish()", " a %7.2f | b %7.2f | r %7.2f ", fga, fgb, fgr);
1963b290 210 printf(" fTheta %f : %5.2f : cos(theta) %f\n", fTheta, GetThetaInDegree(),TMath::Cos(fTheta));
211 if(pri>0) {
212 printf("%i %s | theta %f -> %f\n", GetUniqueID(), GetName(), fTheta, fOK.Phi());
213 printf(" A %f B %f \n", fA, fB);
214
215 fOK.Dump();
216 }
217 }
218}
219
0a4cb131 220//_________________________________________________________________________
25ab8a31 221Double_t AliEMCALShishKebabModule::GetThetaInDegree() const
222{
223 return fTheta*TMath::RadToDeg();
224}