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