]> git.uio.no Git - u/mrichter/AliRoot.git/blob - BCM/AliBCM.cxx
Beam Condition Monitor simulation kick start.
[u/mrichter/AliRoot.git] / BCM / AliBCM.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  Beam Condition Monitor BCM                                               //
21 //                                                                           //
22 //  andreas.morsch@cern.ch                                                   // 
23 ///////////////////////////////////////////////////////////////////////////////
24  
25 #include <TVirtualMC.h>
26 #include <TClonesArray.h>
27 #include <TGeoMaterial.h>
28 #include <TGeoMedium.h>
29 #include <TGeoVolume.h>
30 #include <TGeoMatrix.h>
31 #include <TGeoPgon.h>
32 #include <TGeoXtru.h>
33 #include <TGeoCompositeShape.h>
34 #include <TGeoManager.h>
35
36 #include "AliBCM.h"
37 #include "AliBCMHit.h"
38 #include "AliMagF.h"
39 #include "AliRun.h"
40 #include "AliMC.h"
41  
42 ClassImp(AliBCM)
43
44  
45 //_____________________________________________________________________________
46 AliBCM::AliBCM():
47     AliDetector(),
48     fVolId(0)
49 {
50   //
51   // Default constructor for BCM
52   //
53 }
54  
55 //_____________________________________________________________________________
56 AliBCM::AliBCM(const char *name, const char *title): 
57     AliDetector(name,title),
58     fVolId(0)  
59 {
60 //
61 //  Constructor
62     fHits  = new TClonesArray("AliBCMHit");
63     fNhits = 0;    
64     gAlice->GetMCApp()->AddHitList(fHits);
65 }
66 AliBCM::~AliBCM()
67 {  
68     // Destructor
69     if(fHits)      delete fHits;
70 }
71
72 void AliBCM::StepManager()
73 {
74 //
75 // Step Manager for ALICE Beam Condition Monitor
76 //    
77
78     static Float_t edepT;    
79     static Double_t xh[3] = {0., 0., 0.};
80     Float_t edep = 0.;
81     Int_t   copy = -1; 
82     
83     
84     if (gMC->TrackCharge() && 
85         gMC->CurrentVolID(copy) == fVolId) {
86         // Charged particle inside sensitive volume
87         //
88         // Entering
89         if (gMC->IsTrackEntering()) {
90             edepT = 0.;
91             gMC->TrackPosition(xh[0],xh[1],xh[2]); 
92         }
93         
94         //
95         // Any step
96         if ((edep = gMC->Edep()) > 0.) {
97             Double_t x[3];   
98             gMC->TrackPosition(x[0],x[1],x[2]); 
99             edepT += edep;
100         }
101         //
102         // Exiting 
103         if(gMC->IsTrackExiting()||gMC->IsTrackStop()||gMC->IsTrackDisappeared())
104         {
105             Int_t track = gAlice->GetMCApp()->GetCurrentTrackNumber();
106             TClonesArray &lhits = *fHits;
107             Int_t ic = copy + 10;
108             if (xh[2] < 0.) ic+=10;
109             new(lhits[fNhits++]) AliBCMHit(1, track, xh, ic, edepT);
110         }
111     }
112
113     
114 }
115
116 //_____________________________________________________________________________
117 void AliBCM::CreateGeometry()
118 {
119     //
120     // Create geometry for BCM
121     //
122     
123     //
124     // Top volume 
125     TGeoVolume* top      = gGeoManager->GetVolume("ALIC");
126     // Media 
127     TGeoMedium* medPCD   = gGeoManager->GetMedium("BCM_PCD");
128     // Rotations
129     TGeoRotation* rotxz   = new TGeoRotation("rotxz" ,  270.,   0., 90.,  90., 180., 0.);
130     TGeoRotation* rot000  = new TGeoRotation("rot000",   90.,   0., 90.,  90.,   0., 0.);
131     TGeoRotation* rot090  = new TGeoRotation("rot090",   90.,  90., 90., 180.,   0., 0.);
132     TGeoRotation* rot180  = new TGeoRotation("rot180",   90., 180., 90., 270.,   0., 0.);
133     TGeoRotation* rot270  = new TGeoRotation("rot270",   90., 270., 90.,   0.,   0., 0.);
134     //
135     const Float_t kWidth     = 1.00;
136     const Float_t kThickness = 0.05;
137     const Float_t rBCM       = 7.;
138     
139     
140     TGeoBBox*   shBCMpcd = new TGeoBBox(kWidth/2., kWidth/2., kThickness/2.);
141     TGeoVolume* voBCMpcd = new TGeoVolume("BCMpcd", shBCMpcd, medPCD);
142     TGeoVolumeAssembly* voBCM = new TGeoVolumeAssembly("BCM");
143     
144     voBCM->AddNode(voBCMpcd, 1, new TGeoCombiTrans(+rBCM, 0.    , 0., rot000));
145     voBCM->AddNode(voBCMpcd, 2, new TGeoCombiTrans(0.   , +rBCM , 0., rot090));
146     voBCM->AddNode(voBCMpcd, 3, new TGeoCombiTrans(-rBCM, 0.,     0., rot180));
147     voBCM->AddNode(voBCMpcd, 4, new TGeoCombiTrans(0.   , -rBCM , 0., rot270));
148     
149     top->AddNode(voBCM, 1, new TGeoTranslation(0., 0., 1561.));
150     top->AddNode(voBCM, 2, new TGeoCombiTrans(0., 0., -1908., rotxz));
151     
152 }
153
154 //_____________________________________________________________________________
155 void AliBCM::CreateMaterials()
156 {
157   //
158   // Create materials for BCM
159   //
160   // Polycristalline Diamond
161     Float_t rho  = 3.53;
162     Float_t absl = 86.3 / rho;
163     Float_t radl = 42.7 / rho;
164     //
165     Float_t epsil  = .001;   // Tracking precision, 
166     Float_t stemax = -1.;    // Maximum displacement for multiple scat 
167     Float_t tmaxfd = -20. ;  // Maximum angle due to field deflection 
168     Float_t deemax = -.01;   // Maximum fractional energy loss, DLS 
169     Float_t stmin  = -.8;
170     Int_t   isxfld = gAlice->Field()->Integ();
171     Float_t sxmgmx = gAlice->Field()->Max();
172
173     AliMaterial(1, "PCD", 12.011, 6., rho, radl, absl);
174     //
175     AliMedium(1, "PCD", 1, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
176 }
177
178 //_____________________________________________________________________________
179 void AliBCM::Init()
180 {
181     //
182     // Initialise BCM magnet after it has been built
183     //
184   Int_t i;
185   //
186   if(AliLog::GetGlobalDebugLevel()>0) {
187     printf("\n%s: ",ClassName());
188     for(i=0;i<35;i++) printf("*");
189     printf(" BCM_INIT ");
190     for(i=0;i<35;i++) printf("*");
191     printf("\n%s: ",ClassName());
192     for(i=0;i<80;i++) printf("*");
193     printf("\n");
194   }
195
196     //
197     // Here the BCM initialisation code (if any!)
198     fVolId =  gMC->VolId("BCMpcd");
199 }
200
201 void AliBCM::MakeBranch(Option_t* option)
202 {
203 //Create Tree branches for the BCM
204     
205   const Int_t kBufSize = 4000;
206   const char *cH = strstr(option,"H");
207 //  const char *cD = strstr(option,"D");
208 //  const char *cR = strstr(option,"R");
209 //  const char *cS = strstr(option,"S");
210
211   if(cH && TreeH() && (fHits == 0x0)){
212       fHits  = new TClonesArray("AliBCMHit");
213       fNhits = 0;    
214       MakeBranchInTree(TreeH(), "BCM" ,&fHits ,kBufSize, 0);
215   }
216   AliDetector::MakeBranch(option);
217 }
218
219 void AliBCM::SetTreeAddress()
220 {
221   // Set branch address
222
223     if (TreeH() && fHits==0x0)
224         fHits   = new TClonesArray("AliBCMHit",  4000);
225     AliDetector::SetTreeAddress();
226 }