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