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.10 2000/10/02 21:28:13 fca
19 Removal of useless dependecies via forward declarations
21 Revision 1.9 2000/07/13 16:41:29 fca
22 New START corrected for coding conventions
24 Revision 1.8 2000/03/27 17:24:25 alla
27 Revision 1.6 2000/01/21 15:45:23 fca
30 Revision 1.5 2000/01/19 17:17:15 fca
31 Introducing a list of lists of hits -- more hits allowed for detector now
33 Revision 1.4 1999/11/12 15:04:00 fca
34 Modifications from A.Maevskaya
36 Revision 1.3 1999/09/29 09:24:29 fca
37 Introduction of the Copyright and cvs Log
41 ///////////////////////////////////////////////////////////////////////////////
43 // START (T-Zero) Detector //
44 // This class contains the base procedures for the START //
49 <img src="gif/AliSTARTClass.gif">
52 <font size=+2 color=red>
53 <p>The responsible person for this module is
54 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
61 ///////////////////////////////////////////////////////////////////////////////
70 #include "TGeometry.h"
73 #include "AliSTARTdigit.h"
75 #include "AliSTARThit.h"
76 #include "AliSTARTvertex.h"
80 static AliSTARTdigit *digits;
82 //_____________________________________________________________________________
86 // Default constructor for class AliSTART
93 //_____________________________________________________________________________
94 AliSTART::AliSTART(const char *name, const char *title)
95 : AliDetector(name,title)
98 // Standard constructor for START Detector
103 // Initialise Hit array
104 fHits = new TClonesArray("AliSTARThit", 405);
105 // gAlice->AddHitList(fHits);
106 // fDigits = new TClonesArray("AliSTARTdigit",500);
110 SetMarkerColor(kRed);
113 //_____________________________________________________________________________
114 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
119 TClonesArray &lhits = *fHits;
120 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
123 //_____________________________________________________________________________
125 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
128 // Add a START digit to the list
130 // printf (" AddDigit*******");
131 // TClonesArray &ldigits = *fDigits;
132 // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
135 //_____________________________________________________________________________
136 void AliSTART::BuildGeometry()
139 // Build simple ROOT TNode geometry for event display
142 const int kColorSTART = 19;
144 top=gAlice->GetGeometry()->GetNode("alice");
146 // START define the different volumes
147 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
149 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
151 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
152 node->SetLineColor(kColorSTART);
155 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
157 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
158 node->SetLineColor(kColorSTART);
162 //_____________________________________________________________________________
163 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
166 // Calculate the distance from the mouse to the START on the screen
172 //-------------------------------------------------------------------------
173 void AliSTART::Init()
176 // Initialis the START after it has been built
180 for(i=0;i<35;i++) printf("*");
181 printf(" START_INIT ");
182 for(i=0;i<35;i++) printf("*");
185 // Here the START initialisation code (if any!)
186 for(i=0;i<80;i++) printf("*");
190 // fIdSensRad=gMC->VolId("PTOP");
191 // fIdSensPC =gMC->VolId("T0PC");
195 //---------------------------------------------------------------------------
196 void AliSTART::MakeBranch(Option_t* option)
199 // Specific START branches
201 AliSTARTdigit *digits;
202 // Create Tree branches for the START.
203 Int_t buffersize = 400;
205 sprintf(branchname,"%s",GetName());
207 AliDetector::MakeBranch(option);
209 TTree *td = gAlice->TreeD();
210 digits = new AliSTARTdigit();
211 td->Branch(branchname,"AliSTARTdigit",digits, buffersize);
212 printf("Making Branch %s for digits\n",branchname);
215 gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
216 printf("Making Branch %s for vertex position %d\n",branchname);
220 //_____________________________________________________________________________
222 void AliSTART::Hit2digit(Int_t evnum)
225 // From hits to digits
232 char nameTH[8],nameTD[8];
233 Float_t timediff,timeright,timeleft,timeav;
234 Float_t besttimeright,besttimeleft,meanTime;
235 Int_t channelWidth=10;
238 AliSTARThit *startHit;
240 Int_t buffersize=256;
243 digits= new AliSTARTdigit();
247 // Event ------------------------- LOOP
249 sprintf(nameTD,"TreeD%d",evnum);
250 TTree *td = new TTree(nameTD,"START");
251 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
258 Int_t nparticles = gAlice->GetEvent(evnum);
259 if (nparticles <= 0) return;
260 printf("\n nparticles %d\n",nparticles);
262 TClonesArray *particles = gAlice->Particles();
264 sprintf(nameTH,"TreeH%d",evnum);
265 printf("%s\n",nameTH);
266 TTree *th = gAlice->TreeH();
267 Int_t ntracks = (Int_t) th->GetEntries();
268 if (ntracks<=0) return;
269 // Start loop on tracks in the hits containers
270 for (Int_t track=0; track<ntracks;track++) {
272 nbytes += th->GetEvent(track);
273 particle=(TParticle*)particles->UncheckedAt(track);
274 nhits =fHits->GetEntriesFast();
276 for (hit=0;hit<nhits;hit++) {
277 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
282 volume = startHit->fVolume;
284 timeright = startHit->fTime;
285 if(timeright<besttimeright) {
286 besttimeright=timeright;
288 }//time for right shoulder
290 timeleft = startHit->fTime;
291 // printf("timeleft %f\n",timeleft);
292 if(timeleft<besttimeleft) {
293 besttimeleft=timeleft;
295 }//time for left shoulder
299 //folding with experimental time distribution
300 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
301 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
302 timediff=besttimerightGaus-besttimeleftGaus;
303 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
304 if ( TMath::Abs(timediff)<2. && meanTime<3.)
306 //we assume centre of bunch is 5ns after TTS signal
307 //TOF values are relative of the end of bunch
310 ppBunch=ppBunch-10/2;
311 Float_t t1=1000.*besttimeleftGaus;
312 Float_t t2=1000.*besttimerightGaus;
313 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
314 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
318 // Time to TDC signal
319 // 256 channels for timediff, range 1ns
321 timediff=128+1000*timediff/channelWidth; // time in ps
323 timeAv = (Int_t)(timeav); // time (ps) channel numbres
324 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
325 digits->Set(timeAv,timeDiff);
328 {timeAv=999999; timeDiff=99999;}
331 printf("digits-> %d \n",digits->GetTime());