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