]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - START/AliSTART.cxx
Added contructor from TPartice.
[u/mrichter/AliRoot.git] / START / AliSTART.cxx
... / ...
CommitLineData
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#include "TClonesArray.h"
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#include "AliSTARTRecPoint.h"
64#include "AliLog.h"
65
66ClassImp(AliSTART)
67
68 //static AliSTARTdigit *digits;
69
70//_____________________________________________________________________________
71AliSTART::AliSTART()
72 : AliDetector(), fIdSens(0), fDigits(NULL), fRecPoints(NULL)
73{
74 //
75 // Default constructor for class AliSTART
76 //
77 fIshunt = 1;
78 fHits = 0;
79 fDigits = 0;
80 fRecPoints = 0;
81}
82
83//_____________________________________________________________________________
84AliSTART::AliSTART(const char *name, const char *title)
85 : AliDetector(name,title), fIdSens(0), fDigits(new AliSTARTdigit()), fRecPoints(new AliSTARTRecPoint())
86{
87 //
88 // Standard constructor for START Detector
89 //
90
91
92 //
93 // Initialise Hit array
94 fHits = new TClonesArray("AliSTARThit", 405);
95 gAlice->GetMCApp()->AddHitList(fHits);
96 // fDigits = new AliSTARTdigit();
97 // fRecPoints = new AliSTARTRecPoint();
98 fIshunt = 1;
99 // fIdSens = 0;
100 SetMarkerColor(kRed);
101}
102
103//_____________________________________________________________________________
104AliSTART::~AliSTART() {
105
106 if (fHits) {
107 fHits->Delete();
108 delete fHits;
109 }
110 /*
111 if (fDigits) {
112 fDigits->Delete();
113 delete fDigits;
114 cout<<" delete fDigits; "<<endl;
115 }
116 if (fRecPoints) {
117 fRecPoints ->Delete();
118 delete fRecPoints;
119 cout<<" delete fRecPoints; "<<endl;
120 }
121 */
122}
123
124//______________________________________________________________________________
125AliSTART::AliSTART(const AliSTART &source):
126 AliDetector(source)
127{
128 // Copy constructor
129 // not implemented
130 AliWarning("Copy constructor not implemented!");
131}
132
133//______________________________________________________________________________
134AliSTART& AliSTART::operator= (const AliSTART& source)
135{
136 // Asignment operator
137 // not implemented
138 if(this==&source) return *this;
139
140 AliWarning("Asignment operator not implemented!");
141
142 ((TObject *)this)->operator=(source);
143
144 return *this;
145}
146
147//_____________________________________________________________________________
148void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
149{
150 //
151 // Add a START hit
152 //
153 TClonesArray &lhits = *fHits;
154 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
155}
156
157
158//_____________________________________________________________________________
159
160void AliSTART::AddDigit(Int_t besttimeright, Int_t besttimeleft, Int_t meantime,
161 Int_t timediff, Int_t sumMult,
162 TArrayI *time, TArrayI *adc, TArrayI *timeAmp, TArrayI *adcAmp)
163{
164
165 // Add a START digit to the list.
166 //
167
168 if (!fDigits) {
169 fDigits = new AliSTARTdigit();
170 }
171 fDigits-> SetTimeBestRight(besttimeright);
172 fDigits->SetTimeBestLeft(besttimeleft);
173 fDigits-> SetMeanTime(meantime);
174 fDigits-> SetDiffTime(timediff);
175 fDigits-> SetSumMult(sumMult);
176 fDigits->SetTime(*time);
177 fDigits->SetTimeAmp(*timeAmp);
178 fDigits->SetADC(*adc);
179 fDigits->SetADCAmp(*adcAmp);
180}
181
182
183//_____________________________________________________________________________
184void AliSTART::BuildGeometry()
185{
186 //
187 // Build simple ROOT TNode geometry for event display
188 //
189 TNode *node, *top;
190 const int kColorSTART = 19;
191
192 top=gAlice->GetGeometry()->GetNode("alice");
193
194 // START define the different volumes
195 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
196
197 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
198 top->cd();
199 node = new TNode("0ST1","0ST01","S_0ST1",0,0,-69.7,"");
200 node->SetLineColor(kColorSTART);
201 fNodes->Add(node);
202
203 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
204 top->cd();
205 node = new TNode("0ST2","0ST2","S_0ST2",0,0,350,"rotx999");
206 node->SetLineColor(kColorSTART);
207 fNodes->Add(node);
208}
209
210//_____________________________________________________________________________
211Int_t AliSTART::DistanceToPrimitive(Int_t /*px*/, Int_t /*py*/)
212{
213 //
214 // Calculate the distance from the mouse to the START on the screen
215 // Dummy routine
216 //
217 return 9999;
218}
219
220//-------------------------------------------------------------------------
221void AliSTART::Init()
222{
223 //
224 // Initialis the START after it has been built
225 Int_t i;
226 //
227 if(AliLog::GetGlobalDebugLevel()>0) {
228 printf("\n%s: ",ClassName());
229 for(i=0;i<35;i++) printf("*");
230 printf(" START_INIT ");
231 for(i=0;i<35;i++) printf("*");
232 printf("\n%s: ",ClassName());
233 //
234 // Here the START initialisation code (if any!)
235 for(i=0;i<80;i++) printf("*");
236 printf("\n");
237 }
238}
239
240//---------------------------------------------------------------------------
241void AliSTART::MakeBranch(Option_t* option)
242{
243 //
244// Create Tree branches for the START.
245
246 // Options:
247 //
248 // H Make a branch of TClonesArray of AliSTARTHit's
249 // D Make a branch of TClonesArray of AliSTARTDigit's
250 //
251 // R Make a branch of AliSTARTRecPoints
252 //
253 char branchname[20];
254 sprintf(branchname,"%s",GetName());
255
256 const char *cH = strstr(option,"H");
257 const char *cD = strstr(option,"D");
258 const char *cR = strstr(option,"R");
259
260 if (cH && fLoader->TreeH())
261 {
262 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
263 AliDetector::MakeBranch(option);
264 }
265
266
267 if (cD && fLoader->TreeD())
268 {
269 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
270 // MakeBranchInTree(fLoader->TreeD(), branchname,
271 // &fDigits, 405, 0);
272 fLoader->TreeD()->Branch(branchname,"AliSTARTdigit",&fDigits,405,1);
273 // fLoader->TreeD()->Print();
274 }
275 if (cR && fLoader->TreeR())
276 {
277 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint();
278 MakeBranchInTree(fLoader->TreeR(), branchname,
279 &fRecPoints, 405, 0);
280 }
281
282}
283
284//_____________________________________________________________________________
285void AliSTART::ResetHits()
286{
287 AliDetector::ResetHits();
288
289}
290//____________________________________________________________________
291void AliSTART::ResetDigits()
292{
293 //
294 // Reset number of digits and the digits array for this detector
295 //
296 if (fDigits) fDigits->Clear();
297}
298
299//_____________________________________________________________________________
300void AliSTART::SetTreeAddress()
301{
302
303 TTree *treeH;
304 treeH = TreeH();
305
306 if (treeH)
307 {
308 if (fHits == 0x0) fHits = new TClonesArray("AliSTARThit", 405);
309 }
310
311 AliDetector::SetTreeAddress();
312 TTree *treeD = fLoader->TreeD();
313 if (treeD) {
314 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
315 TBranch* branch = treeD->GetBranch ("START");
316 if (branch) branch->SetAddress(&fDigits);
317 }
318
319 TTree *treeR = fLoader->TreeR();
320 if (treeR) {
321 if (fRecPoints == 0x0) fRecPoints = new AliSTARTRecPoint() ;
322 TBranch* branch = treeR->GetBranch ("START");
323 if (branch) branch->SetAddress(&fRecPoints);
324 }
325
326}
327
328
329//_____________________________________________________________________________
330void AliSTART::MakeBranchInTreeD(TTree *treeD, const char *file)
331{
332 //
333 // Create TreeD branches for the FMD
334 //
335 const Int_t kBufferSize = 4000;
336 char branchname[20];
337 sprintf(branchname,"%s",GetName());
338 if(treeD)
339 {
340 MakeBranchInTree(treeD, branchname,&fDigits, kBufferSize, file);
341 }
342}
343
344//_____________________________________________________________________________
345AliDigitizer* AliSTART::CreateDigitizer(AliRunDigitizer* manager) const
346{
347 return new AliSTARTDigitizer(manager);
348}
349//____________________________________________________________________________
350void AliSTART::Digits2Raw()
351{
352//
353// Starting from the START digits, writes the Raw Data objects
354//
355// AliSTARTLoader* pStartLoader = (AliSTARTLoader*)fLoader;
356 fLoader ->LoadDigits("read");
357 TTree* treeD = fLoader->TreeD();
358 if (!treeD) {
359 AliError("no digits tree");
360 return;
361 }
362 if (fDigits == 0x0) fDigits = new AliSTARTdigit();
363
364 TBranch *branch = treeD->GetBranch("START");
365 if (branch) {
366 branch->SetAddress(&fDigits);
367 }else{
368 AliError("Branch START DIGIT not found");
369 exit(111);
370 }
371 AliSTARTRawData rawWriter;
372 rawWriter.SetVerbose(0);
373
374 AliDebug(2,Form(" Formatting raw data for START "));
375 branch->GetEntry(0);
376 // rawWriter.RawDataSTART(treeD->GetBranch("START"));
377 rawWriter.RawDataSTART(fDigits);
378
379
380 fLoader->UnloadDigits();
381
382}