]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDC.cxx
Introduce hit array fStHits reset only at the end of the event (for digitization)
[u/mrichter/AliRoot.git] / ZDC / AliZDC.cxx
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$
18 Revision 1.10  2000/11/22 11:32:58  coppedis
19 Major code revision
20
21 Revision 1.9  2000/10/02 21:28:20  fca
22 Removal of useless dependecies via forward declarations
23
24 Revision 1.8  2000/07/10 13:58:01  fca
25 New version of ZDC from E.Scomparin & C.Oppedisano
26
27 Revision 1.7  2000/01/19 17:17:40  fca
28
29 Revision 1.6  1999/09/29 09:24:35  fca
30 Introduction of the Copyright and cvs Log
31
32 */
33
34 ///////////////////////////////////////////////////////////////////////////////
35 //                                                                           //
36 //  Zero Degree Calorimeter                                                  //
37 //  This class contains the basic functions for the ZDCs                     //
38 //  Functions specific to one particular geometry are                        //
39 //  contained in the derived classes                                         //
40 //                                                                           //
41 ///////////////////////////////////////////////////////////////////////////////
42
43 // --- ROOT system
44 #include <TBRIK.h>
45 #include <TNode.h>
46 #include "TGeometry.h"
47
48 // --- AliRoot header files
49 #include "AliZDC.h"
50 #include "AliZDCHit.h"
51 #include "AliRun.h"
52 #include "AliDetector.h"
53 #include "AliCallf77.h"
54 #include "AliConst.h"
55 #include "AliMC.h"
56
57  
58 ClassImp(AliZDC)
59  
60 //_____________________________________________________________________________
61 AliZDC::AliZDC()
62 {
63   //
64   // Default constructor for the Zero Degree Calorimeter base class
65   //
66   fIshunt = 1;
67
68   fHits = 0;
69   fNhits = 0;
70
71   fStHits = 0;
72   fNStHits = 0;
73
74   fNPrimaryHits = 0;
75 }
76  
77 //_____________________________________________________________________________
78 AliZDC::AliZDC(const char *name, const char *title)
79   : AliDetector(name,title)
80 {
81   //
82   // Standard constructor for the Zero Degree Calorimeter base class
83   //
84
85   //
86   // Allocate the array of hits
87
88   fHits   = new TClonesArray("AliZDCHit",1000);
89   gAlice->AddHitList(fHits);
90   
91   fStHits = new TClonesArray("AliZDCHit",1000);
92
93   fNStHits = 0;
94
95   fNPrimaryHits = 0;
96   
97   fIshunt =  1;
98   
99   fDimZN[0] = 3.52;
100   fDimZN[1] = 3.52;
101   fDimZN[2] = 50.;
102   fDimZP[0] = 11.2;
103   fDimZP[1] = 6.;
104   fDimZP[2] = 75.;
105   fPosZN[0] = 0.;
106   fPosZN[1] = 0.;
107   fPosZN[2] = 11650.;
108   fPosZP[0] = -23.;
109   fPosZP[1] = 0.;
110   fPosZP[2] = 11600.;
111   fFibZN[0] = 0.;
112   fFibZN[1] = 0.01825;
113   fFibZN[2] = 50.;
114   fFibZP[0] = 0.;
115   fFibZP[1] = 0.0275;
116   fFibZP[2] = 75.;
117   fGrvZN[0] = 0.03;
118   fGrvZN[1] = 0.03;
119   fGrvZN[2] = 50.;
120   fGrvZP[0] = 0.04;
121   fGrvZP[1] = 0.04;
122   fGrvZP[2] = 75.;
123   fDivZN[0] = 11;
124   fDivZN[1] = 11;
125   fDivZN[2] = 0;
126   fDivZP[0] = 7;
127   fDivZP[1] = 15;
128   fDivZP[2] = 0;
129   fTowZN[0] = 2;
130   fTowZN[1] = 2;
131   fTowZP[0] = 4;
132   fTowZP[1] = 1;
133   
134   // EM Calorimeter
135   fDimZEMPb  = 0.15*(TMath::Sqrt(2.));
136   fDimZEMAir = 0.001;
137   fFibRadZEM = 0.0315;
138   fDivZEM[0] = 92;
139   fDivZEM[1] = 0;
140   fDivZEM[2] = 20;
141   fDimZEM[0] = 2*fDivZEM[2]*(fDimZEMPb+fDimZEMAir+fFibRadZEM*(TMath::Sqrt(2.)));
142   fDimZEM[1] = 3.5;
143   fDimZEM[2] = 3.5;
144   fDimZEM[3] = 45.;
145   fDimZEM[4] = 0.;
146   fDimZEM[5] = 0.;
147   fFibZEM[0] = 0.;
148   fFibZEM[1] = 0.0275;
149   fFibZEM[2] = fDimZEM[2]/TMath::Sin(fDimZEM[3]*kDegrad)-fFibRadZEM;
150   fPosZEM[0] = 0.;
151   fPosZEM[1] = 5.8;
152   fPosZEM[2] = 11600.;
153
154 }
155 //____________________________________________________________________________ 
156 AliZDC::~AliZDC()
157 {
158   //
159   // ZDC destructor
160   //
161
162   fIshunt   = 0;
163   delete fHits;
164   if(fStHits){
165     fStHits->Delete();
166     delete fStHits;
167     fNStHits = 0;
168   }
169   delete fDigits;
170 }
171 //_____________________________________________________________________________
172 void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
173 {
174   //
175   //            Add a ZDC hit to the hit list.
176   // -> We make use of 2 array of hits:
177   // [1]  fHits (the usual one) that contains hits for each PRIMARY
178   // [2]  fStHits that contains hits for each EVENT and is used to
179   //      obtain digits at the end of each event
180   //
181   
182   static Float_t primKinEn, xImpact, yImpact, sFlag;
183
184   TClonesArray &lsthits = *fStHits;
185   TClonesArray &lhits = *fHits;
186
187
188   AliZDCHit *newquad, *curevquad, *curprimquad;
189   newquad = new AliZDCHit(fIshunt, track, vol, hits);
190    
191   Int_t i,j,kStHit = 1;
192   for(i=0; i<fNStHits; i++){
193     // If the hits are equal (same track, same volume), sum them.
194      curevquad = (AliZDCHit*) lsthits[i];
195      kStHit = 1;
196      if(*curevquad == *newquad){
197         *curevquad = *curevquad+*newquad;
198         kStHit = 0;
199      } 
200   }
201
202   for(j=0; j<fNhits; j++){
203     // If the hits are equal (same track, same volume), sum them.
204      curprimquad = (AliZDCHit*) lhits[j];
205      if(*curprimquad == *newquad){
206         *curprimquad = *curprimquad+*newquad;
207         delete newquad;
208         return;
209      } 
210   }
211   
212   if(fNhits==0){
213       // First hit -> setting flag for primary or secondary particle
214       Int_t primary = gAlice->GetPrimary(track);     
215       if(track != primary){
216         newquad->fSFlag = 1;  // Hit created by secondary particle entering the ZDC
217       }
218       else if(track == primary){
219         newquad->fSFlag = 0;  // Hit created by PRIMARY particle entering the ZDC
220       }  
221       fNPrimaryHits = fNPrimaryHits + 1;
222       sFlag = newquad->fSFlag;
223       primKinEn = newquad->fPrimKinEn;
224       xImpact = newquad->fXImpact;
225       yImpact = newquad->fYImpact;
226    }
227    else{       
228       newquad->fPrimKinEn = primKinEn;
229       newquad->fXImpact = xImpact;
230       newquad->fYImpact = yImpact;
231       newquad->fSFlag = sFlag;
232    }
233
234     //Otherwise create a new hit
235     new(lhits[fNhits]) AliZDCHit(newquad);
236     fNhits++;
237     
238     if(kStHit){
239       new(lsthits[fNStHits]) AliZDCHit(newquad);
240       fNStHits++;
241     }
242  
243 //    printf("\nPrimary Hits --------------------------------------------------------\n");
244 //    fHits->Print("");
245 //    printf("\n  Event Hits --------------------------------------------------------\n");
246 //    fStHits->Print("");
247
248     delete newquad;
249   }
250   
251 //_____________________________________________________________________________
252 void AliZDC::ResetHits()
253 {
254   //
255   // Reset number of hits and the hits array
256   //
257     
258 //    fStHits->Clear();
259 //    fNStHits = 0;
260     
261     AliDetector::ResetHits();
262 }
263   
264 //_____________________________________________________________________________
265 void AliZDC::ResetDigits()
266 {
267   //
268   // Reset number of digits and the digits array
269   //
270     
271     AliDetector::ResetDigits();
272     if(fStHits){
273       fStHits->Delete();
274       fNStHits = 0;
275     }
276 }
277
278 //_____________________________________________________________________________
279 void AliZDC::BuildGeometry()
280 {
281   //
282   // Build the ROOT TNode geometry for event display 
283   // in the Zero Degree Calorimeter
284   // This routine is dummy for the moment
285   //
286
287   TNode *node, *top;
288   TBRIK *brik;
289   const int kColorZDC  = kRed;
290   
291   //
292   top=gAlice->GetGeometry()->GetNode("alice");
293   
294   // ZDC
295     brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
296     top->cd();
297     node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
298     node->SetLineColor(kColorZDC);
299     fNodes->Add(node);
300 }
301
302 //_____________________________________________________________________________
303 Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
304 {
305   //
306   // Distance from the mouse to the Zero Degree Calorimeter
307   // Dummy routine
308   //
309   return 9999;
310 }
311  
312 //_____________________________________________________________________________
313 void AliZDC::StepManager()
314 {
315   //
316   // Routine called at every step in the Zero Degree Calorimeter
317   //
318 }