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.11 2000/10/13 13:14:08 hristov
19 Bug fixes and code cleaning
21 Revision 1.10 2000/10/02 21:28:13 fca
22 Removal of useless dependecies via forward declarations
24 Revision 1.9 2000/07/13 16:41:29 fca
25 New START corrected for coding conventions
27 Revision 1.8 2000/03/27 17:24:25 alla
30 Revision 1.6 2000/01/21 15:45:23 fca
33 Revision 1.5 2000/01/19 17:17:15 fca
34 Introducing a list of lists of hits -- more hits allowed for detector now
36 Revision 1.4 1999/11/12 15:04:00 fca
37 Modifications from A.Maevskaya
39 Revision 1.3 1999/09/29 09:24:29 fca
40 Introduction of the Copyright and cvs Log
44 ///////////////////////////////////////////////////////////////////////////////
46 // START (T-Zero) Detector //
47 // This class contains the base procedures for the START //
52 <img src="gif/AliSTARTClass.gif">
55 <font size=+2 color=red>
56 <p>The responsible person for this module is
57 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
64 ///////////////////////////////////////////////////////////////////////////////
73 #include "TGeometry.h"
74 #include "TParticle.h"
77 #include "AliSTARTdigit.h"
79 #include "AliSTARThit.h"
80 #include "AliSTARTvertex.h"
84 static AliSTARTdigit *digits;
86 //_____________________________________________________________________________
90 // Default constructor for class AliSTART
97 //_____________________________________________________________________________
98 AliSTART::AliSTART(const char *name, const char *title)
99 : AliDetector(name,title)
102 // Standard constructor for START Detector
107 // Initialise Hit array
108 fHits = new TClonesArray("AliSTARThit", 405);
109 // gAlice->AddHitList(fHits);
110 // fDigits = new TClonesArray("AliSTARTdigit",500);
114 SetMarkerColor(kRed);
117 //_____________________________________________________________________________
118 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
123 TClonesArray &lhits = *fHits;
124 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
127 //_____________________________________________________________________________
129 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
132 // Add a START digit to the list
134 // printf (" AddDigit*******");
135 // TClonesArray &ldigits = *fDigits;
136 // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
139 //_____________________________________________________________________________
140 void AliSTART::BuildGeometry()
143 // Build simple ROOT TNode geometry for event display
146 const int kColorSTART = 19;
148 top=gAlice->GetGeometry()->GetNode("alice");
150 // START define the different volumes
151 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
153 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
155 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
156 node->SetLineColor(kColorSTART);
159 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
161 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
162 node->SetLineColor(kColorSTART);
166 //_____________________________________________________________________________
167 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
170 // Calculate the distance from the mouse to the START on the screen
176 //-------------------------------------------------------------------------
177 void AliSTART::Init()
180 // Initialis the START after it has been built
184 for(i=0;i<35;i++) printf("*");
185 printf(" START_INIT ");
186 for(i=0;i<35;i++) printf("*");
189 // Here the START initialisation code (if any!)
190 for(i=0;i<80;i++) printf("*");
194 // fIdSensRad=gMC->VolId("PTOP");
195 // fIdSensPC =gMC->VolId("T0PC");
199 //---------------------------------------------------------------------------
200 void AliSTART::MakeBranch(Option_t* option)
203 // Specific START branches
205 AliSTARTdigit *digits;
206 // Create Tree branches for the START.
207 Int_t buffersize = 400;
209 sprintf(branchname,"%s",GetName());
211 AliDetector::MakeBranch(option);
213 TTree *td = gAlice->TreeD();
214 digits = new AliSTARTdigit();
215 td->Branch(branchname,"AliSTARTdigit",digits, buffersize);
216 printf("Making Branch %s for digits\n",branchname);
219 gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
220 printf("Making Branch %s for vertex position %d\n",branchname);
224 //_____________________________________________________________________________
226 void AliSTART::Hit2digit(Int_t evnum)
229 // From hits to digits
236 char nameTH[8],nameTD[8];
237 Float_t timediff,timeright,timeleft,timeav;
238 Float_t besttimeright,besttimeleft,meanTime;
239 Int_t channelWidth=10;
242 AliSTARThit *startHit;
244 Int_t buffersize=256;
247 digits= new AliSTARTdigit();
251 // Event ------------------------- LOOP
253 sprintf(nameTD,"TreeD%d",evnum);
254 TTree *td = new TTree(nameTD,"START");
255 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
262 Int_t nparticles = gAlice->GetEvent(evnum);
263 if (nparticles <= 0) return;
264 printf("\n nparticles %d\n",nparticles);
266 TClonesArray *particles = gAlice->Particles();
268 sprintf(nameTH,"TreeH%d",evnum);
269 printf("%s\n",nameTH);
270 TTree *th = gAlice->TreeH();
271 Int_t ntracks = (Int_t) th->GetEntries();
272 if (ntracks<=0) return;
273 // Start loop on tracks in the hits containers
274 for (Int_t track=0; track<ntracks;track++) {
276 nbytes += th->GetEvent(track);
277 particle=(TParticle*)particles->UncheckedAt(track);
278 nhits =fHits->GetEntriesFast();
280 for (hit=0;hit<nhits;hit++) {
281 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
286 volume = startHit->fVolume;
288 timeright = startHit->fTime;
289 if(timeright<besttimeright) {
290 besttimeright=timeright;
292 }//time for right shoulder
294 timeleft = startHit->fTime;
295 // printf("timeleft %f\n",timeleft);
296 if(timeleft<besttimeleft) {
297 besttimeleft=timeleft;
299 }//time for left shoulder
303 //folding with experimental time distribution
304 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
305 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
306 timediff=besttimerightGaus-besttimeleftGaus;
307 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
308 if ( TMath::Abs(timediff)<2. && meanTime<3.)
310 //we assume centre of bunch is 5ns after TTS signal
311 //TOF values are relative of the end of bunch
314 ppBunch=ppBunch-10/2;
315 Float_t t1=1000.*besttimeleftGaus;
316 Float_t t2=1000.*besttimerightGaus;
317 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
318 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
322 // Time to TDC signal
323 // 256 channels for timediff, range 1ns
325 timediff=128+1000*timediff/channelWidth; // time in ps
327 timeAv = (Int_t)(timeav); // time (ps) channel numbres
328 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
329 digits->Set(timeAv,timeDiff);
332 {timeAv=999999; timeDiff=99999;}
335 printf("digits-> %d \n",digits->GetTime());