dFree = 0.45;
[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$
588ed15d 18Revision 1.11 2000/11/30 17:21:03 coppedis
19Introduce hit array fStHits reset only at the end of the event (for digitization)
20
f901045b 21Revision 1.10 2000/11/22 11:32:58 coppedis
22Major code revision
23
866ab5a2 24Revision 1.9 2000/10/02 21:28:20 fca
25Removal of useless dependecies via forward declarations
26
94de3818 27Revision 1.8 2000/07/10 13:58:01 fca
28New version of ZDC from E.Scomparin & C.Oppedisano
29
68ca986e 30Revision 1.7 2000/01/19 17:17:40 fca
31
1cedd08a 32Revision 1.6 1999/09/29 09:24:35 fca
33Introduction of the Copyright and cvs Log
34
4c039060 35*/
36
fe4da5cc 37///////////////////////////////////////////////////////////////////////////////
38// //
39// Zero Degree Calorimeter //
f901045b 40// This class contains the basic functions for the ZDCs //
41// Functions specific to one particular geometry are //
fe4da5cc 42// contained in the derived classes //
43// //
fe4da5cc 44///////////////////////////////////////////////////////////////////////////////
45
f901045b 46// --- ROOT system
fe4da5cc 47#include <TBRIK.h>
48#include <TNode.h>
94de3818 49#include "TGeometry.h"
fe4da5cc 50
f901045b 51// --- AliRoot header files
fe4da5cc 52#include "AliZDC.h"
f901045b 53#include "AliZDCHit.h"
fe4da5cc 54#include "AliRun.h"
f901045b 55#include "AliDetector.h"
fe4da5cc 56#include "AliCallf77.h"
57#include "AliConst.h"
58#include "AliMC.h"
59
fe4da5cc 60
61ClassImp(AliZDC)
62
63//_____________________________________________________________________________
64AliZDC::AliZDC()
65{
66 //
67 // Default constructor for the Zero Degree Calorimeter base class
68 //
588ed15d 69
68ca986e 70 fIshunt = 1;
f901045b 71
68ca986e 72 fHits = 0;
f901045b 73 fNhits = 0;
74
75 fStHits = 0;
76 fNStHits = 0;
77
78 fNPrimaryHits = 0;
fe4da5cc 79}
80
81//_____________________________________________________________________________
82AliZDC::AliZDC(const char *name, const char *title)
83 : AliDetector(name,title)
84{
85 //
86 // Standard constructor for the Zero Degree Calorimeter base class
87 //
88
588ed15d 89 // Check that DIPO is there (otherwise tracking is wrong!!!)
90
91 AliModule* DIPO=gAlice->GetModule("DIPO");
92 if(!DIPO) {
93 Error("Constructor","ZDC needs DIPO!!!\n");
94 exit(1);
95 }
96
fe4da5cc 97 //
98 // Allocate the array of hits
f901045b 99
100 fHits = new TClonesArray("AliZDCHit",1000);
1cedd08a 101 gAlice->AddHitList(fHits);
fe4da5cc 102
f901045b 103 fStHits = new TClonesArray("AliZDCHit",1000);
104
105 fNStHits = 0;
106
107 fNPrimaryHits = 0;
108
68ca986e 109 fIshunt = 1;
110
111 fDimZN[0] = 3.52;
112 fDimZN[1] = 3.52;
113 fDimZN[2] = 50.;
114 fDimZP[0] = 11.2;
115 fDimZP[1] = 6.;
116 fDimZP[2] = 75.;
117 fPosZN[0] = 0.;
118 fPosZN[1] = 0.;
119 fPosZN[2] = 11650.;
120 fPosZP[0] = -23.;
121 fPosZP[1] = 0.;
122 fPosZP[2] = 11600.;
123 fFibZN[0] = 0.;
124 fFibZN[1] = 0.01825;
125 fFibZN[2] = 50.;
126 fFibZP[0] = 0.;
127 fFibZP[1] = 0.0275;
128 fFibZP[2] = 75.;
129 fGrvZN[0] = 0.03;
130 fGrvZN[1] = 0.03;
131 fGrvZN[2] = 50.;
132 fGrvZP[0] = 0.04;
133 fGrvZP[1] = 0.04;
134 fGrvZP[2] = 75.;
135 fDivZN[0] = 11;
136 fDivZN[1] = 11;
137 fDivZN[2] = 0;
138 fDivZP[0] = 7;
139 fDivZP[1] = 15;
140 fDivZP[2] = 0;
141 fTowZN[0] = 2;
142 fTowZN[1] = 2;
143 fTowZP[0] = 4;
144 fTowZP[1] = 1;
866ab5a2 145
146 // EM Calorimeter
147 fDimZEMPb = 0.15*(TMath::Sqrt(2.));
148 fDimZEMAir = 0.001;
149 fFibRadZEM = 0.0315;
150 fDivZEM[0] = 92;
151 fDivZEM[1] = 0;
152 fDivZEM[2] = 20;
153 fDimZEM[0] = 2*fDivZEM[2]*(fDimZEMPb+fDimZEMAir+fFibRadZEM*(TMath::Sqrt(2.)));
154 fDimZEM[1] = 3.5;
155 fDimZEM[2] = 3.5;
156 fDimZEM[3] = 45.;
157 fDimZEM[4] = 0.;
158 fDimZEM[5] = 0.;
159 fFibZEM[0] = 0.;
160 fFibZEM[1] = 0.0275;
161 fFibZEM[2] = fDimZEM[2]/TMath::Sin(fDimZEM[3]*kDegrad)-fFibRadZEM;
162 fPosZEM[0] = 0.;
163 fPosZEM[1] = 5.8;
164 fPosZEM[2] = 11600.;
165
166}
167//____________________________________________________________________________
168AliZDC::~AliZDC()
169{
170 //
171 // ZDC destructor
172 //
173
174 fIshunt = 0;
175 delete fHits;
f901045b 176 if(fStHits){
177 fStHits->Delete();
178 delete fStHits;
179 fNStHits = 0;
180 }
181 delete fDigits;
fe4da5cc 182}
fe4da5cc 183//_____________________________________________________________________________
184void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
185{
186 //
f901045b 187 // Add a ZDC hit to the hit list.
188 // -> We make use of 2 array of hits:
189 // [1] fHits (the usual one) that contains hits for each PRIMARY
190 // [2] fStHits that contains hits for each EVENT and is used to
191 // obtain digits at the end of each event
fe4da5cc 192 //
f901045b 193
68ca986e 194 static Float_t primKinEn, xImpact, yImpact, sFlag;
195
f901045b 196 TClonesArray &lsthits = *fStHits;
fe4da5cc 197 TClonesArray &lhits = *fHits;
68ca986e 198
f901045b 199
200 AliZDCHit *newquad, *curevquad, *curprimquad;
201 newquad = new AliZDCHit(fIshunt, track, vol, hits);
202
203 Int_t i,j,kStHit = 1;
204 for(i=0; i<fNStHits; i++){
205 // If the hits are equal (same track, same volume), sum them.
206 curevquad = (AliZDCHit*) lsthits[i];
207 kStHit = 1;
208 if(*curevquad == *newquad){
209 *curevquad = *curevquad+*newquad;
210 kStHit = 0;
211 }
212 }
213
214 for(j=0; j<fNhits; j++){
68ca986e 215 // If the hits are equal (same track, same volume), sum them.
f901045b 216 curprimquad = (AliZDCHit*) lhits[j];
217 if(*curprimquad == *newquad){
218 *curprimquad = *curprimquad+*newquad;
219 delete newquad;
68ca986e 220 return;
f901045b 221 }
222 }
223
224 if(fNhits==0){
68ca986e 225 // First hit -> setting flag for primary or secondary particle
226 Int_t primary = gAlice->GetPrimary(track);
227 if(track != primary){
228 newquad->fSFlag = 1; // Hit created by secondary particle entering the ZDC
229 }
230 else if(track == primary){
231 newquad->fSFlag = 0; // Hit created by PRIMARY particle entering the ZDC
232 }
f901045b 233 fNPrimaryHits = fNPrimaryHits + 1;
68ca986e 234 sFlag = newquad->fSFlag;
235 primKinEn = newquad->fPrimKinEn;
236 xImpact = newquad->fXImpact;
237 yImpact = newquad->fYImpact;
238 }
239 else{
240 newquad->fPrimKinEn = primKinEn;
241 newquad->fXImpact = xImpact;
242 newquad->fYImpact = yImpact;
243 newquad->fSFlag = sFlag;
244 }
f901045b 245
246 //Otherwise create a new hit
247 new(lhits[fNhits]) AliZDCHit(newquad);
248 fNhits++;
249
250 if(kStHit){
251 new(lsthits[fNStHits]) AliZDCHit(newquad);
252 fNStHits++;
253 }
254
255// printf("\nPrimary Hits --------------------------------------------------------\n");
68ca986e 256// fHits->Print("");
f901045b 257// printf("\n Event Hits --------------------------------------------------------\n");
258// fStHits->Print("");
259
866ab5a2 260 delete newquad;
261 }
68ca986e 262
866ab5a2 263//_____________________________________________________________________________
264void AliZDC::ResetHits()
265{
266 //
267 // Reset number of hits and the hits array
268 //
f901045b 269
270// fStHits->Clear();
271// fNStHits = 0;
272
866ab5a2 273 AliDetector::ResetHits();
fe4da5cc 274}
f901045b 275
276//_____________________________________________________________________________
277void AliZDC::ResetDigits()
278{
279 //
280 // Reset number of digits and the digits array
281 //
282
283 AliDetector::ResetDigits();
284 if(fStHits){
285 fStHits->Delete();
286 fNStHits = 0;
287 }
288}
289
fe4da5cc 290//_____________________________________________________________________________
291void AliZDC::BuildGeometry()
292{
293 //
294 // Build the ROOT TNode geometry for event display
295 // in the Zero Degree Calorimeter
296 // This routine is dummy for the moment
297 //
298
68ca986e 299 TNode *node, *top;
300 TBRIK *brik;
301 const int kColorZDC = kRed;
fe4da5cc 302
303 //
68ca986e 304 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 305
306 // ZDC
fe4da5cc 307 brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
68ca986e 308 top->cd();
309 node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
310 node->SetLineColor(kColorZDC);
311 fNodes->Add(node);
fe4da5cc 312}
313
314//_____________________________________________________________________________
315Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
316{
317 //
318 // Distance from the mouse to the Zero Degree Calorimeter
319 // Dummy routine
320 //
321 return 9999;
322}
323
fe4da5cc 324//_____________________________________________________________________________
325void AliZDC::StepManager()
326{
327 //
328 // Routine called at every step in the Zero Degree Calorimeter
fe4da5cc 329 //
fe4da5cc 330}