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