Taking into account the masked local boards in regional input (Christian)
[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
25ab8a31 38AliEMCALShishKebabModule::AliEMCALShishKebabModule() : TNamed()
39{
40 // theta in radians ; first object shold be with theta=pi/2.
1963b290 41 if(fgGeometry==0) {
25ab8a31 42 fTheta = TMath::PiOver2();
1963b290 43 if(GetParameters()) {
44 DefineFirstModule();
25ab8a31 45 DefineName(fTheta);
1963b290 46 }
25ab8a31 47 } else {
48 Warning("AliEMCALShishKebabModule(theta)","You should call this constractor just once !!");
49 }
1963b290 50}
51
52AliEMCALShishKebabModule::AliEMCALShishKebabModule(AliEMCALShishKebabModule &leftNeighbor) : TNamed()
25ab8a31 53{
54 // 22-sep-04
1963b290 55 TObject::SetUniqueID(leftNeighbor.GetUniqueID()+1);
56 Init(leftNeighbor.GetA(),leftNeighbor.GetB());
57}
58
25ab8a31 59void AliEMCALShishKebabModule::Init(Double_t A, Double_t B)
1963b290 60{
25ab8a31 61 //
62 // Initialisation method
63 //
1963b290 64 Double_t thetaMin, thetaMax, par[4];
65 Int_t npar=0;
66 if(A<0){
67 // DefineSecondModuleFirstAssumption();
68 thetaMax = TMath::ATan2(fgr, 1.4*fga);
69 thetaMin = TMath::ATan2(fgr, 1.6*fga);
70 fTheta = Solve(AliEMCALShishKebabModule::Y2, thetaMin,thetaMax,npar,par);
71 } else{
72 npar = 4;
73 par[0] = fga;
74 par[1] = fgr;
75 par[2] = A;
76 par[3] = B;
77 Double_t x = fgr/A;
78 thetaMax = TMath::ATan2(fgr,x + 0.5*fga);
79 thetaMin = TMath::ATan2(fgr,x + 1.5*fga);
80 fTheta = Solve(AliEMCALShishKebabModule::YALL, thetaMin,thetaMax,npar,par);
81 }
82
83 Double_t rOK = fgr / TMath::Sin(fTheta) + (fga/2.)/TMath::Tan(fTheta) + fgb/2.;
84 fOK.SetMagPhi(rOK, fTheta);
85 // have to define A and B
86 fA = TMath::Tan(fTheta);
87 fB = -fga/(2.*TMath::Cos(fTheta));
88 DefineName(fTheta);
89}
90
91void AliEMCALShishKebabModule::DefineFirstModule()
92{
25ab8a31 93 // Define first module
1963b290 94 fOK.Set(fga/2., fgr + fgb/2.); // position the center of module vs o
95
96 fB = fga/2.; // z=fB
97 fA = -999.; // fA=infinite in this case
98 TObject::SetUniqueID(1); //
99}
100
101void AliEMCALShishKebabModule::DefineSecondModuleFirstAssumption()
102{ // Keep for testing and checking
103 // cos(theta) << 1, theta ~ pi/2.; a/r = 11.4/462.54 = 0.0246465 << 1;
104 // theta=1.53382 from this case; theta=1.533869 from TGraph::Zero
105 Double_t x = (3.*fga)/(2.*fgr);
106 fTheta = TMath::ACos(x);
107 /*
108 Double_t rOK = fgr / TMath::Sin(fTheta) + (fga/2.)/TMath::Tan(fTheta) + fgb/2.;
109 fOK.SetMagPhi(rOK, fTheta);
110 // have to define A and B
111 fA = TMath::Tan(fTheta);
112 fB = -fga/(2.*TMath::Cos(fTheta));
113 DefineName(fTheta);
114 */
115}
116
117Double_t AliEMCALShishKebabModule::Solve(Double_t (*fcn)(Double_t*,Double_t*),
118Double_t xmin, Double_t xmax, Int_t npar, Double_t *par, Double_t eps, Int_t maxIter)
119{
25ab8a31 120 // Find out "zero" using TGraph method
1963b290 121 if(npar); // unused now
122 TGraph gr;
25ab8a31 123 Double_t x,y;
1963b290 124 Int_t k = 0;
25ab8a31 125 gr.Zero(k, xmin,xmax, eps, x,y, maxIter); // remember initial interval
1963b290 126 while(k!=2) {
25ab8a31 127 y = fcn(&x, par);
128 gr.Zero(k, xmin,xmax, eps, x,y, maxIter);
1963b290 129 }
25ab8a31 130 return x;
1963b290 131}
132
25ab8a31 133Double_t AliEMCALShishKebabModule::Y2(Double_t *x, Double_t *par)
134{
135 // For position calulation of second module
1963b290 136 if(par);
137 Double_t theta = x[0];
138 Double_t cos = TMath::Cos(theta);
139 Double_t sin = TMath::Sin(theta);
140 Double_t y1 = fgr*cos/sin + fga/(2.*sin) - fga*sin;
141 Double_t y2 = fga, y = y1-y2;;
142 // printf(" theta %f Y %12.5e \n", theta, y);
143 return y;
144}
145
25ab8a31 146Double_t AliEMCALShishKebabModule::YALL(Double_t *x, Double_t *par)
147{
148 // For position calulation of 3th, 4th to 30th modules
149 Double_t a=par[0], r=par[1], aa=par[2], bb=par[3];
1963b290 150 Double_t theta = x[0];
151 Double_t cos = TMath::Cos(theta);
152 Double_t sin = TMath::Sin(theta);
153
154 Double_t y1 = r + a*cos;
25ab8a31 155 Double_t y2 = aa*(r*cos/sin + a/(2.*sin) - a*sin) + bb;
1963b290 156 Double_t y = y1-y2;
157 // printf(" theta %f Y %12.5e \n", theta, y);
158 return y;
159}
160
25ab8a31 161void AliEMCALShishKebabModule::DefineName(Double_t theta)
1963b290 162{
25ab8a31 163 // Define name of object
164 SetName(Form("%2i(%5.2f)", TObject::GetUniqueID(), theta*TMath::RadToDeg()));
1963b290 165}
166
167Bool_t AliEMCALShishKebabModule::GetParameters()
168{
25ab8a31 169 // Get needing module parameters from EMCAL geometry
1963b290 170 fgGeometry = AliEMCALGeometry::GetInstance();
1963b290 171 if(!fgGeometry) {
172 Warning("GetParameters()"," No geometry ");
173 return kFALSE;
174 }
175
176 fga = (Double_t)fgGeometry->GetPhiModuleSize();
177 fgb = (Double_t)fgGeometry->GetLongModuleSize();
178 fgr = (Double_t)(fgGeometry->GetIPDistance() + fgGeometry->GetSteelFrontThickness());
c63c3c5d 179 PrintShish(0);
1963b290 180 return kTRUE;
181}
182
25ab8a31 183void AliEMCALShishKebabModule::PrintShish(Int_t pri) const
1963b290 184{
25ab8a31 185 // service method
1963b290 186 if(pri>=0) {
c63c3c5d 187 Info("PrintShish()", " a %7.2f | b %7.2f | r %7.2f ", fga, fgb, fgr);
1963b290 188 printf(" fTheta %f : %5.2f : cos(theta) %f\n", fTheta, GetThetaInDegree(),TMath::Cos(fTheta));
189 if(pri>0) {
190 printf("%i %s | theta %f -> %f\n", GetUniqueID(), GetName(), fTheta, fOK.Phi());
191 printf(" A %f B %f \n", fA, fB);
192
193 fOK.Dump();
194 }
195 }
196}
197
25ab8a31 198Double_t AliEMCALShishKebabModule::GetThetaInDegree() const
199{
200 return fTheta*TMath::RadToDeg();
201}