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.6 2000/01/21 15:45:23 fca
21 Revision 1.5 2000/01/19 17:17:15 fca
22 Introducing a list of lists of hits -- more hits allowed for detector now
24 Revision 1.4 1999/11/12 15:04:00 fca
25 Modifications from A.Maevskaya
27 Revision 1.3 1999/09/29 09:24:29 fca
28 Introduction of the Copyright and cvs Log
32 ///////////////////////////////////////////////////////////////////////////////
34 // START (T-Zero) Detector //
35 // This class contains the base procedures for the START //
40 <img src="gif/AliSTARTClass.gif">
43 <font size=+2 color=red>
44 <p>The responsible person for this module is
45 <a href="mailto:Alla.Maevskaia@cern.ch">Alla Maevskaia</a>.
52 ///////////////////////////////////////////////////////////////////////////////
61 #include "TGeometry.h"
64 #include "AliSTARTdigit.h"
66 #include "AliSTARThit.h"
67 #include "AliSTARTvertex.h"
70 AliSTARTdigit *digits;
71 //_____________________________________________________________________________
75 // Default constructor for class AliSTART
82 //_____________________________________________________________________________
83 AliSTART::AliSTART(const char *name, const char *title)
84 : AliDetector(name,title)
87 // Standard constructor for START Detector
92 // Initialise Hit array
93 fHits = new TClonesArray("AliSTARThit", 405);
94 // gAlice->AddHitList(fHits);
95 // fDigits = new TClonesArray("AliSTARTdigit",500);
102 //_____________________________________________________________________________
103 void AliSTART::AddHit(Int_t track, Int_t *vol, Float_t *hits)
108 TClonesArray &lhits = *fHits;
109 new(lhits[fNhits++]) AliSTARThit(fIshunt,track,vol,hits);
112 //_____________________________________________________________________________
114 void AliSTART::AddDigit(Int_t *tracks,Int_t *digits)
117 // Add a START digit to the list
119 // printf (" AddDigit*******");
120 // TClonesArray &ldigits = *fDigits;
121 // new(ldigits[fNdigits++]) AliSTARTdigit(tracks,digits);
124 //_____________________________________________________________________________
125 void AliSTART::BuildGeometry()
128 // Build simple ROOT TNode geometry for event display
131 const int kColorSTART = 19;
133 Top=gAlice->GetGeometry()->GetNode("alice");
135 // START define the different volumes
136 new TRotMatrix("rot999","rot999", 90,0,90,90,180,0);
138 new TTUBE("S_STR1","START volume 1","void",5.,10.7,5.3);
140 Node = new TNode("STR1","STR1","S_STR1",0,0,75.,"");
141 Node->SetLineColor(kColorSTART);
144 new TTUBE("S_STR2","START volume 2","void",5.,10.7,5.3);
146 Node = new TNode("STR2","STR2","S_STR2",0,0,-75,"rot999");
147 Node->SetLineColor(kColorSTART);
151 //_____________________________________________________________________________
152 Int_t AliSTART::DistanceToPrimitive(Int_t px, Int_t py)
155 // Calculate the distance from the mouse to the START on the screen
161 //-------------------------------------------------------------------------
162 void AliSTART::Init()
165 // Initialis the START after it has been built
169 for(i=0;i<35;i++) printf("*");
170 printf(" START_INIT ");
171 for(i=0;i<35;i++) printf("*");
174 // Here the START initialisation code (if any!)
175 for(i=0;i<80;i++) printf("*");
179 // fIdSensRad=gMC->VolId("PTOP");
180 // fIdSensPC =gMC->VolId("T0PC");
184 //---------------------------------------------------------------------------
185 void AliSTART::MakeBranch(Option_t* option)
188 AliSTARTdigit *digits;
189 // Create Tree branches for the START.
190 Int_t buffersize = 400;
192 sprintf(branchname,"%s",GetName());
194 AliDetector::MakeBranch(option);
196 TTree *TD = gAlice->TreeD();
197 digits = new AliSTARTdigit();
198 TD->Branch(branchname,"AliSTARTdigit",&digits, buffersize);
199 printf("Making Branch %s for digits\n",branchname);
202 gAlice->TreeR()->Branch(branchname,"Int_t",&fZposit, buffersize);
203 printf("Making Branch %s for vertex position %d\n",branchname);
207 //_____________________________________________________________________________
209 void AliSTART::Hit2digit(Int_t evnum)
217 char nameTH[8],nameTD[8];
218 Float_t timediff,timeright,timeleft,timeav;
219 Float_t besttimeright,besttimeleft,meanTime;
220 Int_t channel_width=10;
223 AliSTARThit *startHit;
225 Int_t buffersize=256;
228 digits= new AliSTARTdigit();
234 TH1F *hTimediff = new TH1F("hTimediff","Time different",100,-2,2);
235 TH1F *hMeanTime = new TH1F("hMeanTime","Mean Time",100,2.2,2.8);
237 TH1F *hTime1stright = new TH1F("hTime1stright","Time flight of 1st particle right", 100,1.5,3.2);
238 TH1F *hTime1stleft = new TH1F("hTime1sleft","Time flight of 1st particle left",100,1.5,3.2);
241 // AliSTART *START = (AliSTART*) gAlice->GetDetector("START");
243 // Event ------------------------- LOOP
245 sprintf(nameTD,"TreeD%d",evnum);
246 TTree *TD = new TTree(nameTD,"START");
247 bDig = TD->Branch("START","AliSTARTdigit",&digits,buffersize,split);
254 Int_t nparticles = gAlice->GetEvent(evnum);
255 if (nparticles <= 0) return;
256 printf("\n nparticles %d\n",nparticles);
258 TClonesArray *Particles = gAlice->Particles();
260 sprintf(nameTH,"TreeH%d",evnum);
261 printf("%s\n",nameTH);
262 TTree *TH = gAlice->TreeH();
263 Int_t ntracks = (Int_t) TH->GetEntries();
264 if (ntracks<=0) return;
265 // Start loop on tracks in the hits containers
266 for (Int_t track=0; track<ntracks;track++) {
268 nbytes += TH->GetEvent(track);
269 particle=(TParticle*)Particles->UncheckedAt(track);
270 nhits =fHits->GetEntriesFast();
272 for (hit=0;hit<nhits;hit++) {
273 startHit = (AliSTARThit*)fHits->UncheckedAt(hit);
278 volume = startHit->fVolume;
280 timeright = startHit->fTime;
281 if(timeright<besttimeright) {
282 besttimeright=timeright;
284 }//time for right shoulder
286 timeleft = startHit->fTime;
287 // printf("timeleft %f\n",timeleft);
288 if(timeleft<besttimeleft) {
289 besttimeleft=timeleft;
291 }//time for left shoulder
295 //folding with experimental time distribution
296 Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
297 Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
298 timediff=besttimerightGaus-besttimeleftGaus;
299 meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
300 if ( TMath::Abs(timediff)<2. && meanTime<3.)
302 //we assume centre of bunch is 5ns after TTS signal
303 //TOF values are relative of the end of bunch
304 // hTimediff->Fill(timediff);
305 //hMeanTime->Fill(meanTime);
308 pp_bunch=pp_bunch-10/2;
309 Float_t t1=1000.*besttimeleftGaus;
310 Float_t t2=1000.*besttimerightGaus;
311 t1=t1/channel_width+pp_bunch; //time in ps to channel_width
312 t2=t2/channel_width+pp_bunch; //time in ps to channel_width
316 // Time to TDC signal
317 // 256 channels for timediff, range 1ns
319 timediff=128+1000*timediff/channel_width; // time in ps
322 Timeav = (Int_t)(timeav); // time in ps
323 Timediff = (Int_t)(timediff); // time in ps
324 digits->Set(Timeav,Timediff);