]> git.uio.no Git - u/mrichter/AliRoot.git/blob - START/AliSTART.cxx
new slow simulation up to RawData
[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 "AliLog.h"
53 #include "AliMC.h"
54 #include "AliLoader.h"
55 #include "AliRun.h"
56
57 #include "AliSTART.h"
58 #include "AliSTARTLoader.h"
59 #include "AliSTARTdigit.h"
60 #include "AliSTARThit.h"
61 #include "AliSTARTDigitizer.h"
62 #include "AliSTARTRawData.h"
63
64 ClassImp(AliSTART)
65
66   //static  AliSTARTdigit *digits; 
67
68 //_____________________________________________________________________________
69 AliSTART::AliSTART()
70 {
71   //
72   // Default constructor for class AliSTART
73   //
74   fIshunt   = 1;
75   fHits     = 0;
76   fDigits   = 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   fIshunt     =  1;
93   fIdSens   =  0;
94   SetMarkerColor(kRed);
95 }
96
97 //_____________________________________________________________________________
98 AliSTART::~AliSTART() {
99   if (fHits) {
100     fHits->Delete();
101     delete fHits;
102   }
103 }
104  
105 //_____________________________________________________________________________
106 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
107 {
108   //
109   // Add a START hit
110   //
111   TClonesArray &lhits = *fHits;
112   new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
113 }
114
115
116 //_____________________________________________________________________________
117
118 void AliSTART::AddDigit(Int_t * /*tracks*/, Int_t * /*digits*/)
119 {
120   
121   //  Add a START digit to the list. Dummy function.
122   
123 }
124
125 //_____________________________________________________________________________
126 void AliSTART::BuildGeometry()
127 {
128   //
129   // Build simple ROOT TNode geometry for event display
130   //
131   TNode *node, *top;
132   const int kColorSTART  = 19;
133
134   top=gAlice->GetGeometry()->GetNode("alice");
135
136   // START define the different volumes
137   new TRotMatrix("rotx999","rot999",  90,0,90,90,180,0);
138
139   new TTUBE("S_0ST1","START  volume 1","void",5.,10.7,5.3);
140   top->cd();
141   node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
142   node->SetLineColor(kColorSTART);
143   fNodes->Add(node);
144
145   new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
146   top->cd();
147   node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
148   node->SetLineColor(kColorSTART);
149   fNodes->Add(node);
150 }
151  
152 //_____________________________________________________________________________
153 Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
154 {
155   //
156   // Calculate the distance from the mouse to the START on the screen
157   // Dummy routine
158   //
159   return 9999;
160 }
161  
162 //-------------------------------------------------------------------------
163 void AliSTART::Init()
164 {
165   //
166   // Initialis the START after it has been built
167   Int_t i;
168   //
169   if(fDebug) {
170     printf("\n%s: ",ClassName());
171     for(i=0;i<35;i++) printf("*");
172     printf(" START_INIT ");
173     for(i=0;i<35;i++) printf("*");
174     printf("\n%s: ",ClassName());
175     //
176     // Here the START initialisation code (if any!)
177     for(i=0;i<80;i++) printf("*");
178     printf("\n");
179   }
180 }
181
182 //---------------------------------------------------------------------------
183 void AliSTART::MakeBranch(Option_t* option)
184 {
185   //
186   // Specific START branches
187   //
188   // Create Tree branches for the START.
189   char branchname[20];
190   sprintf(branchname,"%s",GetName());
191
192   const char *cH = strstr(option,"H");
193   
194   if (cH && fLoader->TreeH())
195   {
196      if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
197   } 
198   
199   AliDetector::MakeBranch(option);
200 }    
201
202 //_____________________________________________________________________________
203 void AliSTART::ResetHits()
204 {
205   AliDetector::ResetHits();
206   
207 }
208
209 //_____________________________________________________________________________
210 void AliSTART::SetTreeAddress()
211 {
212
213   TTree    *treeH;
214   treeH = TreeH();
215   
216   if (treeH)
217     {
218       if (fHits == 0x0) fHits  = new TClonesArray("AliSTARThit",  405);
219     }
220     
221   AliDetector::SetTreeAddress();
222   
223 }
224
225 //______________________________________________________________________
226 AliLoader* AliSTART::MakeLoader(const char* topfoldername)
227
228
229   AliDebug(2,Form(" Creating AliSTARTLoader "));
230   fLoader = new AliSTARTLoader(GetName(), topfoldername);
231   return fLoader;
232 }
233
234 //_____________________________________________________________________________
235 AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
236 {
237   return new AliSTARTDigitizer(manager);
238 }
239 //____________________________________________________________________________
240 void AliSTART::Digits2Raw()
241 {
242 //
243 // Starting from the START digits, writes the Raw Data objects
244 //
245   AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
246   pStartLoader ->LoadDigits();
247   AliSTARTdigit* fDigits=pStartLoader->Digits();
248   AliSTARTRawData rawWriter;
249   rawWriter.SetVerbose(0);
250
251   AliDebug(2,Form(" Formatting raw data for START "));
252   
253   rawWriter.RawDataSTART (fDigits);
254
255    pStartLoader->UnloadDigits();
256
257 }