Change SetDir to SetDirection
[u/mrichter/AliRoot.git] / ZDC / AliZDC.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/*
17$Log$
866ab5a2 18Revision 1.9 2000/10/02 21:28:20 fca
19Removal of useless dependecies via forward declarations
20
94de3818 21Revision 1.8 2000/07/10 13:58:01 fca
22New version of ZDC from E.Scomparin & C.Oppedisano
23
68ca986e 24Revision 1.7 2000/01/19 17:17:40 fca
25
1cedd08a 26Revision 1.6 1999/09/29 09:24:35 fca
27Introduction of the Copyright and cvs Log
28
4c039060 29*/
30
fe4da5cc 31///////////////////////////////////////////////////////////////////////////////
32// //
33// Zero Degree Calorimeter //
34// This class contains the basic functions for the Time Of Flight //
35// detector. Functions specific to one particular geometry are //
36// contained in the derived classes //
37// //
fe4da5cc 38///////////////////////////////////////////////////////////////////////////////
39
40#include <TBRIK.h>
41#include <TNode.h>
94de3818 42#include "TGeometry.h"
fe4da5cc 43
44#include "AliZDC.h"
45#include "AliRun.h"
46#include "AliCallf77.h"
47#include "AliConst.h"
48#include "AliMC.h"
49
fe4da5cc 50
51ClassImp(AliZDC)
52
53//_____________________________________________________________________________
54AliZDC::AliZDC()
55{
56 //
57 // Default constructor for the Zero Degree Calorimeter base class
58 //
68ca986e 59 fIshunt = 1;
60 fHits = 0;
fe4da5cc 61}
62
63//_____________________________________________________________________________
64AliZDC::AliZDC(const char *name, const char *title)
65 : AliDetector(name,title)
66{
67 //
68 // Standard constructor for the Zero Degree Calorimeter base class
69 //
70
71 //
72 // Allocate the array of hits
73 fHits = new TClonesArray("AliZDChit", 405);
1cedd08a 74 gAlice->AddHitList(fHits);
fe4da5cc 75
68ca986e 76 fIshunt = 1;
77
78 fDimZN[0] = 3.52;
79 fDimZN[1] = 3.52;
80 fDimZN[2] = 50.;
81 fDimZP[0] = 11.2;
82 fDimZP[1] = 6.;
83 fDimZP[2] = 75.;
84 fPosZN[0] = 0.;
85 fPosZN[1] = 0.;
86 fPosZN[2] = 11650.;
87 fPosZP[0] = -23.;
88 fPosZP[1] = 0.;
89 fPosZP[2] = 11600.;
90 fFibZN[0] = 0.;
91 fFibZN[1] = 0.01825;
92 fFibZN[2] = 50.;
93 fFibZP[0] = 0.;
94 fFibZP[1] = 0.0275;
95 fFibZP[2] = 75.;
96 fGrvZN[0] = 0.03;
97 fGrvZN[1] = 0.03;
98 fGrvZN[2] = 50.;
99 fGrvZP[0] = 0.04;
100 fGrvZP[1] = 0.04;
101 fGrvZP[2] = 75.;
102 fDivZN[0] = 11;
103 fDivZN[1] = 11;
104 fDivZN[2] = 0;
105 fDivZP[0] = 7;
106 fDivZP[1] = 15;
107 fDivZP[2] = 0;
108 fTowZN[0] = 2;
109 fTowZN[1] = 2;
110 fTowZP[0] = 4;
111 fTowZP[1] = 1;
866ab5a2 112
113 // EM Calorimeter
114 fDimZEMPb = 0.15*(TMath::Sqrt(2.));
115 fDimZEMAir = 0.001;
116 fFibRadZEM = 0.0315;
117 fDivZEM[0] = 92;
118 fDivZEM[1] = 0;
119 fDivZEM[2] = 20;
120 fDimZEM[0] = 2*fDivZEM[2]*(fDimZEMPb+fDimZEMAir+fFibRadZEM*(TMath::Sqrt(2.)));
121 fDimZEM[1] = 3.5;
122 fDimZEM[2] = 3.5;
123 fDimZEM[3] = 45.;
124 fDimZEM[4] = 0.;
125 fDimZEM[5] = 0.;
126 fFibZEM[0] = 0.;
127 fFibZEM[1] = 0.0275;
128 fFibZEM[2] = fDimZEM[2]/TMath::Sin(fDimZEM[3]*kDegrad)-fFibRadZEM;
129 fPosZEM[0] = 0.;
130 fPosZEM[1] = 5.8;
131 fPosZEM[2] = 11600.;
132
133}
134//____________________________________________________________________________
135AliZDC::~AliZDC()
136{
137 //
138 // ZDC destructor
139 //
140
141 fIshunt = 0;
142 delete fHits;
fe4da5cc 143}
fe4da5cc 144//_____________________________________________________________________________
145void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
146{
147 //
68ca986e 148 // Add a ZDC hit
fe4da5cc 149 //
68ca986e 150 static Float_t primKinEn, xImpact, yImpact, sFlag;
151
fe4da5cc 152 TClonesArray &lhits = *fHits;
68ca986e 153
154 AliZDChit *newquad, *curquad;
155 newquad = new AliZDChit(fIshunt, track, vol, hits);
156 Int_t i;
157 for(i=0; i<fNhits; i++){
158 // If the hits are equal (same track, same volume), sum them.
159 curquad=(AliZDChit*) lhits[i];
160 if(*curquad==*newquad){
161 *curquad = *curquad+*newquad;
162 delete newquad;
163// fHits->Print("");
164 return;
165 }
166 }
167
168 //Otherwise create a new hit.
169 if(fNhits==0){
170 // First hit -> setting flag for primary or secondary particle
171 Int_t primary = gAlice->GetPrimary(track);
172 if(track != primary){
173 newquad->fSFlag = 1; // Hit created by secondary particle entering the ZDC
174 }
175 else if(track == primary){
176 newquad->fSFlag = 0; // Hit created by PRIMARY particle entering the ZDC
177 }
178 sFlag = newquad->fSFlag;
179 primKinEn = newquad->fPrimKinEn;
180 xImpact = newquad->fXImpact;
181 yImpact = newquad->fYImpact;
182 }
183 else{
184 newquad->fPrimKinEn = primKinEn;
185 newquad->fXImpact = xImpact;
186 newquad->fYImpact = yImpact;
187 newquad->fSFlag = sFlag;
188 }
866ab5a2 189// printf("\n");
68ca986e 190// fHits->Print("");
866ab5a2 191 new(lhits[fNhits++]) AliZDChit(newquad);
192 delete newquad;
193 }
68ca986e 194
866ab5a2 195//_____________________________________________________________________________
196void AliZDC::ResetHits()
197{
198 //
199 // Reset number of hits and the hits array
200 //
201 AliDetector::ResetHits();
fe4da5cc 202}
fe4da5cc 203//_____________________________________________________________________________
204void AliZDC::BuildGeometry()
205{
206 //
207 // Build the ROOT TNode geometry for event display
208 // in the Zero Degree Calorimeter
209 // This routine is dummy for the moment
210 //
211
68ca986e 212 TNode *node, *top;
213 TBRIK *brik;
214 const int kColorZDC = kRed;
fe4da5cc 215
216 //
68ca986e 217 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 218
219 // ZDC
fe4da5cc 220 brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
68ca986e 221 top->cd();
222 node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
223 node->SetLineColor(kColorZDC);
224 fNodes->Add(node);
fe4da5cc 225}
226
227//_____________________________________________________________________________
228Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
229{
230 //
231 // Distance from the mouse to the Zero Degree Calorimeter
232 // Dummy routine
233 //
234 return 9999;
235}
236
237//_____________________________________________________________________________
fe4da5cc 238void AliZDC::StepManager()
239{
240 //
241 // Routine called at every step in the Zero Degree Calorimeter
fe4da5cc 242 //
fe4da5cc 243}
244
245ClassImp(AliZDChit)
246
247//_____________________________________________________________________________
248AliZDChit::AliZDChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
249 AliHit(shunt, track)
250{
251 //
68ca986e 252 // Add a ZDC hit
fe4da5cc 253 //
254 Int_t i;
68ca986e 255 for(i=0; i<2; i++) fVolume[i] = vol[i];
256 fX = hits[0];
257 fY = hits[1];
258 fZ = hits[2];
259 fPrimKinEn = hits[3];
260 fXImpact = hits[4];
261 fYImpact = hits[5];
262 fSFlag = hits[6];
263 fLightPMQ = hits[7];
264 fLightPMC = hits[8];
265 fEnergy = hits[9];
fe4da5cc 266}