]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
Code clean-up, a lot of corrections to the usage of loaders (T.Kuhr)
[u/mrichter/AliRoot.git] / START / AliSTART.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 //  START (T-Zero) Detector                                            //
21 //  This class contains the base procedures for the START     //
22 //  detector                                                                 //
23 //                                                                           //
24 //Begin_Html
25 /*
26 <img src="gif/AliSTARTClass.gif">
27 </pre>
28 <br clear=left>
29 <font size=+2 color=red>
30 <p>The responsible person for this module is
31 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
32 </font>
33 <pre>
34 */
35 //End_Html
36 //                                                                           //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include <Riostream.h>
41
42 #include <TFile.h>
43 #include <TGeometry.h>
44 #include <TMath.h>
45 #include <TNode.h>
46 #include <TParticle.h>
47 #include <TRandom.h>
48 #include <TTUBE.h>
49 #include <TVirtualMC.h>
50 #include <AliESD.h>
51
52 #include "AliLoader.h"
53 #include "AliRun.h"
54 #include "AliSTART.h"
55 #include "AliSTARTLoader.h"
56 #include "AliSTARTdigit.h"
57 #include "AliSTARThit.h"
58 #include "AliSTARThitPhoton.h"
59 #include "AliSTARTvertex.h"
60 #include "AliMC.h"
61 #include "AliSTARTDigitizer.h"
62
63 ClassImp(AliSTART)
64
65 static  AliSTARTdigit *digits; 
66
67 //_____________________________________________________________________________
68 AliSTART::AliSTART()
69 {
70   //
71   // Default constructor for class AliSTART
72   //
73   fIshunt   = 1;
74   fHits     = 0;
75   fDigits   = 0;
76   fPhotons  = 0;
77 }
78  
79 //_____________________________________________________________________________
80 AliSTART::AliSTART(const char *name, const char *title)
81        : AliDetector(name,title)
82 {
83   //
84   // Standard constructor for START Detector
85   //
86
87   
88   //
89   // Initialise Hit array
90   fHits       = new TClonesArray("AliSTARThit",  405);
91   gAlice->GetMCApp()->AddHitList(fHits);
92
93   fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
94   gAlice->GetMCApp()->AddHitList (fPhotons);
95   if (GetDebug()>2) cout<<" Debug "<<endl;
96   fIshunt     =  1;
97   fIdSens   =  0;
98   fNPhotons =  0;
99   SetMarkerColor(kRed);
100 }
101
102 //_____________________________________________________________________________
103 AliSTART::~AliSTART() {
104   if (fHits) {
105     fHits->Delete();
106     delete fHits;
107   }
108   if (fPhotons) {
109     fPhotons->Delete();
110     delete fPhotons;
111   }
112 }
113  
114 //_____________________________________________________________________________
115 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
116 {
117   //
118   // Add a START hit
119   //
120   TClonesArray &lhits = *fHits;
121   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
122 }
123
124 //_____________________________________________________________________________
125 void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
126 {
127   //  Add a START hit of photons
128   
129   TClonesArray &lhits = *fPhotons;
130   new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
131 }
132
133 //_____________________________________________________________________________
134
135 void AliSTART::AddDigit(Int_t * /*tracks*/, Int_t * /*digits*/)
136 {
137   
138   //  Add a START digit to the list. Dummy function.
139   
140 }
141
142 //_____________________________________________________________________________
143 void AliSTART::BuildGeometry()
144 {
145   //
146   // Build simple ROOT TNode geometry for event display
147   //
148   TNode *node, *top;
149   const int kColorSTART  = 19;
150
151   top=gAlice->GetGeometry()->GetNode("alice");
152
153   // START define the different volumes
154   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
155
156   new TTUBE("S_0ST1","START  volume 1","void",5.,10.7,5.3);
157   top->cd();
158   node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
159   node->SetLineColor(kColorSTART);
160   fNodes->Add(node);
161
162   new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
163   top->cd();
164   node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
165   node->SetLineColor(kColorSTART);
166   fNodes->Add(node);
167 }
168  
169 //_____________________________________________________________________________
170 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
171 {
172   //
173   // Calculate the distance from the mouse to the START on the screen
174   // Dummy routine
175   //
176   return 9999;
177 }
178  
179 //-------------------------------------------------------------------------
180 void AliSTART::Init()
181 {
182   //
183   // Initialis the START after it has been built
184   Int_t i;
185   //
186   if(fDebug) {
187     printf("\n%s: ",ClassName());
188     for(i=0;i<35;i++) printf("*");
189     printf(" START_INIT ");
190     for(i=0;i<35;i++) printf("*");
191     printf("\n%s: ",ClassName());
192     //
193     // Here the START initialisation code (if any!)
194     for(i=0;i<80;i++) printf("*");
195     printf("\n");
196   }
197 }
198
199 //---------------------------------------------------------------------------
200 void AliSTART::MakeBranch(Option_t* option)
201 {
202   //
203   // Specific START branches
204   //
205   // Create Tree branches for the START.
206   Int_t buffersize = 4000;
207   char branchname[20];
208   sprintf(branchname,"%s",GetName());
209
210
211   const char *cD = strstr(option,"D");
212   const char *cH = strstr(option,"H");
213   
214   if (cH && fLoader->TreeH())
215   {
216      if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
217      sprintf (branchname, "%shitPhoton", GetName());
218      MakeBranchInTree (fLoader->TreeH(), branchname, &fPhotons, 50000, 0);
219      if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
220   } 
221   
222   AliDetector::MakeBranch(option);
223
224   if (cD) {
225     digits = new AliSTARTdigit();
226     MakeBranchInTree(fLoader->TreeD(), branchname, "AliSTARTdigit", digits, buffersize, 1, 0);
227   } 
228 }    
229
230 //_____________________________________________________________________________
231 void AliSTART::ResetHits()
232 {
233   AliDetector::ResetHits();
234   
235   fNPhotons = 0;
236   if (fPhotons)  fPhotons->Clear();
237 }
238
239 //_____________________________________________________________________________
240 void AliSTART::SetTreeAddress()
241 {
242   TBranch  *branch;
243   TTree    *treeH;
244  
245   
246   treeH = TreeH();
247   
248   if (treeH)
249     {
250       if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
251       branch = treeH->GetBranch("STARThitPhoton");
252       if (branch)  branch->SetAddress(&fPhotons);
253       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
254     }
255     
256   AliDetector::SetTreeAddress();
257   
258 }
259
260 //______________________________________________________________________
261 AliLoader* AliSTART::MakeLoader(const char* topfoldername)
262
263   Info("MakeLoader", "Creating AliSTARTLoader. Top folder is %s.", topfoldername);
264   fLoader = new AliSTARTLoader(GetName(), topfoldername);
265   return fLoader;
266 }
267
268 //_____________________________________________________________________________
269 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
270 {
271   return new AliSTARTDigitizer(manager);
272 }
273
274 //_____________________________________________________________________________
275 void AliSTART::FillESD(AliESD* pESD)  const
276 {
277   AliSTARTvertex reco;
278   reco.Reconstruct(fLoader->GetRunLoader(), pESD);
279 }
280