]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDC.cxx
Changes to add AliZDCFragment class
[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.22  2001/05/14 09:53:32  coppedis
19 Adding functions ZMin and ZMax
20
21 Revision 1.21  2001/04/20 10:05:02  coppedis
22 Minor changes
23
24 Revision 1.20  2001/03/26 13:39:20  coppedis
25 Comment prints
26
27 Revision 1.19  2001/03/26 09:10:23  coppedis
28 Corrected bug in constructor (fIshunt has to be =1)
29
30 Revision 1.18  2001/03/20 08:21:55  coppedis
31 ZDC needs PIPE, ABSO, DIPO and SHIL
32
33 Revision 1.17  2001/03/16 16:18:03  coppedis
34 Correction for superposition of ZDC volumes with MUON arm one
35
36 Revision 1.16  2001/03/15 16:01:11  coppedis
37 Code review
38
39 Revision 1.15  2001/01/26 19:56:27  hristov
40 Major upgrade of AliRoot code
41
42 Revision 1.14  2000/12/12 13:17:01  coppedis
43 Minor corrections suggested by P. Hristov
44
45 Revision 1.12  2000/12/01 08:19:01  coppedis
46 Adding a message error if ZDC is constructed without DIPO
47
48 Revision 1.11  2000/11/30 17:21:03  coppedis
49 Introduce hit array fStHits reset only at the end of the event (for digitization)
50
51 Revision 1.10  2000/11/22 11:32:58  coppedis
52 Major code revision
53
54 Revision 1.9  2000/10/02 21:28:20  fca
55 Removal of useless dependecies via forward declarations
56
57 Revision 1.8  2000/07/10 13:58:01  fca
58 New version of ZDC from E.Scomparin & C.Oppedisano
59
60 Revision 1.7  2000/01/19 17:17:40  fca
61
62 Revision 1.6  1999/09/29 09:24:35  fca
63 Introduction of the Copyright and cvs Log
64
65 */
66
67 ///////////////////////////////////////////////////////////////////////////////
68 //                                                                           //
69 //  Zero Degree Calorimeter                                                  //
70 //  This class contains the basic functions for the ZDCs                     //
71 //  Functions specific to one particular geometry are                        //
72 //  contained in the derived classes                                         //
73 //                                                                           //
74 ///////////////////////////////////////////////////////////////////////////////
75
76 #include <stdlib.h>
77
78 // --- ROOT system
79 #include <TBRIK.h>
80 #include <TNode.h>
81 #include <TGeometry.h>
82 #include <TFile.h>
83 #include <TTree.h>
84
85 // --- AliRoot header files
86 #include "AliZDC.h"
87 #include "AliZDCHit.h"
88 #include "AliRun.h"
89 #include "AliDetector.h"
90 #include "AliCallf77.h"
91 #include "AliConst.h"
92 #include "AliMC.h"
93
94  
95 ClassImp(AliZDC)
96  
97 //_____________________________________________________________________________
98 AliZDC::AliZDC()
99 {
100   //
101   // Default constructor for the Zero Degree Calorimeter base class
102   //
103   
104   fIshunt = 1;
105
106   fNhits = 0;
107
108 //  fNStHits = 0;
109
110 //  fNPrimaryHits = 0;
111   fNoShower   = 0;
112 }
113  
114 //_____________________________________________________________________________
115 AliZDC::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
124   
125   fIshunt =  1;
126
127   fHits   = new TClonesArray("AliZDCHit",1000);
128   gAlice->AddHitList(fHits);
129   
130 //  fStHits = new TClonesArray("AliZDCHit",1000);
131 //  fNStHits = 0;
132
133 //  fNPrimaryHits = 0;
134   fNoShower   = 0;
135
136 }
137 //____________________________________________________________________________ 
138 AliZDC::~AliZDC()
139 {
140   //
141   // ZDC destructor
142   //
143
144   fIshunt   = 0;
145
146 //  delete fHits;
147 //  if(fStHits){
148 //    fStHits->Delete();
149 //    delete fStHits;
150 //    fNStHits = 0;
151 //  }
152 //  delete fDigits;
153 }
154 //_____________________________________________________________________________
155 void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
156 {
157   //
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
163   //
164   
165   static Float_t primKinEn, xImpact, yImpact, sFlag;
166
167   AliZDCHit *newquad, *curprimquad;
168 //  AliZDCHit *curevquad;  
169   newquad = new AliZDCHit(fIshunt, track, vol, hits);
170
171 //  TClonesArray &lsthits = *fStHits;
172   TClonesArray &lhits = *fHits;
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  
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 //  }
208
209   for(j=0; j<fNhits; j++){
210     // If hits are equal (same track, same volume), sum them.
211      curprimquad = (AliZDCHit*) lhits[j];
212      if(*curprimquad == *newquad){
213         *curprimquad = *curprimquad+*newquad;
214         delete newquad;
215         return;
216      } 
217   }
218
219     //Otherwise create a new hit
220     new(lhits[fNhits]) AliZDCHit(newquad);
221     fNhits++;
222     
223 //    if(kStHit){
224 //      new(lsthits[fNStHits]) AliZDCHit(newquad);
225 //      fNStHits++;
226 //    }
227
228     if(fDebug == 1){ 
229       printf("\n  Primary Hits --------------------------------------------------------\n");
230       fHits->Print("");
231 //      printf("\n  Event Hits --------------------------------------------------------\n");
232 //      fStHits->Print("");
233     }
234
235     delete newquad;
236   }
237 //____________________________________________________________________________
238 Float_t AliZDC::ZMin(void) const
239 {
240   // Minimum dimension of the ZDC module in z
241   return 11600.;
242 }
243
244 //____________________________________________________________________________
245 Float_t AliZDC::ZMax(void) const
246 {
247   // Maximum dimension of the ZDC module in z
248   return  11750.;
249 }
250   
251 //_____________________________________________________________________________
252 void AliZDC::ResetDigits()
253 {
254   //
255   // Reset number of digits and the digits array
256   //
257     
258     AliDetector::ResetDigits();
259 //    fNStHits = 0;
260 //    if(fStHits) fStHits->Clear();
261 }
262
263 //_____________________________________________________________________________
264 void 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
272   TNode *node, *top;
273   TBRIK *brik;
274   const int kColorZDC  = kRed;
275   
276   //
277   top=gAlice->GetGeometry()->GetNode("alice");
278   
279   // ZDC
280     brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
281     top->cd();
282     node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
283     node->SetLineColor(kColorZDC);
284     fNodes->Add(node);
285 }
286
287 //_____________________________________________________________________________
288 Int_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 //_____________________________________________________________________________
298 void AliZDC::StepManager()
299 {
300   //
301   // Routine called at every step in the Zero Degree Calorimeter
302   //
303 }