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.8 2000/03/27 17:24:25 alla
21 Revision 1.6 2000/01/21 15:45:23 fca
24 Revision 1.5 2000/01/19 17:17:15 fca
25 Introducing a list of lists of hits -- more hits allowed for detector now
27 Revision 1.4 1999/11/12 15:04:00 fca
28 Modifications from A.Maevskaya
30 Revision 1.3 1999/09/29 09:24:29 fca
31 Introduction of the Copyright and cvs Log
35 ///////////////////////////////////////////////////////////////////////////////
37 // START (T-Zero) Detector //
38 // This class contains the base procedures for the START //
43 <img src="gif/AliSTARTClass.gif">
46 <font size=+2 color=red>
47 <p>The responsible person for this module is
48 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
55 ///////////////////////////////////////////////////////////////////////////////
64 #include "TGeometry.h"
67 #include "AliSTARTdigit.h"
69 #include "AliSTARThit.h"
70 #include "AliSTARTvertex.h"
74 static AliSTARTdigit *digits;
76 //_____________________________________________________________________________
80 // Default constructor for class AliSTART
87 //_____________________________________________________________________________
88 AliSTART::AliSTART(const char *name, const char *title)
89 : AliDetector(name,title)
92 // Standard constructor for START Detector
97 // Initialise Hit array
98 fHits = new TClonesArray("AliSTARThit", 405);
99 // gAlice->AddHitList(fHits);
100 // fDigits = new TClonesArray("AliSTARTdigit",500);
104 SetMarkerColor(kRed);
107 //_____________________________________________________________________________
108 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
113 TClonesArray &lhits = *fHits;
114 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
117 //_____________________________________________________________________________
119 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
122 // Add a START digit to the list
124 // printf (" AddDigit*******");
125 // TClonesArray &ldigits = *fDigits;
126 // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
129 //_____________________________________________________________________________
130 void AliSTART::BuildGeometry()
133 // Build simple ROOT TNode geometry for event display
136 const int kColorSTART = 19;
138 top=gAlice->GetGeometry()->GetNode("alice");
140 // START define the different volumes
141 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
143 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
145 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
146 node->SetLineColor(kColorSTART);
149 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
151 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
152 node->SetLineColor(kColorSTART);
156 //_____________________________________________________________________________
157 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
160 // Calculate the distance from the mouse to the START on the screen
166 //-------------------------------------------------------------------------
167 void AliSTART::Init()
170 // Initialis the START after it has been built
174 for(i=0;i<35;i++) printf("*");
175 printf(" START_INIT ");
176 for(i=0;i<35;i++) printf("*");
179 // Here the START initialisation code (if any!)
180 for(i=0;i<80;i++) printf("*");
184 // fIdSensRad=gMC->VolId("PTOP");
185 // fIdSensPC =gMC->VolId("T0PC");
189 //---------------------------------------------------------------------------
190 void AliSTART::MakeBranch(Option_t* option)
193 // Specific START branches
195 AliSTARTdigit *digits;
196 // Create Tree branches for the START.
197 Int_t buffersize = 400;
199 sprintf(branchname,"%s",GetName());
201 AliDetector::MakeBranch(option);
203 TTree *td = gAlice->TreeD();
204 digits = new AliSTARTdigit();
205 td->Branch(branchname,"AliSTARTdigit",&digits, buffersize);
206 printf("Making Branch %s for digits\n",branchname);
209 gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
210 printf("Making Branch %s for vertex position %d\n",branchname);
214 //_____________________________________________________________________________
216 void AliSTART::Hit2digit(Int_t evnum)
219 // From hits to digits
226 char nameTH[8],nameTD[8];
227 Float_t timediff,timeright,timeleft,timeav;
228 Float_t besttimeright,besttimeleft,meanTime;
229 Int_t channelWidth=10;
232 AliSTARThit *startHit;
234 Int_t buffersize=256;
237 digits= new AliSTARTdigit();
241 // Event ------------------------- LOOP
243 sprintf(nameTD,"TreeD%d",evnum);
244 TTree *td = new TTree(nameTD,"START");
245 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
252 Int_t nparticles = gAlice->GetEvent(evnum);
253 if (nparticles <= 0) return;
254 printf("\n nparticles %d\n",nparticles);
256 TClonesArray *particles = gAlice->Particles();
258 sprintf(nameTH,"TreeH%d",evnum);
259 printf("%s\n",nameTH);
260 TTree *th = gAlice->TreeH();
261 Int_t ntracks = (Int_t) th->GetEntries();
262 if (ntracks<=0) return;
263 // Start loop on tracks in the hits containers
264 for (Int_t track=0; track<ntracks;track++) {
266 nbytes += th->GetEvent(track);
267 particle=(TParticle*)particles->UncheckedAt(track);
268 nhits =fHits->GetEntriesFast();
270 for (hit=0;hit<nhits;hit++) {
271 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
276 volume = startHit->fVolume;
278 timeright = startHit->fTime;
279 if(timeright<besttimeright) {
280 besttimeright=timeright;
282 }//time for right shoulder
284 timeleft = startHit->fTime;
285 // printf("timeleft %f\n",timeleft);
286 if(timeleft<besttimeleft) {
287 besttimeleft=timeleft;
289 }//time for left shoulder
293 //folding with experimental time distribution
294 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
295 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
296 timediff=besttimerightGaus-besttimeleftGaus;
297 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
298 if ( TMath::Abs(timediff)<2. && meanTime<3.)
300 //we assume centre of bunch is 5ns after TTS signal
301 //TOF values are relative of the end of bunch
304 ppBunch=ppBunch-10/2;
305 Float_t t1=1000.*besttimeleftGaus;
306 Float_t t2=1000.*besttimerightGaus;
307 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
308 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
312 // Time to TDC signal
313 // 256 channels for timediff, range 1ns
315 timediff=128+1000*timediff/channelWidth; // time in ps
317 timeAv = (Int_t)(timeav); // time (ps) channel numbres
318 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
319 digits->Set(timeAv,timeDiff);
322 {timeAv=999999; timeDiff=99999;}
325 printf("digits-> %d \n",digits->GetTime());