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