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