]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDC.cxx
New version of ZDC from E.Scomparin & C.Oppedisano
[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.7  2000/01/19 17:17:40  fca
19
20 Revision 1.6  1999/09/29 09:24:35  fca
21 Introduction of the Copyright and cvs Log
22
23 */
24
25 ///////////////////////////////////////////////////////////////////////////////
26 //                                                                           //
27 //  Zero Degree Calorimeter                                                  //
28 //  This class contains the basic functions for the Time Of Flight           //
29 //  detector. Functions specific to one particular geometry are              //
30 //  contained in the derived classes                                         //
31 //                                                                           //
32 ///////////////////////////////////////////////////////////////////////////////
33
34 #include <TBRIK.h>
35 #include <TNode.h>
36
37 #include "AliZDC.h"
38 #include "AliRun.h"
39 #include "AliCallf77.h"
40 #include "AliConst.h"
41 #include "AliMC.h"
42
43  
44 ClassImp(AliZDC)
45  
46 //_____________________________________________________________________________
47 AliZDC::AliZDC()
48 {
49   //
50   // Default constructor for the Zero Degree Calorimeter base class
51   //
52   fIshunt = 1;
53   fHits = 0;
54 }
55  
56 //_____________________________________________________________________________
57 AliZDC::AliZDC(const char *name, const char *title)
58   : AliDetector(name,title)
59 {
60   //
61   // Standard constructor for the Zero Degree Calorimeter base class
62   //
63
64   //
65   // Allocate the array of hits
66   fHits   = new TClonesArray("AliZDChit",  405);
67   gAlice->AddHitList(fHits);
68   
69   fIshunt =  1;
70   
71   fDimZN[0] = 3.52;
72   fDimZN[1] = 3.52;
73   fDimZN[2] = 50.;
74   fDimZP[0] = 11.2;
75   fDimZP[1] = 6.;
76   fDimZP[2] = 75.;
77   fPosZN[0] = 0.;
78   fPosZN[1] = 0.;
79   fPosZN[2] = 11650.;
80   fPosZP[0] = -23.;
81   fPosZP[1] = 0.;
82   fPosZP[2] = 11600.;
83   fFibZN[0] = 0.;
84   fFibZN[1] = 0.01825;
85   fFibZN[2] = 50.;
86   fFibZP[0] = 0.;
87   fFibZP[1] = 0.0275;
88   fFibZP[2] = 75.;
89   fGrvZN[0] = 0.03;
90   fGrvZN[1] = 0.03;
91   fGrvZN[2] = 50.;
92   fGrvZP[0] = 0.04;
93   fGrvZP[1] = 0.04;
94   fGrvZP[2] = 75.;
95   fDivZN[0] = 11;
96   fDivZN[1] = 11;
97   fDivZN[2] = 0;
98   fDivZP[0] = 7;
99   fDivZP[1] = 15;
100   fDivZP[2] = 0;
101   fTowZN[0] = 2;
102   fTowZN[1] = 2;
103   fTowZP[0] = 4;
104   fTowZP[1] = 1;
105 }
106  
107 //_____________________________________________________________________________
108 void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
109 {
110   //
111   // Add a ZDC hit
112   //
113   static Float_t primKinEn, xImpact, yImpact, sFlag;
114
115   TClonesArray &lhits = *fHits;
116
117   AliZDChit *newquad, *curquad;
118   newquad = new AliZDChit(fIshunt, track, vol, hits);
119   Int_t i;
120   for(i=0; i<fNhits; i++){
121     // If the hits are equal (same track, same volume), sum them.
122      curquad=(AliZDChit*) lhits[i];
123      if(*curquad==*newquad){
124         *curquad = *curquad+*newquad;
125         delete newquad;
126 //        fHits->Print("");
127         return;
128       }
129    }
130    
131    //Otherwise create a new hit.
132    if(fNhits==0){
133       // First hit -> setting flag for primary or secondary particle
134       Int_t primary = gAlice->GetPrimary(track);     
135       if(track != primary){
136         newquad->fSFlag = 1;  // Hit created by secondary particle entering the ZDC
137       }
138       else if(track == primary){
139         newquad->fSFlag = 0;  // Hit created by PRIMARY particle entering the ZDC
140       }  
141       sFlag = newquad->fSFlag;
142       primKinEn = newquad->fPrimKinEn;
143       xImpact = newquad->fXImpact;
144       yImpact = newquad->fYImpact;
145    }
146    else{       
147       newquad->fPrimKinEn = primKinEn;
148       newquad->fXImpact = xImpact;
149       newquad->fYImpact = yImpact;
150       newquad->fSFlag = sFlag;
151    }
152    new(lhits[fNhits++]) AliZDChit(newquad);
153     if(fNhits==1) {
154 //      Int_t Curtrack = gAlice->CurrentTrack();
155 //      Int_t Prim = gAlice->GetPrimary(Curtrack);
156 //      printf ("               Primary track: %d, Current track: %d \n", 
157 //              Prim, Curtrack);
158 //      fHits->Print("");
159     }
160     delete newquad;
161 //    fHits->Print("");
162   
163 }
164   
165 //_____________________________________________________________________________
166 void AliZDC::BuildGeometry()
167 {
168   //
169   // Build the ROOT TNode geometry for event display 
170   // in the Zero Degree Calorimeter
171   // This routine is dummy for the moment
172   //
173
174   TNode *node, *top;
175   TBRIK *brik;
176   const int kColorZDC  = kRed;
177   
178   //
179   top=gAlice->GetGeometry()->GetNode("alice");
180   
181   // ZDC
182     brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
183     top->cd();
184     node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
185     node->SetLineColor(kColorZDC);
186     fNodes->Add(node);
187 }
188
189 //_____________________________________________________________________________
190 Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
191 {
192   //
193   // Distance from the mouse to the Zero Degree Calorimeter
194   // Dummy routine
195   //
196   return 9999;
197 }
198  
199 //_____________________________________________________________________________
200 void AliZDC::StepManager()
201 {
202   //
203   // Routine called at every step in the Zero Degree Calorimeter
204   //
205 }
206
207 ClassImp(AliZDChit)
208   
209 //_____________________________________________________________________________
210 AliZDChit::AliZDChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
211   AliHit(shunt, track)
212 {
213   //
214   // Add a ZDC hit
215   //
216   Int_t i;
217   for(i=0; i<2; i++) fVolume[i] = vol[i];
218   fX = hits[0];
219   fY = hits[1];
220   fZ = hits[2];
221   fPrimKinEn = hits[3];
222   fXImpact = hits[4];
223   fYImpact = hits[5];
224   fSFlag = hits[6];
225   fLightPMQ = hits[7];
226   fLightPMC = hits[8];
227   fEnergy = hits[9]; 
228 }