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.25 2002/10/14 14:57:32 hristov
19 Merging the VirtualMC branch to the main development branch (HEAD)
21 Revision 1.23.8.1 2002/07/24 09:50:10 alibrary
24 Revision 1.24 2002/07/23 11:48:05 alla
27 Revision 1.23 2001/09/19 18:41:45 alla
28 Asimmetric START geometry
30 Revision 1.22 2001/07/27 13:03:12 hristov
31 Default Branch split level set to 99
33 Revision 1.21 2001/06/27 16:06:59 hristov
34 Rotation matrix in BuildGeometry has been changed to rotx999
36 Revision 1.20.2.1 2001/06/27 10:51:15 alla
37 Rotation matrix in BuildGeometry has benn changed to rotx999
39 Revision 1.20 2001/05/16 14:57:21 alibrary
40 New files for folders and Stack
42 Revision 1.19 2001/04/04 12:10:18 alla
43 changes according Coding Convension
45 Revision 1.18 2001/03/12 17:46:43 hristov
46 Changes needed on Sun with CC 5.0
48 Revision 1.17 2001/01/26 19:59:53 hristov
49 Major upgrade of AliRoot code
51 Revision 1.16 2001/01/17 10:56:08 hristov
52 Corrections to destructors
54 Revision 1.15 2001/01/01 13:10:42 hristov
55 Local definition of digits removed
57 Revision 1.14 2000/12/22 16:17:15 hristov
58 Updated START code from Alla
60 Revision 1.13 2000/12/18 11:39:41 alibrary
61 Quick fix to avoid crash in display waiting for new version
63 Revision 1.12 2000/12/04 08:48:19 alibrary
64 Fixing problems in the HEAD
66 Revision 1.11 2000/10/13 13:14:08 hristov
67 Bug fixes and code cleaning
69 Revision 1.10 2000/10/02 21:28:13 fca
70 Removal of useless dependecies via forward declarations
72 Revision 1.9 2000/07/13 16:41:29 fca
73 New START corrected for coding conventions
75 Revision 1.8 2000/03/27 17:24:25 alla
78 Revision 1.6 2000/01/21 15:45:23 fca
81 Revision 1.5 2000/01/19 17:17:15 fca
82 Introducing a list of lists of hits -- more hits allowed for detector now
84 Revision 1.4 1999/11/12 15:04:00 fca
85 Modifications from A.Maevskaya
87 Revision 1.3 1999/09/29 09:24:29 fca
88 Introduction of the Copyright and cvs Log
92 ///////////////////////////////////////////////////////////////////////////////
94 // START (T-Zero) Detector //
95 // This class contains the base procedures for the START //
100 <img src="gif/AliSTARTClass.gif">
103 <font size=+2 color=red>
104 <p>The responsible person for this module is
105 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
112 ///////////////////////////////////////////////////////////////////////////////
114 #include <Riostream.h>
115 #include <Riostream.h>
121 #include "TGeometry.h"
123 #include "TParticle.h"
126 #include "AliSTART.h"
127 #include "AliSTARTdigit.h"
129 #include "AliSTARThit.h"
130 #include "AliSTARThitPhoton.h"
131 #include "AliSTARTvertex.h"
135 static AliSTARTdigit *digits;
137 //_____________________________________________________________________________
141 // Default constructor for class AliSTART
149 //_____________________________________________________________________________
150 AliSTART::AliSTART(const char *name, const char *title)
151 : AliDetector(name,title)
154 // Standard constructor for START Detector
159 // Initialise Hit array
160 fHits = new TClonesArray("AliSTARThit", 405);
161 gAlice->AddHitList(fHits);
163 fPhotons = new TClonesArray("AliSTARThitPhoton", 10000);
164 gAlice->AddHitList (fPhotons);
169 SetMarkerColor(kRed);
172 //_____________________________________________________________________________
173 AliSTART::~AliSTART() {
184 //_____________________________________________________________________________
185 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
190 TClonesArray &lhits = *fHits;
191 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
194 //_____________________________________________________________________________
195 void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
197 // Add a START hit of photons
199 TClonesArray &lhits = *fPhotons;
200 new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
203 //_____________________________________________________________________________
205 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
208 // Add a START digit to the list. Dummy function.
212 //_____________________________________________________________________________
213 void AliSTART::BuildGeometry()
216 // Build simple ROOT TNode geometry for event display
219 const int kColorSTART = 19;
221 top=gAlice->GetGeometry()->GetNode("alice");
223 // START define the different volumes
224 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
226 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
228 node = new TNode("0ST1","0ST01","S_0ST1",0,0,69.7,"");
229 node->SetLineColor(kColorSTART);
232 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
234 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-350,"rotx999");
235 node->SetLineColor(kColorSTART);
239 //_____________________________________________________________________________
240 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
243 // Calculate the distance from the mouse to the START on the screen
249 //-------------------------------------------------------------------------
250 void AliSTART::Init()
253 // Initialis the START after it has been built
257 printf("\n%s: ",ClassName());
258 for(i=0;i<35;i++) printf("*");
259 printf(" START_INIT ");
260 for(i=0;i<35;i++) printf("*");
261 printf("\n%s: ",ClassName());
263 // Here the START initialisation code (if any!)
264 for(i=0;i<80;i++) printf("*");
269 //---------------------------------------------------------------------------
270 void AliSTART::MakeBranch(Option_t* option, const char *file)
273 // Specific START branches
275 // Create Tree branches for the START.
276 Int_t buffersize = 4000;
278 sprintf(branchname,"%s",GetName());
280 AliDetector::MakeBranch(option,file);
282 const char *cD = strstr(option,"D");
283 const char *cH = strstr(option,"H");
287 sprintf (branchname, "%shitPhoton", GetName());
288 MakeBranchInTree (gAlice->TreeH(), branchname, &fPhotons, 50000, file);
293 digits = new AliSTARTdigit();
294 MakeBranchInTree(gAlice->TreeD(),
295 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
298 char *cR = strstr(option,"R");
301 MakeBranchInTree(gAlice->TreeR(),
302 branchname, "Int_t", &fZposit, buffersize, 1, file);
307 //_____________________________________________________________________________
308 void AliSTART::ResetHits()
310 AliDetector::ResetHits();
313 if (fPhotons) fPhotons->Clear();
316 //_____________________________________________________________________________
317 void AliSTART::SetTreeAddress()
322 AliDetector::SetTreeAddress();
323 treeH = gAlice->TreeH();
328 branch = treeH->GetBranch ("STARThitPhoton");
329 if (branch) branch->SetAddress (&fPhotons);
334 //_____________________________________________________________________________
336 void AliSTART::Hit2digit(Int_t evnum)
339 // From hits to digits
347 char nameTH[8],nameTD[8];
348 Float_t timediff,timeright,timeleft,timeav;
349 Float_t besttimeright,besttimeleft,meanTime;
350 Int_t channelWidth=10;
353 AliSTARThit *startHit;
355 Int_t buffersize=256;
357 digits= new AliSTARTdigit();
361 // Event ------------------------- LOOP
363 sprintf(nameTD,"TreeD%d",evnum);
364 TTree *td = new TTree(nameTD,"START");
365 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
372 Int_t nparticles = gAlice->GetEvent(evnum);
373 if (nparticles <= 0) return;
374 printf("\n nparticles %d\n",nparticles);
377 sprintf(nameTH,"TreeH%d",evnum);
378 printf("%s\n",nameTH);
379 TTree *th = gAlice->TreeH();
380 Int_t ntracks = (Int_t) th->GetEntries();
381 if (ntracks<=0) return;
382 // Start loop on tracks in the hits containers
383 for (Int_t track=0; track<ntracks;track++) {
385 nbytes += th->GetEvent(track);
386 particle=gAlice->Particle(track);
387 nhits =fHits->GetEntriesFast();
389 for (hit=0;hit<nhits;hit++) {
390 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
395 volume = startHit->fVolume;
397 timeright = startHit->fTime;
398 if(timeright<besttimeright) {
399 besttimeright=timeright;
401 }//time for right shoulder
403 timeleft = startHit->fTime;
404 // printf("timeleft %f\n",timeleft);
405 if(timeleft<besttimeleft) {
406 besttimeleft=timeleft;
408 }//time for left shoulder
412 //folding with experimental time distribution
413 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
414 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
415 timediff=besttimerightGaus-besttimeleftGaus;
416 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
417 if ( TMath::Abs(timediff)<2. && meanTime<3.)
419 //we assume centre of bunch is 5ns after TTS signal
420 //TOF values are relative of the end of bunch
423 ppBunch=ppBunch-10/2;
424 Float_t t1=1000.*besttimeleftGaus;
425 Float_t t2=1000.*besttimerightGaus;
426 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
427 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
431 // Time to TDC signal
432 // 256 channels for timediff, range 1ns
434 timediff=128+1000*timediff/channelWidth; // time in ps
436 timeAv = (Int_t)(timeav); // time (ps) channel numbres
437 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
438 digits->Set(timeAv,timeDiff);
441 {timeAv=999999; timeDiff=99999;}
444 printf("digits-> %d \n",digits->GetTime());