]> git.uio.no Git - u/mrichter/AliRoot.git/blame - START/AliSTART.cxx
Additional protection: to be discussed with the Root team (M.Ivanov)
[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
16/*
17$Log$
4c475d27 18Revision 1.26 2002/10/22 15:40:19 alibrary
19Introducing Riostream.h
20
ef0750c2 21Revision 1.25 2002/10/14 14:57:32 hristov
22Merging the VirtualMC branch to the main development branch (HEAD)
23
b9d0a01d 24Revision 1.23.8.1 2002/07/24 09:50:10 alibrary
25Updating VirtualMC
26
27Revision 1.24 2002/07/23 11:48:05 alla
28new Digits structure
29
e73d68f2 30Revision 1.23 2001/09/19 18:41:45 alla
31Asimmetric START geometry
32
a94466c5 33Revision 1.22 2001/07/27 13:03:12 hristov
34Default Branch split level set to 99
35
d0f40f23 36Revision 1.21 2001/06/27 16:06:59 hristov
37Rotation matrix in BuildGeometry has been changed to rotx999
38
44b06417 39Revision 1.20.2.1 2001/06/27 10:51:15 alla
40Rotation matrix in BuildGeometry has benn changed to rotx999
41
42Revision 1.20 2001/05/16 14:57:21 alibrary
43New files for folders and Stack
44
9e1a0ddb 45Revision 1.19 2001/04/04 12:10:18 alla
46changes according Coding Convension
47
2ca99a7f 48Revision 1.18 2001/03/12 17:46:43 hristov
49Changes needed on Sun with CC 5.0
50
5cf7bbad 51Revision 1.17 2001/01/26 19:59:53 hristov
52Major upgrade of AliRoot code
53
2ab0c725 54Revision 1.16 2001/01/17 10:56:08 hristov
55Corrections to destructors
56
bff160c8 57Revision 1.15 2001/01/01 13:10:42 hristov
58Local definition of digits removed
59
9d0cd3ab 60Revision 1.14 2000/12/22 16:17:15 hristov
61Updated START code from Alla
62
f3ed336b 63Revision 1.13 2000/12/18 11:39:41 alibrary
64Quick fix to avoid crash in display waiting for new version
65
b169435d 66Revision 1.12 2000/12/04 08:48:19 alibrary
67Fixing problems in the HEAD
68
0cc62300 69Revision 1.11 2000/10/13 13:14:08 hristov
70Bug fixes and code cleaning
71
528332ba 72Revision 1.10 2000/10/02 21:28:13 fca
73Removal of useless dependecies via forward declarations
74
94de3818 75Revision 1.9 2000/07/13 16:41:29 fca
76New START corrected for coding conventions
77
ef51244a 78Revision 1.8 2000/03/27 17:24:25 alla
79Modifing geometry
80
c345bb4f 81Revision 1.6 2000/01/21 15:45:23 fca
82New Version from Alla
83
971579f6 84Revision 1.5 2000/01/19 17:17:15 fca
85Introducing a list of lists of hits -- more hits allowed for detector now
86
1cedd08a 87Revision 1.4 1999/11/12 15:04:00 fca
88Modifications from A.Maevskaya
89
82fc3fb3 90Revision 1.3 1999/09/29 09:24:29 fca
91Introduction of the Copyright and cvs Log
92
4c039060 93*/
94
6ca40650 95///////////////////////////////////////////////////////////////////////////////
96// //
97// START (T-Zero) Detector //
98// This class contains the base procedures for the START //
99// detector //
100// //
101//Begin_Html
102/*
103<img src="gif/AliSTARTClass.gif">
104</pre>
105<br clear=left>
106<font size=+2 color=red>
107<p>The responsible person for this module is
108<a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
109</font>
110<pre>
111*/
112//End_Html
113// //
114// //
115///////////////////////////////////////////////////////////////////////////////
116
ef0750c2 117#include <Riostream.h>
118#include <Riostream.h>
971579f6 119
120#include "TMath.h"
121#include "TTUBE.h"
122#include "TNode.h"
c345bb4f 123#include "TRandom.h"
971579f6 124#include "TGeometry.h"
2ab0c725 125#include "TFile.h"
0cc62300 126#include "TParticle.h"
2ab0c725 127
971579f6 128#include "AliRun.h"
129#include "AliSTART.h"
130#include "AliSTARTdigit.h"
971579f6 131#include "AliSTARThit.h"
e73d68f2 132#include "AliSTARThitPhoton.h"
c345bb4f 133#include "AliSTARTvertex.h"
971579f6 134
6ca40650 135ClassImp(AliSTART)
ef51244a 136
137static AliSTARTdigit *digits;
138
6ca40650 139//_____________________________________________________________________________
99560b47 140AliSTART::AliSTART()
6ca40650 141{
142 //
143 // Default constructor for class AliSTART
144 //
f3ed336b 145 fIshunt = 1;
971579f6 146 fHits = 0;
147 fDigits = 0;
e73d68f2 148 fPhotons = 0;
6ca40650 149}
150
151//_____________________________________________________________________________
152AliSTART::AliSTART(const char *name, const char *title)
153 : AliDetector(name,title)
154{
155 //
156 // Standard constructor for START Detector
157 //
971579f6 158
c345bb4f 159
6ca40650 160 //
161 // Initialise Hit array
971579f6 162 fHits = new TClonesArray("AliSTARThit", 405);
b169435d 163 gAlice->AddHitList(fHits);
e73d68f2 164
165 fPhotons = new TClonesArray("AliSTARThitPhoton", 10000);
166 gAlice->AddHitList (fPhotons);
6ca40650 167
f3ed336b 168 fIshunt = 1;
c345bb4f 169 fIdSens = 0;
e73d68f2 170 fNPhotons = 0;
6ca40650 171 SetMarkerColor(kRed);
172}
bff160c8 173
174//_____________________________________________________________________________
175AliSTART::~AliSTART() {
176 if (fHits) {
177 fHits->Delete();
178 delete fHits;
179 }
e73d68f2 180 if (fPhotons) {
181 fPhotons->Delete();
182 delete fPhotons;
183 }
bff160c8 184}
6ca40650 185
186//_____________________________________________________________________________
187void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
188{
189 //
190 // Add a START hit
191 //
192 TClonesArray &lhits = *fHits;
193 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
194}
971579f6 195
e73d68f2 196//_____________________________________________________________________________
197void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
198{
199 // Add a START hit of photons
200
201 TClonesArray &lhits = *fPhotons;
202 new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
203}
204
971579f6 205//_____________________________________________________________________________
c345bb4f 206
971579f6 207void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
208{
c345bb4f 209
f3ed336b 210 // Add a START digit to the list. Dummy function.
c345bb4f 211
971579f6 212}
c345bb4f 213
6ca40650 214//_____________________________________________________________________________
215void AliSTART::BuildGeometry()
216{
217 //
218 // Build simple ROOT TNode geometry for event display
219 //
ef51244a 220 TNode *node, *top;
6ca40650 221 const int kColorSTART = 19;
f3ed336b 222
ef51244a 223 top=gAlice->GetGeometry()->GetNode("alice");
6ca40650 224
225 // START define the different volumes
44b06417 226 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
6ca40650 227
2ca99a7f 228 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
ef51244a 229 top->cd();
a94466c5 230 node = new TNode("0ST1","0ST01","S_0ST1",0,0,69.7,"");
ef51244a 231 node->SetLineColor(kColorSTART);
232 fNodes->Add(node);
6ca40650 233
2ca99a7f 234 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
ef51244a 235 top->cd();
a94466c5 236 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-350,"rotx999");
ef51244a 237 node->SetLineColor(kColorSTART);
238 fNodes->Add(node);
6ca40650 239}
240
241//_____________________________________________________________________________
242Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
243{
244 //
245 // Calculate the distance from the mouse to the START on the screen
246 // Dummy routine
247 //
248 return 9999;
249}
250
6ca40650 251//-------------------------------------------------------------------------
252void AliSTART::Init()
253{
254 //
255 // Initialis the START after it has been built
256 Int_t i;
6ca40650 257 //
9e1a0ddb 258 if(fDebug) {
259 printf("\n%s: ",ClassName());
260 for(i=0;i<35;i++) printf("*");
261 printf(" START_INIT ");
262 for(i=0;i<35;i++) printf("*");
263 printf("\n%s: ",ClassName());
264 //
265 // Here the START initialisation code (if any!)
266 for(i=0;i<80;i++) printf("*");
267 printf("\n");
268 }
6ca40650 269}
270
271//---------------------------------------------------------------------------
9e1a0ddb 272void AliSTART::MakeBranch(Option_t* option, const char *file)
6ca40650 273{
ef51244a 274 //
275 // Specific START branches
276 //
6ca40650 277 // Create Tree branches for the START.
e73d68f2 278 Int_t buffersize = 4000;
279 char branchname[20];
6ca40650 280 sprintf(branchname,"%s",GetName());
281
2ab0c725 282 AliDetector::MakeBranch(option,file);
6ca40650 283
5cf7bbad 284 const char *cD = strstr(option,"D");
e73d68f2 285 const char *cH = strstr(option,"H");
286
287 if (cH)
288 {
289 sprintf (branchname, "%shitPhoton", GetName());
290 MakeBranchInTree (gAlice->TreeH(), branchname, &fPhotons, 50000, file);
291 }
292
2ab0c725 293
294 if (cD) {
295 digits = new AliSTARTdigit();
9e1a0ddb 296 MakeBranchInTree(gAlice->TreeD(),
297 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
2ab0c725 298 }
c345bb4f 299/*
2ab0c725 300 char *cR = strstr(option,"R");
301
302 if (cR) {
9e1a0ddb 303 MakeBranchInTree(gAlice->TreeR(),
304 branchname, "Int_t", &fZposit, buffersize, 1, file);
2ab0c725 305 }
c345bb4f 306 */
6ca40650 307}
971579f6 308
e73d68f2 309//_____________________________________________________________________________
310void AliSTART::ResetHits()
311{
312 AliDetector::ResetHits();
313
314 fNPhotons = 0;
315 if (fPhotons) fPhotons->Clear();
316}
317
318//_____________________________________________________________________________
319void AliSTART::SetTreeAddress()
320{
321 TBranch *branch;
322 TTree *treeH;
323
324 AliDetector::SetTreeAddress();
325 treeH = gAlice->TreeH();
326
327 if (treeH)
328 if (fPhotons)
329 {
330 branch = treeH->GetBranch ("STARThitPhoton");
331 if (branch) branch->SetAddress (&fPhotons);
332 }
333}
334
335
971579f6 336//_____________________________________________________________________________
c345bb4f 337
971579f6 338void AliSTART::Hit2digit(Int_t evnum)
339{
ef51244a 340 //
341 // From hits to digits
342 //
e73d68f2 343 /*
ef51244a 344 Float_t x,y,e;
971579f6 345 Int_t nbytes = 0;
ef51244a 346 Int_t hit;
971579f6 347 Int_t nhits;
348 Int_t volume,pmt;
c345bb4f 349 char nameTH[8],nameTD[8];
350 Float_t timediff,timeright,timeleft,timeav;
351 Float_t besttimeright,besttimeleft,meanTime;
ef51244a 352 Int_t channelWidth=10;
971579f6 353
354 TParticle *particle;
971579f6 355 AliSTARThit *startHit;
356
c345bb4f 357 Int_t buffersize=256;
c345bb4f 358
359 digits= new AliSTARTdigit();
360 TBranch *bDig=0;
971579f6 361
c345bb4f 362
363 // Event ------------------------- LOOP
364
365 sprintf(nameTD,"TreeD%d",evnum);
ef51244a 366 TTree *td = new TTree(nameTD,"START");
d0f40f23 367 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
971579f6 368
369 besttimeright=9999.;
370 besttimeleft=9999.;
ef51244a 371 Int_t timeDiff=0;
372 Int_t timeAv=0;
971579f6 373
374 Int_t nparticles = gAlice->GetEvent(evnum);
375 if (nparticles <= 0) return;
376 printf("\n nparticles %d\n",nparticles);
377
c345bb4f 378
971579f6 379 sprintf(nameTH,"TreeH%d",evnum);
380 printf("%s\n",nameTH);
ef51244a 381 TTree *th = gAlice->TreeH();
382 Int_t ntracks = (Int_t) th->GetEntries();
971579f6 383 if (ntracks<=0) return;
384 // Start loop on tracks in the hits containers
385 for (Int_t track=0; track<ntracks;track++) {
386 gAlice->ResetHits();
ef51244a 387 nbytes += th->GetEvent(track);
2ab0c725 388 particle=gAlice->Particle(track);
c345bb4f 389 nhits =fHits->GetEntriesFast();
390
971579f6 391 for (hit=0;hit<nhits;hit++) {
392 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
393 pmt=startHit->fPmt;
394 e=startHit->fEtot;
94de3818 395 x=startHit->X();
396 y=startHit->Y();
971579f6 397 volume = startHit->fVolume;
398 if(volume==1){
399 timeright = startHit->fTime;
400 if(timeright<besttimeright) {
401 besttimeright=timeright;
971579f6 402 } //timeright
403 }//time for right shoulder
404 if(volume==2){
405 timeleft = startHit->fTime;
406 // printf("timeleft %f\n",timeleft);
407 if(timeleft<besttimeleft) {
408 besttimeleft=timeleft;
971579f6 409 } //timeleftbest
410 }//time for left shoulder
411 } //hit loop
412 } //track loop
971579f6 413
c345bb4f 414 //folding with experimental time distribution
ef51244a 415 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
416 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
417 timediff=besttimerightGaus-besttimeleftGaus;
418 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
419 if ( TMath::Abs(timediff)<2. && meanTime<3.)
c345bb4f 420 {
ef51244a 421 //we assume centre of bunch is 5ns after TTS signal
422 //TOF values are relative of the end of bunch
423 Float_t ppBunch=25;
971579f6 424
ef51244a 425 ppBunch=ppBunch-10/2;
c345bb4f 426 Float_t t1=1000.*besttimeleftGaus;
427 Float_t t2=1000.*besttimerightGaus;
ef51244a 428 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
429 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
c345bb4f 430
431 timeav=(t1+t2)/2.;
432
433 // Time to TDC signal
434 // 256 channels for timediff, range 1ns
435
ef51244a 436 timediff=128+1000*timediff/channelWidth; // time in ps
437
438 timeAv = (Int_t)(timeav); // time (ps) channel numbres
439 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
440 digits->Set(timeAv,timeDiff);
441 }
f3ed336b 442 else
443 {timeAv=999999; timeDiff=99999;}
444
445 td->Fill();
446 printf("digits-> %d \n",digits->GetTime());
447 td->Write();
e73d68f2 448 */
f3ed336b 449}
c345bb4f 450
451
452
453
454
455
456
457
458
6ca40650 459
971579f6 460
ef51244a 461
971579f6 462
c345bb4f 463