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.19 2001/04/04 12:10:18 alla
19 changes according Coding Convension
21 Revision 1.18 2001/03/12 17:46:43 hristov
22 Changes needed on Sun with CC 5.0
24 Revision 1.17 2001/01/26 19:59:53 hristov
25 Major upgrade of AliRoot code
27 Revision 1.16 2001/01/17 10:56:08 hristov
28 Corrections to destructors
30 Revision 1.15 2001/01/01 13:10:42 hristov
31 Local definition of digits removed
33 Revision 1.14 2000/12/22 16:17:15 hristov
34 Updated START code from Alla
36 Revision 1.13 2000/12/18 11:39:41 alibrary
37 Quick fix to avoid crash in display waiting for new version
39 Revision 1.12 2000/12/04 08:48:19 alibrary
40 Fixing problems in the HEAD
42 Revision 1.11 2000/10/13 13:14:08 hristov
43 Bug fixes and code cleaning
45 Revision 1.10 2000/10/02 21:28:13 fca
46 Removal of useless dependecies via forward declarations
48 Revision 1.9 2000/07/13 16:41:29 fca
49 New START corrected for coding conventions
51 Revision 1.8 2000/03/27 17:24:25 alla
54 Revision 1.6 2000/01/21 15:45:23 fca
57 Revision 1.5 2000/01/19 17:17:15 fca
58 Introducing a list of lists of hits -- more hits allowed for detector now
60 Revision 1.4 1999/11/12 15:04:00 fca
61 Modifications from A.Maevskaya
63 Revision 1.3 1999/09/29 09:24:29 fca
64 Introduction of the Copyright and cvs Log
68 ///////////////////////////////////////////////////////////////////////////////
70 // START (T-Zero) Detector //
71 // This class contains the base procedures for the START //
76 <img src="gif/AliSTARTClass.gif">
79 <font size=+2 color=red>
80 <p>The responsible person for this module is
81 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
88 ///////////////////////////////////////////////////////////////////////////////
97 #include "TGeometry.h"
99 #include "TParticle.h"
102 #include "AliSTART.h"
103 #include "AliSTARTdigit.h"
105 #include "AliSTARThit.h"
106 #include "AliSTARTvertex.h"
110 static AliSTARTdigit *digits;
112 //_____________________________________________________________________________
116 // Default constructor for class AliSTART
123 //_____________________________________________________________________________
124 AliSTART::AliSTART(const char *name, const char *title)
125 : AliDetector(name,title)
128 // Standard constructor for START Detector
133 // Initialise Hit array
134 fHits = new TClonesArray("AliSTARThit", 405);
135 gAlice->AddHitList(fHits);
139 SetMarkerColor(kRed);
142 //_____________________________________________________________________________
143 AliSTART::~AliSTART() {
150 //_____________________________________________________________________________
151 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
156 TClonesArray &lhits = *fHits;
157 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
160 //_____________________________________________________________________________
162 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
165 // Add a START digit to the list. Dummy function.
169 //_____________________________________________________________________________
170 void AliSTART::BuildGeometry()
173 // Build simple ROOT TNode geometry for event display
176 const int kColorSTART = 19;
178 top=gAlice->GetGeometry()->GetNode("alice");
180 // START define the different volumes
181 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
183 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
185 node = new TNode("0ST1","0ST01","S_0ST1",0,0,75.,"");
186 node->SetLineColor(kColorSTART);
189 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
191 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-75,"rot999");
192 node->SetLineColor(kColorSTART);
196 //_____________________________________________________________________________
197 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
200 // Calculate the distance from the mouse to the START on the screen
206 //-------------------------------------------------------------------------
207 void AliSTART::Init()
210 // Initialis the START after it has been built
214 printf("\n%s: ",ClassName());
215 for(i=0;i<35;i++) printf("*");
216 printf(" START_INIT ");
217 for(i=0;i<35;i++) printf("*");
218 printf("\n%s: ",ClassName());
220 // Here the START initialisation code (if any!)
221 for(i=0;i<80;i++) printf("*");
226 //---------------------------------------------------------------------------
227 void AliSTART::MakeBranch(Option_t* option, const char *file)
230 // Specific START branches
232 // Create Tree branches for the START.
233 Int_t buffersize = 400;
235 sprintf(branchname,"%s",GetName());
237 AliDetector::MakeBranch(option,file);
239 const char *cD = strstr(option,"D");
242 digits = new AliSTARTdigit();
243 MakeBranchInTree(gAlice->TreeD(),
244 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
247 char *cR = strstr(option,"R");
250 MakeBranchInTree(gAlice->TreeR(),
251 branchname, "Int_t", &fZposit, buffersize, 1, file);
256 //_____________________________________________________________________________
258 void AliSTART::Hit2digit(Int_t evnum)
261 // From hits to digits
268 char nameTH[8],nameTD[8];
269 Float_t timediff,timeright,timeleft,timeav;
270 Float_t besttimeright,besttimeleft,meanTime;
271 Int_t channelWidth=10;
274 AliSTARThit *startHit;
276 Int_t buffersize=256;
279 digits= new AliSTARTdigit();
283 // Event ------------------------- LOOP
285 sprintf(nameTD,"TreeD%d",evnum);
286 TTree *td = new TTree(nameTD,"START");
287 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
294 Int_t nparticles = gAlice->GetEvent(evnum);
295 if (nparticles <= 0) return;
296 printf("\n nparticles %d\n",nparticles);
299 sprintf(nameTH,"TreeH%d",evnum);
300 printf("%s\n",nameTH);
301 TTree *th = gAlice->TreeH();
302 Int_t ntracks = (Int_t) th->GetEntries();
303 if (ntracks<=0) return;
304 // Start loop on tracks in the hits containers
305 for (Int_t track=0; track<ntracks;track++) {
307 nbytes += th->GetEvent(track);
308 particle=gAlice->Particle(track);
309 nhits =fHits->GetEntriesFast();
311 for (hit=0;hit<nhits;hit++) {
312 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
317 volume = startHit->fVolume;
319 timeright = startHit->fTime;
320 if(timeright<besttimeright) {
321 besttimeright=timeright;
323 }//time for right shoulder
325 timeleft = startHit->fTime;
326 // printf("timeleft %f\n",timeleft);
327 if(timeleft<besttimeleft) {
328 besttimeleft=timeleft;
330 }//time for left shoulder
334 //folding with experimental time distribution
335 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
336 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
337 timediff=besttimerightGaus-besttimeleftGaus;
338 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
339 if ( TMath::Abs(timediff)<2. && meanTime<3.)
341 //we assume centre of bunch is 5ns after TTS signal
342 //TOF values are relative of the end of bunch
345 ppBunch=ppBunch-10/2;
346 Float_t t1=1000.*besttimeleftGaus;
347 Float_t t2=1000.*besttimerightGaus;
348 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
349 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
353 // Time to TDC signal
354 // 256 channels for timediff, range 1ns
356 timediff=128+1000*timediff/channelWidth; // time in ps
358 timeAv = (Int_t)(timeav); // time (ps) channel numbres
359 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
360 digits->Set(timeAv,timeDiff);
363 {timeAv=999999; timeDiff=99999;}
366 printf("digits-> %d \n",digits->GetTime());