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