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