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