reconstruction from RAWData added
[u/mrichter/AliRoot.git] / START / AliSTART.cxx
CommitLineData
4c039060 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
88cb7938 16/* $Id$ */
4c039060 17
6ca40650 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
ef0750c2 40#include <Riostream.h>
971579f6 41
88cb7938 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>
affef71b 50#include <AliESD.h>
2ab0c725 51
e4da63c2 52#include "AliLog.h"
53#include "AliMC.h"
88cb7938 54#include "AliLoader.h"
971579f6 55#include "AliRun.h"
e4da63c2 56
971579f6 57#include "AliSTART.h"
6fc133d2 58#include "AliSTARTLoader.h"
971579f6 59#include "AliSTARTdigit.h"
971579f6 60#include "AliSTARThit.h"
85a5290f 61#include "AliSTARTDigitizer.h"
e4da63c2 62#include "AliSTARTRawData.h"
971579f6 63
6ca40650 64ClassImp(AliSTART)
ef51244a 65
e4da63c2 66 //static AliSTARTdigit *digits;
ef51244a 67
6ca40650 68//_____________________________________________________________________________
99560b47 69AliSTART::AliSTART()
6ca40650 70{
71 //
72 // Default constructor for class AliSTART
73 //
f3ed336b 74 fIshunt = 1;
971579f6 75 fHits = 0;
76 fDigits = 0;
6ca40650 77}
78
79//_____________________________________________________________________________
80AliSTART::AliSTART(const char *name, const char *title)
81 : AliDetector(name,title)
82{
83 //
84 // Standard constructor for START Detector
85 //
971579f6 86
c345bb4f 87
6ca40650 88 //
89 // Initialise Hit array
971579f6 90 fHits = new TClonesArray("AliSTARThit", 405);
f1538e33 91 gAlice->GetMCApp()->AddHitList(fHits);
f3ed336b 92 fIshunt = 1;
c345bb4f 93 fIdSens = 0;
6ca40650 94 SetMarkerColor(kRed);
95}
bff160c8 96
97//_____________________________________________________________________________
98AliSTART::~AliSTART() {
99 if (fHits) {
100 fHits->Delete();
101 delete fHits;
102 }
103}
6ca40650 104
105//_____________________________________________________________________________
106void 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}
971579f6 114
e73d68f2 115
116//_____________________________________________________________________________
c345bb4f 117
f1538e33 118void AliSTART::AddDigit(Int_t * /*tracks*/, Int_t * /*digits*/)
971579f6 119{
c345bb4f 120
f3ed336b 121 // Add a START digit to the list. Dummy function.
c345bb4f 122
971579f6 123}
c345bb4f 124
6ca40650 125//_____________________________________________________________________________
126void AliSTART::BuildGeometry()
127{
128 //
129 // Build simple ROOT TNode geometry for event display
130 //
ef51244a 131 TNode *node, *top;
6ca40650 132 const int kColorSTART = 19;
f3ed336b 133
ef51244a 134 top=gAlice->GetGeometry()->GetNode("alice");
6ca40650 135
136 // START define the different volumes
44b06417 137 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
6ca40650 138
2ca99a7f 139 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
ef51244a 140 top->cd();
1663993c 141 node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
ef51244a 142 node->SetLineColor(kColorSTART);
143 fNodes->Add(node);
6ca40650 144
2ca99a7f 145 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
ef51244a 146 top->cd();
1663993c 147 node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
ef51244a 148 node->SetLineColor(kColorSTART);
149 fNodes->Add(node);
6ca40650 150}
151
152//_____________________________________________________________________________
7fe81cad 153Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
6ca40650 154{
155 //
156 // Calculate the distance from the mouse to the START on the screen
157 // Dummy routine
158 //
159 return 9999;
160}
161
6ca40650 162//-------------------------------------------------------------------------
163void AliSTART::Init()
164{
165 //
166 // Initialis the START after it has been built
167 Int_t i;
6ca40650 168 //
9e1a0ddb 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 }
6ca40650 180}
181
182//---------------------------------------------------------------------------
88cb7938 183void AliSTART::MakeBranch(Option_t* option)
6ca40650 184{
ef51244a 185 //
186 // Specific START branches
187 //
6ca40650 188 // Create Tree branches for the START.
e73d68f2 189 char branchname[20];
6ca40650 190 sprintf(branchname,"%s",GetName());
191
e73d68f2 192 const char *cH = strstr(option,"H");
193
88cb7938 194 if (cH && fLoader->TreeH())
e73d68f2 195 {
88cb7938 196 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
e73d68f2 197 }
2ab0c725 198
88cb7938 199 AliDetector::MakeBranch(option);
6ca40650 200}
971579f6 201
202//_____________________________________________________________________________
e73d68f2 203void AliSTART::ResetHits()
204{
205 AliDetector::ResetHits();
206
e73d68f2 207}
208
209//_____________________________________________________________________________
210void AliSTART::SetTreeAddress()
211{
e4da63c2 212
88cb7938 213 TTree *treeH;
88cb7938 214 treeH = TreeH();
e73d68f2 215
216 if (treeH)
e73d68f2 217 {
88cb7938 218 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
e73d68f2 219 }
88cb7938 220
221 AliDetector::SetTreeAddress();
222
e73d68f2 223}
224
6fc133d2 225//______________________________________________________________________
226AliLoader* AliSTART::MakeLoader(const char* topfoldername)
227{
e4da63c2 228
229 AliDebug(2,Form(" Creating AliSTARTLoader "));
6fc133d2 230 fLoader = new AliSTARTLoader(GetName(), topfoldername);
231 return fLoader;
232}
233
85a5290f 234//_____________________________________________________________________________
c92eb8ad 235AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 236{
237 return new AliSTARTDigitizer(manager);
238}
e4da63c2 239//____________________________________________________________________________
240void 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}