1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.26 2002/10/22 15:40:19 alibrary
19 Introducing Riostream.h
21 Revision 1.25 2002/10/14 14:57:32 hristov
22 Merging the VirtualMC branch to the main development branch (HEAD)
24 Revision 1.23.8.1 2002/07/24 09:50:10 alibrary
27 Revision 1.24 2002/07/23 11:48:05 alla
30 Revision 1.23 2001/09/19 18:41:45 alla
31 Asimmetric START geometry
33 Revision 1.22 2001/07/27 13:03:12 hristov
34 Default Branch split level set to 99
36 Revision 1.21 2001/06/27 16:06:59 hristov
37 Rotation matrix in BuildGeometry has been changed to rotx999
39 Revision 1.20.2.1 2001/06/27 10:51:15 alla
40 Rotation matrix in BuildGeometry has benn changed to rotx999
42 Revision 1.20 2001/05/16 14:57:21 alibrary
43 New files for folders and Stack
45 Revision 1.19 2001/04/04 12:10:18 alla
46 changes according Coding Convension
48 Revision 1.18 2001/03/12 17:46:43 hristov
49 Changes needed on Sun with CC 5.0
51 Revision 1.17 2001/01/26 19:59:53 hristov
52 Major upgrade of AliRoot code
54 Revision 1.16 2001/01/17 10:56:08 hristov
55 Corrections to destructors
57 Revision 1.15 2001/01/01 13:10:42 hristov
58 Local definition of digits removed
60 Revision 1.14 2000/12/22 16:17:15 hristov
61 Updated START code from Alla
63 Revision 1.13 2000/12/18 11:39:41 alibrary
64 Quick fix to avoid crash in display waiting for new version
66 Revision 1.12 2000/12/04 08:48:19 alibrary
67 Fixing problems in the HEAD
69 Revision 1.11 2000/10/13 13:14:08 hristov
70 Bug fixes and code cleaning
72 Revision 1.10 2000/10/02 21:28:13 fca
73 Removal of useless dependecies via forward declarations
75 Revision 1.9 2000/07/13 16:41:29 fca
76 New START corrected for coding conventions
78 Revision 1.8 2000/03/27 17:24:25 alla
81 Revision 1.6 2000/01/21 15:45:23 fca
84 Revision 1.5 2000/01/19 17:17:15 fca
85 Introducing a list of lists of hits -- more hits allowed for detector now
87 Revision 1.4 1999/11/12 15:04:00 fca
88 Modifications from A.Maevskaya
90 Revision 1.3 1999/09/29 09:24:29 fca
91 Introduction of the Copyright and cvs Log
95 ///////////////////////////////////////////////////////////////////////////////
97 // START (T-Zero) Detector //
98 // This class contains the base procedures for the START //
103 <img src="gif/AliSTARTClass.gif">
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>.
115 ///////////////////////////////////////////////////////////////////////////////
117 #include <Riostream.h>
118 #include <Riostream.h>
124 #include "TGeometry.h"
126 #include "TParticle.h"
129 #include "AliSTART.h"
130 #include "AliSTARTdigit.h"
131 #include "AliSTARThit.h"
132 #include "AliSTARThitPhoton.h"
133 #include "AliSTARTvertex.h"
137 static AliSTARTdigit *digits;
139 //_____________________________________________________________________________
143 // Default constructor for class AliSTART
151 //_____________________________________________________________________________
152 AliSTART::AliSTART(const char *name, const char *title)
153 : AliDetector(name,title)
156 // Standard constructor for START Detector
161 // Initialise Hit array
162 fHits = new TClonesArray("AliSTARThit", 405);
163 gAlice->AddHitList(fHits);
165 fPhotons = new TClonesArray("AliSTARThitPhoton", 10000);
166 gAlice->AddHitList (fPhotons);
171 SetMarkerColor(kRed);
174 //_____________________________________________________________________________
175 AliSTART::~AliSTART() {
186 //_____________________________________________________________________________
187 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
192 TClonesArray &lhits = *fHits;
193 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
196 //_____________________________________________________________________________
197 void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
199 // Add a START hit of photons
201 TClonesArray &lhits = *fPhotons;
202 new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
205 //_____________________________________________________________________________
207 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
210 // Add a START digit to the list. Dummy function.
214 //_____________________________________________________________________________
215 void AliSTART::BuildGeometry()
218 // Build simple ROOT TNode geometry for event display
221 const int kColorSTART = 19;
223 top=gAlice->GetGeometry()->GetNode("alice");
225 // START define the different volumes
226 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
228 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
230 node = new TNode("0ST1","0ST01","S_0ST1",0,0,69.7,"");
231 node->SetLineColor(kColorSTART);
234 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
236 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-350,"rotx999");
237 node->SetLineColor(kColorSTART);
241 //_____________________________________________________________________________
242 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
245 // Calculate the distance from the mouse to the START on the screen
251 //-------------------------------------------------------------------------
252 void AliSTART::Init()
255 // Initialis the START after it has been built
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());
265 // Here the START initialisation code (if any!)
266 for(i=0;i<80;i++) printf("*");
271 //---------------------------------------------------------------------------
272 void AliSTART::MakeBranch(Option_t* option, const char *file)
275 // Specific START branches
277 // Create Tree branches for the START.
278 Int_t buffersize = 4000;
280 sprintf(branchname,"%s",GetName());
282 AliDetector::MakeBranch(option,file);
284 const char *cD = strstr(option,"D");
285 const char *cH = strstr(option,"H");
289 sprintf (branchname, "%shitPhoton", GetName());
290 MakeBranchInTree (gAlice->TreeH(), branchname, &fPhotons, 50000, file);
295 digits = new AliSTARTdigit();
296 MakeBranchInTree(gAlice->TreeD(),
297 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
300 char *cR = strstr(option,"R");
303 MakeBranchInTree(gAlice->TreeR(),
304 branchname, "Int_t", &fZposit, buffersize, 1, file);
309 //_____________________________________________________________________________
310 void AliSTART::ResetHits()
312 AliDetector::ResetHits();
315 if (fPhotons) fPhotons->Clear();
318 //_____________________________________________________________________________
319 void AliSTART::SetTreeAddress()
324 AliDetector::SetTreeAddress();
325 treeH = gAlice->TreeH();
330 branch = treeH->GetBranch ("STARThitPhoton");
331 if (branch) branch->SetAddress (&fPhotons);
336 //_____________________________________________________________________________
338 void AliSTART::Hit2digit(Int_t evnum)
341 // From hits to digits
349 char nameTH[8],nameTD[8];
350 Float_t timediff,timeright,timeleft,timeav;
351 Float_t besttimeright,besttimeleft,meanTime;
352 Int_t channelWidth=10;
355 AliSTARThit *startHit;
357 Int_t buffersize=256;
359 digits= new AliSTARTdigit();
363 // Event ------------------------- LOOP
365 sprintf(nameTD,"TreeD%d",evnum);
366 TTree *td = new TTree(nameTD,"START");
367 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
374 Int_t nparticles = gAlice->GetEvent(evnum);
375 if (nparticles <= 0) return;
376 printf("\n nparticles %d\n",nparticles);
379 sprintf(nameTH,"TreeH%d",evnum);
380 printf("%s\n",nameTH);
381 TTree *th = gAlice->TreeH();
382 Int_t ntracks = (Int_t) th->GetEntries();
383 if (ntracks<=0) return;
384 // Start loop on tracks in the hits containers
385 for (Int_t track=0; track<ntracks;track++) {
387 nbytes += th->GetEvent(track);
388 particle=gAlice->Particle(track);
389 nhits =fHits->GetEntriesFast();
391 for (hit=0;hit<nhits;hit++) {
392 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
397 volume = startHit->fVolume;
399 timeright = startHit->fTime;
400 if(timeright<besttimeright) {
401 besttimeright=timeright;
403 }//time for right shoulder
405 timeleft = startHit->fTime;
406 // printf("timeleft %f\n",timeleft);
407 if(timeleft<besttimeleft) {
408 besttimeleft=timeleft;
410 }//time for left shoulder
414 //folding with experimental time distribution
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.)
421 //we assume centre of bunch is 5ns after TTS signal
422 //TOF values are relative of the end of bunch
425 ppBunch=ppBunch-10/2;
426 Float_t t1=1000.*besttimeleftGaus;
427 Float_t t2=1000.*besttimerightGaus;
428 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
429 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
433 // Time to TDC signal
434 // 256 channels for timediff, range 1ns
436 timediff=128+1000*timediff/channelWidth; // time in ps
438 timeAv = (Int_t)(timeav); // time (ps) channel numbres
439 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
440 digits->Set(timeAv,timeDiff);
443 {timeAv=999999; timeDiff=99999;}
446 printf("digits-> %d \n",digits->GetTime());