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.16 2001/01/17 10:56:08 hristov
19 Corrections to destructors
21 Revision 1.15 2001/01/01 13:10:42 hristov
22 Local definition of digits removed
24 Revision 1.14 2000/12/22 16:17:15 hristov
25 Updated START code from Alla
27 Revision 1.13 2000/12/18 11:39:41 alibrary
28 Quick fix to avoid crash in display waiting for new version
30 Revision 1.12 2000/12/04 08:48:19 alibrary
31 Fixing problems in the HEAD
33 Revision 1.11 2000/10/13 13:14:08 hristov
34 Bug fixes and code cleaning
36 Revision 1.10 2000/10/02 21:28:13 fca
37 Removal of useless dependecies via forward declarations
39 Revision 1.9 2000/07/13 16:41:29 fca
40 New START corrected for coding conventions
42 Revision 1.8 2000/03/27 17:24:25 alla
45 Revision 1.6 2000/01/21 15:45:23 fca
48 Revision 1.5 2000/01/19 17:17:15 fca
49 Introducing a list of lists of hits -- more hits allowed for detector now
51 Revision 1.4 1999/11/12 15:04:00 fca
52 Modifications from A.Maevskaya
54 Revision 1.3 1999/09/29 09:24:29 fca
55 Introduction of the Copyright and cvs Log
59 ///////////////////////////////////////////////////////////////////////////////
61 // START (T-Zero) Detector //
62 // This class contains the base procedures for the START //
67 <img src="gif/AliSTARTClass.gif">
70 <font size=+2 color=red>
71 <p>The responsible person for this module is
72 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
79 ///////////////////////////////////////////////////////////////////////////////
88 #include "TGeometry.h"
90 #include "TParticle.h"
94 #include "AliSTARTdigit.h"
96 #include "AliSTARThit.h"
97 #include "AliSTARTvertex.h"
101 static AliSTARTdigit *digits;
103 //_____________________________________________________________________________
107 // Default constructor for class AliSTART
114 //_____________________________________________________________________________
115 AliSTART::AliSTART(const char *name, const char *title)
116 : AliDetector(name,title)
119 // Standard constructor for START Detector
124 // Initialise Hit array
125 fHits = new TClonesArray("AliSTARThit", 405);
126 gAlice->AddHitList(fHits);
130 SetMarkerColor(kRed);
133 //_____________________________________________________________________________
134 AliSTART::~AliSTART() {
141 //_____________________________________________________________________________
142 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
147 TClonesArray &lhits = *fHits;
148 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
151 //_____________________________________________________________________________
153 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
156 // Add a START digit to the list. Dummy function.
160 //_____________________________________________________________________________
161 void AliSTART::BuildGeometry()
164 // Build simple ROOT TNode geometry for event display
167 const int kColorSTART = 19;
169 top=gAlice->GetGeometry()->GetNode("alice");
171 // START define the different volumes
172 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
174 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
176 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
177 node->SetLineColor(kColorSTART);
180 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
182 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
183 node->SetLineColor(kColorSTART);
187 //_____________________________________________________________________________
188 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
191 // Calculate the distance from the mouse to the START on the screen
197 //-------------------------------------------------------------------------
198 void AliSTART::Init()
201 // Initialis the START after it has been built
205 for(i=0;i<35;i++) printf("*");
206 printf(" START_INIT ");
207 for(i=0;i<35;i++) printf("*");
210 // Here the START initialisation code (if any!)
211 for(i=0;i<80;i++) printf("*");
215 // fIdSensRad=gMC->VolId("PTOP");
216 // fIdSensPC =gMC->VolId("T0PC");
220 //---------------------------------------------------------------------------
221 void AliSTART::MakeBranch(Option_t* option, char *file)
224 // Specific START branches
226 // Create Tree branches for the START.
227 Int_t buffersize = 400;
229 sprintf(branchname,"%s",GetName());
231 AliDetector::MakeBranch(option,file);
233 char *cD = strstr(option,"D");
236 digits = new AliSTARTdigit();
237 gAlice->MakeBranchInTree(gAlice->TreeD(),
238 branchname, "AliSTARTdigit", digits, buffersize, 1, file) ;
241 char *cR = strstr(option,"R");
244 gAlice->MakeBranchInTree(gAlice->TreeR(),
245 branchname, "Int_t", &fZposit, buffersize, 1, file) ;
250 //_____________________________________________________________________________
252 void AliSTART::Hit2digit(Int_t evnum)
255 // From hits to digits
262 char nameTH[8],nameTD[8];
263 Float_t timediff,timeright,timeleft,timeav;
264 Float_t besttimeright,besttimeleft,meanTime;
265 Int_t channelWidth=10;
268 AliSTARThit *startHit;
270 Int_t buffersize=256;
273 digits= new AliSTARTdigit();
277 // Event ------------------------- LOOP
279 sprintf(nameTD,"TreeD%d",evnum);
280 TTree *td = new TTree(nameTD,"START");
281 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
288 Int_t nparticles = gAlice->GetEvent(evnum);
289 if (nparticles <= 0) return;
290 printf("\n nparticles %d\n",nparticles);
293 sprintf(nameTH,"TreeH%d",evnum);
294 printf("%s\n",nameTH);
295 TTree *th = gAlice->TreeH();
296 Int_t ntracks = (Int_t) th->GetEntries();
297 if (ntracks<=0) return;
298 // Start loop on tracks in the hits containers
299 for (Int_t track=0; track<ntracks;track++) {
301 nbytes += th->GetEvent(track);
302 particle=gAlice->Particle(track);
303 nhits =fHits->GetEntriesFast();
305 for (hit=0;hit<nhits;hit++) {
306 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
311 volume = startHit->fVolume;
313 timeright = startHit->fTime;
314 if(timeright<besttimeright) {
315 besttimeright=timeright;
317 }//time for right shoulder
319 timeleft = startHit->fTime;
320 // printf("timeleft %f\n",timeleft);
321 if(timeleft<besttimeleft) {
322 besttimeleft=timeleft;
324 }//time for left shoulder
328 //folding with experimental time distribution
329 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
330 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
331 timediff=besttimerightGaus-besttimeleftGaus;
332 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
333 if ( TMath::Abs(timediff)<2. && meanTime<3.)
335 //we assume centre of bunch is 5ns after TTS signal
336 //TOF values are relative of the end of bunch
339 ppBunch=ppBunch-10/2;
340 Float_t t1=1000.*besttimeleftGaus;
341 Float_t t2=1000.*besttimerightGaus;
342 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
343 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
347 // Time to TDC signal
348 // 256 channels for timediff, range 1ns
350 timediff=128+1000*timediff/channelWidth; // time in ps
352 timeAv = (Int_t)(timeav); // time (ps) channel numbres
353 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
354 digits->Set(timeAv,timeDiff);
357 {timeAv=999999; timeDiff=99999;}
360 printf("digits-> %d \n",digits->GetTime());