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.22 2001/07/27 13:03:12 hristov
19 Default Branch split level set to 99
21 Revision 1.21 2001/06/27 16:06:59 hristov
22 Rotation matrix in BuildGeometry has been changed to rotx999
24 Revision 1.20.2.1 2001/06/27 10:51:15 alla
25 Rotation matrix in BuildGeometry has benn changed to rotx999
27 Revision 1.20 2001/05/16 14:57:21 alibrary
28 New files for folders and Stack
30 Revision 1.19 2001/04/04 12:10:18 alla
31 changes according Coding Convension
33 Revision 1.18 2001/03/12 17:46:43 hristov
34 Changes needed on Sun with CC 5.0
36 Revision 1.17 2001/01/26 19:59:53 hristov
37 Major upgrade of AliRoot code
39 Revision 1.16 2001/01/17 10:56:08 hristov
40 Corrections to destructors
42 Revision 1.15 2001/01/01 13:10:42 hristov
43 Local definition of digits removed
45 Revision 1.14 2000/12/22 16:17:15 hristov
46 Updated START code from Alla
48 Revision 1.13 2000/12/18 11:39:41 alibrary
49 Quick fix to avoid crash in display waiting for new version
51 Revision 1.12 2000/12/04 08:48:19 alibrary
52 Fixing problems in the HEAD
54 Revision 1.11 2000/10/13 13:14:08 hristov
55 Bug fixes and code cleaning
57 Revision 1.10 2000/10/02 21:28:13 fca
58 Removal of useless dependecies via forward declarations
60 Revision 1.9 2000/07/13 16:41:29 fca
61 New START corrected for coding conventions
63 Revision 1.8 2000/03/27 17:24:25 alla
66 Revision 1.6 2000/01/21 15:45:23 fca
69 Revision 1.5 2000/01/19 17:17:15 fca
70 Introducing a list of lists of hits -- more hits allowed for detector now
72 Revision 1.4 1999/11/12 15:04:00 fca
73 Modifications from A.Maevskaya
75 Revision 1.3 1999/09/29 09:24:29 fca
76 Introduction of the Copyright and cvs Log
80 ///////////////////////////////////////////////////////////////////////////////
82 // START (T-Zero) Detector //
83 // This class contains the base procedures for the START //
88 <img src="gif/AliSTARTClass.gif">
91 <font size=+2 color=red>
92 <p>The responsible person for this module is
93 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
100 ///////////////////////////////////////////////////////////////////////////////
102 #include <iostream.h>
109 #include "TGeometry.h"
111 #include "TParticle.h"
114 #include "AliSTART.h"
115 #include "AliSTARTdigit.h"
117 #include "AliSTARThit.h"
118 #include "AliSTARTvertex.h"
122 static AliSTARTdigit *digits;
124 //_____________________________________________________________________________
128 // Default constructor for class AliSTART
135 //_____________________________________________________________________________
136 AliSTART::AliSTART(const char *name, const char *title)
137 : AliDetector(name,title)
140 // Standard constructor for START Detector
145 // Initialise Hit array
146 fHits = new TClonesArray("AliSTARThit", 405);
147 gAlice->AddHitList(fHits);
151 SetMarkerColor(kRed);
154 //_____________________________________________________________________________
155 AliSTART::~AliSTART() {
162 //_____________________________________________________________________________
163 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
168 TClonesArray &lhits = *fHits;
169 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
172 //_____________________________________________________________________________
174 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
177 // Add a START digit to the list. Dummy function.
181 //_____________________________________________________________________________
182 void AliSTART::BuildGeometry()
185 // Build simple ROOT TNode geometry for event display
188 const int kColorSTART = 19;
190 top=gAlice->GetGeometry()->GetNode("alice");
192 // START define the different volumes
193 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
195 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
197 node = new TNode("0ST1","0ST01","S_0ST1",0,0,69.7,"");
198 node->SetLineColor(kColorSTART);
201 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
203 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-350,"rotx999");
204 node->SetLineColor(kColorSTART);
208 //_____________________________________________________________________________
209 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
212 // Calculate the distance from the mouse to the START on the screen
218 //-------------------------------------------------------------------------
219 void AliSTART::Init()
222 // Initialis the START after it has been built
226 printf("\n%s: ",ClassName());
227 for(i=0;i<35;i++) printf("*");
228 printf(" START_INIT ");
229 for(i=0;i<35;i++) printf("*");
230 printf("\n%s: ",ClassName());
232 // Here the START initialisation code (if any!)
233 for(i=0;i<80;i++) printf("*");
238 //---------------------------------------------------------------------------
239 void AliSTART::MakeBranch(Option_t* option, const char *file)
242 // Specific START branches
244 // Create Tree branches for the START.
245 Int_t buffersize = 400;
247 sprintf(branchname,"%s",GetName());
249 AliDetector::MakeBranch(option,file);
251 const char *cD = strstr(option,"D");
254 digits = new AliSTARTdigit();
255 MakeBranchInTree(gAlice->TreeD(),
256 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
259 char *cR = strstr(option,"R");
262 MakeBranchInTree(gAlice->TreeR(),
263 branchname, "Int_t", &fZposit, buffersize, 1, file);
268 //_____________________________________________________________________________
270 void AliSTART::Hit2digit(Int_t evnum)
273 // From hits to digits
280 char nameTH[8],nameTD[8];
281 Float_t timediff,timeright,timeleft,timeav;
282 Float_t besttimeright,besttimeleft,meanTime;
283 Int_t channelWidth=10;
286 AliSTARThit *startHit;
288 Int_t buffersize=256;
290 digits= new AliSTARTdigit();
294 // Event ------------------------- LOOP
296 sprintf(nameTD,"TreeD%d",evnum);
297 TTree *td = new TTree(nameTD,"START");
298 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
305 Int_t nparticles = gAlice->GetEvent(evnum);
306 if (nparticles <= 0) return;
307 printf("\n nparticles %d\n",nparticles);
310 sprintf(nameTH,"TreeH%d",evnum);
311 printf("%s\n",nameTH);
312 TTree *th = gAlice->TreeH();
313 Int_t ntracks = (Int_t) th->GetEntries();
314 if (ntracks<=0) return;
315 // Start loop on tracks in the hits containers
316 for (Int_t track=0; track<ntracks;track++) {
318 nbytes += th->GetEvent(track);
319 particle=gAlice->Particle(track);
320 nhits =fHits->GetEntriesFast();
322 for (hit=0;hit<nhits;hit++) {
323 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
328 volume = startHit->fVolume;
330 timeright = startHit->fTime;
331 if(timeright<besttimeright) {
332 besttimeright=timeright;
334 }//time for right shoulder
336 timeleft = startHit->fTime;
337 // printf("timeleft %f\n",timeleft);
338 if(timeleft<besttimeleft) {
339 besttimeleft=timeleft;
341 }//time for left shoulder
345 //folding with experimental time distribution
346 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
347 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
348 timediff=besttimerightGaus-besttimeleftGaus;
349 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
350 if ( TMath::Abs(timediff)<2. && meanTime<3.)
352 //we assume centre of bunch is 5ns after TTS signal
353 //TOF values are relative of the end of bunch
356 ppBunch=ppBunch-10/2;
357 Float_t t1=1000.*besttimeleftGaus;
358 Float_t t2=1000.*besttimerightGaus;
359 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
360 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
364 // Time to TDC signal
365 // 256 channels for timediff, range 1ns
367 timediff=128+1000*timediff/channelWidth; // time in ps
369 timeAv = (Int_t)(timeav); // time (ps) channel numbres
370 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
371 digits->Set(timeAv,timeDiff);
374 {timeAv=999999; timeDiff=99999;}
377 printf("digits-> %d \n",digits->GetTime());