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.23.8.1 2002/07/24 09:50:10 alibrary
21 Revision 1.24 2002/07/23 11:48:05 alla
24 Revision 1.23 2001/09/19 18:41:45 alla
25 Asimmetric START geometry
27 Revision 1.22 2001/07/27 13:03:12 hristov
28 Default Branch split level set to 99
30 Revision 1.21 2001/06/27 16:06:59 hristov
31 Rotation matrix in BuildGeometry has been changed to rotx999
33 Revision 1.20.2.1 2001/06/27 10:51:15 alla
34 Rotation matrix in BuildGeometry has benn changed to rotx999
36 Revision 1.20 2001/05/16 14:57:21 alibrary
37 New files for folders and Stack
39 Revision 1.19 2001/04/04 12:10:18 alla
40 changes according Coding Convension
42 Revision 1.18 2001/03/12 17:46:43 hristov
43 Changes needed on Sun with CC 5.0
45 Revision 1.17 2001/01/26 19:59:53 hristov
46 Major upgrade of AliRoot code
48 Revision 1.16 2001/01/17 10:56:08 hristov
49 Corrections to destructors
51 Revision 1.15 2001/01/01 13:10:42 hristov
52 Local definition of digits removed
54 Revision 1.14 2000/12/22 16:17:15 hristov
55 Updated START code from Alla
57 Revision 1.13 2000/12/18 11:39:41 alibrary
58 Quick fix to avoid crash in display waiting for new version
60 Revision 1.12 2000/12/04 08:48:19 alibrary
61 Fixing problems in the HEAD
63 Revision 1.11 2000/10/13 13:14:08 hristov
64 Bug fixes and code cleaning
66 Revision 1.10 2000/10/02 21:28:13 fca
67 Removal of useless dependecies via forward declarations
69 Revision 1.9 2000/07/13 16:41:29 fca
70 New START corrected for coding conventions
72 Revision 1.8 2000/03/27 17:24:25 alla
75 Revision 1.6 2000/01/21 15:45:23 fca
78 Revision 1.5 2000/01/19 17:17:15 fca
79 Introducing a list of lists of hits -- more hits allowed for detector now
81 Revision 1.4 1999/11/12 15:04:00 fca
82 Modifications from A.Maevskaya
84 Revision 1.3 1999/09/29 09:24:29 fca
85 Introduction of the Copyright and cvs Log
89 ///////////////////////////////////////////////////////////////////////////////
91 // START (T-Zero) Detector //
92 // This class contains the base procedures for the START //
97 <img src="gif/AliSTARTClass.gif">
100 <font size=+2 color=red>
101 <p>The responsible person for this module is
102 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
109 ///////////////////////////////////////////////////////////////////////////////
111 #include <iostream.h>
118 #include "TGeometry.h"
120 #include "TParticle.h"
123 #include "AliSTART.h"
124 #include "AliSTARTdigit.h"
126 #include "AliSTARThit.h"
127 #include "AliSTARThitPhoton.h"
128 #include "AliSTARTvertex.h"
132 static AliSTARTdigit *digits;
134 //_____________________________________________________________________________
138 // Default constructor for class AliSTART
146 //_____________________________________________________________________________
147 AliSTART::AliSTART(const char *name, const char *title)
148 : AliDetector(name,title)
151 // Standard constructor for START Detector
156 // Initialise Hit array
157 fHits = new TClonesArray("AliSTARThit", 405);
158 gAlice->AddHitList(fHits);
160 fPhotons = new TClonesArray("AliSTARThitPhoton", 10000);
161 gAlice->AddHitList (fPhotons);
166 SetMarkerColor(kRed);
169 //_____________________________________________________________________________
170 AliSTART::~AliSTART() {
181 //_____________________________________________________________________________
182 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
187 TClonesArray &lhits = *fHits;
188 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
191 //_____________________________________________________________________________
192 void AliSTART::AddHitPhoton(Int_t track, Int_t *vol, Float_t *hits)
194 // Add a START hit of photons
196 TClonesArray &lhits = *fPhotons;
197 new(lhits[fNPhotons++]) AliSTARThitPhoton(fIshunt,track,vol,hits);
200 //_____________________________________________________________________________
202 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
205 // Add a START digit to the list. Dummy function.
209 //_____________________________________________________________________________
210 void AliSTART::BuildGeometry()
213 // Build simple ROOT TNode geometry for event display
216 const int kColorSTART = 19;
218 top=gAlice->GetGeometry()->GetNode("alice");
220 // START define the different volumes
221 new TRotMatrix("rotx999","rot999", 90,0,90,90,180,0);
223 new TTUBE("S_0ST1","START volume 1","void",5.,10.7,5.3);
225 node = new TNode("0ST1","0ST01","S_0ST1",0,0,69.7,"");
226 node->SetLineColor(kColorSTART);
229 new TTUBE("S_0ST2","START volume 2","void",5.,10.7,5.3);
231 node = new TNode("0ST2","0ST2","S_0ST2",0,0,-350,"rotx999");
232 node->SetLineColor(kColorSTART);
236 //_____________________________________________________________________________
237 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
240 // Calculate the distance from the mouse to the START on the screen
246 //-------------------------------------------------------------------------
247 void AliSTART::Init()
250 // Initialis the START after it has been built
254 printf("\n%s: ",ClassName());
255 for(i=0;i<35;i++) printf("*");
256 printf(" START_INIT ");
257 for(i=0;i<35;i++) printf("*");
258 printf("\n%s: ",ClassName());
260 // Here the START initialisation code (if any!)
261 for(i=0;i<80;i++) printf("*");
266 //---------------------------------------------------------------------------
267 void AliSTART::MakeBranch(Option_t* option, const char *file)
270 // Specific START branches
272 // Create Tree branches for the START.
273 Int_t buffersize = 4000;
275 sprintf(branchname,"%s",GetName());
277 AliDetector::MakeBranch(option,file);
279 const char *cD = strstr(option,"D");
280 const char *cH = strstr(option,"H");
284 sprintf (branchname, "%shitPhoton", GetName());
285 MakeBranchInTree (gAlice->TreeH(), branchname, &fPhotons, 50000, file);
290 digits = new AliSTARTdigit();
291 MakeBranchInTree(gAlice->TreeD(),
292 branchname, "AliSTARTdigit", digits, buffersize, 1, file);
295 char *cR = strstr(option,"R");
298 MakeBranchInTree(gAlice->TreeR(),
299 branchname, "Int_t", &fZposit, buffersize, 1, file);
304 //_____________________________________________________________________________
305 void AliSTART::ResetHits()
307 AliDetector::ResetHits();
310 if (fPhotons) fPhotons->Clear();
313 //_____________________________________________________________________________
314 void AliSTART::SetTreeAddress()
319 AliDetector::SetTreeAddress();
320 treeH = gAlice->TreeH();
325 branch = treeH->GetBranch ("STARThitPhoton");
326 if (branch) branch->SetAddress (&fPhotons);
331 //_____________________________________________________________________________
333 void AliSTART::Hit2digit(Int_t evnum)
336 // From hits to digits
344 char nameTH[8],nameTD[8];
345 Float_t timediff,timeright,timeleft,timeav;
346 Float_t besttimeright,besttimeleft,meanTime;
347 Int_t channelWidth=10;
350 AliSTARThit *startHit;
352 Int_t buffersize=256;
354 digits= new AliSTARTdigit();
358 // Event ------------------------- LOOP
360 sprintf(nameTD,"TreeD%d",evnum);
361 TTree *td = new TTree(nameTD,"START");
362 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize);
369 Int_t nparticles = gAlice->GetEvent(evnum);
370 if (nparticles <= 0) return;
371 printf("\n nparticles %d\n",nparticles);
374 sprintf(nameTH,"TreeH%d",evnum);
375 printf("%s\n",nameTH);
376 TTree *th = gAlice->TreeH();
377 Int_t ntracks = (Int_t) th->GetEntries();
378 if (ntracks<=0) return;
379 // Start loop on tracks in the hits containers
380 for (Int_t track=0; track<ntracks;track++) {
382 nbytes += th->GetEvent(track);
383 particle=gAlice->Particle(track);
384 nhits =fHits->GetEntriesFast();
386 for (hit=0;hit<nhits;hit++) {
387 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
392 volume = startHit->fVolume;
394 timeright = startHit->fTime;
395 if(timeright<besttimeright) {
396 besttimeright=timeright;
398 }//time for right shoulder
400 timeleft = startHit->fTime;
401 // printf("timeleft %f\n",timeleft);
402 if(timeleft<besttimeleft) {
403 besttimeleft=timeleft;
405 }//time for left shoulder
409 //folding with experimental time distribution
410 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
411 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
412 timediff=besttimerightGaus-besttimeleftGaus;
413 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
414 if ( TMath::Abs(timediff)<2. && meanTime<3.)
416 //we assume centre of bunch is 5ns after TTS signal
417 //TOF values are relative of the end of bunch
420 ppBunch=ppBunch-10/2;
421 Float_t t1=1000.*besttimeleftGaus;
422 Float_t t2=1000.*besttimerightGaus;
423 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
424 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
428 // Time to TDC signal
429 // 256 channels for timediff, range 1ns
431 timediff=128+1000*timediff/channelWidth; // time in ps
433 timeAv = (Int_t)(timeav); // time (ps) channel numbres
434 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
435 digits->Set(timeAv,timeDiff);
438 {timeAv=999999; timeDiff=99999;}
441 printf("digits-> %d \n",digits->GetTime());