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