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