]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
Coding convention, reconstruction fill ESD
[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 "AliSTARTdigit.h"
56 #include "AliSTARThit.h"
57 #include "AliSTARThitPhoton.h"
58 #include "AliSTARTvertex.h"
59 #include "AliMC.h"
60 #include "AliSTARTDigitizer.h"
61
62 ClassImp(AliSTART)
63
64 static  AliSTARTdigit *digits; 
65
66 //_____________________________________________________________________________
67 AliSTART::AliSTART()
68 {
69   //
70   // Default constructor for class AliSTART
71   //
72   fIshunt   = 1;
73   fHits     = 0;
74   fDigits   = 0;
75   fPhotons  = 0;
76 }
77  
78 //_____________________________________________________________________________
79 AliSTART::AliSTART(const char *name, const char *title)
80        : AliDetector(name,title)
81 {
82   //
83   // Standard constructor for START Detector
84   //
85
86   
87   //
88   // Initialise Hit array
89   fHits       = new TClonesArray("AliSTARThit",  405);
90   gAlice->GetMCApp()->AddHitList(fHits);
91
92   fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
93   gAlice->GetMCApp()->AddHitList (fPhotons);
94   if (GetDebug()>2) cout<<" Debug "<<endl;
95   fIshunt     =  1;
96   fIdSens   =  0;
97   fNPhotons =  0;
98   SetMarkerColor(kRed);
99 }
100
101 //_____________________________________________________________________________
102 AliSTART::~AliSTART() {
103   if (fHits) {
104     fHits->Delete();
105     delete fHits;
106   }
107   if (fPhotons) {
108     fPhotons->Delete();
109     delete fPhotons;
110   }
111 }
112  
113 //_____________________________________________________________________________
114 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
115 {
116   //
117   // Add a START hit
118   //
119   TClonesArray &lhits = *fHits;
120   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
121 }
122
123 //_____________________________________________________________________________
124 void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
125 {
126   //  Add a START hit of photons
127   
128   TClonesArray &lhits = *fPhotons;
129   new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
130 }
131
132 //_____________________________________________________________________________
133
134 void AliSTART::AddDigit(Int_t * /*tracks*/, Int_t * /*digits*/)
135 {
136   
137   //  Add a START digit to the list. Dummy function.
138   
139 }
140
141 //_____________________________________________________________________________
142 void AliSTART::BuildGeometry()
143 {
144   //
145   // Build simple ROOT TNode geometry for event display
146   //
147   TNode *node, *top;
148   const int kColorSTART  = 19;
149
150   top=gAlice->GetGeometry()->GetNode("alice");
151
152   // START define the different volumes
153   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
154
155   new TTUBE("S_0ST1","START  volume 1","void",5.,10.7,5.3);
156   top->cd();
157   node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
158   node->SetLineColor(kColorSTART);
159   fNodes->Add(node);
160
161   new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
162   top->cd();
163   node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
164   node->SetLineColor(kColorSTART);
165   fNodes->Add(node);
166 }
167  
168 //_____________________________________________________________________________
169 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
170 {
171   //
172   // Calculate the distance from the mouse to the START on the screen
173   // Dummy routine
174   //
175   return 9999;
176 }
177  
178 //-------------------------------------------------------------------------
179 void AliSTART::Init()
180 {
181   //
182   // Initialis the START after it has been built
183   Int_t i;
184   //
185   if(fDebug) {
186     printf("\n%s: ",ClassName());
187     for(i=0;i<35;i++) printf("*");
188     printf(" START_INIT ");
189     for(i=0;i<35;i++) printf("*");
190     printf("\n%s: ",ClassName());
191     //
192     // Here the START initialisation code (if any!)
193     for(i=0;i<80;i++) printf("*");
194     printf("\n");
195   }
196 }
197
198 //---------------------------------------------------------------------------
199 void AliSTART::MakeBranch(Option_t* option)
200 {
201   //
202   // Specific START branches
203   //
204   // Create Tree branches for the START.
205   Int_t buffersize = 4000;
206   char branchname[20];
207   sprintf(branchname,"%s",GetName());
208
209
210   const char *cD = strstr(option,"D");
211   const char *cH = strstr(option,"H");
212   
213   if (cH && fLoader->TreeH())
214   {
215      if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
216      sprintf (branchname, "%shitPhoton", GetName());
217      MakeBranchInTree (fLoader->TreeH(), branchname, &fPhotons, 50000, 0);
218      if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
219   } 
220   
221   AliDetector::MakeBranch(option);
222
223   if (cD) {
224     digits = new AliSTARTdigit();
225     MakeBranchInTree(fLoader->TreeD(), branchname, "AliSTARTdigit", digits, buffersize, 1, 0);
226   } 
227 }    
228
229 //_____________________________________________________________________________
230 void AliSTART::ResetHits()
231 {
232   AliDetector::ResetHits();
233   
234   fNPhotons = 0;
235   if (fPhotons)  fPhotons->Clear();
236 }
237
238 //_____________________________________________________________________________
239 void AliSTART::SetTreeAddress()
240 {
241   TBranch  *branch;
242   TTree    *treeH;
243  
244   
245   treeH = TreeH();
246   
247   if (treeH)
248     {
249       if (fPhotons == 0x0) fPhotons  = new TClonesArray("AliSTARThitPhoton", 10000);
250       branch = treeH->GetBranch("STARThitPhoton");
251       if (branch)  branch->SetAddress(&fPhotons);
252       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
253     }
254     
255   AliDetector::SetTreeAddress();
256   
257 }
258
259 //_____________________________________________________________________________
260 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
261 {
262   return new AliSTARTDigitizer(manager);
263 }
264