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.18 2001/03/12 17:46:43 hristov
19 Changes needed on Sun with CC 5.0
21 Revision 1.17 2001/01/26 19:59:53 hristov
22 Major upgrade of AliRoot code
24 Revision 1.16 2001/01/17 10:56:08 hristov
25 Corrections to destructors
27 Revision 1.15 2001/01/01 13:10:42 hristov
28 Local definition of digits removed
30 Revision 1.14 2000/12/22 16:17:15 hristov
31 Updated START code from Alla
33 Revision 1.13 2000/12/18 11:39:41 alibrary
34 Quick fix to avoid crash in display waiting for new version
36 Revision 1.12 2000/12/04 08:48:19 alibrary
37 Fixing problems in the HEAD
39 Revision 1.11 2000/10/13 13:14:08 hristov
40 Bug fixes and code cleaning
42 Revision 1.10 2000/10/02 21:28:13 fca
43 Removal of useless dependecies via forward declarations
45 Revision 1.9 2000/07/13 16:41:29 fca
46 New START corrected for coding conventions
48 Revision 1.8 2000/03/27 17:24:25 alla
51 Revision 1.6 2000/01/21 15:45:23 fca
54 Revision 1.5 2000/01/19 17:17:15 fca
55 Introducing a list of lists of hits -- more hits allowed for detector now
57 Revision 1.4 1999/11/12 15:04:00 fca
58 Modifications from A.Maevskaya
60 Revision 1.3 1999/09/29 09:24:29 fca
61 Introduction of the Copyright and cvs Log
65 ///////////////////////////////////////////////////////////////////////////////
67 // START (T-Zero) Detector //
68 // This class contains the base procedures for the START //
73 <img src="gif/AliSTARTClass.gif">
76 <font size=+2 color=red>
77 <p>The responsible person for this module is
78 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
85 ///////////////////////////////////////////////////////////////////////////////
94 #include "TGeometry.h"
96 #include "TParticle.h"
100 #include "AliSTARTdigit.h"
102 #include "AliSTARThit.h"
103 #include "AliSTARTvertex.h"
107 static AliSTARTdigit *digits;
109 //_____________________________________________________________________________
113 // Default constructor for class AliSTART
120 //_____________________________________________________________________________
121 AliSTART::AliSTART(const char *name, const char *title)
122 : AliDetector(name,title)
125 // Standard constructor for START Detector
130 // Initialise Hit array
131 fHits = new TClonesArray("AliSTARThit", 405);
132 gAlice->AddHitList(fHits);
136 SetMarkerColor(kRed);
139 //_____________________________________________________________________________
140 AliSTART::~AliSTART() {
147 //_____________________________________________________________________________
148 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
153 TClonesArray &lhits = *fHits;
154 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
157 //_____________________________________________________________________________
159 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
162 // Add a START digit to the list. Dummy function.
166 //_____________________________________________________________________________
167 void AliSTART::BuildGeometry()
170 // Build simple ROOT TNode geometry for event display
173 const int kColorSTART = 19;
175 top=gAlice->GetGeometry()->GetNode("alice");
177 // START define the different volumes
178 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
180 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
182 node = new TNode("0ST1","0ST01","S_0ST1",0,0,75.,"");
183 node->SetLineColor(kColorSTART);
186 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
188 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-75,"rot999");
189 node->SetLineColor(kColorSTART);
193 //_____________________________________________________________________________
194 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
197 // Calculate the distance from the mouse to the START on the screen
203 //-------------------------------------------------------------------------
204 void AliSTART::Init()
207 // Initialis the START after it has been built
211 for(i=0;i<35;i++) printf("*");
212 printf(" START_INIT ");
213 for(i=0;i<35;i++) printf("*");
216 // Here the START initialisation code (if any!)
217 for(i=0;i<80;i++) printf("*");
222 //---------------------------------------------------------------------------
223 void AliSTART::MakeBranch(Option_t* option, char *file)
226 // Specific START branches
228 // Create Tree branches for the START.
229 Int_t buffersize = 400;
231 sprintf(branchname,"%s",GetName());
233 AliDetector::MakeBranch(option,file);
235 const char *cD = strstr(option,"D");
238 digits = new AliSTARTdigit();
239 gAlice->MakeBranchInTree(gAlice->TreeD(),
240 branchname, "AliSTARTdigit", digits, buffersize, 1, file) ;
243 char *cR = strstr(option,"R");
246 gAlice->MakeBranchInTree(gAlice->TreeR(),
247 branchname, "Int_t", &fZposit, buffersize, 1, file) ;
252 //_____________________________________________________________________________
254 void AliSTART::Hit2digit(Int_t evnum)
257 // From hits to digits
264 char nameTH[8],nameTD[8];
265 Float_t timediff,timeright,timeleft,timeav;
266 Float_t besttimeright,besttimeleft,meanTime;
267 Int_t channelWidth=10;
270 AliSTARThit *startHit;
272 Int_t buffersize=256;
275 digits= new AliSTARTdigit();
279 // Event ------------------------- LOOP
281 sprintf(nameTD,"TreeD%d",evnum);
282 TTree *td = new TTree(nameTD,"START");
283 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
290 Int_t nparticles = gAlice->GetEvent(evnum);
291 if (nparticles <= 0) return;
292 printf("\n nparticles %d\n",nparticles);
295 sprintf(nameTH,"TreeH%d",evnum);
296 printf("%s\n",nameTH);
297 TTree *th = gAlice->TreeH();
298 Int_t ntracks = (Int_t) th->GetEntries();
299 if (ntracks<=0) return;
300 // Start loop on tracks in the hits containers
301 for (Int_t track=0; track<ntracks;track++) {
303 nbytes += th->GetEvent(track);
304 particle=gAlice->Particle(track);
305 nhits =fHits->GetEntriesFast();
307 for (hit=0;hit<nhits;hit++) {
308 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
313 volume = startHit->fVolume;
315 timeright = startHit->fTime;
316 if(timeright<besttimeright) {
317 besttimeright=timeright;
319 }//time for right shoulder
321 timeleft = startHit->fTime;
322 // printf("timeleft %f\n",timeleft);
323 if(timeleft<besttimeleft) {
324 besttimeleft=timeleft;
326 }//time for left shoulder
330 //folding with experimental time distribution
331 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
332 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
333 timediff=besttimerightGaus-besttimeleftGaus;
334 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
335 if ( TMath::Abs(timediff)<2. && meanTime<3.)
337 //we assume centre of bunch is 5ns after TTS signal
338 //TOF values are relative of the end of bunch
341 ppBunch=ppBunch-10/2;
342 Float_t t1=1000.*besttimeleftGaus;
343 Float_t t2=1000.*besttimerightGaus;
344 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
345 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
349 // Time to TDC signal
350 // 256 channels for timediff, range 1ns
352 timediff=128+1000*timediff/channelWidth; // time in ps
354 timeAv = (Int_t)(timeav); // time (ps) channel numbres
355 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
356 digits->Set(timeAv,timeDiff);
359 {timeAv=999999; timeDiff=99999;}
362 printf("digits-> %d \n",digits->GetTime());