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.21 2001/06/27 16:06:59 hristov
19 Rotation matrix in BuildGeometry has been changed to rotx999
21 Revision 1.20.2.1 2001/06/27 10:51:15 alla
22 Rotation matrix in BuildGeometry has benn changed to rotx999
24 Revision 1.20 2001/05/16 14:57:21 alibrary
25 New files for folders and Stack
27 Revision 1.19 2001/04/04 12:10:18 alla
28 changes according Coding Convension
30 Revision 1.18 2001/03/12 17:46:43 hristov
31 Changes needed on Sun with CC 5.0
33 Revision 1.17 2001/01/26 19:59:53 hristov
34 Major upgrade of AliRoot code
36 Revision 1.16 2001/01/17 10:56:08 hristov
37 Corrections to destructors
39 Revision 1.15 2001/01/01 13:10:42 hristov
40 Local definition of digits removed
42 Revision 1.14 2000/12/22 16:17:15 hristov
43 Updated START code from Alla
45 Revision 1.13 2000/12/18 11:39:41 alibrary
46 Quick fix to avoid crash in display waiting for new version
48 Revision 1.12 2000/12/04 08:48:19 alibrary
49 Fixing problems in the HEAD
51 Revision 1.11 2000/10/13 13:14:08 hristov
52 Bug fixes and code cleaning
54 Revision 1.10 2000/10/02 21:28:13 fca
55 Removal of useless dependecies via forward declarations
57 Revision 1.9 2000/07/13 16:41:29 fca
58 New START corrected for coding conventions
60 Revision 1.8 2000/03/27 17:24:25 alla
63 Revision 1.6 2000/01/21 15:45:23 fca
66 Revision 1.5 2000/01/19 17:17:15 fca
67 Introducing a list of lists of hits -- more hits allowed for detector now
69 Revision 1.4 1999/11/12 15:04:00 fca
70 Modifications from A.Maevskaya
72 Revision 1.3 1999/09/29 09:24:29 fca
73 Introduction of the Copyright and cvs Log
77 ///////////////////////////////////////////////////////////////////////////////
79 // START (T-Zero) Detector //
80 // This class contains the base procedures for the START //
85 <img src="gif/AliSTARTClass.gif">
88 <font size=+2 color=red>
89 <p>The responsible person for this module is
90 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
97 ///////////////////////////////////////////////////////////////////////////////
106 #include "TGeometry.h"
108 #include "TParticle.h"
111 #include "AliSTART.h"
112 #include "AliSTARTdigit.h"
114 #include "AliSTARThit.h"
115 #include "AliSTARTvertex.h"
119 static AliSTARTdigit *digits;
121 //_____________________________________________________________________________
125 // Default constructor for class AliSTART
132 //_____________________________________________________________________________
133 AliSTART::AliSTART(const char *name, const char *title)
134 : AliDetector(name,title)
137 // Standard constructor for START Detector
142 // Initialise Hit array
143 fHits = new TClonesArray("AliSTARThit", 405);
144 gAlice->AddHitList(fHits);
148 SetMarkerColor(kRed);
151 //_____________________________________________________________________________
152 AliSTART::~AliSTART() {
159 //_____________________________________________________________________________
160 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
165 TClonesArray &lhits = *fHits;
166 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
169 //_____________________________________________________________________________
171 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
174 // Add a START digit to the list. Dummy function.
178 //_____________________________________________________________________________
179 void AliSTART::BuildGeometry()
182 // Build simple ROOT TNode geometry for event display
185 const int kColorSTART = 19;
187 top=gAlice->GetGeometry()->GetNode("alice");
189 // START define the different volumes
190 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
192 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
194 node = new TNode("0ST1","0ST01","S_0ST1",0,0,75.,"");
195 node->SetLineColor(kColorSTART);
198 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
200 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-75,"rotx999");
201 node->SetLineColor(kColorSTART);
205 //_____________________________________________________________________________
206 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
209 // Calculate the distance from the mouse to the START on the screen
215 //-------------------------------------------------------------------------
216 void AliSTART::Init()
219 // Initialis the START after it has been built
223 printf("\n%s: ",ClassName());
224 for(i=0;i<35;i++) printf("*");
225 printf(" START_INIT ");
226 for(i=0;i<35;i++) printf("*");
227 printf("\n%s: ",ClassName());
229 // Here the START initialisation code (if any!)
230 for(i=0;i<80;i++) printf("*");
235 //---------------------------------------------------------------------------
236 void AliSTART::MakeBranch(Option_t* option, const char *file)
239 // Specific START branches
241 // Create Tree branches for the START.
242 Int_t buffersize = 400;
244 sprintf(branchname,"%s",GetName());
246 AliDetector::MakeBranch(option,file);
248 const char *cD = strstr(option,"D");
251 digits = new AliSTARTdigit();
252 MakeBranchInTree(gAlice->TreeD(),
253 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
256 char *cR = strstr(option,"R");
259 MakeBranchInTree(gAlice->TreeR(),
260 branchname, "Int_t", &fZposit, buffersize, 1, file);
265 //_____________________________________________________________________________
267 void AliSTART::Hit2digit(Int_t evnum)
270 // From hits to digits
277 char nameTH[8],nameTD[8];
278 Float_t timediff,timeright,timeleft,timeav;
279 Float_t besttimeright,besttimeleft,meanTime;
280 Int_t channelWidth=10;
283 AliSTARThit *startHit;
285 Int_t buffersize=256;
287 digits= new AliSTARTdigit();
291 // Event ------------------------- LOOP
293 sprintf(nameTD,"TreeD%d",evnum);
294 TTree *td = new TTree(nameTD,"START");
295 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
302 Int_t nparticles = gAlice->GetEvent(evnum);
303 if (nparticles <= 0) return;
304 printf("\n nparticles %d\n",nparticles);
307 sprintf(nameTH,"TreeH%d",evnum);
308 printf("%s\n",nameTH);
309 TTree *th = gAlice->TreeH();
310 Int_t ntracks = (Int_t) th->GetEntries();
311 if (ntracks<=0) return;
312 // Start loop on tracks in the hits containers
313 for (Int_t track=0; track<ntracks;track++) {
315 nbytes += th->GetEvent(track);
316 particle=gAlice->Particle(track);
317 nhits =fHits->GetEntriesFast();
319 for (hit=0;hit<nhits;hit++) {
320 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
325 volume = startHit->fVolume;
327 timeright = startHit->fTime;
328 if(timeright<besttimeright) {
329 besttimeright=timeright;
331 }//time for right shoulder
333 timeleft = startHit->fTime;
334 // printf("timeleft %f\n",timeleft);
335 if(timeleft<besttimeleft) {
336 besttimeleft=timeleft;
338 }//time for left shoulder
342 //folding with experimental time distribution
343 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
344 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
345 timediff=besttimerightGaus-besttimeleftGaus;
346 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
347 if ( TMath::Abs(timediff)<2. && meanTime<3.)
349 //we assume centre of bunch is 5ns after TTS signal
350 //TOF values are relative of the end of bunch
353 ppBunch=ppBunch-10/2;
354 Float_t t1=1000.*besttimeleftGaus;
355 Float_t t2=1000.*besttimerightGaus;
356 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
357 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
361 // Time to TDC signal
362 // 256 channels for timediff, range 1ns
364 timediff=128+1000*timediff/channelWidth; // time in ps
366 timeAv = (Int_t)(timeav); // time (ps) channel numbres
367 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
368 digits->Set(timeAv,timeDiff);
371 {timeAv=999999; timeDiff=99999;}
374 printf("digits-> %d \n",digits->GetTime());