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.17 2001/01/26 19:59:53 hristov
19 Major upgrade of AliRoot code
21 Revision 1.16 2001/01/17 10:56:08 hristov
22 Corrections to destructors
24 Revision 1.15 2001/01/01 13:10:42 hristov
25 Local definition of digits removed
27 Revision 1.14 2000/12/22 16:17:15 hristov
28 Updated START code from Alla
30 Revision 1.13 2000/12/18 11:39:41 alibrary
31 Quick fix to avoid crash in display waiting for new version
33 Revision 1.12 2000/12/04 08:48:19 alibrary
34 Fixing problems in the HEAD
36 Revision 1.11 2000/10/13 13:14:08 hristov
37 Bug fixes and code cleaning
39 Revision 1.10 2000/10/02 21:28:13 fca
40 Removal of useless dependecies via forward declarations
42 Revision 1.9 2000/07/13 16:41:29 fca
43 New START corrected for coding conventions
45 Revision 1.8 2000/03/27 17:24:25 alla
48 Revision 1.6 2000/01/21 15:45:23 fca
51 Revision 1.5 2000/01/19 17:17:15 fca
52 Introducing a list of lists of hits -- more hits allowed for detector now
54 Revision 1.4 1999/11/12 15:04:00 fca
55 Modifications from A.Maevskaya
57 Revision 1.3 1999/09/29 09:24:29 fca
58 Introduction of the Copyright and cvs Log
62 ///////////////////////////////////////////////////////////////////////////////
64 // START (T-Zero) Detector //
65 // This class contains the base procedures for the START //
70 <img src="gif/AliSTARTClass.gif">
73 <font size=+2 color=red>
74 <p>The responsible person for this module is
75 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
82 ///////////////////////////////////////////////////////////////////////////////
91 #include "TGeometry.h"
93 #include "TParticle.h"
97 #include "AliSTARTdigit.h"
99 #include "AliSTARThit.h"
100 #include "AliSTARTvertex.h"
104 static AliSTARTdigit *digits;
106 //_____________________________________________________________________________
110 // Default constructor for class AliSTART
117 //_____________________________________________________________________________
118 AliSTART::AliSTART(const char *name, const char *title)
119 : AliDetector(name,title)
122 // Standard constructor for START Detector
127 // Initialise Hit array
128 fHits = new TClonesArray("AliSTARThit", 405);
129 gAlice->AddHitList(fHits);
133 SetMarkerColor(kRed);
136 //_____________________________________________________________________________
137 AliSTART::~AliSTART() {
144 //_____________________________________________________________________________
145 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
150 TClonesArray &lhits = *fHits;
151 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
154 //_____________________________________________________________________________
156 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
159 // Add a START digit to the list. Dummy function.
163 //_____________________________________________________________________________
164 void AliSTART::BuildGeometry()
167 // Build simple ROOT TNode geometry for event display
170 const int kColorSTART = 19;
172 top=gAlice->GetGeometry()->GetNode("alice");
174 // START define the different volumes
175 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
177 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
179 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
180 node->SetLineColor(kColorSTART);
183 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
185 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
186 node->SetLineColor(kColorSTART);
190 //_____________________________________________________________________________
191 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
194 // Calculate the distance from the mouse to the START on the screen
200 //-------------------------------------------------------------------------
201 void AliSTART::Init()
204 // Initialis the START after it has been built
208 for(i=0;i<35;i++) printf("*");
209 printf(" START_INIT ");
210 for(i=0;i<35;i++) printf("*");
213 // Here the START initialisation code (if any!)
214 for(i=0;i<80;i++) printf("*");
218 // fIdSensRad=gMC->VolId("PTOP");
219 // fIdSensPC =gMC->VolId("T0PC");
223 //---------------------------------------------------------------------------
224 void AliSTART::MakeBranch(Option_t* option, char *file)
227 // Specific START branches
229 // Create Tree branches for the START.
230 Int_t buffersize = 400;
232 sprintf(branchname,"%s",GetName());
234 AliDetector::MakeBranch(option,file);
236 const char *cD = strstr(option,"D");
239 digits = new AliSTARTdigit();
240 gAlice->MakeBranchInTree(gAlice->TreeD(),
241 branchname, "AliSTARTdigit", digits, buffersize, 1, file) ;
244 char *cR = strstr(option,"R");
247 gAlice->MakeBranchInTree(gAlice->TreeR(),
248 branchname, "Int_t", &fZposit, buffersize, 1, file) ;
253 //_____________________________________________________________________________
255 void AliSTART::Hit2digit(Int_t evnum)
258 // From hits to digits
265 char nameTH[8],nameTD[8];
266 Float_t timediff,timeright,timeleft,timeav;
267 Float_t besttimeright,besttimeleft,meanTime;
268 Int_t channelWidth=10;
271 AliSTARThit *startHit;
273 Int_t buffersize=256;
276 digits= new AliSTARTdigit();
280 // Event ------------------------- LOOP
282 sprintf(nameTD,"TreeD%d",evnum);
283 TTree *td = new TTree(nameTD,"START");
284 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
291 Int_t nparticles = gAlice->GetEvent(evnum);
292 if (nparticles <= 0) return;
293 printf("\n nparticles %d\n",nparticles);
296 sprintf(nameTH,"TreeH%d",evnum);
297 printf("%s\n",nameTH);
298 TTree *th = gAlice->TreeH();
299 Int_t ntracks = (Int_t) th->GetEntries();
300 if (ntracks<=0) return;
301 // Start loop on tracks in the hits containers
302 for (Int_t track=0; track<ntracks;track++) {
304 nbytes += th->GetEvent(track);
305 particle=gAlice->Particle(track);
306 nhits =fHits->GetEntriesFast();
308 for (hit=0;hit<nhits;hit++) {
309 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
314 volume = startHit->fVolume;
316 timeright = startHit->fTime;
317 if(timeright<besttimeright) {
318 besttimeright=timeright;
320 }//time for right shoulder
322 timeleft = startHit->fTime;
323 // printf("timeleft %f\n",timeleft);
324 if(timeleft<besttimeleft) {
325 besttimeleft=timeleft;
327 }//time for left shoulder
331 //folding with experimental time distribution
332 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
333 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
334 timediff=besttimerightGaus-besttimeleftGaus;
335 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
336 if ( TMath::Abs(timediff)<2. && meanTime<3.)
338 //we assume centre of bunch is 5ns after TTS signal
339 //TOF values are relative of the end of bunch
342 ppBunch=ppBunch-10/2;
343 Float_t t1=1000.*besttimeleftGaus;
344 Float_t t2=1000.*besttimerightGaus;
345 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
346 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
350 // Time to TDC signal
351 // 256 channels for timediff, range 1ns
353 timediff=128+1000*timediff/channelWidth; // time in ps
355 timeAv = (Int_t)(timeav); // time (ps) channel numbres
356 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
357 digits->Set(timeAv,timeDiff);
360 {timeAv=999999; timeDiff=99999;}
363 printf("digits-> %d \n",digits->GetTime());