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