]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALShishKebabTrd1Module.cxx
Tuning of EMCAL cluster finder for TRD1 geometry
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALShishKebabTrd1Module.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2004, 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 /* $Id$ */
17
18 //*-- Author: Aleksei Pavlinov(WSU)
19
20 #include "AliEMCALShishKebabTrd1Module.h"
21 #include <assert.h>
22 #include "AliEMCALGeometry.h"
23
24 #include "Riostream.h"
25 #include <TMath.h>
26
27 ClassImp(AliEMCALShishKebabTrd1Module)
28
29   AliEMCALGeometry *AliEMCALShishKebabTrd1Module::fgGeometry=0; 
30   Double_t AliEMCALShishKebabTrd1Module::fga=0.; 
31   Double_t AliEMCALShishKebabTrd1Module::fga2=0.; 
32   Double_t AliEMCALShishKebabTrd1Module::fgb=0.; 
33   Double_t AliEMCALShishKebabTrd1Module::fgr=0.; 
34   Double_t AliEMCALShishKebabTrd1Module::fgangle=0.;   // around one degree 
35   Double_t AliEMCALShishKebabTrd1Module::fgtanBetta=0; //
36
37 AliEMCALShishKebabTrd1Module::AliEMCALShishKebabTrd1Module(double theta, AliEMCALGeometry *g) : TNamed()
38 { // theta in radians ; first object shold be with theta=pi/2.
39   cout<< " theta " << theta << " geometry " << g << endl;  
40   fTheta = theta;
41   if(fgGeometry==0) {
42     fgGeometry = g;
43     if(GetParameters()) {
44       DefineFirstModule();
45     }
46   } else Warning("AliEMCALShishKebabTrd1Module(theta)","You should call this constractor just once !!");
47   DefineName(fTheta);
48 }
49
50 AliEMCALShishKebabTrd1Module::AliEMCALShishKebabTrd1Module(AliEMCALShishKebabTrd1Module &leftNeighbor) : TNamed()
51 { // 22-sep-04
52   //  printf("** Left Neighbor : %s **\n", leftNeighbor.GetName());
53   TObject::SetUniqueID(leftNeighbor.GetUniqueID()+1);
54   fTheta  = leftNeighbor.GetTheta() - fgangle; 
55   Init(leftNeighbor.GetA(),leftNeighbor.GetB());
56 }
57
58 void AliEMCALShishKebabTrd1Module::Init(double A, double B)
59 { // Define parameter module from parameters A,B from previos.
60   Double_t yl = (fgb/2)*TMath::Sin(fTheta) + (fga/2)*TMath::Cos(fTheta) + fgr, y = yl;
61   Double_t xl = (yl - B) / A;     // y=A*x+B
62
63   //  Double_t xp1 = (fga/2. + fgb/2.*fgtanBetta)/(TMath::Sin(fTheta) + fgtanBetta*TMath::Cos(fTheta));
64   //  printf(" xp1 %9.3f \n ", xp1);
65   // xp1 == xp => both methods give the same results - 3-feb-05
66   Double_t alpha = TMath::Pi()/2. + fgangle/2;
67   Double_t xt = (fga+fga2)*TMath::Tan(fTheta)*TMath::Tan(alpha)/(4.*(1.-TMath::Tan(fTheta)*TMath::Tan(alpha)));
68   Double_t yt = xt / TMath::Tan(fTheta), xp = TMath::Sqrt(xt*xt + yt*yt);
69   Double_t x  = xl + xp;
70   fOK.Set(x, y);
71   //  printf(" yl %9.3f | xl %9.3f | xp %9.3f \n", yl, xl, xp);
72
73   // have to define A and B; 
74   Double_t yCprev = fgr + fga*TMath::Cos(fTheta);
75   Double_t xCprev = (yCprev - B) / A;
76   Double_t xA     = xCprev + fga*TMath::Sin(fTheta), yA = fgr;
77
78   fThetaA = fTheta - fgangle/2.;
79   fA = TMath::Tan(fThetaA); // !!
80   fB = yA - fA*xA;
81
82   DefineName(fTheta);
83   // Centers of module
84   Double_t kk1 = (fga+fga2)/(2.*4.); // kk1=kk2 
85
86   Double_t xk1 = fOK.X() - kk1*TMath::Sin(fTheta);
87   Double_t yk1 = fOK.Y() + kk1*TMath::Cos(fTheta) - fgr;
88   fOK1.Set(xk1,yk1);
89
90   Double_t xk2 = fOK.X() + kk1*TMath::Sin(fTheta);
91   Double_t yk2 = fOK.Y() - kk1*TMath::Cos(fTheta) - fgr;
92   fOK2.Set(xk2,yk2);
93 }
94
95 void AliEMCALShishKebabTrd1Module::DefineFirstModule()
96 {
97   fOK.Set(fga2/2., fgr + fgb/2.); // position the center of module vs o
98
99   // parameters of right line : y = A*z + B in system where zero point is IP.
100   fThetaA = fTheta - fgangle/2.;
101   fA      = TMath::Tan(fThetaA);
102   Double_t xA = fga/2. + fga2/2., yA = fgr;
103   fB = yA - fA*xA;
104
105   Double_t kk1 = (fga+fga2)/(2.*4.); // kk1=kk2 
106   fOK1.Set(fOK.X() - kk1, fOK.Y()-fgr);
107   fOK2.Set(fOK.X() + kk1, fOK.Y()-fgr);
108
109   TObject::SetUniqueID(1); //
110 }
111
112 void AliEMCALShishKebabTrd1Module::DefineName(double theta)
113 {
114   char name[100];
115   // sprintf(name,"theta_%5.2f",theta*180./TMath::Pi());
116   sprintf(name,"%2i(%5.2f)", TObject::GetUniqueID(), theta*180./TMath::Pi());
117   SetName(name);
118 }
119
120 Bool_t AliEMCALShishKebabTrd1Module::GetParameters()
121 {
122   if(!fgGeometry) fgGeometry = AliEMCALGeometry::GetInstance();
123   TString sn(fgGeometry->GetName()); // 2-Feb-05
124   sn.ToUpper();
125   if(!fgGeometry) {
126     Warning("GetParameters()"," No geometry ");
127     return kFALSE; 
128   }
129
130   fga        = (Double_t)fgGeometry->GetEtaModuleSize();
131   fgb        = (Double_t)fgGeometry->GetLongModuleSize();
132   fgangle    = Double_t(fgGeometry->GetTrd1Angle())*TMath::DegToRad();
133   fgtanBetta = TMath::Tan(fgangle/2.);
134   fgr        = (Double_t)fgGeometry->GetIPDistance();
135   if(!sn.Contains("TRD2")) fgr += fgGeometry->GetSteelFrontThickness();
136   fga2       = Double_t(fgGeometry->Get2Trd1Dx2());
137   PrintShish(0);
138   return kTRUE;
139 }
140
141 // service methods
142 void AliEMCALShishKebabTrd1Module::PrintShish(int pri) const
143 {
144   if(pri>=0) {
145     Info("\n PrintShish()", "\n a %7.3f:%7.3f | b %7.2f | r %7.2f \n TRD1 angle %7.6f(%5.2f) | tanBetta %7.6f", 
146     fga, fga2, fgb, fgr, fgangle, fgangle*TMath::RadToDeg(), fgtanBetta);
147     printf(" fTheta %f : %5.2f : cos(theta) %f\n", 
148     fTheta, GetThetaInDegree(),TMath::Cos(fTheta)); 
149     if(pri>=1) {
150       printf("\n%i |%s| theta %f :  fOK.Phi = %f(%5.2f)\n", 
151       GetUniqueID(), GetName(), fTheta, fOK.Phi(),fOK.Phi()*TMath::RadToDeg());
152       printf(" A %f B %f | fThetaA %7.6f(%5.2f)\n", fA,fB, fThetaA,fThetaA*TMath::RadToDeg());
153       printf(" fOK  : X %8.3f: Y %8.3f \n",  fOK.X(), fOK.Y());
154       printf(" fOK1 : X %8.3f: Y %8.3f (in SM, ieta=2)\n", fOK1.X(), fOK1.Y());
155       printf(" fOK2 : X %8.3f: Y %8.3f (in SM, ieta=1)\n\n", fOK2.X(), fOK2.Y());
156       fOK.Dump();
157     }
158   }
159 }