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.9 2000/07/13 16:41:29 fca
19 New START corrected for coding conventions
21 Revision 1.8 2000/03/27 17:24:25 alla
24 Revision 1.6 2000/01/21 15:45:23 fca
27 Revision 1.5 2000/01/19 17:17:15 fca
28 Introducing a list of lists of hits -- more hits allowed for detector now
30 Revision 1.4 1999/11/12 15:04:00 fca
31 Modifications from A.Maevskaya
33 Revision 1.3 1999/09/29 09:24:29 fca
34 Introduction of the Copyright and cvs Log
38 ///////////////////////////////////////////////////////////////////////////////
40 // START (T-Zero) Detector //
41 // This class contains the base procedures for the START //
46 <img src="gif/AliSTARTClass.gif">
49 <font size=+2 color=red>
50 <p>The responsible person for this module is
51 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
58 ///////////////////////////////////////////////////////////////////////////////
67 #include "TGeometry.h"
70 #include "AliSTARTdigit.h"
72 #include "AliSTARThit.h"
73 #include "AliSTARTvertex.h"
77 static AliSTARTdigit *digits;
79 //_____________________________________________________________________________
83 // Default constructor for class AliSTART
90 //_____________________________________________________________________________
91 AliSTART::AliSTART(const char *name, const char *title)
92 : AliDetector(name,title)
95 // Standard constructor for START Detector
100 // Initialise Hit array
101 fHits = new TClonesArray("AliSTARThit", 405);
102 // gAlice->AddHitList(fHits);
103 // fDigits = new TClonesArray("AliSTARTdigit",500);
107 SetMarkerColor(kRed);
110 //_____________________________________________________________________________
111 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
116 TClonesArray &lhits = *fHits;
117 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
120 //_____________________________________________________________________________
122 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
125 // Add a START digit to the list
127 // printf (" AddDigit*******");
128 // TClonesArray &ldigits = *fDigits;
129 // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
132 //_____________________________________________________________________________
133 void AliSTART::BuildGeometry()
136 // Build simple ROOT TNode geometry for event display
139 const int kColorSTART = 19;
141 top=gAlice->GetGeometry()->GetNode("alice");
143 // START define the different volumes
144 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
146 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
148 node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
149 node->SetLineColor(kColorSTART);
152 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
154 node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
155 node->SetLineColor(kColorSTART);
159 //_____________________________________________________________________________
160 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
163 // Calculate the distance from the mouse to the START on the screen
169 //-------------------------------------------------------------------------
170 void AliSTART::Init()
173 // Initialis the START after it has been built
177 for(i=0;i<35;i++) printf("*");
178 printf(" START_INIT ");
179 for(i=0;i<35;i++) printf("*");
182 // Here the START initialisation code (if any!)
183 for(i=0;i<80;i++) printf("*");
187 // fIdSensRad=gMC->VolId("PTOP");
188 // fIdSensPC =gMC->VolId("T0PC");
192 //---------------------------------------------------------------------------
193 void AliSTART::MakeBranch(Option_t* option)
196 // Specific START branches
198 AliSTARTdigit *digits;
199 // Create Tree branches for the START.
200 Int_t buffersize = 400;
202 sprintf(branchname,"%s",GetName());
204 AliDetector::MakeBranch(option);
206 TTree *td = gAlice->TreeD();
207 digits = new AliSTARTdigit();
208 td->Branch(branchname,"AliSTARTdigit",&digits, buffersize);
209 printf("Making Branch %s for digits\n",branchname);
212 gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
213 printf("Making Branch %s for vertex position %d\n",branchname);
217 //_____________________________________________________________________________
219 void AliSTART::Hit2digit(Int_t evnum)
222 // From hits to digits
229 char nameTH[8],nameTD[8];
230 Float_t timediff,timeright,timeleft,timeav;
231 Float_t besttimeright,besttimeleft,meanTime;
232 Int_t channelWidth=10;
235 AliSTARThit *startHit;
237 Int_t buffersize=256;
240 digits= new AliSTARTdigit();
244 // Event ------------------------- LOOP
246 sprintf(nameTD,"TreeD%d",evnum);
247 TTree *td = new TTree(nameTD,"START");
248 bDig = td->Branch("START","AliSTARTdigit",&digits,buffersize,split);
255 Int_t nparticles = gAlice->GetEvent(evnum);
256 if (nparticles <= 0) return;
257 printf("\n nparticles %d\n",nparticles);
259 TClonesArray *particles = gAlice->Particles();
261 sprintf(nameTH,"TreeH%d",evnum);
262 printf("%s\n",nameTH);
263 TTree *th = gAlice->TreeH();
264 Int_t ntracks = (Int_t) th->GetEntries();
265 if (ntracks<=0) return;
266 // Start loop on tracks in the hits containers
267 for (Int_t track=0; track<ntracks;track++) {
269 nbytes += th->GetEvent(track);
270 particle=(TParticle*)particles->UncheckedAt(track);
271 nhits =fHits->GetEntriesFast();
273 for (hit=0;hit<nhits;hit++) {
274 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
279 volume = startHit->fVolume;
281 timeright = startHit->fTime;
282 if(timeright<besttimeright) {
283 besttimeright=timeright;
285 }//time for right shoulder
287 timeleft = startHit->fTime;
288 // printf("timeleft %f\n",timeleft);
289 if(timeleft<besttimeleft) {
290 besttimeleft=timeleft;
292 }//time for left shoulder
296 //folding with experimental time distribution
297 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
298 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
299 timediff=besttimerightGaus-besttimeleftGaus;
300 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
301 if ( TMath::Abs(timediff)<2. && meanTime<3.)
303 //we assume centre of bunch is 5ns after TTS signal
304 //TOF values are relative of the end of bunch
307 ppBunch=ppBunch-10/2;
308 Float_t t1=1000.*besttimeleftGaus;
309 Float_t t2=1000.*besttimerightGaus;
310 t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
311 t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
315 // Time to TDC signal
316 // 256 channels for timediff, range 1ns
318 timediff=128+1000*timediff/channelWidth; // time in ps
320 timeAv = (Int_t)(timeav); // time (ps) channel numbres
321 timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
322 digits->Set(timeAv,timeDiff);
325 {timeAv=999999; timeDiff=99999;}
328 printf("digits-> %d \n",digits->GetTime());